From gitlab at gitlab.haskell.org Wed May 1 02:45:52 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 30 Apr 2024 22:45:52 -0400 Subject: [Git][ghc/ghc][master] testsuite: Handle exceptions in framework_fail when testdir is not initialised Message-ID: <6631ace0ff63_3e57f3aa214286bb@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - 1 changed file: - testsuite/driver/testlib.py Changes: ===================================== testsuite/driver/testlib.py ===================================== @@ -1542,7 +1542,13 @@ def override_options(pre_cmd): def framework_fail(name: Optional[TestName], way: Optional[WayName], reason: str) -> None: opts = getTestOpts() - directory = re.sub(r'^\.[/\\]', '', str(opts.testdir)) + # framework_fail can be called before testdir is initialised, + # so we need to take care not to blow up with the wrong way + # and report the actual reason for the failure. + try: + directory = re.sub(r'^\.[/\\]', '', str(opts.testdir)) + except: + directory = '' full_name = '%s(%s)' % (name, way) if_verbose(1, '*** framework failure for %s %s ' % (full_name, reason)) name2 = name if name is not None else TestName('none') View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c56d728e1f8702db02cf7e7e3cdc567b3df47ac3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c56d728e1f8702db02cf7e7e3cdc567b3df47ac3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 1 02:46:33 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 30 Apr 2024 22:46:33 -0400 Subject: [Git][ghc/ghc][master] EPA: Fix range for GADT decl with sig only Message-ID: <6631ad09cb4f2_3e57f57009433227@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4 changed files: - compiler/GHC/Parser.y - + testsuite/tests/printer/DataDeclShort.hs - testsuite/tests/printer/Makefile - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1303,7 +1303,7 @@ ty_decl :: { LTyClDecl GhcPs } | type_data_or_newtype capi_ctype tycl_hdr opt_kind_sig gadt_constrlist maybe_derivings - {% mkTyData (comb4 $1 $3 $5 $6) (sndOf3 $ unLoc $1) (thdOf3 $ unLoc $1) $2 $3 + {% mkTyData (comb5 $1 $3 $4 $5 $6) (sndOf3 $ unLoc $1) (thdOf3 $ unLoc $1) $2 $3 (snd $ unLoc $4) (snd $ unLoc $5) (fmap reverse $6) ((fstOf3 $ unLoc $1)++(fst $ unLoc $4)++(fst $ unLoc $5)) } ===================================== testsuite/tests/printer/DataDeclShort.hs ===================================== @@ -0,0 +1,8 @@ +module DataDeclShort where + +data GenericOptions + :: fieldLabelModifier + -> tagSingleConstructors + -> Type + +x = 1 ===================================== testsuite/tests/printer/Makefile ===================================== @@ -836,3 +836,8 @@ CaseAltComments: MatchPatComments: $(CHECK_PPR) $(LIBDIR) MatchPatComments.hs $(CHECK_EXACT) $(LIBDIR) MatchPatComments.hs + +.PHONY: DataDeclShort +DataDeclShort: + $(CHECK_PPR) $(LIBDIR) DataDeclShort.hs + $(CHECK_EXACT) $(LIBDIR) DataDeclShort.hs ===================================== testsuite/tests/printer/all.T ===================================== @@ -200,3 +200,4 @@ test('Test24533', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24533']) test('PprLetIn', [ignore_stderr, req_ppr_deps], makefile_test, ['PprLetIn']) test('CaseAltComments', [ignore_stderr, req_ppr_deps], makefile_test, ['CaseAltComments']) test('MatchPatComments', [ignore_stderr, req_ppr_deps], makefile_test, ['MatchPatComments']) +test('DataDeclShort', [ignore_stderr, req_ppr_deps], makefile_test, ['DataDeclShort']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d5bea4d6bce785b1d09f1b8faad7451af23b728d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d5bea4d6bce785b1d09f1b8faad7451af23b728d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 1 07:11:19 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Wed, 01 May 2024 03:11:19 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/mksolo-hash] Rename Solo# data constructor to MkSolo# (#24673) Message-ID: <6631eb178daec_3e57f20d0e743746e@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/mksolo-hash at Glasgow Haskell Compiler / GHC Commits: ee4e2e3a by Andrei Borzenkov at 2024-05-01T11:10:51+04:00 Rename Solo# data constructor to MkSolo# (#24673) - data Solo# a = (# a #) + data Solo# a = MkSolo# a And `(# foo #)` syntax now becomes just a syntactic sugar for `MkSolo# a`. - - - - - 11 changed files: - compiler/GHC/Builtin/Types.hs - libraries/ghc-boot/GHC/Utils/Encoding.hs - libraries/ghc-experimental/src/Data/Tuple/Experimental.hs - libraries/ghc-prim/GHC/Types.hs - libraries/template-haskell/Language/Haskell/TH/Syntax.hs - testsuite/tests/core-to-stg/T24124.stderr - testsuite/tests/ghci/scripts/ListTuplePunsPpr.script - testsuite/tests/ghci/scripts/ListTuplePunsPpr.stdout - testsuite/tests/interface-stability/ghc-experimental-exports.stdout - testsuite/tests/simplStg/should_compile/T15226b.stderr - testsuite/tests/th/TH_tuple1.stdout Changes: ===================================== compiler/GHC/Builtin/Types.hs ===================================== @@ -1015,7 +1015,7 @@ mkUnboxedTupleStr ns 0 | isDataConNameSpace ns = "(##)" | otherwise = "Unit#" mkUnboxedTupleStr ns 1 - | isDataConNameSpace ns = "(# #)" -- See Note [One-tuples] + | isDataConNameSpace ns = "MkSolo#" -- See Note [One-tuples] | otherwise = "Solo#" mkUnboxedTupleStr ns ar | isDataConNameSpace ns = "(#" ++ commas ar ++ "#)" ===================================== libraries/ghc-boot/GHC/Utils/Encoding.hs ===================================== @@ -79,7 +79,7 @@ The basic encoding scheme is this. :+ ZCzp () Z0T 0-tuple (,,,,) Z5T 5-tuple - (# #) Z1H unboxed 1-tuple (note the space) + (##) Z0H unboxed 0-tuple (#,,,,#) Z5H unboxed 5-tuple -} @@ -212,7 +212,6 @@ decode_tuple d rest go n (c : rest) | isDigit c = go (10*n + digitToInt c) rest go 0 ('T':rest) = "()" ++ zDecodeString rest go n ('T':rest) = '(' : replicate (n-1) ',' ++ ")" ++ zDecodeString rest - go 1 ('H':rest) = "(# #)" ++ zDecodeString rest go n ('H':rest) = '(' : '#' : replicate (n-1) ',' ++ "#)" ++ zDecodeString rest go n other = error ("decode_tuple: " ++ show n ++ ' ':other) @@ -223,15 +222,13 @@ for 3-tuples or unboxed 3-tuples respectively. No other encoding starts Z * "(##)" is the tycon for an unboxed 0-tuple -* "(# #)" is the tycon for an unboxed 1-tuple -* "()" is the tycon for a boxed 0-tuple. +* "()" is the tycon for a boxed 0-tuple -} maybe_tuple :: UserString -> Maybe EncodedString maybe_tuple "(##)" = Just("Z0H") -maybe_tuple "(# #)" = Just("Z1H") maybe_tuple ('(' : '#' : cs) = case count_commas (0::Int) cs of (n, '#' : ')' : _) -> Just ('Z' : shows (n+1) "H") _ -> Nothing ===================================== libraries/ghc-experimental/src/Data/Tuple/Experimental.hs ===================================== @@ -21,7 +21,7 @@ module Data.Tuple.Experimental ( -- * Unboxed tuples Unit#, - Solo#, + Solo#(..), Tuple0#, Tuple1#, Tuple2#, ===================================== libraries/ghc-prim/GHC/Types.hs ===================================== @@ -65,7 +65,7 @@ module GHC.Types ( -- * Unboxed tuples Unit#, - Solo#, + Solo#(..), Tuple0#, Tuple1#, Tuple2#, @@ -889,7 +889,7 @@ type Unit# :: TYPE (TupleRep '[]) data Unit# = (# #) type Solo# :: TYPE rep -> TYPE (TupleRep '[rep]) -data Solo# a = (# a #) +data Solo# a = MkSolo# a type Tuple0# = Unit# type Tuple1# = Solo# ===================================== libraries/template-haskell/Language/Haskell/TH/Syntax.hs ===================================== @@ -1938,10 +1938,7 @@ mk_tup_name n space boxed solo | space == DataName = "MkSolo" | otherwise = "Solo" - - unboxed_solo - | space == DataName = "(# #)" - | otherwise = "Solo#" + unboxed_solo = solo ++ "#" -- Unboxed sum data and type constructors -- | Unboxed sum data constructor ===================================== testsuite/tests/core-to-stg/T24124.stderr ===================================== @@ -24,7 +24,7 @@ T15226b.testFun1 case y of conrep { __DEFAULT -> case T15226b.MkStrictPair [sat conrep] of sat { - __DEFAULT -> (# #) [sat]; + __DEFAULT -> MkSolo# [sat]; }; }; }; ===================================== testsuite/tests/ghci/scripts/ListTuplePunsPpr.script ===================================== @@ -1,6 +1,7 @@ -:set -XUnboxedTuples -XNoListTuplePuns -XDataKinds +:set -XUnboxedTuples -XMagicHash -XNoListTuplePuns -XDataKinds import GHC.Tuple (Solo (MkSolo)) +import Data.Tuple.Experimental (Solo# (MkSolo#)) :i () :i (##) @@ -26,3 +27,5 @@ f i (j, k) = i + j + k :: Int :t f :t (\ (_, _) -> ()) :t (\ (MkSolo _) -> ()) +:i Solo# +:t MkSolo# ===================================== testsuite/tests/ghci/scripts/ListTuplePunsPpr.stdout ===================================== @@ -75,13 +75,17 @@ data Tuple2# a b = (#,#) a b (Int, Int) :: Tuple2 (*) (*) type T :: Tuple2 (*) (*) type T = (Int, Int) :: Tuple2 (*) (*) - -- Defined at :18:1 + -- Defined at :19:1 type S :: Solo (*) type S = MkSolo Int :: Solo (*) - -- Defined at :19:1 + -- Defined at :20:1 type L :: List (*) type L = [Int] :: List (*) - -- Defined at :20:1 + -- Defined at :21:1 f :: Int -> Tuple2 Int Int -> Int (\ (_, _) -> ()) :: Tuple2 a b -> Unit (\ (MkSolo _) -> ()) :: Solo a -> Unit +type Solo# :: * -> TYPE (GHC.Types.TupleRep [GHC.Types.LiftedRep]) +data Solo# a = MkSolo# a + -- Defined in ‘GHC.Types’ +MkSolo# :: a -> Solo# a ===================================== testsuite/tests/interface-stability/ghc-experimental-exports.stdout ===================================== @@ -2633,7 +2633,7 @@ module Data.Tuple.Experimental where type Solo :: * -> * data Solo a = MkSolo a type Solo# :: forall (k :: GHC.Types.RuntimeRep). TYPE k -> TYPE (GHC.Types.TupleRep '[k]) - data Solo# a = ... + data Solo# a = MkSolo# a type Tuple0 :: * type Tuple0 = () type Tuple0# :: GHC.Types.ZeroBitType ===================================== testsuite/tests/simplStg/should_compile/T15226b.stderr ===================================== @@ -20,7 +20,7 @@ T15226b.bar1 sat [Occ=Once1] :: T15226b.Str (GHC.Internal.Maybe.Maybe a) [LclId] = T15226b.Str! [sat]; - } in (# #) [sat]; + } in MkSolo# [sat]; }; T15226b.bar ===================================== testsuite/tests/th/TH_tuple1.stdout ===================================== @@ -6,5 +6,5 @@ GHC.Tuple.MkSolo 1 :: GHC.Tuple.Solo GHC.Num.Integer.Integer SigE (AppE (AppE (ConE GHC.Types.(#,#)) (LitE (IntegerL 1))) (LitE (IntegerL 2))) (AppT (AppT (ConT GHC.Types.Tuple2#) (ConT GHC.Num.Integer.Integer)) (ConT GHC.Num.Integer.Integer)) GHC.Types.(#,#) 1 2 :: GHC.Types.Tuple2# GHC.Num.Integer.Integer GHC.Num.Integer.Integer -SigE (AppE (ConE GHC.Types.(# #)) (LitE (IntegerL 1))) (AppT (ConT GHC.Types.Solo#) (ConT GHC.Num.Integer.Integer)) -GHC.Types.(# #) 1 :: GHC.Types.Solo# GHC.Num.Integer.Integer +SigE (AppE (ConE GHC.Types.MkSolo#) (LitE (IntegerL 1))) (AppT (ConT GHC.Types.Solo#) (ConT GHC.Num.Integer.Integer)) +GHC.Types.MkSolo# 1 :: GHC.Types.Solo# GHC.Num.Integer.Integer View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ee4e2e3ada13db527d2bc69740267b257106e5fc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ee4e2e3ada13db527d2bc69740267b257106e5fc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 1 07:43:52 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Wed, 01 May 2024 03:43:52 -0400 Subject: [Git][ghc/ghc][wip/az/T24736-epa-prefixcon-comments] 3 commits: testsuite: Handle exceptions in framework_fail when testdir is not initialised Message-ID: <6631f2b819eab_3e57f2559644426db@gitlab.mail> Alan Zimmerman pushed to branch wip/az/T24736-epa-prefixcon-comments at Glasgow Haskell Compiler / GHC Commits: c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 144893b9 by Alan Zimmerman at 2024-05-01T08:43:12+01:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 8 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - testsuite/driver/testlib.py - testsuite/tests/parser/should_compile/T20846.stderr - + testsuite/tests/printer/DataDeclShort.hs - testsuite/tests/printer/Makefile - + testsuite/tests/printer/PrefixConComment.hs - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1303,7 +1303,7 @@ ty_decl :: { LTyClDecl GhcPs } | type_data_or_newtype capi_ctype tycl_hdr opt_kind_sig gadt_constrlist maybe_derivings - {% mkTyData (comb4 $1 $3 $5 $6) (sndOf3 $ unLoc $1) (thdOf3 $ unLoc $1) $2 $3 + {% mkTyData (comb5 $1 $3 $4 $5 $6) (sndOf3 $ unLoc $1) (thdOf3 $ unLoc $1) $2 $3 (snd $ unLoc $4) (snd $ unLoc $5) (fmap reverse $6) ((fstOf3 $ unLoc $1)++(fst $ unLoc $4)++(fst $ unLoc $5)) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1210,37 +1210,34 @@ checkPattern_details :: ParseContext -> PV (LocatedA (PatBuilder GhcPs)) -> P (L checkPattern_details extraDetails pp = runPV_details extraDetails (pp >>= checkLPat) checkLArgPat :: LocatedA (ArgPatBuilder GhcPs) -> PV (LPat GhcPs) -checkLArgPat (L l (ArgPatBuilderVisPat p)) - = checkPat l (L l p) [] [] +checkLArgPat (L l (ArgPatBuilderVisPat p)) = checkLPat (L l p) checkLArgPat (L l (ArgPatBuilderArgPat p)) = return (L l p) checkLPat :: LocatedA (PatBuilder GhcPs) -> PV (LPat GhcPs) -checkLPat e@(L l _) = checkPat l e [] [] - -checkPat :: SrcSpanAnnA -> LocatedA (PatBuilder GhcPs) -> [HsConPatTyArg GhcPs] -> [LPat GhcPs] - -> PV (LPat GhcPs) -checkPat loc (L l e@(PatBuilderVar (L ln c))) tyargs args - | isRdrDataCon c = do - let (_l', loc') = transferCommentsOnlyA l loc - return . L loc' $ ConPat - { pat_con_ext = noAnn -- AZ: where should this come from? - , pat_con = L ln c - , pat_args = PrefixCon tyargs args - } +checkLPat (L l@(EpAnn anc an _) p) = do + (L l' p', cs) <- checkPat (EpAnn anc an emptyComments) emptyComments (L l p) [] [] + return (L (addCommentsToEpAnn l' cs) p') + +checkPat :: SrcSpanAnnA -> EpAnnComments -> LocatedA (PatBuilder GhcPs) -> [HsConPatTyArg GhcPs] -> [LPat GhcPs] + -> PV (LPat GhcPs, EpAnnComments) +checkPat loc cs (L l e@(PatBuilderVar (L ln c))) tyargs args + | isRdrDataCon c = return (L loc $ ConPat + { pat_con_ext = noAnn -- AZ: where should this come from? + , pat_con = L ln c + , pat_args = PrefixCon tyargs args + }, comments l Semi.<> cs) | (not (null args) && patIsRec c) = do ctx <- askParseContext patFail (locA l) . PsErrInPat e $ PEIP_RecPattern args YesPatIsRecursive ctx -checkPat loc (L _ (PatBuilderAppType (L lf f) at t)) tyargs args = do - let (loc', lf') = transferCommentsOnlyA loc lf - checkPat loc' (L lf' f) (HsConPatTyArg at t : tyargs) args -checkPat loc (L _ (PatBuilderApp f (L le e))) [] args = do - let (loc', le') = transferCommentsOnlyA loc le - p <- checkLPat (L le' e) - checkPat loc' f [] (p : args) -checkPat loc (L l e) [] [] = do +checkPat loc cs (L la (PatBuilderAppType f at t)) tyargs args = + checkPat loc (cs Semi.<> comments la) f (HsConPatTyArg at t : tyargs) args +checkPat loc cs (L la (PatBuilderApp f e)) [] args = do + p <- checkLPat e + checkPat loc (cs Semi.<> comments la) f [] (p : args) +checkPat loc cs (L l e) [] [] = do p <- checkAPat loc e - return (L l p) -checkPat loc e _ _ = do + return (L l p, cs) +checkPat loc _ e _ _ = do details <- fromParseContext <$> askParseContext patFail (locA loc) (PsErrInPat (unLoc e) details) @@ -1349,13 +1346,13 @@ checkFunBind :: SrcStrictness -> [LocatedA (ArgPatBuilder GhcPs)] -> Located (GRHSs GhcPs (LHsExpr GhcPs)) -> P (HsBind GhcPs) -checkFunBind strictness locF ann fun is_infix pats (L _ grhss) +checkFunBind strictness locF ann (L lf fun) is_infix pats (L _ grhss) = do ps <- runPV_details extraDetails (mapM checkLArgPat pats) let match_span = noAnnSrcSpan $ locF - return (makeFunBind fun (L (noAnnSrcSpan $ locA match_span) + return (makeFunBind (L (l2l lf) fun) (L (noAnnSrcSpan $ locA match_span) [L match_span (Match { m_ext = ann , m_ctxt = FunRhs - { mc_fun = fun + { mc_fun = L lf fun , mc_fixity = is_infix , mc_strictness = strictness } , m_pats = ps @@ -1364,7 +1361,7 @@ checkFunBind strictness locF ann fun is_infix pats (L _ grhss) -- That isn't quite right, but it'll do for now. where extraDetails - | Infix <- is_infix = ParseContext (Just $ unLoc fun) NoIncompleteDoBlock + | Infix <- is_infix = ParseContext (Just fun) NoIncompleteDoBlock | otherwise = noParseContext makeFunBind :: LocatedN RdrName -> LocatedL [LMatch GhcPs (LHsExpr GhcPs)] ===================================== testsuite/driver/testlib.py ===================================== @@ -1542,7 +1542,13 @@ def override_options(pre_cmd): def framework_fail(name: Optional[TestName], way: Optional[WayName], reason: str) -> None: opts = getTestOpts() - directory = re.sub(r'^\.[/\\]', '', str(opts.testdir)) + # framework_fail can be called before testdir is initialised, + # so we need to take care not to blow up with the wrong way + # and report the actual reason for the failure. + try: + directory = re.sub(r'^\.[/\\]', '', str(opts.testdir)) + except: + directory = '' full_name = '%s(%s)' % (name, way) if_verbose(1, '*** framework failure for %s %s ' % (full_name, reason)) name2 = name if name is not None else TestName('none') ===================================== testsuite/tests/parser/should_compile/T20846.stderr ===================================== @@ -71,11 +71,7 @@ (L (EpAnn (EpaSpan { T20846.hs:4:1-6 }) - (NameAnn - (NameParens) - (EpaSpan { T20846.hs:4:1 }) - (EpaSpan { T20846.hs:4:2-5 }) - (EpaSpan { T20846.hs:4:6 }) + (NameAnnTrailing []) (EpaComments [])) ===================================== testsuite/tests/printer/DataDeclShort.hs ===================================== @@ -0,0 +1,8 @@ +module DataDeclShort where + +data GenericOptions + :: fieldLabelModifier + -> tagSingleConstructors + -> Type + +x = 1 ===================================== testsuite/tests/printer/Makefile ===================================== @@ -836,3 +836,8 @@ CaseAltComments: MatchPatComments: $(CHECK_PPR) $(LIBDIR) MatchPatComments.hs $(CHECK_EXACT) $(LIBDIR) MatchPatComments.hs + +.PHONY: DataDeclShort +DataDeclShort: + $(CHECK_PPR) $(LIBDIR) DataDeclShort.hs + $(CHECK_EXACT) $(LIBDIR) DataDeclShort.hs ===================================== testsuite/tests/printer/PrefixConComment.hs ===================================== @@ -0,0 +1,4 @@ +module PrefixConComment where + +fun (Con {- c1 -} a {- c2 -} b {- c3 -}) + = undefined ===================================== testsuite/tests/printer/all.T ===================================== @@ -200,3 +200,4 @@ test('Test24533', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24533']) test('PprLetIn', [ignore_stderr, req_ppr_deps], makefile_test, ['PprLetIn']) test('CaseAltComments', [ignore_stderr, req_ppr_deps], makefile_test, ['CaseAltComments']) test('MatchPatComments', [ignore_stderr, req_ppr_deps], makefile_test, ['MatchPatComments']) +test('DataDeclShort', [ignore_stderr, req_ppr_deps], makefile_test, ['DataDeclShort']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1cb0245a9d0ec0e067b54342d831c3869a7323df...144893b946a3f12494450fc6297494d77bdb99f6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1cb0245a9d0ec0e067b54342d831c3869a7323df...144893b946a3f12494450fc6297494d77bdb99f6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 1 10:09:52 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 01 May 2024 06:09:52 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/mpickering-9.6-darwin Message-ID: <663214f04f3de_267538b465546415c@gitlab.mail> Matthew Pickering pushed new branch wip/mpickering-9.6-darwin at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/mpickering-9.6-darwin You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 1 11:19:04 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Wed, 01 May 2024 07:19:04 -0400 Subject: [Git][ghc/ghc][wip/fendor/ifacetype-deduplication] 3 commits: Add run-time configurability of .hi file compression Message-ID: <6632252843bc9_267538169126085935@gitlab.mail> Hannes Siebenhandl pushed to branch wip/fendor/ifacetype-deduplication at Glasgow Haskell Compiler / GHC Commits: 5abb60f3 by Matthew Pickering at 2024-04-30T15:51:23+02:00 Add run-time configurability of .hi file compression Introduce the flag `-fwrite-if-compression=<n>` which allows to configure the compression level of writing .hi files. The motivation is that some deduplication operations are too expensive for the average use case. Hence, we introduce multiple compression levels that have a minimal impact on performance, but still reduce the memory residency and `.hi` file size on disk considerably. We introduce three compression levels: * `1`: `Normal` mode. This is the least amount of compression. It deduplicates only `Name` and `FastString`s, and is naturally the fastest compression mode. * `2`: `Safe` mode. It has a noticeable impact on .hi file size and is marginally slower than `Normal` mode. In general, it should be safe to always use `Safe` mode. * `3`: `Full` deduplication mode. Deduplicate as much as we can, resulting in minimal .hi files, but at the cost of additional compilation time. Reading .hi files doesn't need to know the initial compression level, and can always deserialise a `ModIface`. This allows users to experiment with different compression levels for packages, without recompilation of dependencies. Note, the deduplication also has an additional side effect of reduced memory consumption to implicit sharing of deduplicated elements. See https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for example where that matters. ------------------------- Metric Decrease: MultiLayerModulesDefsGhciWithCore T16875 T21839c T24471 hard_hole_fits ------------------------- - - - - - 1b91e077 by Matthew Pickering at 2024-04-30T15:53:05+02:00 Introduce regression tests for `.hi` file sizes Add regression tests to track how `-fwrite-if-compression` levels affect the size of `.hi` files. - - - - - 53880781 by Fendor at 2024-04-30T15:53:05+02:00 Implement TrieMap for IfaceType - - - - - 21 changed files: - compiler/GHC/Core/Map/Expr.hs - compiler/GHC/Data/TrieMap.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Type.hs - + compiler/GHC/Iface/Type/Map.hs - compiler/GHC/Stg/CSE.hs - compiler/ghc.cabal.in - docs/users_guide/using-optimisation.rst - + testsuite/tests/iface/IfaceSharingIfaceType.hs - + testsuite/tests/iface/IfaceSharingName.hs - + testsuite/tests/iface/Lib.hs - + testsuite/tests/iface/Makefile - + testsuite/tests/iface/all.T - + testsuite/tests/iface/if_faststring.hs - + testsuite/tests/iface/if_ifacetype.hs - + testsuite/tests/iface/if_name.hs Changes: ===================================== compiler/GHC/Core/Map/Expr.hs ===================================== @@ -129,7 +129,7 @@ instance TrieMap CoreMap where -- inside another 'TrieMap', this is the type you want. type CoreMapG = GenMap CoreMapX -type LiteralMap a = Map.Map Literal a +type LiteralMap a = Map.Map Literal a -- | @CoreMapX a@ is the base map from @DeBruijn CoreExpr@ to @a@, but without -- the 'GenMap' optimization. ===================================== compiler/GHC/Data/TrieMap.hs ===================================== @@ -36,6 +36,8 @@ import qualified Data.IntMap as IntMap import GHC.Utils.Outputable import Control.Monad( (>=>) ) import Data.Kind( Type ) +import Data.Functor.Compose +import Data.Functor.Product import qualified Data.Semigroup as S @@ -340,6 +342,95 @@ ftList :: TrieMap m => (a -> Bool) -> ListMap m a -> ListMap m a ftList f (LM { lm_nil = mnil, lm_cons = mcons }) = LM { lm_nil = filterMaybe f mnil, lm_cons = fmap (filterTM f) mcons } + +{- +************************************************************************ +* * + Composition +* * +************************************************************************ +-} + +instance (TrieMap m, TrieMap n) => TrieMap (Compose m n) where + type Key (Compose m n) = (Key m, Key n) + emptyTM = Compose emptyTM + lookupTM = lkCompose lookupTM lookupTM + {-# INLINE lookupTM #-} + alterTM = xtCompose alterTM alterTM + {-# INLINE alterTM #-} + foldTM = fdCompose + {-# INLINE foldTM #-} + filterTM = ftCompose + {-# INLINE filterTM #-} + +lkCompose :: Monad m => (t1 -> f (g a1) -> m a2) -> (t2 -> a2 -> m b) -> (t1, t2) -> Compose f g a1 -> m b +lkCompose f g (a, b) (Compose m) = f a m >>= g b +{-# INLINE lkCompose #-} + +xtCompose :: + (TrieMap m, TrieMap n) + => (forall a . Key m -> XT a -> m a -> m a) + -> (forall a . Key n -> XT a -> n a -> n a) + -> Key (Compose m n) + -> XT a + -> Compose m n a + -> Compose m n a + +xtCompose f g (a, b) xt (Compose m) = Compose ((f a |>> g b xt) m) + +{-# INLINE xtCompose #-} + +fdCompose :: (TrieMap m1, TrieMap m2) => (a -> b -> b) -> Compose m1 m2 a -> b -> b +fdCompose f (Compose m) = foldTM (foldTM f) m + +{-# INLINE fdCompose #-} + + +ftCompose :: (TrieMap n, Functor m) => (a -> Bool) -> Compose m n a -> Compose m n a +ftCompose f (Compose m) = Compose (fmap (filterTM f) m) + +{-# INLINE ftCompose #-} + +{- Product -} +instance (TrieMap m, TrieMap n) => TrieMap (Product m n) where + type Key (Product m n) = Either (Key m) (Key n) + emptyTM = Pair emptyTM emptyTM + lookupTM = lkProduct + {-# INLINE lookupTM #-} + alterTM = xtProduct + {-# INLINE alterTM #-} + foldTM = fdProduct + {-# INLINE foldTM #-} + filterTM = ftProduct + {-# INLINE filterTM #-} + +lkProduct :: (TrieMap m1, TrieMap m2) => Either (Key m1) (Key m2) -> Product m1 m2 b -> Maybe b +lkProduct k (Pair am bm) = + case k of + Left a -> lookupTM a am + Right b -> lookupTM b bm + +{-# INLINE lkProduct #-} + +xtProduct :: (TrieMap f, TrieMap g) => Either (Key f) (Key g) -> XT a -> Product f g a -> Product f g a +xtProduct k xt (Pair am bm) = + case k of + Left a -> Pair (alterTM a xt am) bm + Right b -> Pair am (alterTM b xt bm) + +{-# INLINE xtProduct #-} + +fdProduct :: (TrieMap f, TrieMap g) => (a -> c -> c) -> Product f g a -> c -> c +fdProduct f (Pair am bm) = foldTM f am . foldTM f bm + +{-# INLINE fdProduct #-} + +ftProduct :: (TrieMap f, TrieMap g) => (a -> Bool) -> Product f g a -> Product f g a +ftProduct f (Pair am bm) = Pair (filterTM f am) (filterTM f bm) + +{-# INLINE ftProduct #-} + + {- ************************************************************************ * * ===================================== compiler/GHC/Driver/DynFlags.hs ===================================== @@ -207,6 +207,7 @@ data DynFlags = DynFlags { dmdUnboxWidth :: !Int, -- ^ Whether DmdAnal should optimistically put an -- Unboxed demand on returned products with at most -- this number of fields + ifCompression :: Int, specConstrThreshold :: Maybe Int, -- ^ Threshold for SpecConstr specConstrCount :: Maybe Int, -- ^ Max number of specialisations for any one function specConstrRecursive :: Int, -- ^ Max number of specialisations for recursive types @@ -546,6 +547,7 @@ defaultDynFlags mySettings = maxPmCheckModels = 30, simplTickFactor = 100, dmdUnboxWidth = 3, -- Default: Assume an unboxed demand on function bodies returning a triple + ifCompression = 2, -- Default: Apply safe compressions specConstrThreshold = Just 2000, specConstrCount = Just 3, specConstrRecursive = 3, ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -163,7 +163,7 @@ import GHC.JS.Syntax import GHC.IfaceToCore ( typecheckIface, typecheckWholeCoreBindings ) -import GHC.Iface.Load ( ifaceStats, writeIface ) +import GHC.Iface.Load ( ifaceStats, writeIface, flagsToIfCompression ) import GHC.Iface.Make import GHC.Iface.Recomp import GHC.Iface.Tidy @@ -612,7 +612,7 @@ extract_renamed_stuff mod_summary tc_result = do -- enables the option which keeps the renamed source. hieFile <- mkHieFile mod_summary tc_result (fromJust rn_info) let out_file = ml_hie_file $ ms_location mod_summary - liftIO $ writeHieFile out_file hieFile + liftIO $ writeHieFile (flagsToIfCompression dflags) out_file hieFile liftIO $ putDumpFileMaybe logger Opt_D_dump_hie "HIE AST" FormatHaskell (ppr $ hie_asts hieFile) -- Validate HIE files @@ -1207,7 +1207,7 @@ hscMaybeWriteIface logger dflags is_simple iface old_iface mod_location = do withTiming logger (text "WriteIface"<+>brackets (text iface_name)) (const ()) - (writeIface logger profile iface_name iface) + (writeIface logger profile (flagsToIfCompression dflags) iface_name iface) if (write_interface || force_write_interface) then do ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -1695,6 +1695,9 @@ dynamic_flags_deps = [ , make_ord_flag defFlag "fno-refinement-level-hole-fits" (noArg (\d -> d { refLevelHoleFits = Nothing })) + , make_ord_flag defFlag "fwrite-if-compression" + (intSuffix (\n d -> d { ifCompression = n })) + , make_dep_flag defGhcFlag "fllvm-pass-vectors-in-regs" (noArg id) "vectors registers are now passed in registers by default." ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -14,6 +14,7 @@ module GHC.Iface.Binary ( writeBinIface, readBinIface, readBinIfaceHeader, + CompressionIFace(..), getSymtabName, CheckHiWay(..), TraceBinIFace(..), @@ -48,7 +49,7 @@ import GHC.Types.SrcLoc import GHC.Platform import GHC.Settings.Constants import GHC.Utils.Fingerprint -import GHC.Iface.Type (IfaceType, getIfaceType, putIfaceType) +import GHC.Iface.Type (IfaceType(..), getIfaceType, putIfaceType, ifaceTypeSharedByte) import Control.Monad import Data.Array @@ -73,6 +74,21 @@ data TraceBinIFace = TraceBinIFace (SDoc -> IO ()) | QuietBinIFace +data CompressionIFace + = NormalCompression + -- ^ Perform the normal compression operations, + -- such as deduplicating 'Name's and 'FastString's + | SafeExtraCompression + -- ^ Perform some extra compression steps that have minimal impact + -- on the run-time of 'ghc'. + -- + -- This reduces the size of '.hi' files significantly in some cases + -- and reduces overall memory usage in certain scenarios. + | MaximalCompression + -- ^ Try to compress as much as possible. + -- + -- Yields the smallest '.hi' files but at the cost of additional run-time. + -- | Read an interface file header, checking the magic number, version, and -- way. Returns the hash of the source file and a BinHandle which points at the -- start of the rest of the interface file data. @@ -199,8 +215,8 @@ getTables name_cache bh = do -- | Write an interface file. -- -- See Note [Deduplication during iface binary serialisation] for details. -writeBinIface :: Profile -> TraceBinIFace -> FilePath -> ModIface -> IO () -writeBinIface profile traceBinIface hi_path mod_iface = do +writeBinIface :: Profile -> TraceBinIFace -> CompressionIFace -> FilePath -> ModIface -> IO () +writeBinIface profile traceBinIface compressionLevel hi_path mod_iface = do bh <- openBinMem initBinMemSize let platform = profilePlatform profile put_ bh (binaryInterfaceMagic platform) @@ -214,7 +230,7 @@ writeBinIface profile traceBinIface hi_path mod_iface = do extFields_p_p <- tellBinWriter bh put_ bh extFields_p_p - putWithUserData traceBinIface bh mod_iface + putWithUserData traceBinIface compressionLevel bh mod_iface extFields_p <- tellBinWriter bh putAt bh extFields_p_p extFields_p @@ -228,9 +244,9 @@ writeBinIface profile traceBinIface hi_path mod_iface = do -- is necessary if you want to serialise Names or FastStrings. -- It also writes a symbol table and the dictionary. -- This segment should be read using `getWithUserData`. -putWithUserData :: Binary a => TraceBinIFace -> WriteBinHandle -> a -> IO () -putWithUserData traceBinIface bh payload = do - (name_count, fs_count, _b) <- putWithTables bh (\bh' -> put bh' payload) +putWithUserData :: Binary a => TraceBinIFace -> CompressionIFace -> WriteBinHandle -> a -> IO () +putWithUserData traceBinIface compressionLevel bh payload = do + (name_count, fs_count, _b) <- putWithTables compressionLevel bh (\bh' -> put bh' payload) case traceBinIface of QuietBinIFace -> return () @@ -253,12 +269,12 @@ putWithUserData traceBinIface bh payload = do -- It returns (number of names, number of FastStrings, payload write result) -- -- See Note [Order of deduplication tables during iface binary serialisation] -putWithTables :: WriteBinHandle -> (WriteBinHandle -> IO b) -> IO (Int, Int, b) -putWithTables bh' put_payload = do +putWithTables :: CompressionIFace -> WriteBinHandle -> (WriteBinHandle -> IO b) -> IO (Int, Int, b) +putWithTables compressionLevel bh' put_payload = do -- Initialise deduplicating tables. (fast_wt, fsWriter) <- initFastStringWriterTable (name_wt, nameWriter) <- initNameWriterTable - (ifaceType_wt, ifaceTypeWriter) <- initWriteIfaceType + (ifaceType_wt, ifaceTypeWriter) <- initWriteIfaceType compressionLevel -- Initialise the 'WriterUserData'. let writerUserData = mkWriterUserData @@ -485,15 +501,33 @@ initReadIfaceTypeTable ud = do , mkReaderFromTable = \tbl -> mkReader (getGenericSymtab tbl) } -initWriteIfaceType :: IO (WriterTable, BinaryWriter IfaceType) -initWriteIfaceType = do +initWriteIfaceType :: CompressionIFace -> IO (WriterTable, BinaryWriter IfaceType) +initWriteIfaceType compressionLevel = do sym_tab <- initGenericSymbolTable @(Map IfaceType) pure ( WriterTable { putTable = putGenericSymbolTable sym_tab (lazyPut' putIfaceType) } - , mkWriter $ putGenericSymTab sym_tab + , mkWriter $ ifaceWriter sym_tab ) + where + ifaceWriter sym_tab = case compressionLevel of + NormalCompression -> literalIfaceTypeSerialiser + SafeExtraCompression -> ifaceTyConAppSerialiser sym_tab + MaximalCompression -> fullIfaceTypeSerialiser sym_tab + + ifaceTyConAppSerialiser sym_tab bh ty = case ty of + IfaceTyConApp {} -> do + put_ bh ifaceTypeSharedByte + putGenericSymTab sym_tab bh ty + _ -> putIfaceType bh ty + + + fullIfaceTypeSerialiser sym_tab bh ty = do + put_ bh ifaceTypeSharedByte + putGenericSymTab sym_tab bh ty + + literalIfaceTypeSerialiser = putIfaceType initNameReaderTable :: NameCache -> IO (ReaderTable Name) ===================================== compiler/GHC/Iface/Ext/Binary.hs ===================================== @@ -43,7 +43,7 @@ import System.Directory ( createDirectoryIfMissing ) import System.FilePath ( takeDirectory ) import GHC.Iface.Ext.Types -import GHC.Iface.Binary (initWriteIfaceType, putAllTables, initReadIfaceTypeTable) +import GHC.Iface.Binary (initWriteIfaceType, putAllTables, initReadIfaceTypeTable, CompressionIFace) import GHC.Iface.Type (IfaceType) import System.IO.Unsafe (unsafeInterleaveIO) import qualified GHC.Utils.Binary as Binary @@ -73,8 +73,8 @@ putBinLine bh xs = do -- | Write a `HieFile` to the given `FilePath`, with a proper header and -- symbol tables for `Name`s and `FastString`s -writeHieFile :: FilePath -> HieFile -> IO () -writeHieFile hie_file_path hiefile = do +writeHieFile :: CompressionIFace -> FilePath -> HieFile -> IO () +writeHieFile compression hie_file_path hiefile = do bh0 <- openBinMem initBinMemSize -- Write the header: hieHeader followed by the @@ -85,7 +85,7 @@ writeHieFile hie_file_path hiefile = do (fs_tbl, fs_w) <- initFastStringWriterTable (name_tbl, name_w) <- initWriteNameTable - (iface_tbl, iface_w) <- initWriteIfaceType + (iface_tbl, iface_w) <- initWriteIfaceType compression let bh = setWriterUserData bh0 $ mkWriterUserData [ mkSomeBinaryWriter @IfaceType iface_w ===================================== compiler/GHC/Iface/Load.hs ===================================== @@ -26,6 +26,7 @@ module GHC.Iface.Load ( loadInterface, loadSysInterface, loadUserInterface, loadPluginInterface, findAndReadIface, readIface, writeIface, + flagsToIfCompression, moduleFreeHolesPrecise, needWiredInHomeIface, loadWiredInHomeIface, @@ -965,11 +966,18 @@ read_file logger name_cache unit_state dflags wanted_mod file_path = do -- | Write interface file -writeIface :: Logger -> Profile -> FilePath -> ModIface -> IO () -writeIface logger profile hi_file_path new_iface +writeIface :: Logger -> Profile -> CompressionIFace -> FilePath -> ModIface -> IO () +writeIface logger profile compression_level hi_file_path new_iface = do createDirectoryIfMissing True (takeDirectory hi_file_path) let printer = TraceBinIFace (debugTraceMsg logger 3) - writeBinIface profile printer hi_file_path new_iface + writeBinIface profile printer compression_level hi_file_path new_iface + +flagsToIfCompression :: DynFlags -> CompressionIFace +flagsToIfCompression dflags = case ifCompression dflags of + 0 -> NormalCompression + 1 -> NormalCompression + 2 -> SafeExtraCompression + _ -> MaximalCompression -- | @readIface@ tries just the one file. -- ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -34,7 +34,7 @@ module GHC.Iface.Type ( ifTyConBinderVar, ifTyConBinderName, -- Binary utilities - putIfaceType, getIfaceType, + putIfaceType, getIfaceType, ifaceTypeSharedByte, -- Equality testing isIfaceLiftedTypeKind, @@ -92,12 +92,13 @@ import GHC.Utils.Misc import GHC.Utils.Panic import {-# SOURCE #-} GHC.Tc.Utils.TcType ( isMetaTyVar, isTyConableTyVar ) -import Control.DeepSeq +import Data.Maybe (isJust) import Data.Proxy -import Control.Monad ((<$!>)) -import Control.Arrow (first) import qualified Data.Semigroup as Semi -import Data.Maybe (isJust) +import Data.Word (Word8) +import Control.Arrow (first) +import Control.DeepSeq +import Control.Monad ((<$!>)) {- ************************************************************************ @@ -112,6 +113,10 @@ newtype IfLclName = IfLclName { getIfLclName :: LexicalFastString } deriving (Eq, Ord, Show) +instance Uniquable IfLclName where + getUnique = getUnique . ifLclNameFS + + ifLclNameFS :: IfLclName -> FastString ifLclNameFS = getLexicalFastString . getIfLclName @@ -2194,12 +2199,35 @@ ppr_parend_preds :: [IfacePredType] -> SDoc ppr_parend_preds preds = parens (fsep (punctuate comma (map ppr preds))) instance Binary IfaceType where - put_ bh tyCon = case findUserDataWriter Proxy bh of - tbl -> putEntry tbl bh tyCon + put_ bh ty = + case findUserDataWriter Proxy bh of + tbl -> putEntry tbl bh ty - get bh = case findUserDataReader Proxy bh of - tbl -> getEntry tbl bh + get bh = getIfaceTypeShared bh +-- | This is the byte tag we expect to read when the next +-- value is not an 'IfaceType' value, but an offset into a +-- lookup value. +-- +-- Must not overlap with any byte tag in 'getIfaceType'. +ifaceTypeSharedByte :: Word8 +ifaceTypeSharedByte = 99 + +-- | Like 'getIfaceType' but checks for a specific byte tag +-- that indicates that we won't be able to read a 'IfaceType' value +-- but rather an offset into a lookup table. Consequentially, +-- we look up the value for the 'IfaceType' in the look up table. +-- +-- See Note [Deduplication during iface binary serialisation] +-- for details. +getIfaceTypeShared :: ReadBinHandle -> IO IfaceType +getIfaceTypeShared bh = do + start <- tellBinReader bh + tag <- getByte bh + if ifaceTypeSharedByte == tag + then case findUserDataReader Proxy bh of + tbl -> getEntry tbl bh + else seekBinReader bh start >> getIfaceType bh putIfaceType :: WriteBinHandle -> IfaceType -> IO () putIfaceType _ (IfaceFreeTyVar tv) ===================================== compiler/GHC/Iface/Type/Map.hs ===================================== @@ -0,0 +1,180 @@ +{-# LANGUAGE TypeFamilies #-} +module GHC.Iface.Type.Map where + +import GHC.Prelude +import GHC.Data.TrieMap +import GHC.Iface.Type +import qualified Data.Map as Map +import Data.Functor.Compose +import GHC.Types.Basic +import Control.Monad ((>=>)) +import GHC.Types.Unique.DFM +import Data.Functor.Product +import GHC.Types.Var (VarBndr(..)) + + +newtype IfaceTypeMap a = IfaceTypeMap (IfaceTypeMapG a) + +instance Functor IfaceTypeMap where + fmap f (IfaceTypeMap m) = IfaceTypeMap (fmap f m) + +instance TrieMap IfaceTypeMap where + type Key IfaceTypeMap = IfaceType + + emptyTM = IfaceTypeMap emptyTM + + lookupTM k (IfaceTypeMap m) = lookupTM k m + + alterTM k f (IfaceTypeMap m) = IfaceTypeMap (alterTM k f m) + + filterTM f (IfaceTypeMap m) = IfaceTypeMap (filterTM f m) + + foldTM f (IfaceTypeMap m) = foldTM f m + +type IfaceTypeMapG = GenMap IfaceTypeMapX + +data IfaceTypeMapX a + = IFM { ifm_lit :: IfaceLiteralMap a + , ifm_var :: UniqDFM IfLclName a + , ifm_app :: IfaceTypeMapG (IfaceAppArgsMap a) + , ifm_fun_ty :: FunTyFlagMap (IfaceTypeMapG (IfaceTypeMapG (IfaceTypeMapG a))) + , ifm_ty_con_app :: IfaceTyConMap (IfaceAppArgsMap a) + , ifm_forall_ty :: IfaceForAllBndrMap (IfaceTypeMapG a) + , ifm_cast_ty :: IfaceTypeMapG (IfaceCoercionMap a) + , ifm_coercion_ty :: IfaceCoercionMap a + , ifm_tuple_ty :: TupleSortMap (PromotionFlagMap (IfaceAppArgsMap a)) } + +type IfaceLiteralMap = Map.Map IfaceTyLit +type FunTyFlagMap = Map.Map FunTyFlag +type IfaceTyConMap = Map.Map IfaceTyCon +type ForAllTyFlagMap = Map.Map ForAllTyFlag +type IfaceCoercionMap = Map.Map IfaceCoercion +type TupleSortMap = Map.Map TupleSort +type PromotionFlagMap = Map.Map PromotionFlag +type IfaceForAllBndrMap = Compose IfaceBndrMap ForAllTyFlagMap + +type IfaceIdBndrMap = Compose IfaceTypeMapG (Compose (UniqDFM IfLclName) IfaceTypeMapG) +type IfaceTvBndrMap = Compose (UniqDFM IfLclName) IfaceTypeMapG + +type IfaceBndrMap = Product IfaceIdBndrMap IfaceTvBndrMap + + + + +type IfaceAppArgsMap a = ListMap (Compose IfaceTypeMapG ForAllTyFlagMap) a + +emptyE :: IfaceTypeMapX a +emptyE = IFM { ifm_lit = emptyTM + , ifm_var = emptyTM + , ifm_app = emptyTM + , ifm_fun_ty = emptyTM + , ifm_ty_con_app = emptyTM + , ifm_forall_ty = emptyTM + , ifm_cast_ty = emptyTM + , ifm_coercion_ty = emptyTM + , ifm_tuple_ty = emptyTM } + +instance Functor IfaceTypeMapX where + fmap f IFM { ifm_lit = ilit + , ifm_var = ivar + , ifm_app = iapp + , ifm_fun_ty = ift + , ifm_ty_con_app = itc + , ifm_forall_ty = ifal + , ifm_cast_ty = icast + , ifm_coercion_ty = ico + , ifm_tuple_ty = itup } + + = IFM { ifm_lit = fmap f ilit + , ifm_var = fmap f ivar + , ifm_app = fmap (fmap f) iapp + , ifm_fun_ty = fmap (fmap (fmap (fmap f))) ift + , ifm_ty_con_app = fmap (fmap f) itc + , ifm_forall_ty = fmap (fmap f) ifal + , ifm_cast_ty = fmap (fmap f) icast + , ifm_coercion_ty = fmap f ico + , ifm_tuple_ty = fmap (fmap (fmap f)) itup } + +instance TrieMap IfaceTypeMapX where + type Key IfaceTypeMapX = IfaceType + + emptyTM = emptyE + lookupTM = lkE + alterTM = xtE + foldTM = fdE + filterTM = ftE + {-# INLINE lookupTM #-} + {-# INLINE alterTM #-} + +{-# INLINE ftE #-} +ftE :: (a -> Bool) -> IfaceTypeMapX a -> IfaceTypeMapX a +ftE f IFM { ifm_lit = ilit + , ifm_var = ivar + , ifm_app = iapp + , ifm_fun_ty = ift + , ifm_ty_con_app = itc + , ifm_forall_ty = ifal + , ifm_cast_ty = icast + , ifm_coercion_ty = ico + , ifm_tuple_ty = itup } + + = IFM { ifm_lit = filterTM f ilit + , ifm_var = filterTM f ivar + , ifm_app = fmap (filterTM f) iapp + , ifm_fun_ty = fmap (fmap (fmap (filterTM f))) ift + , ifm_ty_con_app = fmap (filterTM f) itc + , ifm_forall_ty = fmap (filterTM f) ifal + , ifm_cast_ty = fmap (filterTM f) icast + , ifm_coercion_ty = filterTM f ico + , ifm_tuple_ty = fmap (fmap (filterTM f)) itup } + +{-# INLINE fdE #-} +fdE :: (a -> b -> b) -> IfaceTypeMapX a -> b -> b +fdE f IFM { ifm_lit = ilit + , ifm_var = ivar + , ifm_app = iapp + , ifm_fun_ty = ift + , ifm_ty_con_app = itc + , ifm_forall_ty = ifal + , ifm_cast_ty = icast + , ifm_coercion_ty = ico + , ifm_tuple_ty = itup } + = foldTM f ilit . foldTM f ivar . foldTM (foldTM f) iapp + . foldTM (foldTM (foldTM (foldTM f))) ift + . foldTM (foldTM f) itc + . foldTM (foldTM f) ifal + . foldTM (foldTM f) icast + . foldTM f ico + . foldTM (foldTM (foldTM f)) itup + +bndrToKey :: IfaceBndr -> Either (IfaceType, (IfLclName, IfaceType)) IfaceTvBndr +bndrToKey (IfaceIdBndr (a,b,c)) = Left (a, (b,c)) +bndrToKey (IfaceTvBndr k) = Right k + +{-# INLINE lkE #-} +lkE :: IfaceType -> IfaceTypeMapX a -> Maybe a +lkE it ifm = go it ifm + where + go (IfaceFreeTyVar {}) = error "ftv" + go (IfaceTyVar var) = ifm_var >.> lookupTM var + go (IfaceLitTy l) = ifm_lit >.> lookupTM l + go (IfaceAppTy ift args) = ifm_app >.> lkG ift >=> lookupTM (appArgsIfaceTypesForAllTyFlags args) + go (IfaceFunTy ft t1 t2 t3) = ifm_fun_ty >.> lookupTM ft >=> lkG t1 >=> lkG t2 >=> lkG t3 + go (IfaceForAllTy (Bndr a b) t) = ifm_forall_ty >.> lookupTM (bndrToKey a,b) >=> lkG t + go (IfaceTyConApp tc args) = ifm_ty_con_app >.> lookupTM tc >=> lookupTM (appArgsIfaceTypesForAllTyFlags args) + go (IfaceCastTy ty co) = ifm_cast_ty >.> lkG ty >=> lookupTM co + go (IfaceCoercionTy co) = ifm_coercion_ty >.> lookupTM co + go (IfaceTupleTy sort prom args) = ifm_tuple_ty >.> lookupTM sort >=> lookupTM prom >=> lookupTM (appArgsIfaceTypesForAllTyFlags args) + +{-# INLINE xtE #-} +xtE :: IfaceType -> XT a -> IfaceTypeMapX a -> IfaceTypeMapX a +xtE (IfaceFreeTyVar {}) _ _ = error "ftv" +xtE (IfaceTyVar var) f m = m { ifm_var = ifm_var m |> alterTM var f } +xtE (IfaceLitTy l) f m = m { ifm_lit = ifm_lit m |> alterTM l f } +xtE (IfaceAppTy ift args) f m = m { ifm_app = ifm_app m |> xtG ift |>> alterTM (appArgsIfaceTypesForAllTyFlags args) f } +xtE (IfaceFunTy ft t1 t2 t3) f m = m { ifm_fun_ty = ifm_fun_ty m |> alterTM ft |>> xtG t1 |>> xtG t2 |>> xtG t3 f } +xtE (IfaceForAllTy (Bndr a b) t) f m = m { ifm_forall_ty = ifm_forall_ty m |> alterTM (bndrToKey a,b) |>> xtG t f } +xtE (IfaceTyConApp tc args) f m = m { ifm_ty_con_app = ifm_ty_con_app m |> alterTM tc |>> alterTM (appArgsIfaceTypesForAllTyFlags args) f } +xtE (IfaceCastTy ty co) f m = m { ifm_cast_ty = ifm_cast_ty m |> xtG ty |>> alterTM co f } +xtE (IfaceCoercionTy co) f m = m { ifm_coercion_ty = ifm_coercion_ty m |> alterTM co f } +xtE (IfaceTupleTy sort prom args) f m = m { ifm_tuple_ty = ifm_tuple_ty m |> alterTM sort |>> alterTM prom |>> alterTM (appArgsIfaceTypesForAllTyFlags args) f } ===================================== compiler/GHC/Stg/CSE.hs ===================================== @@ -124,7 +124,7 @@ data StgArgMap a = SAM , sam_lit :: LiteralMap a } -type LiteralMap a = Map.Map Literal a +type LiteralMap = Map.Map Literal -- TODO(22292): derive instance Functor StgArgMap where ===================================== compiler/ghc.cabal.in ===================================== @@ -594,6 +594,7 @@ Library GHC.Iface.Tidy.StaticPtrTable GHC.IfaceToCore GHC.Iface.Type + GHC.Iface.Type.Map GHC.JS.Ident GHC.JS.Make GHC.JS.Optimizer ===================================== docs/users_guide/using-optimisation.rst ===================================== @@ -1777,3 +1777,12 @@ as such you shouldn't need to set any of them explicitly. A flag This flag sets the size (in bytes) threshold above which the second approach is used. You can disable the second approach entirely by setting the threshold to 0. + +.. ghc-flag:: -fwrite-if-compression=⟨n⟩ + :shortdesc: *default: 2.* Tweak the level of interface file compression. + :type: dynamic + :category: optimization + + :default: 2 + + TODO ===================================== testsuite/tests/iface/IfaceSharingIfaceType.hs ===================================== @@ -0,0 +1,44 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE OverloadedStrings #-} + +module IfaceSharingIfaceType (types) where + +import GHC.Data.FastString +import GHC.Builtin.Uniques +import GHC.Builtin.Names +import GHC.Builtin.Types +import GHC.Types.Name +import GHC.Types.SrcLoc +import GHC.Iface.Type +import GHC.CoreToIface +import GHC.Core.TyCo.Rep +import GHC + +[f1,f2,f3,f4,f5] = map mkVarOcc ["a", "b","c","d","e"] + +[u1,u2,u3,u4,u5] = map mkPreludeMiscIdUnique [10000..10004] + +names = [ mkExternalName u1 pRELUDE f1 noSrcSpan + , mkExternalName u2 pRELUDE f2 noSrcSpan + , mkExternalName u3 pRELUDE f3 noSrcSpan + , mkExternalName u4 pRELUDE f4 noSrcSpan + , mkExternalName u5 pRELUDE f5 noSrcSpan ] + +-- Int +intIfaceTy = toIfaceType intTy + +wordIfaceTy = toIfaceType wordTy + +listIntTy = toIfaceType (mkListTy intTy) + +funTy = (intTy `mkVisFunTyMany` wordTy `mkVisFunTyMany` mkListTy intTy) + +funIfaceTy = toIfaceType funTy + +reallyBigFunTy = toIfaceType (funTy `mkVisFunTyMany` funTy `mkVisFunTyMany` funTy `mkVisFunTyMany` funTy) + +forallIfaceTy = toIfaceType (dataConType justDataCon) + + +types = [intIfaceTy, wordIfaceTy, listIntTy, funIfaceTy, reallyBigFunTy, forallIfaceTy] + ===================================== testsuite/tests/iface/IfaceSharingName.hs ===================================== @@ -0,0 +1,21 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE OverloadedStrings #-} + +module IfaceSharingName where + +import Lib +import GHC.Data.FastString +import GHC.Builtin.Uniques +import GHC.Builtin.Names +import GHC.Types.Name +import GHC.Types.SrcLoc + +[f1,f2,f3,f4,f5] = map mkVarOcc ["a", "b","c","d","e"] + +[u1,u2,u3,u4,u5] = map mkPreludeMiscIdUnique [10000..10004] + +names = [ mkExternalName u1 pRELUDE f1 noSrcSpan + , mkExternalName u2 pRELUDE f2 noSrcSpan + , mkExternalName u3 pRELUDE f3 noSrcSpan + , mkExternalName u4 pRELUDE f4 noSrcSpan + , mkExternalName u5 pRELUDE f5 noSrcSpan ] ===================================== testsuite/tests/iface/Lib.hs ===================================== @@ -0,0 +1,15 @@ +module Lib where + +import GHC.Utils.Binary +import GHC.Iface.Binary +import qualified Data.ByteString as B +import System.Environment +import Data.Maybe + +testSize :: Binary a => CompressionIFace -> a -> IO Int +testSize compLvl payload = do + args <- getArgs + bh <- openBinMem 1024 + putWithUserData QuietBinIFace compLvl bh payload + withBinBuffer bh (\b -> return (B.length b)) + ===================================== testsuite/tests/iface/Makefile ===================================== @@ -0,0 +1,4 @@ +TOP=../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + ===================================== testsuite/tests/iface/all.T ===================================== @@ -0,0 +1,24 @@ +test( 'if_faststring' + , [ stat_from_file('normal', 5, 'NORMALSIZE') + , stat_from_file('medium', 5, 'MEDIUMSIZE') + , stat_from_file('full', 5, 'FULLSIZE') + , extra_files(["Lib.hs"])] + , compile_and_run + , ['-package ghc']) + +test( 'if_name' + , [ stat_from_file('normal', 5, 'NORMALSIZE') + , stat_from_file('medium', 5, 'MEDIUMSIZE') + , stat_from_file('full', 5, 'FULLSIZE') + , extra_files(["Lib.hs", "IfaceSharingName.hs"])] + , compile_and_run + , ['-package ghc']) + +test( 'if_ifacetype' + , [ stat_from_file('normal', 5, 'NORMALSIZE') + , stat_from_file('medium', 5, 'MEDIUMSIZE') + , stat_from_file('full', 5, 'FULLSIZE') + , extra_files(["Lib.hs", "IfaceSharingIfaceType.hs"])] + , compile_and_run + , ['-package ghc']) + ===================================== testsuite/tests/iface/if_faststring.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE OverloadedStrings #-} + +import Lib +import GHC.Data.FastString +import GHC.Iface.Binary + +main :: IO () +main = do + sz <- testSize MaximalCompression (concat (replicate 1000 ["abc", "cde", "efg" :: FastString])) + writeFile "FULLSIZE" (show sz) + sz <- testSize SafeExtraCompression (concat (replicate 1000 ["abc", "cde", "efg" :: FastString])) + writeFile "MEDIUMSIZE" (show sz) + sz <- testSize NormalCompression (concat (replicate 1000 ["abc", "cde", "efg" :: FastString])) + writeFile "NORMALSIZE" (show sz) ===================================== testsuite/tests/iface/if_ifacetype.hs ===================================== @@ -0,0 +1,13 @@ +import Lib +import IfaceSharingIfaceType +import GHC.Iface.Binary + +main :: IO () +main = do + sz <- testSize MaximalCompression (concat (replicate 500 types)) + writeFile "FULLSIZE" (show sz) + sz <- testSize SafeExtraCompression (concat (replicate 500 types)) + writeFile "MEDIUMSIZE" (show sz) + sz <- testSize NormalCompression (concat (replicate 500 types)) + writeFile "NORMALSIZE" (show sz) + ===================================== testsuite/tests/iface/if_name.hs ===================================== @@ -0,0 +1,12 @@ +import Lib +import IfaceSharingName +import GHC.Iface.Binary + +main :: IO () +main = do + sz <- testSize MaximalCompression (concat (replicate 1000 names)) + writeFile "FULLSIZE" (show sz) + sz <- testSize SafeExtraCompression (concat (replicate 1000 names)) + writeFile "MEDIUMSIZE" (show sz) + sz <- testSize NormalCompression (concat (replicate 1000 names)) + writeFile "NORMALSIZE" (show sz) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/485d2cb3fedc7f2dbf9d20c309bf7878af38bf3f...5388078182762a2912f2feaae024ec465975f912 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/485d2cb3fedc7f2dbf9d20c309bf7878af38bf3f...5388078182762a2912f2feaae024ec465975f912 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 1 12:56:17 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 01 May 2024 08:56:17 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/mr-12536 Message-ID: <66323bf1baabe_3074b4e5ee948580@gitlab.mail> Matthew Pickering pushed new branch wip/mr-12536 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/mr-12536 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 1 14:16:18 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 01 May 2024 10:16:18 -0400 Subject: [Git][ghc/ghc][ghc-9.10] Add missing entries in the base-4.20 release notes Message-ID: <66324eb2abe37_3074b418cf40010118@gitlab.mail> Ben Gamari pushed to branch ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: 2c6375b9 by Hécate Moonlight at 2024-05-01T01:44:10+02:00 Add missing entries in the base-4.20 release notes - - - - - 1 changed file: - docs/users_guide/9.10.1-notes.rst Changes: ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -293,6 +293,13 @@ Runtime system can be individually enabled and disabled via :base-ref:`GHC.Exception.Backtrace.setEnabledBacktraceMechanisms`. +- Deprecation of ``GHC.Pack`` has reached Phase 2. A warning is now thrown when importing the module. + See `ghc/ghc#21461 `_. + +- `CLC proposal #258 `_: + ``Data.List.NonEmpty.unzip`` raises a specific warning about its future monomorphisation. + Do consider switching to ``Data.Functor.unzip`` if you need to keep it polymorphic. + ``ghc-prim`` library ~~~~~~~~~~~~~~~~~~~~ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2c6375b9a804ac7fca1e82eb6fcfc8594c67c5f5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2c6375b9a804ac7fca1e82eb6fcfc8594c67c5f5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 1 15:22:58 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 01 May 2024 11:22:58 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: testsuite: Handle exceptions in framework_fail when testdir is not initialised Message-ID: <66325e5210501_3074b420a698011385b@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - a821ad4e by Sylvain Henry at 2024-05-01T11:22:49-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 050446c5 by Sylvain Henry at 2024-05-01T11:22:49-04:00 Bump haddock submodule - - - - - 9c4634e5 by Sylvain Henry at 2024-05-01T11:22:53-04:00 JS: cleanup to prepare for #24743 - - - - - 15 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Parser.y - compiler/GHC/StgToJS/Apply.hs - compiler/GHC/StgToJS/Arg.hs - compiler/GHC/StgToJS/Closure.hs - compiler/GHC/StgToJS/CodeGen.hs - compiler/GHC/StgToJS/Expr.hs - compiler/GHC/StgToJS/Heap.hs - compiler/GHC/StgToJS/Rts/Rts.hs - compiler/GHC/StgToJS/Stack.hs - compiler/GHC/StgToJS/Types.hs - hadrian/src/Rules/Dependencies.hs - libraries/ghc-internal/src/GHC/Internal/Base.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs - + libraries/template-haskell/Language/Haskell/TH/Lib/Syntax.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c79e96939225583820318f4d91afe32682e2feee...9c4634e56ccad69095b516d84205cebeabdc6a08 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c79e96939225583820318f4d91afe32682e2feee...9c4634e56ccad69095b516d84205cebeabdc6a08 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 1 17:16:58 2024 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Wed, 01 May 2024 13:16:58 -0400 Subject: [Git][ghc/ghc][wip/t24277] 87 commits: Prefer packed representation for CompiledByteCode Message-ID: <6632790a1226d_3074b4302988013226b@gitlab.mail> Finley McIlwaine pushed to branch wip/t24277 at Glasgow Haskell Compiler / GHC Commits: 868c8a78 by Fendor at 2024-04-09T08:51:50-04:00 Prefer packed representation for CompiledByteCode As there are many 'CompiledByteCode' objects alive during a GHCi session, representing its element in a more packed manner improves space behaviour at a minimal cost. When running GHCi on the agda codebase, we find around 380 live 'CompiledByteCode' objects. Packing their respective 'UnlinkedByteCode' can save quite some pointers. - - - - - be3bddde by Alan Zimmerman at 2024-04-09T08:52:26-04:00 EPA: Capture all comments in a ClassDecl Hopefully the final fix needed for #24533 - - - - - 3d0806fc by Jade at 2024-04-10T05:39:53-04:00 Validate -main-is flag using parseIdentifier Fixes #24368 - - - - - dd530bb7 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: free error message before returning Fixes a memory leak in rts/linker/PEi386.c - - - - - e008a19a by Alexis King at 2024-04-10T05:40:29-04:00 linker: Avoid linear search when looking up Haskell symbols via dlsym See the primary Note [Looking up symbols in the relevant objects] for a more in-depth explanation. When dynamically loading a Haskell symbol (typical when running a splice or GHCi expression), before this commit we would search for the symbol in all dynamic libraries that were loaded. However, this could be very inefficient when too many packages are loaded (which can happen if there are many package dependencies) because the time to lookup the would be linear in the number of packages loaded. This commit drastically improves symbol loading performance by introducing a mapping from units to the handles of corresponding loaded dlls. These handles are returned by dlopen when we load a dll, and can then be used to look up in a specific dynamic library. Looking up a given Name is now much more precise because we can get lookup its unit in the mapping and lookup the symbol solely in the handles of the dynamic libraries loaded for that unit. In one measurement, the wait time before the expression was executed went from +-38 seconds down to +-2s. This commit also includes Note [Symbols may not be found in pkgs_loaded], explaining the fallback to the old behaviour in case no dll can be found in the unit mapping for a given Name. Fixes #23415 Co-authored-by: Rodrigo Mesquita (@alt-romes) - - - - - dcfaa190 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: Make addDLL a wrapper around loadNativeObj Rewrite the implementation of `addDLL` as a wrapper around the more principled `loadNativeObj` rts linker function. The latter should be preferred while the former is preserved for backwards compatibility. `loadNativeObj` was previously only available on ELF platforms, so this commit further refactors the rts linker to transform loadNativeObj_ELF into loadNativeObj_POSIX, which is available in ELF and MachO platforms. The refactor made it possible to remove the `dl_mutex` mutex in favour of always using `linker_mutex` (rather than a combination of both). Lastly, we implement `loadNativeObj` for Windows too. - - - - - 12931698 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 Use symbol cache in internal interpreter too This commit makes the symbol cache that was used by the external interpreter available for the internal interpreter too. This follows from the analysis in #23415 that suggests the internal interpreter could benefit from this cache too, and that there is no good reason not to have the cache for it too. It also makes it a bit more uniform to have the symbol cache range over both the internal and external interpreter. This commit also refactors the cache into a function which is used by both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the caching logic to `lookupSymbolInDLL` too. - - - - - dccd3ea1 by Ben Gamari at 2024-04-10T05:40:29-04:00 testsuite: Add test for lookupSymbolInNativeObj - - - - - 1b1a92bd by Alan Zimmerman at 2024-04-10T05:41:05-04:00 EPA: Remove unnecessary XRec in CompleteMatchSig The XRec for [LIdP pass] is not needed for exact printing, remove it. - - - - - 6e18ce2b by Ben Gamari at 2024-04-12T08:16:09-04:00 users-guide: Clarify language extension documentation Over the years the users guide's language extension documentation has gone through quite a few refactorings. In the process some of the descriptions have been rendered non-sensical. For instance, the description of `NoImplicitPrelude` actually describes the semantics of `ImplicitPrelude`. To fix this we: * ensure that all extensions are named in their "positive" sense (e.g. `ImplicitPrelude` rather than `NoImplicitPrelude`). * rework the documentation to avoid flag-oriented wording like "enable" and "disable" * ensure that the polarity of the documentation is consistent with reality. Fixes #23895. - - - - - a933aff3 by Zubin Duggal at 2024-04-12T08:16:45-04:00 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - 23c3e624 by Andreas Klebinger at 2024-04-12T08:17:21-04:00 RTS: Emit warning when -M < -H Fixes #24487 - - - - - d23afb8c by Ben Gamari at 2024-04-12T08:17:56-04:00 testsuite: Add broken test for CApiFFI with -fprefer-bytecode See #24634. - - - - - a4bb3a51 by Ben Gamari at 2024-04-12T08:18:32-04:00 base: Deprecate GHC.Pack As proposed in #21461. Closes #21540. - - - - - 55eb8c98 by Ben Gamari at 2024-04-12T08:19:08-04:00 ghc-internal: Fix mentions of ghc-internal in deprecation warnings Closes #24609. - - - - - b0fbd181 by Ben Gamari at 2024-04-12T08:19:44-04:00 rts: Implement set_initial_registers for AArch64 Fixes #23680. - - - - - 14c9ec62 by Ben Gamari at 2024-04-12T08:20:20-04:00 ghcup-metadata: Use Debian 9 binaries on Ubuntu 16, 17 Closes #24646. - - - - - 35a1621e by Ben Gamari at 2024-04-12T08:20:55-04:00 Bump unix submodule to 2.8.5.1 Closes #24640. - - - - - a1c24df0 by Finley McIlwaine at 2024-04-12T08:21:31-04:00 Correct default -funfolding-use-threshold in docs - - - - - 0255d03c by Oleg Grenrus at 2024-04-12T08:22:07-04:00 FastString is a __Modified__ UTF-8 - - - - - c3489547 by Matthew Pickering at 2024-04-12T13:13:44-04:00 rts: Improve tracing message when nursery is resized It is sometimes more useful to know how much bigger or smaller the nursery got when it is resized. In particular I am trying to investigate situations where we end up with fragmentation due to the nursery (#24577) - - - - - 5e4f4ba8 by Simon Peyton Jones at 2024-04-12T13:14:20-04:00 Don't generate wrappers for `type data` constructors with StrictData Previously, the logic for checking if a data constructor needs a wrapper or not would take into account whether the constructor's fields have explicit strictness (e.g., `data T = MkT !Int`), but the logic would _not_ take into account whether `StrictData` was enabled. This meant that something like `type data T = MkT Int` would incorrectly generate a wrapper for `MkT` if `StrictData` was enabled, leading to the horrible errors seen in #24620. To fix this, we disable generating wrappers for `type data` constructors altogether. Fixes #24620. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - dbdf1995 by Alex Mason at 2024-04-15T15:28:26+10:00 Implements MO_S_Mul2 and MO_U_Mul2 using the UMULH, UMULL and SMULH instructions for AArch64 Also adds a test for MO_S_Mul2 - - - - - 42bd0407 by Teo Camarasu at 2024-04-16T20:06:39-04:00 Make template-haskell a stage1 package Promoting template-haskell from a stage0 to a stage1 package means that we can much more easily refactor template-haskell. We implement this by duplicating the in-tree `template-haskell`. A new `template-haskell-next` library is autogenerated to mirror `template-haskell` `stage1:ghc` to depend on the new interface of the library including the `Binary` instances without adding an explicit dependency on `template-haskell`. This is controlled by the `bootstrap-th` cabal flag When building `template-haskell` modules as part of this vendoring we do not have access to quote syntax, so we cannot use variable quote notation (`'Just`). So we either replace these with hand-written `Name`s or hide the code behind CPP. We can remove the `th_hack` from hadrian, which was required when building stage0 packages using the in-tree `template-haskell` library. For more details see Note [Bootstrapping Template Haskell]. Resolves #23536 Co-Authored-By: Sebastian Graf <sgraf1337 at gmail.com> Co-Authored-By: Matthew Craven <5086-clyring at users.noreply.gitlab.haskell.org> - - - - - 3d973e47 by Ben Gamari at 2024-04-16T20:07:15-04:00 Bump parsec submodule to 3.1.17.0 - - - - - 9d38bfa0 by Simon Peyton Jones at 2024-04-16T20:07:51-04:00 Clone CoVars in CorePrep This MR addresses #24463. It's all explained in the new Note [Cloning CoVars and TyVars] - - - - - 0fe2b410 by Andreas Klebinger at 2024-04-16T20:08:27-04:00 NCG: Fix a bug where we errounously removed a required jump instruction. Add a new method to the Instruction class to check if we can eliminate a jump in favour of fallthrough control flow. Fixes #24507 - - - - - 9f99126a by Teo Camarasu at 2024-04-16T20:09:04-04:00 Fix documentation preview from doc-tarball job - Include all the .html files and assets in the job artefacts - Include all the .pdf files in the job artefacts - Mark the artefact as an "exposed" artefact meaning it turns up in the UI. Resolves #24651 - - - - - 3a0642ea by Ben Gamari at 2024-04-16T20:09:39-04:00 rts: Ignore EINTR while polling in timerfd itimer implementation While the RTS does attempt to mask signals, it may be that a foreign library unmasks them. This previously caused benign warnings which we now ignore. See #24610. - - - - - 9a53cd3f by Alan Zimmerman at 2024-04-16T20:10:15-04:00 EPA: Add additional comments field to AnnsModule This is used in exact printing to store comments coming after the `where` keyword but before any comments allocated to imports or decls. It is used in ghc-exactprint, see https://github.com/alanz/ghc-exactprint/commit/44bbed311fd8f0d053053fef195bf47c17d34fa7 - - - - - e5c43259 by Bryan Richter at 2024-04-16T20:10:51-04:00 Remove unrunnable FreeBSD CI jobs FreeBSD runner supply is inelastic. Currently there is only one, and it's unavailable because of a hardware issue. - - - - - 914eb49a by Ben Gamari at 2024-04-16T20:11:27-04:00 rel-eng: Fix mktemp usage in recompress-all We need a temporary directory, not a file. - - - - - f30e4984 by Teo Camarasu at 2024-04-16T20:12:03-04:00 Fix ghc API link in docs/index.html This was missing part of the unit ID meaning it would 404. Resolves #24674 - - - - - d7a3d6b5 by Ben Gamari at 2024-04-16T20:12:39-04:00 template-haskell: Declare TH.Lib.Internal as not-home Rather than `hide`. Closes #24659. - - - - - 5eaa46e7 by Matthew Pickering at 2024-04-19T02:14:55-04:00 testsuite: Rename isCross() predicate to needsTargetWrapper() isCross() was a misnamed because it assumed that all cross targets would provide a target wrapper, but the two most common cross targets (javascript, wasm) don't need a target wrapper. Therefore we rename this predicate to `needsTargetWrapper()` so situations in the testsuite where we can check whether running executables requires a target wrapper or not. - - - - - 55a9d699 by Simon Peyton Jones at 2024-04-19T02:15:32-04:00 Do not float HNFs out of lambdas This MR adjusts SetLevels so that it is less eager to float a HNF (lambda or constructor application) out of a lambda, unless it gets to top level. Data suggests that this change is a small net win: * nofib bytes-allocated falls by -0.09% (but a couple go up) * perf/should_compile bytes-allocated falls by -0.5% * perf/should_run bytes-allocated falls by -0.1% See !12410 for more detail. When fiddling elsewhere, I also found that this patch had a huge positive effect on the (very delicate) test perf/should_run/T21839r But that improvement doesn't show up in this MR by itself. Metric Decrease: MultiLayerModulesRecomp T15703 parsing001 - - - - - f0701585 by Alan Zimmerman at 2024-04-19T02:16:08-04:00 EPA: Fix comments in mkListSyntaxTy0 Also extend the test to confirm. Addresses #24669, 1 of 4 - - - - - b01c01d4 by Serge S. Gulin at 2024-04-19T02:16:51-04:00 JS: set image `x86_64-linux-deb11-emsdk-closure` for build - - - - - c90c6039 by Alan Zimmerman at 2024-04-19T02:17:27-04:00 EPA: Provide correct span for PatBind And remove unused parameter in checkPatBind Contributes to #24669 - - - - - 26036f96 by Alan Zimmerman at 2024-04-19T13:11:08-04:00 EPA: Fix span for PatBuilderAppType Include the location of the prefix @ in the span for InVisPat. Also removes unnecessary annotations from HsTP. Contributes to #24669 - - - - - dba03aab by Matthew Craven at 2024-04-19T13:11:44-04:00 testsuite: Give the pre_cmd for mhu-perf more time - - - - - d31fbf6c by Krzysztof Gogolewski at 2024-04-19T21:04:09-04:00 Fix quantification order for a `op` b and a %m -> b Fixes #23764 Implements https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0640-tyop-quantification-order.rst Updates haddock submodule. - - - - - 385cd1c4 by Sebastian Graf at 2024-04-19T21:04:45-04:00 Make `seq#` a magic Id and inline it in CorePrep (#24124) We can save much code and explanation in Tag Inference and StgToCmm by making `seq#` a known-key Magic Id in `GHC.Internal.IO` and inline this definition in CorePrep. See the updated `Note [seq# magic]`. I also implemented a new `Note [Flatten case-bind]` to get better code for otherwise nested case scrutinees. I renamed the contructors of `ArgInfo` to use an `AI` prefix in order to resolve the clash between `type CpeApp = CoreExpr` and the data constructor of `ArgInfo`, as well as fixed typos in `Note [CorePrep invariants]`. Fixes #24252 and #24124. - - - - - 275e41a9 by Jade at 2024-04-20T11:10:40-04:00 Put the newline after errors instead of before them This mainly has consequences for GHCi but also slightly alters how the output of GHC on the commandline looks. Fixes: #22499 - - - - - dd339c7a by Teo Camarasu at 2024-04-20T11:11:16-04:00 Remove unecessary stage0 packages Historically quite a few packages had to be stage0 as they depended on `template-haskell` and that was stage0. In #23536 we made it so that was no longer the case. This allows us to remove a bunch of packages from this list. A few still remain. A new version of `Win32` is required by `semaphore-compat`. Including `Win32` in the stage0 set requires also including `filepath` because otherwise Hadrian's dependency logic gets confused. Once our boot compiler has a newer version of `Win32` all of these will be able to be dropped. Resolves #24652 - - - - - 2f8e3a25 by Alan Zimmerman at 2024-04-20T11:11:52-04:00 EPA: Avoid duplicated comments in splice decls Contributes to #24669 - - - - - c70b9ddb by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fix typos and namings (fixes #24602) You may noted that I've also changed term of ``` , global "h$vt_double" ||= toJExpr IntV ``` See "IntV" and ``` WaitReadOp -> \[] [fd] -> pure $ PRPrimCall $ returnS (app "h$waidRead" [fd]) ``` See "h$waidRead" - - - - - 3db54f9b by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: trivial checks for variable presence (fixes #24602) - - - - - 777f108f by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fs module imported twice (by emscripten and by ghc-internal). ghc-internal import wrapped in a closure to prevent conflict with emscripten (fixes #24602) Better solution is to use some JavaScript module system like AMD, CommonJS or even UMD. It will be investigated at other issues. At first glance we should try UMD (See https://github.com/umdjs/umd) - - - - - a45a5712 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: thread.js requires h$fds and h$fdReady to be declared for static code analysis, minimal code copied from GHCJS (fixes #24602) I've just copied some old pieces of GHCJS from publicly available sources (See https://github.com/Taneb/shims/blob/a6dd0202dcdb86ad63201495b8b5d9763483eb35/src/io.js#L607). Also I didn't put details to h$fds. I took minimal and left only its object initialization: `var h$fds = {};` - - - - - ad90bf12 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: heap and stack overflows reporting defined as js hard failure (fixes #24602) These errors were treated as a hard failure for browser application. The fix is trivial: just throw error. - - - - - 5962fa52 by Serge S. Gulin at 2024-04-21T16:33:44+03:00 JS: Stubs for code without actual implementation detected by Google Closure Compiler (fixes #24602) These errors were fixed just by introducing stubbed functions with throw for further implementation. - - - - - a0694298 by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add externs to linker (fixes #24602) After enabling jsdoc and built-in google closure compiler types I was needed to deal with the following: 1. Define NodeJS-environment types. I've just copied minimal set of externs from semi-official repo (see https://github.com/externs/nodejs/blob/6c6882c73efcdceecf42e7ba11f1e3e5c9c041f0/v8/nodejs.js#L8). 2. Define Emscripten-environment types: `HEAP8`. Emscripten already provides some externs in our code but it supposed to be run in some module system. And its definitions do not work well in plain bundle. 3. We have some functions which purpose is to add to functions some contextual information via function properties. These functions should be marked as `modifies` to let google closure compiler remove calls if these functions are not used actually by call graph. Such functions are: `h$o`, `h$sti`, `h$init_closure`, `h$setObjInfo`. 4. STG primitives such as registries and stuff from `GHC.StgToJS`. `dXX` properties were already present at externs generator function but they are started from `7`, not from `1`. This message is related: `// fixme does closure compiler bite us here?` - - - - - e58bb29f by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: added both tests: for size and for correctness (fixes #24602) By some reason MacOS builds add to stderr messages like: Ignoring unexpected archive entry: __.SYMDEF ... However I left stderr to `/dev/null` for compatibility with linux CI builds. - - - - - 909f3a9c by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Disable js linker warning for empty symbol table to make js tests running consistent across environments - - - - - 83eb10da by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add special preprocessor for js files due of needing to keep jsdoc comments (fixes #24602) Our js files have defined google closure compiler types at jsdoc entries but these jsdoc entries are removed by cpp preprocessor. I considered that reusing them in javascript-backend would be a nice thing. Right now haskell processor uses `-traditional` option to deal with comments and `//` operators. But now there are following compiler options: `-C` and `-CC`. You can read about them at GCC (see https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#index-CC) and CLang (see https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-CC). It seems that `-CC` works better for javascript jsdoc than `-traditional`. At least it leaves `/* ... */` comments w/o changes. - - - - - e1cf8dc2 by brandon s allbery kf8nh at 2024-04-22T03:48:26-04:00 fix link in CODEOWNERS It seems that our local Gitlab no longer has documentation for the `CODEOWNERS` file, but the master documentation still does. Use that instead. - - - - - 593f4e04 by Fendor at 2024-04-23T10:19:14-04:00 Add performance regression test for '-fwrite-simplified-core' - - - - - 1ba39b05 by Fendor at 2024-04-23T10:19:14-04:00 Typecheck corebindings lazily during bytecode generation This delays typechecking the corebindings until the bytecode generation happens. We also avoid allocating a thunk that is retained by `unsafeInterleaveIO`. In general, we shouldn't retain values of the hydrated `Type`, as not evaluating the bytecode object keeps it alive. It is better if we retain the unhydrated `IfaceType`. See Note [Hydrating Modules] - - - - - e916fc92 by Alan Zimmerman at 2024-04-23T10:19:50-04:00 EPA: Keep comments in a CaseAlt match The comments now live in the surrounding location, not inside the Match. Make sure we keep them. Closes #24707 - - - - - d2b17f32 by Cheng Shao at 2024-04-23T15:01:22-04:00 driver: force merge objects when building dynamic objects This patch forces the driver to always merge objects when building dynamic objects even when ar -L is supported. It is an oversight of !8887: original rationale of that patch is favoring the relatively cheap ar -L operation over object merging when ar -L is supported, which makes sense but only if we are building static objects! Omitting check for whether we are building dynamic objects will result in broken .so files with undefined reference errors at executable link time when building GHC with llvm-ar. Fixes #22210. - - - - - 209d09f5 by Julian Ospald at 2024-04-23T15:02:03-04:00 Allow non-absolute values for bootstrap GHC variable Fixes #24682 - - - - - 3fff0977 by Matthew Pickering at 2024-04-23T15:02:38-04:00 Don't depend on registerPackage function in Cabal More recent versions of Cabal modify the behaviour of libAbiHash which breaks our usage of registerPackage. It is simpler to inline the part of registerPackage that we need and avoid any additional dependency and complication using the higher-level function introduces. - - - - - c62dc317 by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: remove obsolete ln script This commit removes an obsolete ln script in ghc-bignum/gmp. See 060251c24ad160264ae8553efecbb8bed2f06360 for its original intention, but it's been obsolete for a long time, especially since the removal of the make build system. Hence the house cleaning. - - - - - 6399d52b by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: update gmp to 6.3.0 This patch bumps the gmp-tarballs submodule and updates gmp to 6.3.0. The tarball format is now xz, and gmpsrc.patch has been patched into the tarball so hadrian no longer needs to deal with patching logic when building in-tree GMP. - - - - - 65b4b92f by Cheng Shao at 2024-04-25T01:32:02-04:00 hadrian: remove obsolete Patch logic This commit removes obsolete Patch logic from hadrian, given we no longer need to patch the gmp tarball when building in-tree GMP. - - - - - 71f28958 by Cheng Shao at 2024-04-25T01:32:02-04:00 autoconf: remove obsolete patch detection This commit removes obsolete deletection logic of the patch command from autoconf scripts, given we no longer need to patch anything in the GHC build process. - - - - - daeda834 by Sylvain Henry at 2024-04-25T01:32:43-04:00 JS: correctly handle RUBBISH literals (#24664) - - - - - 8a06ddf6 by Matthew Pickering at 2024-04-25T11:16:16-04:00 Linearise ghc-internal and base build This is achieved by requesting the final package database for ghc-internal, which mandates it is fully built as a dependency of configuring the `base` package. This is at the expense of cross-package parrallelism between ghc-internal and the base package. Fixes #24436 - - - - - 94da9365 by Andrei Borzenkov at 2024-04-25T11:16:54-04:00 Fix tuple puns renaming (24702) Move tuple renaming short cutter from `isBuiltInOcc_maybe` to `isPunOcc_maybe`, so we consider incoming module. I also fixed some hidden bugs that raised after the change was done. - - - - - fa03b1fb by Fendor at 2024-04-26T18:03:13-04:00 Refactor the Binary serialisation interface The goal is simplifiy adding deduplication tables to `ModIface` interface serialisation. We identify two main points of interest that make this difficult: 1. UserData hardcodes what `Binary` instances can have deduplication tables. Moreover, it heavily uses partial functions. 2. GHC.Iface.Binary hardcodes the deduplication tables for 'Name' and 'FastString', making it difficult to add more deduplication. Instead of having a single `UserData` record with fields for all the types that can have deduplication tables, we allow to provide custom serialisers for any `Typeable`. These are wrapped in existentials and stored in a `Map` indexed by their respective `TypeRep`. The `Binary` instance of the type to deduplicate still needs to explicitly look up the decoder via `findUserDataReader` and `findUserDataWriter`, which is no worse than the status-quo. `Map` was chosen as microbenchmarks indicate it is the fastest for a small number of keys (< 10). To generalise the deduplication table serialisation mechanism, we introduce the types `ReaderTable` and `WriterTable` which provide a simple interface that is sufficient to implement a general purpose deduplication mechanism for `writeBinIface` and `readBinIface`. This allows us to provide a list of deduplication tables for serialisation that can be extended more easily, for example for `IfaceTyCon`, see the issue https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for more motivation. In addition to this refactoring, we split `UserData` into `ReaderUserData` and `WriterUserData`, to avoid partial functions and reduce overall memory usage, as we need fewer mutable variables. Bump haddock submodule to accomodate for `UserData` split. ------------------------- Metric Increase: MultiLayerModulesTH_Make MultiLayerModulesRecomp T21839c ------------------------- - - - - - bac57298 by Fendor at 2024-04-26T18:03:13-04:00 Split `BinHandle` into `ReadBinHandle` and `WriteBinHandle` A `BinHandle` contains too much information for reading data. For example, it needs to keep a `FastMutInt` and a `IORef BinData`, when the non-mutable variants would suffice. Additionally, this change has the benefit that anyone can immediately tell whether the `BinHandle` is used for reading or writing. Bump haddock submodule BinHandle split. - - - - - 4d6394dd by Simon Peyton Jones at 2024-04-26T18:03:49-04:00 Fix missing escaping-kind check in tcPatSynSig Note [Escaping kind in type signatures] explains how we deal with escaping kinds in type signatures, e.g. f :: forall r (a :: TYPE r). a where the kind of the body is (TYPE r), but `r` is not in scope outside the forall-type. I had missed this subtlety in tcPatSynSig, leading to #24686. This MR fixes it; and a similar bug in tc_top_lhs_type. (The latter is tested by T24686a.) - - - - - 981c2c2c by Alan Zimmerman at 2024-04-26T18:04:25-04:00 EPA: check-exact: check that the roundtrip reproduces the source Closes #24670 - - - - - a8616747 by Andrew Lelechenko at 2024-04-26T18:05:01-04:00 Document that setEnv is not thread-safe - - - - - 1e41de83 by Bryan Richter at 2024-04-26T18:05:37-04:00 CI: Work around frequent Signal 9 errors - - - - - a6d5f9da by Naïm Favier at 2024-04-27T17:52:40-04:00 ghc-internal: add MonadFix instance for (,) Closes https://gitlab.haskell.org/ghc/ghc/-/issues/24288, implements CLC proposal https://github.com/haskell/core-libraries-committee/issues/238. Adds a MonadFix instance for tuples, permitting value recursion in the "native" writer monad and bringing consistency with the existing instance for transformers's WriterT (and, to a lesser extent, for Solo). - - - - - 64feadcd by Rodrigo Mesquita at 2024-04-27T17:53:16-04:00 bindist: Fix xattr cleaning The original fix (725343aa) was incorrect because it used the shell bracket syntax which is the quoting syntax in autoconf, making the test for existence be incorrect and therefore `xattr` was never run. Fixes #24554 - - - - - e2094df3 by damhiya at 2024-04-28T23:52:00+09:00 Make read accepts binary integer formats CLC proposal : https://github.com/haskell/core-libraries-committee/issues/177 - - - - - 1c2fd963 by Alan Zimmerman at 2024-04-29T23:17:00-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 - - - - - 4189d17e by Sylvain Henry at 2024-04-29T23:17:42-04:00 LLVM: better unreachable default destination in Switch (#24717) See added note. Co-authored-by: Siddharth Bhat <siddu.druid at gmail.com> - - - - - a3725c88 by Cheng Shao at 2024-04-29T23:18:20-04:00 ci: enable wasm jobs for MRs with wasm label This patch enables wasm jobs for MRs with wasm label. Previously the wasm label didn't actually have any effect on the CI pipeline, and full-ci needed to be applied to run wasm jobs which was a waste of runners when working on the wasm backend, hence the fix here. - - - - - 702f7964 by Matthew Pickering at 2024-04-29T23:18:56-04:00 Make interface files and object files depend on inplace .conf file A potential fix for #24737 - - - - - 728af21e by Cheng Shao at 2024-04-30T05:30:23-04:00 utils: remove obsolete vagrant scripts Vagrantfile has long been removed in !5288. This commit further removes the obsolete vagrant scripts in the tree. - - - - - 36f2c342 by Cheng Shao at 2024-04-30T05:31:00-04:00 Update autoconf scripts Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 - - - - - ecbf22a6 by Ben Gamari at 2024-04-30T05:31:36-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - 67244b0c by Finley McIlwaine at 2024-05-01T10:15:11-07:00 ghc-internal: Add CostCentreId, currentCallStackIds, ccsToIds, ccId Add functions for gettings the IDs of cost centres to the interface of `GHC.Internal.Stack`, `GHC.Internal.Stack.CCS`, and `GHC.Internal.Exts`. Also add an opaque type for cost center ids, `CostCentreId`, with appropriate instances. Resolves #24277 - - - - - 30 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - .gitlab/rel_eng/recompress-all - CODEOWNERS - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/DmdAnal.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0206cc7cb47bb82d9d83e849047ae23c1f3a4ad0...67244b0c5ff1b0d2899c99858e13ec07364255f7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0206cc7cb47bb82d9d83e849047ae23c1f3a4ad0...67244b0c5ff1b0d2899c99858e13ec07364255f7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 1 17:18:39 2024 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Wed, 01 May 2024 13:18:39 -0400 Subject: [Git][ghc/ghc][wip/t24277] 3 commits: testsuite: Handle exceptions in framework_fail when testdir is not initialised Message-ID: <6632796f4a0b2_3074b43106154132545@gitlab.mail> Finley McIlwaine pushed to branch wip/t24277 at Glasgow Haskell Compiler / GHC Commits: c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 807da909 by Finley McIlwaine at 2024-05-01T10:18:30-07:00 ghc-internal: Add CostCentreId, currentCallStackIds, ccsToIds, ccId Add functions for gettings the IDs of cost centres to the interface of `GHC.Internal.Stack`, `GHC.Internal.Stack.CCS`, and `GHC.Internal.Exts`. Also add an opaque type for cost center ids, `CostCentreId`, with appropriate instances. Resolves #24277 - - - - - 8 changed files: - compiler/GHC/Parser.y - libraries/ghc-internal/src/GHC/Internal/Exts.hs - libraries/ghc-internal/src/GHC/Internal/Stack.hs - libraries/ghc-internal/src/GHC/Internal/Stack/CCS.hsc - testsuite/driver/testlib.py - + testsuite/tests/printer/DataDeclShort.hs - testsuite/tests/printer/Makefile - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1303,7 +1303,7 @@ ty_decl :: { LTyClDecl GhcPs } | type_data_or_newtype capi_ctype tycl_hdr opt_kind_sig gadt_constrlist maybe_derivings - {% mkTyData (comb4 $1 $3 $5 $6) (sndOf3 $ unLoc $1) (thdOf3 $ unLoc $1) $2 $3 + {% mkTyData (comb5 $1 $3 $4 $5 $6) (sndOf3 $ unLoc $1) (thdOf3 $ unLoc $1) $2 $3 (snd $ unLoc $4) (snd $ unLoc $5) (fmap reverse $6) ((fstOf3 $ unLoc $1)++(fst $ unLoc $4)++(fst $ unLoc $5)) } ===================================== libraries/ghc-internal/src/GHC/Internal/Exts.hs ===================================== @@ -103,6 +103,8 @@ module GHC.Internal.Exts -- ** The call stack currentCallStack, + currentCallStackIds, + CostCentreId, -- * Ids with special behaviour inline, noinline, lazy, oneShot, considerAccessible, seq#, ===================================== libraries/ghc-internal/src/GHC/Internal/Stack.hs ===================================== @@ -24,6 +24,7 @@ module GHC.Internal.Stack ( -- * Profiling call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * HasCallStack call stacks @@ -38,14 +39,17 @@ module GHC.Internal.Stack ( -- * Internals CostCentreStack, CostCentre, + CostCentreId, getCurrentCCS, getCCSOf, clearCCS, ccsCC, ccsParent, + ccId, ccLabel, ccModule, ccSrcSpan, + ccsToIds, ccsToStrings, renderStack ) where ===================================== libraries/ghc-internal/src/GHC/Internal/Stack/CCS.hsc ===================================== @@ -16,14 +16,17 @@ ----------------------------------------------------------------------------- {-# LANGUAGE UnboxedTuples, MagicHash, NoImplicitPrelude #-} +{-# LANGUAGE DerivingStrategies, GeneralizedNewtypeDeriving #-} module GHC.Internal.Stack.CCS ( -- * Call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * Internals CostCentreStack, CostCentre, + CostCentreId, getCurrentCCS, getCCSOf, clearCCS, @@ -31,7 +34,9 @@ module GHC.Internal.Stack.CCS ( ccsParent, ccLabel, ccModule, + ccId, ccSrcSpan, + ccsToIds, ccsToStrings, renderStack, ) where @@ -44,6 +49,12 @@ import GHC.Internal.Base import GHC.Internal.Ptr import GHC.Internal.IO.Encoding import GHC.Internal.List ( concatMap, reverse ) +import GHC.Internal.Word ( Word32 ) +import GHC.Internal.Show +import GHC.Internal.Read +import GHC.Internal.Enum +import GHC.Internal.Real +import GHC.Internal.Num #define PROFILING #include "Rts.h" @@ -54,6 +65,13 @@ data CostCentreStack -- | A cost-centre from GHC's cost-center profiler. data CostCentre +-- | Cost centre identifier +-- +-- @since 4.20.0.0 +newtype CostCentreId = CostCentreId Word32 + deriving (Show, Read) + deriving newtype (Eq, Ord, Bounded, Enum, Integral, Num, Real) + -- | Returns the current 'CostCentreStack' (value is @nullPtr@ if the current -- program was not compiled with profiling support). Takes a dummy argument -- which can be used to avoid the call to @getCurrentCCS@ being floated out by @@ -83,6 +101,12 @@ ccsCC p = peekByteOff p 4 ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack) ccsParent p = peekByteOff p 8 +-- | Get the 'CostCentreId' of a 'CostCentre'. +-- +-- @since 4.20.0.0 +ccId :: Ptr CostCentre -> IO CostCentreId +ccId p = fmap CostCentreId $ peekByteOff p 0 + ccLabel :: Ptr CostCentre -> IO CString ccLabel p = peekByteOff p 4 @@ -99,6 +123,12 @@ ccsCC p = (# peek CostCentreStack, cc) p ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack) ccsParent p = (# peek CostCentreStack, prevStack) p +-- | Get the 'CostCentreId' of a 'CostCentre'. +-- +-- @since 4.20.0.0 +ccId :: Ptr CostCentre -> IO CostCentreId +ccId p = fmap CostCentreId $ (# peek CostCentre, ccID) p + -- | Get the label of a 'CostCentre'. ccLabel :: Ptr CostCentre -> IO CString ccLabel p = (# peek CostCentre, label) p @@ -125,6 +155,19 @@ ccSrcSpan p = (# peek CostCentre, srcloc) p currentCallStack :: IO [String] currentCallStack = ccsToStrings =<< getCurrentCCS () +-- | Returns a @[CostCentreId]@ representing the current call stack. This +-- can be useful for debugging. +-- +-- The implementation uses the call-stack simulation maintained by the +-- profiler, so it only works if the program was compiled with @-prof@ +-- and contains suitable SCC annotations (e.g. by using @-fprof-late@). +-- Otherwise, the list returned is likely to be empty or +-- uninformative. +-- +-- @since 4.20.0.0 +currentCallStackIds :: IO [CostCentreId] +currentCallStackIds = ccsToIds =<< getCurrentCCS () + -- | Format a 'CostCentreStack' as a list of lines. ccsToStrings :: Ptr CostCentreStack -> IO [String] ccsToStrings ccs0 = go ccs0 [] @@ -141,6 +184,24 @@ ccsToStrings ccs0 = go ccs0 [] then return acc else go parent ((mdl ++ '.':lbl ++ ' ':'(':loc ++ ")") : acc) +-- | Format a 'CostCentreStack' as a list of cost centre IDs. +-- +-- @since 4.20.0.0 +ccsToIds :: Ptr CostCentreStack -> IO [CostCentreId] +ccsToIds ccs0 = go ccs0 [] + where + go ccs acc + | ccs == nullPtr = return acc + | otherwise = do + cc <- ccsCC ccs + cc_id <- ccId cc + lbl <- GHC.peekCString utf8 =<< ccLabel cc + mdl <- GHC.peekCString utf8 =<< ccModule cc + parent <- ccsParent ccs + if (mdl == "MAIN" && lbl == "MAIN") + then return acc + else go parent (cc_id : acc) + -- | Get the stack trace attached to an object. -- -- @since base-4.5.0.0 ===================================== testsuite/driver/testlib.py ===================================== @@ -1542,7 +1542,13 @@ def override_options(pre_cmd): def framework_fail(name: Optional[TestName], way: Optional[WayName], reason: str) -> None: opts = getTestOpts() - directory = re.sub(r'^\.[/\\]', '', str(opts.testdir)) + # framework_fail can be called before testdir is initialised, + # so we need to take care not to blow up with the wrong way + # and report the actual reason for the failure. + try: + directory = re.sub(r'^\.[/\\]', '', str(opts.testdir)) + except: + directory = '' full_name = '%s(%s)' % (name, way) if_verbose(1, '*** framework failure for %s %s ' % (full_name, reason)) name2 = name if name is not None else TestName('none') ===================================== testsuite/tests/printer/DataDeclShort.hs ===================================== @@ -0,0 +1,8 @@ +module DataDeclShort where + +data GenericOptions + :: fieldLabelModifier + -> tagSingleConstructors + -> Type + +x = 1 ===================================== testsuite/tests/printer/Makefile ===================================== @@ -836,3 +836,8 @@ CaseAltComments: MatchPatComments: $(CHECK_PPR) $(LIBDIR) MatchPatComments.hs $(CHECK_EXACT) $(LIBDIR) MatchPatComments.hs + +.PHONY: DataDeclShort +DataDeclShort: + $(CHECK_PPR) $(LIBDIR) DataDeclShort.hs + $(CHECK_EXACT) $(LIBDIR) DataDeclShort.hs ===================================== testsuite/tests/printer/all.T ===================================== @@ -200,3 +200,4 @@ test('Test24533', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24533']) test('PprLetIn', [ignore_stderr, req_ppr_deps], makefile_test, ['PprLetIn']) test('CaseAltComments', [ignore_stderr, req_ppr_deps], makefile_test, ['CaseAltComments']) test('MatchPatComments', [ignore_stderr, req_ppr_deps], makefile_test, ['MatchPatComments']) +test('DataDeclShort', [ignore_stderr, req_ppr_deps], makefile_test, ['DataDeclShort']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/67244b0c5ff1b0d2899c99858e13ec07364255f7...807da9090b0446c11d548856ae20963ee844b685 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/67244b0c5ff1b0d2899c99858e13ec07364255f7...807da9090b0446c11d548856ae20963ee844b685 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 1 19:42:18 2024 From: gitlab at gitlab.haskell.org (Artin Ghasivand (@Ei30metry)) Date: Wed, 01 May 2024 15:42:18 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24467 Message-ID: <66329b1a671f9_3074b441396d4134834@gitlab.mail> Artin Ghasivand pushed new branch wip/T24467 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24467 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 1 21:23:39 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 01 May 2024 17:23:39 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Fix TH dependencies (#22229) Message-ID: <6632b2db13c2a_3074b44de32a415887@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - 5 changed files: - compiler/GHC/Builtin/Names/TH.hs - hadrian/src/Rules/Dependencies.hs - libraries/ghc-internal/src/GHC/Internal/Base.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs - + libraries/template-haskell/Language/Haskell/TH/Lib/Syntax.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d5bea4d6bce785b1d09f1b8faad7451af23b728d...37e38db486a2391b554f6b43c268e6ac3472e446 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d5bea4d6bce785b1d09f1b8faad7451af23b728d...37e38db486a2391b554f6b43c268e6ac3472e446 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 1 21:24:28 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 01 May 2024 17:24:28 -0400 Subject: [Git][ghc/ghc][master] JS: cleanup to prepare for #24743 Message-ID: <6632b30c484ea_3074b44fc57841617cc@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 9 changed files: - compiler/GHC/StgToJS/Apply.hs - compiler/GHC/StgToJS/Arg.hs - compiler/GHC/StgToJS/Closure.hs - compiler/GHC/StgToJS/CodeGen.hs - compiler/GHC/StgToJS/Expr.hs - compiler/GHC/StgToJS/Heap.hs - compiler/GHC/StgToJS/Rts/Rts.hs - compiler/GHC/StgToJS/Stack.hs - compiler/GHC/StgToJS/Types.hs Changes: ===================================== compiler/GHC/StgToJS/Apply.hs ===================================== @@ -246,7 +246,7 @@ jumpToII i vars load_app_in_r1 return $ mconcat [ assignAllReverseOrder jsRegsFromR2 vars , load_app_in_r1 - , returnS (closureEntry ii) + , returnS (closureInfo ii) ] | otherwise = do ei <- varForEntryId i @@ -449,14 +449,14 @@ genericStackApply cfg = closure info body where -- h$ap_gen body body = jVar $ \cf -> - do fun <- fun_case cf (funArity' cf) + do fun <- fun_case cf (infoFunArity cf) pap <- fun_case cf (papArity r1) return $ mconcat $ [ traceRts cfg (jString "h$ap_gen") - , cf |= closureEntry r1 + , cf |= closureInfo r1 -- switch on closure type - , SwitchStat (entryClosureType cf) + , SwitchStat (infoClosureType cf) [ (toJExpr Thunk , thunk_case cfg cf) , (toJExpr Fun , fun) , (toJExpr Pap , pap) @@ -476,7 +476,7 @@ genericStackApply cfg = closure info body } default_case cf = appS "throw" [jString "h$ap_gen: unexpected closure type " - + (entryClosureType cf)] + + (infoClosureType cf)] thunk_case cfg cf = mconcat [ profStat cfg pushRestoreCCS @@ -596,7 +596,7 @@ genericFastApply s = fast_fun <- jVar \farity -> do fast_fun <- funCase c tag farity return $ mconcat $ - [ farity |= funArity' c + [ farity |= infoFunArity c , traceRts s (jString "h$ap_gen_fast: fun " + farity) , fast_fun] fast_pap <- jVar \parity -> @@ -608,8 +608,8 @@ genericFastApply s = ] return $ mconcat $ [traceRts s (jString "h$ap_gen_fast: " + tag) - , c |= closureEntry r1 - , SwitchStat (entryClosureType c) + , c |= closureInfo r1 + , SwitchStat (infoClosureType c) [ (toJExpr Thunk, traceRts s (jString "h$ap_gen_fast: thunk") <> push_stk_app <> returnS c) @@ -623,7 +623,7 @@ genericFastApply s = <> push_stk_app <> push' s [r1, var "h$return"] <> returnS (app "h$blockOnBlackhole" [r1])) - ] $ appS "throw" [jString "h$ap_gen_fast: unexpected closure type: " + entryClosureType c] + ] $ appS "throw" [jString "h$ap_gen_fast: unexpected closure type: " + infoClosureType c] ] where @@ -729,8 +729,22 @@ stackApply s fun_name nargs nvars = then closure info0 body0 else closure info body where - info = ClosureInfo (global fun_name) (CIRegs 0 [PtrV]) fun_name (CILayoutUnknown nvars) CIStackFrame mempty - info0 = ClosureInfo (global fun_name) (CIRegs 0 [PtrV]) fun_name (CILayoutFixed 0 []) CIStackFrame mempty + info = ClosureInfo + { ciVar = global fun_name + , ciRegs = CIRegs 0 [PtrV] + , ciName = fun_name + , ciLayout = CILayoutUnknown nvars + , ciType = CIStackFrame + , ciStatic = mempty + } + info0 = ClosureInfo + { ciVar = global fun_name + , ciRegs = CIRegs 0 [PtrV] + , ciName = fun_name + , ciLayout = CILayoutFixed 0 [] + , ciType = CIStackFrame + , ciStatic = mempty + } body0 = (adjSpN' 1 <>) <$> enter s r1 @@ -738,18 +752,18 @@ stackApply s fun_name nargs nvars = do fun_case <- funCase c pap_case <- papCase c return $ mconcat - [ c |= closureEntry r1 + [ c |= closureInfo r1 , traceRts s (toJExpr fun_name + jString " " + (c .^ "n") + jString " sp: " + sp + jString " a: " + (c .^ "a")) - , SwitchStat (entryClosureType c) + , SwitchStat (infoClosureType c) [ (toJExpr Thunk, traceRts s (toJExpr $ fun_name <> ": thunk") <> profStat s pushRestoreCCS <> returnS c) , (toJExpr Fun, traceRts s (toJExpr $ fun_name <> ": fun") <> fun_case) , (toJExpr Pap, traceRts s (toJExpr $ fun_name <> ": pap") <> pap_case) , (toJExpr Blackhole, push' s [r1, var "h$return"] <> returnS (app "h$blockOnBlackhole" [r1])) - ] (appS "throw" [toJExpr ("panic: " <> fun_name <> ", unexpected closure type: ") + (entryClosureType c)]) + ] (appS "throw" [toJExpr ("panic: " <> fun_name <> ", unexpected closure type: ") + (infoClosureType c)]) ] funExact c = popSkip 1 (reverse $ take nvars jsRegsFromR2) <> returnS c @@ -783,7 +797,7 @@ stackApply s fun_name nargs nvars = do oversat_case <- oversatCase c ar0 ar return $ mconcat $ case expr of - ValExpr (JVar pap) -> [ ar0 |= funArity' c + ValExpr (JVar pap) -> [ ar0 |= infoFunArity c , ar |= mask8 ar0 , ifS (toJExpr nargs .===. ar) (traceRts s (toJExpr (fun_name <> ": exact")) <> funExact c) @@ -845,18 +859,18 @@ fastApply s fun_name nargs nvars = if nargs == 0 && nvars == 0 do fun_case_fun <- funCase c farity fun_case_pap <- funCase c arity return $ mconcat $ - [ c |= closureEntry r1 + [ c |= closureInfo r1 , traceRts s (toJExpr (fun_name <> ": sp ") + sp) - , SwitchStat (entryClosureType c) + , SwitchStat (infoClosureType c) [(toJExpr Fun, traceRts s (toJExpr (fun_name <> ": ") + clName c + jString " (arity: " + (c .^ "a") + jString ")") - <> (farity |= funArity' c) + <> (farity |= infoFunArity c) <> fun_case_fun) ,(toJExpr Pap, traceRts s (toJExpr (fun_name <> ": pap")) <> (arity |= papArity r1) <> fun_case_pap) ,(toJExpr Thunk, traceRts s (toJExpr (fun_name <> ": thunk")) <> push' s (reverse regArgs ++ mkAp nargs nvars) <> profStat s pushRestoreCCS <> returnS c) ,(toJExpr Blackhole, traceRts s (toJExpr (fun_name <> ": blackhole")) <> push' s (reverse regArgs ++ mkAp nargs nvars) <> push' s [r1, var "h$return"] <> returnS (app "h$blockOnBlackhole" [r1]))] - (appS "throw" [toJExpr (fun_name <> ": unexpected closure type: ") + entryClosureType c]) + (appS "throw" [toJExpr (fun_name <> ": unexpected closure type: ") + infoClosureType c]) ] funCase :: JStgExpr -> JStgExpr -> JSM JStgStat @@ -913,9 +927,9 @@ enter :: StgToJSConfig -> JStgExpr -> JSM JStgStat enter s ex = jVar \c -> return $ mconcat $ [ jwhenS (app "typeof" [ex] .!==. jTyObject) returnStack - , c |= closureEntry ex + , c |= closureInfo ex , jwhenS (c .===. var "h$unbox_e") ((r1 |= closureField1 ex) <> returnStack) - , SwitchStat (entryClosureType c) + , SwitchStat (infoClosureType c) [ (toJExpr Con, mempty) , (toJExpr Fun, mempty) , (toJExpr Pap, returnStack) @@ -930,7 +944,7 @@ updates s = do upd_frm_lne <- update_frame_lne return $ BlockStat [upd_frm, upd_frm_lne] where - unbox_closure f1 = Closure { clEntry = var "h$unbox_e" + unbox_closure f1 = Closure { clInfo = var "h$unbox_e" , clField1 = f1 , clField2 = null_ , clMeta = 0 @@ -946,7 +960,14 @@ updates s = do , postIncrS i ] update_frame = closure - (ClosureInfo (global "h$upd_frame") (CIRegs 0 [PtrV]) "h$upd_frame" (CILayoutFixed 1 [PtrV]) CIStackFrame mempty) + (ClosureInfo + { ciVar = global "h$upd_frame" + , ciRegs = CIRegs 0 [PtrV] + , ciName = "h$upd_frame" + , ciLayout = CILayoutFixed 1 [PtrV] + , ciType = CIStackFrame + , ciStatic = mempty + }) $ jVars \(updatee, waiters, ss, si, sir) -> do upd_loop <- upd_loop' ss si sir wake_thread_loop <- loop zero_ (.<. waiters .^ "length") @@ -967,7 +988,7 @@ updates s = do <> upd_loop) , -- overwrite the object ifS (app "typeof" [r1] .===. jTyObject) - (mconcat [ traceRts s (jString "$upd_frame: boxed: " + ((closureEntry r1) .^ "n")) + (mconcat [ traceRts s (jString "$upd_frame: boxed: " + ((closureInfo r1) .^ "n")) , copyClosure DontCopyCC updatee r1 ]) -- the heap object is represented by another type of value @@ -984,7 +1005,14 @@ updates s = do ] update_frame_lne = closure - (ClosureInfo (global "h$upd_frame_lne") (CIRegs 0 [PtrV]) "h$upd_frame_lne" (CILayoutFixed 1 [PtrV]) CIStackFrame mempty) + (ClosureInfo + { ciVar = global "h$upd_frame_lne" + , ciRegs = CIRegs 0 [PtrV] + , ciName = "h$upd_frame_lne" + , ciLayout = CILayoutFixed 1 [PtrV] + , ciType = CIStackFrame + , ciStatic = mempty + }) $ jVar \updateePos -> return $ mconcat $ [ updateePos |= stack .! (sp - 1) @@ -1028,7 +1056,14 @@ selectors s = , returnS (sel r) ] , closure - (ClosureInfo (global entryName) (CIRegs 0 [PtrV]) ("select " <> name) (CILayoutFixed 1 [PtrV]) CIThunk mempty) + (ClosureInfo + { ciVar = global entryName + , ciRegs = CIRegs 0 [PtrV] + , ciName = "select " <> name + , ciLayout = CILayoutFixed 1 [PtrV] + , ciType = CIThunk + , ciStatic = mempty + }) (jVar $ \tgt -> return $ mconcat $ [ tgt |= closureField1 r1 @@ -1040,7 +1075,14 @@ selectors s = (returnS (app "h$e" [sel tgt])) ]) , closure - (ClosureInfo (global frameName) (CIRegs 0 [PtrV]) ("select " <> name <> " frame") (CILayoutFixed 0 []) CIStackFrame mempty) + (ClosureInfo + { ciVar = global frameName + , ciRegs = CIRegs 0 [PtrV] + , ciName = "select " <> name <> " frame" + , ciLayout = CILayoutFixed 0 [] + , ciType = CIStackFrame + , ciStatic = mempty + }) $ return $ mconcat [ traceRts s (toJExpr ("selector frame: " <> name)) , postDecrS sp @@ -1093,7 +1135,14 @@ specPapIdents = listArray (0,numSpecPap) $ map (global . mkFastString . ("h$pap_ pap :: StgToJSConfig -> Int -> JSM JStgStat -pap s r = closure (ClosureInfo funcIdent CIRegsUnknown funcName (CILayoutUnknown (r+2)) CIPap mempty) body +pap s r = closure (ClosureInfo + { ciVar = funcIdent + , ciRegs = CIRegsUnknown + , ciName = funcName + , ciLayout = CILayoutUnknown (r+2) + , ciType = CIPap + , ciStatic = mempty + }) body where funcIdent = global funcName funcName = mkFastString ("h$pap_" ++ show r) @@ -1102,7 +1151,7 @@ pap s r = closure (ClosureInfo funcIdent CIRegsUnknown funcName (CILayoutUnknown return $ mconcat $ [ c |= closureField1 r1 , d |= closureField2 r1 - , f |= closureEntry c + , f |= closureInfo c , assertRts s (isFun' f .||. isPap' f) (funcName <> ": expected function or pap") , profStat s (enterCostCentreFun currentCCS) , extra |= (funOrPapArity c (Just f) .>>. 8) - toJExpr r @@ -1122,12 +1171,19 @@ pap s r = closure (ClosureInfo funcIdent CIRegsUnknown funcName (CILayoutUnknown -- Construct a generic PAP papGen :: StgToJSConfig -> JSM JStgStat papGen cfg = - closure (ClosureInfo funcIdent CIRegsUnknown funcName CILayoutVariable CIPap mempty) + closure (ClosureInfo + { ciVar = funcIdent + , ciRegs = CIRegsUnknown + , ciName = funcName + , ciLayout = CILayoutVariable + , ciType = CIPap + , ciStatic = mempty + }) (jVars $ \(c, f, d, pr, or, r) -> return $ mconcat [ c |= closureField1 r1 , d |= closureField2 r1 - , f |= closureEntry c + , f |= closureInfo c , pr |= funOrPapArity c (Just f) .>>. 8 , or |= papArity r1 .>>. 8 , r |= pr - or @@ -1174,9 +1230,9 @@ moveRegs2 = jFunction (global "h$moveRegs2") moveSwitch -- Initalize a variable sized object from an array of values initClosure :: StgToJSConfig -> JStgExpr -> JStgExpr -> JStgExpr -> JStgExpr -initClosure cfg entry values ccs = app "h$init_closure" +initClosure cfg info values ccs = app "h$init_closure" [ newClosure $ Closure - { clEntry = entry + { clInfo = info , clField1 = null_ , clField2 = null_ , clMeta = 0 ===================================== compiler/GHC/StgToJS/Arg.hs ===================================== @@ -69,7 +69,7 @@ of generating a wrapper object with a field for the value's payload, such as: // a JS object for an Int8 var anInt8 = { d1 = - , f : entry function which would scrutinize the payload + , f : info table / entry function which would scrutinize the payload } we instead generate: ===================================== compiler/GHC/StgToJS/Closure.hs ===================================== @@ -28,7 +28,6 @@ import GHC.Data.FastString import GHC.StgToJS.Heap import GHC.StgToJS.Types import GHC.StgToJS.Utils -import GHC.StgToJS.Regs (stack,sp) import GHC.JS.Make import GHC.JS.JStg.Syntax @@ -41,18 +40,23 @@ import Data.Array import Data.Monoid import qualified Data.Bits as Bits +-- | Generate statements to set infotable field values for the given ClosureInfo +-- +-- Depending on debug flag, it generates h$setObjInfo(...) or h$o(...). The +-- latter form doesn't store the pretty-printed name in the closure to save +-- space. closureInfoStat :: Bool -> ClosureInfo -> JStgStat -closureInfoStat debug (ClosureInfo obj rs name layout ctype srefs) - = setObjInfoL debug obj rs layout ty name tag srefs +closureInfoStat debug ci + = setObjInfoL debug (ciVar ci) (ciRegs ci) (ciLayout ci) ty (ciName ci) tag (ciStatic ci) where - !ty = case ctype of + !ty = case ciType ci of CIThunk -> Thunk CIFun {} -> Fun CICon {} -> Con CIBlackhole -> Blackhole CIPap -> Pap CIStackFrame -> StackFrame - !tag = case ctype of + !tag = case ciType ci of CIThunk -> 0 CIFun arity nregs -> mkArityTag arity nregs CICon con -> con @@ -118,29 +122,37 @@ setObjInfo debug obj t name fields a size regs static -- | Special case of closures that do not need to generate any @fresh@ names closure :: ClosureInfo -- ^ object being info'd see @ciVar@ - -> (JSM JStgStat) -- ^ rhs + -> JSM JStgStat -- ^ rhs -> JSM JStgStat -closure ci body = do f <- (jFunction' (ciVar ci) body) - return $ f `mappend` closureInfoStat False ci +closure ci body = do + f <- jFunction' (ciVar ci) body + return $ f `mappend` closureInfoStat False ci conClosure :: Ident -> FastString -> CILayout -> Int -> JSM JStgStat conClosure symbol name layout constr = closure ci body where - ci = (ClosureInfo symbol (CIRegs 0 [PtrV]) name layout (CICon constr) mempty) - body = pure . returnS $ stack .! sp + ci = ClosureInfo + { ciVar = symbol + , ciRegs = CIRegs 0 [PtrV] + , ciName = name + , ciLayout = layout + , ciType = CICon constr + , ciStatic = mempty + } + body = pure returnStack -- | Used to pass arguments to newClosure with some safety data Closure = Closure - { clEntry :: JStgExpr - , clField1 :: JStgExpr - , clField2 :: JStgExpr + { clInfo :: JStgExpr -- ^ InfoTable object + , clField1 :: JStgExpr -- ^ Payload field 1 + , clField2 :: JStgExpr -- ^ Payload field 2 , clMeta :: JStgExpr , clCC :: Maybe JStgExpr } newClosure :: Closure -> JStgExpr newClosure Closure{..} = - let xs = [ (closureEntry_ , clEntry) + let xs = [ (closureInfo_ , clInfo) , (closureField1_, clField1) , (closureField2_, clField2) , (closureMeta_ , clMeta) @@ -153,7 +165,7 @@ newClosure Closure{..} = assignClosure :: JStgExpr -> Closure -> JStgStat assignClosure t Closure{..} = BlockStat - [ closureEntry t |= clEntry + [ closureInfo t |= clInfo , closureField1 t |= clField1 , closureField2 t |= clField2 , closureMeta t |= clMeta @@ -165,7 +177,7 @@ data CopyCC = CopyCC | DontCopyCC copyClosure :: CopyCC -> JStgExpr -> JStgExpr -> JStgStat copyClosure copy_cc t s = BlockStat - [ closureEntry t |= closureEntry s + [ closureInfo t |= closureInfo s , closureField1 t |= closureField1 s , closureField2 t |= closureField2 s , closureMeta t |= closureMeta s @@ -174,8 +186,8 @@ copyClosure copy_cc t s = BlockStat CopyCC -> closureCC t |= closureCC s mkClosure :: JStgExpr -> [JStgExpr] -> JStgExpr -> Maybe JStgExpr -> Closure -mkClosure entry fields meta cc = Closure - { clEntry = entry +mkClosure info fields meta cc = Closure + { clInfo = info , clField1 = x1 , clField2 = x2 , clMeta = meta ===================================== compiler/GHC/StgToJS/CodeGen.hs ===================================== @@ -276,11 +276,10 @@ genToplevel (StgRec bs) = genToplevelDecl :: Id -> CgStgRhs -> G JStgStat genToplevelDecl i rhs = do - s1 <- resetSlots (genToplevelConEntry i rhs) - s2 <- resetSlots (genToplevelRhs i rhs) - return (s1 <> s2) + resetSlots (genToplevelConEntry i rhs) + resetSlots (genToplevelRhs i rhs) -genToplevelConEntry :: Id -> CgStgRhs -> G JStgStat +genToplevelConEntry :: Id -> CgStgRhs -> G () genToplevelConEntry i rhs = case rhs of StgRhsCon _cc con _mu _ts _args _typ | isDataConWorkId i @@ -288,24 +287,23 @@ genToplevelConEntry i rhs = case rhs of StgRhsClosure _ _cc _upd_flag _args _body _typ | Just dc <- isDataConWorkId_maybe i -> genSetConInfo i dc (stgRhsLive rhs) -- srt - _ -> pure mempty + _ -> pure () -genSetConInfo :: HasDebugCallStack => Id -> DataCon -> LiveVars -> G JStgStat +genSetConInfo :: HasDebugCallStack => Id -> DataCon -> LiveVars -> G () genSetConInfo i d l {- srt -} = do ei <- identForDataConEntryId i sr <- genStaticRefs l - emitClosureInfo $ ClosureInfo ei - (CIRegs 0 [PtrV]) - (mkFastString $ renderWithContext defaultSDocContext (ppr d)) - (fixedLayout fields) - (CICon $ dataConTag d) - sr - return (mkDataEntry ei) - where - -- dataConRepArgTys sometimes returns unboxed tuples. is that a bug? - fields = concatMap (typeJSRep . unwrapType . scaledThing) + let fields = concatMap (typeJSRep . unwrapType . scaledThing) (dataConRepArgTys d) - -- concatMap (map slotTyToType . repTypeSlots . repType) (dataConRepArgTys d) + emitClosureInfo $ ClosureInfo + { ciVar = ei + , ciRegs = CIRegs 0 [PtrV] + , ciName = mkFastString $ renderWithContext defaultSDocContext (ppr d) + , ciLayout = fixedLayout fields + , ciType = CICon $ dataConTag d + , ciStatic = sr + } + emitToplevel (mkDataEntry ei) mkDataEntry :: Ident -> JStgStat mkDataEntry i = FuncStat i [] returnStack @@ -351,12 +349,14 @@ genToplevelRhs i rhs = case rhs of if et == CIThunk then enterCostCentreThunk else enterCostCentreFun cc - emitClosureInfo (ClosureInfo eid - regs - idt - (fixedLayout $ map (unaryTypeJSRep . idType) lids) - et - sr) + emitClosureInfo $ ClosureInfo + { ciVar = eid + , ciRegs = regs + , ciName = idt + , ciLayout = fixedLayout $ map (unaryTypeJSRep . idType) lids + , ciType = et + , ciStatic = sr + } ccId <- costCentreStackLbl cc emitStatic idt static ccId return $ (FuncStat eid [] (ll <> upd <> setcc <> body)) ===================================== compiler/GHC/StgToJS/Expr.hs ===================================== @@ -243,14 +243,14 @@ genEntryLne ctx i rhs@(StgRhsClosure _ext _cc update args body typ) = ei@(identFS -> eii) <- identForEntryId i sr <- genStaticRefsRhs rhs let f = (blk_hl <> locals <> body) - emitClosureInfo $ - ClosureInfo ei - (CIRegs 0 $ concatMap idJSRep args) - (eii <> ", " <> mkFastString (renderWithContext defaultSDocContext (ppr i))) - (fixedLayout . reverse $ - map (stackSlotType . fst) (ctxLneFrameVars ctx)) - CIStackFrame - sr + emitClosureInfo $ ClosureInfo + { ciVar = ei + , ciRegs = CIRegs 0 $ concatMap idJSRep args + , ciName = eii <> ", " <> mkFastString (renderWithContext defaultSDocContext (ppr i)) + , ciLayout = fixedLayout . reverse $ map (stackSlotType . fst) (ctxLneFrameVars ctx) + , ciType = CIStackFrame + , ciStatic = sr + } emitToplevel (FuncStat ei [] f) genEntryLne ctx i (StgRhsCon cc con _mu _ticks args _typ) = resetSlots $ do let payloadSize = ctxLneFrameSize ctx @@ -265,28 +265,30 @@ genEntryLne ctx i (StgRhsCon cc con _mu _ticks args _typ) = resetSlots $ do -- | Generate the entry function for a local closure genEntry :: HasDebugCallStack => ExprCtx -> Id -> CgStgRhs -> G () genEntry _ _i StgRhsCon {} = return () -genEntry ctx i rhs@(StgRhsClosure _ext cc {-_bi live-} upd_flag args body typ) = resetSlots $ do - let live = stgLneLiveExpr rhs -- error "fixme" -- probably find live vars in body +genEntry ctx i rhs@(StgRhsClosure _ext cc upd_flag args body typ) = resetSlots $ do + let live = stgLneLiveExpr rhs ll <- loadLiveFun live llv <- verifyRuntimeReps live upd <- genUpdFrame upd_flag i + let entryCtx = ctxSetTarget [] (ctxClearLneFrame ctx) body <- genBody entryCtx R2 args body typ - ei@(identFS -> eii) <- identForEntryId i et <- genEntryType args setcc <- ifProfiling $ if et == CIThunk then enterCostCentreThunk else enterCostCentreFun cc sr <- genStaticRefsRhs rhs - emitClosureInfo $ ClosureInfo ei - (CIRegs 0 $ PtrV : concatMap idJSRep args) - (eii <> ", " <> mkFastString (renderWithContext defaultSDocContext (ppr i))) - (fixedLayout $ map (unaryTypeJSRep . idType) live) - et - sr + + ei <- identForEntryId i + emitClosureInfo $ ClosureInfo + { ciVar = ei + , ciRegs = CIRegs 0 $ PtrV : concatMap idJSRep args + , ciName = identFS ei <> ", " <> mkFastString (renderWithContext defaultSDocContext (ppr i)) + , ciLayout = fixedLayout $ map (unaryTypeJSRep . idType) live + , ciType = et + , ciStatic = sr + } emitToplevel (FuncStat ei [] (mconcat [ll, llv, upd, setcc, body])) - where - entryCtx = ctxSetTarget [] (ctxClearLneFrame ctx) -- | Generate the entry function types for identifiers. Note that this only -- returns either 'CIThunk' or 'CIFun'. @@ -456,9 +458,9 @@ genUpdFrame u i -- bhSingleEntry :: StgToJSConfig -> JStgStat bhSingleEntry _settings = mconcat - [ r1 .^ closureEntry_ |= var "h$blackholeTrap" - , r1 .^ closureField1_ |= undefined_ - , r1 .^ closureField2_ |= undefined_ + [ closureInfo r1 |= var "h$blackholeTrap" + , closureField1 r1 |= undefined_ + , closureField2 r1 |= undefined_ ] genStaticRefsRhs :: CgStgRhs -> G CIStatic @@ -646,15 +648,16 @@ genRet ctx e at as l = freshIdent >>= f fun' <- fun free sr <- genStaticRefs l -- srt prof <- profiling - emitClosureInfo $ - ClosureInfo r - (CIRegs 0 altRegs) - ri - (fixedLayout . reverse $ + emitClosureInfo $ ClosureInfo + { ciVar = r + , ciRegs = CIRegs 0 altRegs + , ciName = ri + , ciLayout = fixedLayout . reverse $ map (stackSlotType . fst3) free - ++ if prof then [ObjV] else map stackSlotType lneVars) - CIStackFrame - sr + ++ if prof then [ObjV] else map stackSlotType lneVars + , ciType = CIStackFrame + , ciStatic = sr + } emitToplevel $ FuncStat r [] fun' return (pushLne <> saveCCS <> pushRet) fst3 ~(x,_,_) = x @@ -1012,7 +1015,7 @@ allocDynAll haveDecl middle cls = do ccs <- maybeToList <$> costCentreStackLbl cc pure $ mconcat [ decl_maybe i $ if csInlineAlloc settings - then ValExpr (jhFromList $ [ (closureEntry_ , f) + then ValExpr (jhFromList $ [ (closureInfo_ , f) , (closureField1_, null_) , (closureField2_, null_) , (closureMeta_ , zero_) @@ -1023,34 +1026,25 @@ allocDynAll haveDecl middle cls = do fillObjs :: [JStgStat] fillObjs = map fillObj cls - fillObj (i,_,es,_) - | csInlineAlloc settings || length es > 24 = - case es of - [] -> mempty - [ex] -> toJExpr i .^ closureField1_ |= toJExpr ex - [e1,e2] -> mconcat - [ toJExpr i .^ closureField1_ |= toJExpr e1 - , toJExpr i .^ closureField2_ |= toJExpr e2 - ] - (ex:es) -> mconcat - [ toJExpr i .^ closureField1_ |= toJExpr ex - , toJExpr i .^ closureField2_ |= toJExpr (jhFromList (zip (map dataFieldName [1..]) es)) - ] - | otherwise = case es of - [] -> mempty - [ex] -> toJExpr i .^ closureField1_ |= ex - [e1,e2] -> mconcat - [ toJExpr i .^ closureField1_ |= e1 - , toJExpr i .^ closureField2_ |= e2 - ] - (ex:es) -> mconcat - [ toJExpr i .^ closureField1_ |= ex - , toJExpr i .^ closureField2_ |= fillFun es - ] - - fillFun :: [JStgExpr] -> JStgExpr - fillFun [] = null_ - fillFun es = ApplExpr (allocData (length es)) es + fillObj (ident,_,es,_) = + let i = toJExpr ident + in case es of + [] -> mempty + [ex] -> closureField1 i |= ex + [e1,e2] -> mconcat + [ closureField1 i |= e1 + , closureField2 i |= e2 + ] + (ex:es) + | csInlineAlloc settings || length es > 24 + -> mconcat [ closureField1 i |= ex + , closureField2 i |= ValExpr (jhFromList (zip (map dataFieldName [1..]) es)) + ] + + | otherwise + -> mconcat [ closureField1 i |= ex + , closureField2 i |= ApplExpr (allocData (length es)) es + ] checkObjs :: [JStgStat] checkObjs | csAssertRts settings = ===================================== compiler/GHC/StgToJS/Heap.hs ===================================== @@ -3,7 +3,8 @@ module GHC.StgToJS.Heap ( closureType - , entryClosureType + , infoClosureType + , infoFunArity , isObject , isThunk , isThunk' @@ -16,17 +17,16 @@ module GHC.StgToJS.Heap , isCon' , conTag , conTag' - , closureEntry + , closureInfo , closureMeta , closureField1 , closureField2 , closureCC , funArity - , funArity' , papArity , funOrPapArity -- * Field names - , closureEntry_ + , closureInfo_ , closureMeta_ , closureCC_ , closureField1_ @@ -43,38 +43,51 @@ import GHC.JS.Make import GHC.StgToJS.Types import GHC.Data.FastString -closureEntry_ :: FastString -closureEntry_ = "f" +-- | Closure infotable field name +closureInfo_ :: FastString +closureInfo_ = "f" +-- | Closure first payload field name closureField1_ :: FastString closureField1_ = "d1" +-- | Closure second payload field name closureField2_ :: FastString closureField2_ = "d2" +-- | Closure meta field name closureMeta_ :: FastString closureMeta_ = "m" +-- | Closure cost-center field name closureCC_ :: FastString closureCC_ = "cc" -entryClosureType_ :: FastString -entryClosureType_ = "t" +-- | Infotable type field name +infoClosureType_ :: FastString +infoClosureType_ = "t" -entryConTag_ :: FastString -entryConTag_ = "a" +-- | Infotable tag field name +infoConTag_ :: FastString +infoConTag_ = "a" -entryFunArity_ :: FastString -entryFunArity_ = "a" +-- | Infotable arity field name +infoFunArity_ :: FastString +infoFunArity_ = "a" jTyObject :: JStgExpr jTyObject = jString "object" -closureType :: JStgExpr -> JStgExpr -closureType = entryClosureType . closureEntry +-- | Closure type from infotable +infoClosureType :: JStgExpr -> JStgExpr +infoClosureType f = f .^ infoClosureType_ + +-- | Function arity from infotable +infoFunArity :: JStgExpr -> JStgExpr +infoFunArity f = f .^ infoFunArity_ -entryClosureType :: JStgExpr -> JStgExpr -entryClosureType f = f .^ entryClosureType_ +closureType :: JStgExpr -> JStgExpr +closureType = infoClosureType . closureInfo isObject :: JStgExpr -> JStgExpr isObject c = typeof c .===. String "object" @@ -83,7 +96,7 @@ isThunk :: JStgExpr -> JStgExpr isThunk c = closureType c .===. toJExpr Thunk isThunk' :: JStgExpr -> JStgExpr -isThunk' f = entryClosureType f .===. toJExpr Thunk +isThunk' f = infoClosureType f .===. toJExpr Thunk isBlackhole :: JStgExpr -> JStgExpr isBlackhole c = closureType c .===. toJExpr Blackhole @@ -92,29 +105,29 @@ isFun :: JStgExpr -> JStgExpr isFun c = closureType c .===. toJExpr Fun isFun' :: JStgExpr -> JStgExpr -isFun' f = entryClosureType f .===. toJExpr Fun +isFun' f = infoClosureType f .===. toJExpr Fun isPap :: JStgExpr -> JStgExpr isPap c = closureType c .===. toJExpr Pap isPap' :: JStgExpr -> JStgExpr -isPap' f = entryClosureType f .===. toJExpr Pap +isPap' f = infoClosureType f .===. toJExpr Pap isCon :: JStgExpr -> JStgExpr isCon c = closureType c .===. toJExpr Con isCon' :: JStgExpr -> JStgExpr -isCon' f = entryClosureType f .===. toJExpr Con +isCon' f = infoClosureType f .===. toJExpr Con conTag :: JStgExpr -> JStgExpr -conTag = conTag' . closureEntry +conTag = conTag' . closureInfo conTag' :: JStgExpr -> JStgExpr -conTag' f = f .^ entryConTag_ +conTag' f = f .^ infoConTag_ --- | Get closure entry function -closureEntry :: JStgExpr -> JStgExpr -closureEntry p = p .^ closureEntry_ +-- | Get closure infotable +closureInfo :: JStgExpr -> JStgExpr +closureInfo p = p .^ closureInfo_ -- | Get closure metadata closureMeta :: JStgExpr -> JStgExpr @@ -132,13 +145,9 @@ closureField1 p = p .^ closureField1_ closureField2 :: JStgExpr -> JStgExpr closureField2 p = p .^ closureField2_ --- number of arguments (arity & 0xff = arguments, arity >> 8 = number of registers) +-- | Number of arguments (arity & 0xff = arguments, arity >> 8 = number of registers) funArity :: JStgExpr -> JStgExpr -funArity = funArity' . closureEntry - --- function arity with raw reference to the entry -funArity' :: JStgExpr -> JStgExpr -funArity' f = f .^ entryFunArity_ +funArity = infoFunArity . closureInfo -- arity of a partial application papArity :: JStgExpr -> JStgExpr @@ -146,10 +155,10 @@ papArity cp = closureField1 (closureField2 cp) funOrPapArity :: JStgExpr -- ^ heap object - -> Maybe JStgExpr -- ^ reference to entry, if you have one already (saves a c.f lookup twice) + -> Maybe JStgExpr -- ^ reference to infotable, if you have one already (saves a c.f lookup twice) -> JStgExpr -- ^ arity tag (tag >> 8 = registers, tag & 0xff = arguments) funOrPapArity c = \case Nothing -> ((IfExpr (toJExpr (isFun c))) (toJExpr (funArity c))) (toJExpr (papArity c)) - Just f -> ((IfExpr (toJExpr (isFun' f))) (toJExpr (funArity' f))) + Just f -> ((IfExpr (toJExpr (isFun' f))) (toJExpr (infoFunArity f))) (toJExpr (papArity c)) ===================================== compiler/GHC/StgToJS/Rts/Rts.hs ===================================== @@ -449,13 +449,13 @@ rts_gen s = do , r4 |= d4 , returnS (app "h$ap_3_3_fast" []) ]) - , closure (ClosureInfo (TxtI "h$upd_thunk_e") (CIRegs 0 [PtrV]) "updatable thunk" (CILayoutFixed 1 [PtrV]) CIThunk mempty) + , closure (ClosureInfo (global "h$upd_thunk_e") (CIRegs 0 [PtrV]) "updatable thunk" (CILayoutFixed 1 [PtrV]) CIThunk mempty) (jVar $ \t -> return $ mconcat [t |= closureField1 r1 , adjSp' 2 , stack .! (sp - 1) |= r1 , stack .! sp |= var "h$upd_frame" - , closureEntry r1 |= var "h$blackhole" + , closureInfo r1 |= var "h$blackhole" , closureField1 r1 |= var "h$currentThread" , closureField2 r1 |= null_ , r1 |= t @@ -470,7 +470,7 @@ rts_gen s = do , stack .! (sp - 2) |= r1 , stack .! (sp - 1) |= var "h$upd_frame" , stack .! sp |= var "h$select1_ret" - , closureEntry r1 |= var "h$blackhole" + , closureInfo r1 |= var "h$blackhole" , closureField1 r1 |= var "h$currentThread" , closureField2 r1 |= null_ , r1 |= t @@ -490,7 +490,7 @@ rts_gen s = do , stack .! (sp - 2) |= r1 , stack .! (sp - 1) |= var "h$upd_frame" , stack .! sp |= var "h$select2_ret" - , closureEntry r1 |= var "h$blackhole" + , closureInfo r1 |= var "h$blackhole" , closureField1 r1 |= var "h$currentThread" , closureField2 r1 |= null_ , r1 |= t ===================================== compiler/GHC/StgToJS/Stack.hs ===================================== @@ -347,7 +347,7 @@ popN n = addUnknownSlots n >> adjSpN n bhStats :: StgToJSConfig -> Bool -> JStgStat bhStats s pushUpd = mconcat [ if pushUpd then push' s [r1, var "h$upd_frame"] else mempty - , toJExpr R1 .^ closureEntry_ |= var "h$blackhole" + , toJExpr R1 .^ closureInfo_ |= var "h$blackhole" , toJExpr R1 .^ closureField1_ |= var "h$currentThread" , toJExpr R1 .^ closureField2_ |= null_ -- will be filled with waiters array ] ===================================== compiler/GHC/StgToJS/Types.hs ===================================== @@ -98,9 +98,9 @@ data StgToJSConfig = StgToJSConfig , csLinkerConfig :: !LinkerConfig -- ^ Emscripten linker } --- | Information relevenat to code generation for closures. +-- | Closure info table data ClosureInfo = ClosureInfo - { ciVar :: Ident -- ^ object being infod + { ciVar :: Ident -- ^ entry code identifier: infotable fields are stored as properties of this function , ciRegs :: CIRegs -- ^ size of the payload (in number of JS values) , ciName :: FastString -- ^ friendly name for printing , ciLayout :: CILayout -- ^ heap/stack layout of the object View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ca13075c0c23195450dfedb8c4e6a4778bb7b0bb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ca13075c0c23195450dfedb8c4e6a4778bb7b0bb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 1 21:28:12 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Wed, 01 May 2024 17:28:12 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/az/T24748-empty-case-span Message-ID: <6632b3ec7bd6c_3074b450972841620a9@gitlab.mail> Alan Zimmerman pushed new branch wip/az/T24748-empty-case-span at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/T24748-empty-case-span You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 1 21:55:07 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 01 May 2024 17:55:07 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Fix TH dependencies (#22229) Message-ID: <6632ba3bc0c35_3074b454e607416776e@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 8da5e853 by Alan Zimmerman at 2024-05-01T17:54:59-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - bfbf86cb by Hécate Moonlight at 2024-05-01T17:55:00-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - 15 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/StgToJS/Apply.hs - compiler/GHC/StgToJS/Arg.hs - compiler/GHC/StgToJS/Closure.hs - compiler/GHC/StgToJS/CodeGen.hs - compiler/GHC/StgToJS/Expr.hs - compiler/GHC/StgToJS/Heap.hs - compiler/GHC/StgToJS/Rts/Rts.hs - compiler/GHC/StgToJS/Stack.hs - compiler/GHC/StgToJS/Types.hs - hadrian/src/Rules/Dependencies.hs - libraries/ghc-internal/src/GHC/Internal/Base.hs - libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc - libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9c4634e56ccad69095b516d84205cebeabdc6a08...bfbf86cb853341168949af1f1056401bd4d21224 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9c4634e56ccad69095b516d84205cebeabdc6a08...bfbf86cb853341168949af1f1056401bd4d21224 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 02:45:46 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 01 May 2024 22:45:46 -0400 Subject: [Git][ghc/ghc][master] EPA: Preserve comments for PrefixCon Message-ID: <6632fe5a97d13_3234381bd1fb8259eb@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 3 changed files: - compiler/GHC/Parser/PostProcess.hs - testsuite/tests/parser/should_compile/T20846.stderr - + testsuite/tests/printer/PrefixConComment.hs Changes: ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1210,37 +1210,34 @@ checkPattern_details :: ParseContext -> PV (LocatedA (PatBuilder GhcPs)) -> P (L checkPattern_details extraDetails pp = runPV_details extraDetails (pp >>= checkLPat) checkLArgPat :: LocatedA (ArgPatBuilder GhcPs) -> PV (LPat GhcPs) -checkLArgPat (L l (ArgPatBuilderVisPat p)) - = checkPat l (L l p) [] [] +checkLArgPat (L l (ArgPatBuilderVisPat p)) = checkLPat (L l p) checkLArgPat (L l (ArgPatBuilderArgPat p)) = return (L l p) checkLPat :: LocatedA (PatBuilder GhcPs) -> PV (LPat GhcPs) -checkLPat e@(L l _) = checkPat l e [] [] - -checkPat :: SrcSpanAnnA -> LocatedA (PatBuilder GhcPs) -> [HsConPatTyArg GhcPs] -> [LPat GhcPs] - -> PV (LPat GhcPs) -checkPat loc (L l e@(PatBuilderVar (L ln c))) tyargs args - | isRdrDataCon c = do - let (_l', loc') = transferCommentsOnlyA l loc - return . L loc' $ ConPat - { pat_con_ext = noAnn -- AZ: where should this come from? - , pat_con = L ln c - , pat_args = PrefixCon tyargs args - } +checkLPat (L l@(EpAnn anc an _) p) = do + (L l' p', cs) <- checkPat (EpAnn anc an emptyComments) emptyComments (L l p) [] [] + return (L (addCommentsToEpAnn l' cs) p') + +checkPat :: SrcSpanAnnA -> EpAnnComments -> LocatedA (PatBuilder GhcPs) -> [HsConPatTyArg GhcPs] -> [LPat GhcPs] + -> PV (LPat GhcPs, EpAnnComments) +checkPat loc cs (L l e@(PatBuilderVar (L ln c))) tyargs args + | isRdrDataCon c = return (L loc $ ConPat + { pat_con_ext = noAnn -- AZ: where should this come from? + , pat_con = L ln c + , pat_args = PrefixCon tyargs args + }, comments l Semi.<> cs) | (not (null args) && patIsRec c) = do ctx <- askParseContext patFail (locA l) . PsErrInPat e $ PEIP_RecPattern args YesPatIsRecursive ctx -checkPat loc (L _ (PatBuilderAppType (L lf f) at t)) tyargs args = do - let (loc', lf') = transferCommentsOnlyA loc lf - checkPat loc' (L lf' f) (HsConPatTyArg at t : tyargs) args -checkPat loc (L _ (PatBuilderApp f (L le e))) [] args = do - let (loc', le') = transferCommentsOnlyA loc le - p <- checkLPat (L le' e) - checkPat loc' f [] (p : args) -checkPat loc (L l e) [] [] = do +checkPat loc cs (L la (PatBuilderAppType f at t)) tyargs args = + checkPat loc (cs Semi.<> comments la) f (HsConPatTyArg at t : tyargs) args +checkPat loc cs (L la (PatBuilderApp f e)) [] args = do + p <- checkLPat e + checkPat loc (cs Semi.<> comments la) f [] (p : args) +checkPat loc cs (L l e) [] [] = do p <- checkAPat loc e - return (L l p) -checkPat loc e _ _ = do + return (L l p, cs) +checkPat loc _ e _ _ = do details <- fromParseContext <$> askParseContext patFail (locA loc) (PsErrInPat (unLoc e) details) @@ -1349,13 +1346,13 @@ checkFunBind :: SrcStrictness -> [LocatedA (ArgPatBuilder GhcPs)] -> Located (GRHSs GhcPs (LHsExpr GhcPs)) -> P (HsBind GhcPs) -checkFunBind strictness locF ann fun is_infix pats (L _ grhss) +checkFunBind strictness locF ann (L lf fun) is_infix pats (L _ grhss) = do ps <- runPV_details extraDetails (mapM checkLArgPat pats) let match_span = noAnnSrcSpan $ locF - return (makeFunBind fun (L (noAnnSrcSpan $ locA match_span) + return (makeFunBind (L (l2l lf) fun) (L (noAnnSrcSpan $ locA match_span) [L match_span (Match { m_ext = ann , m_ctxt = FunRhs - { mc_fun = fun + { mc_fun = L lf fun , mc_fixity = is_infix , mc_strictness = strictness } , m_pats = ps @@ -1364,7 +1361,7 @@ checkFunBind strictness locF ann fun is_infix pats (L _ grhss) -- That isn't quite right, but it'll do for now. where extraDetails - | Infix <- is_infix = ParseContext (Just $ unLoc fun) NoIncompleteDoBlock + | Infix <- is_infix = ParseContext (Just fun) NoIncompleteDoBlock | otherwise = noParseContext makeFunBind :: LocatedN RdrName -> LocatedL [LMatch GhcPs (LHsExpr GhcPs)] ===================================== testsuite/tests/parser/should_compile/T20846.stderr ===================================== @@ -71,11 +71,7 @@ (L (EpAnn (EpaSpan { T20846.hs:4:1-6 }) - (NameAnn - (NameParens) - (EpaSpan { T20846.hs:4:1 }) - (EpaSpan { T20846.hs:4:2-5 }) - (EpaSpan { T20846.hs:4:6 }) + (NameAnnTrailing []) (EpaComments [])) ===================================== testsuite/tests/printer/PrefixConComment.hs ===================================== @@ -0,0 +1,4 @@ +module PrefixConComment where + +fun (Con {- c1 -} a {- c2 -} b {- c3 -}) + = undefined View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/40026ac30fcdbe84a551f445f5e20691c0527ded -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/40026ac30fcdbe84a551f445f5e20691c0527ded You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 02:46:24 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 01 May 2024 22:46:24 -0400 Subject: [Git][ghc/ghc][master] Correct `@since` metadata in HpcFlags Message-ID: <6632fe807b5cd_3234381d7b0943029@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - 1 changed file: - libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc Changes: ===================================== libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc ===================================== @@ -380,14 +380,14 @@ data ParFlags = ParFlags -- | Parameters pertaining to Haskell program coverage (HPC) -- --- @since base-4.22.0.0 +-- @since base-4.20.0.0 data HpcFlags = HpcFlags { writeTixFile :: Bool -- ^ Controls whether the @.tix@ file should be -- written after the execution of the program. } - deriving (Show -- ^ @since base-4.22.0.0 - , Generic -- ^ @since base-4.22.0.0 + deriving (Show -- ^ @since base-4.20.0.0 + , Generic -- ^ @since base-4.20.0.0 ) -- | Parameters of the runtime system -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9213478931b18402998c18f5c4e6f0ee09054b18 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9213478931b18402998c18f5c4e6f0ee09054b18 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 07:39:50 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Thu, 02 May 2024 03:39:50 -0400 Subject: [Git][ghc/ghc][wip/fendor/ghc-iface-sharing] Improve sharing of duplicated values in `ModIface` Message-ID: <66334346a5226_3234383dd3f8038677@gitlab.mail> Hannes Siebenhandl pushed to branch wip/fendor/ghc-iface-sharing at Glasgow Haskell Compiler / GHC Commits: 5484fe76 by Fendor at 2024-05-02T09:35:07+02:00 Improve sharing of duplicated values in `ModIface` As a `ModIface` contains often duplicated values that are not necessarily shared, we improve sharing by serialising the `ModIface` to an in-memory byte array. Serialisation uses deduplication tables, and deserialisation implicitly shares duplicated values. This helps reducing the peak memory usage while compiling in `--make` mode. The peak memory usage is especially reduced when generating interface files with core expressions (`-fwrite-if-simplified-core`). On agda, this reduces the peak memory usage: * `2.2 GB` to `1.9 GB` for a ghci session. On `lib:Cabal`, we report: * `570 MB` to `500 MB` for a ghci session * `790 MB` to `667 MB` for compiling `lib:Cabal` with ghc The execution time is not affected. - - - - - 4 changed files: - compiler/GHC/Driver/Main.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Utils/Binary.hs Changes: ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -966,10 +966,11 @@ loadByteCode iface mod_sum = do -------------------------------------------------------------- + -- Knot tying! See Note [Knot-tying typecheckIface] -- See Note [ModDetails and --make mode] initModDetails :: HscEnv -> ModIface -> IO ModDetails -initModDetails hsc_env iface = +initModDetails hsc_env iface = do fixIO $ \details' -> do let act hpt = addToHpt hpt (moduleName $ mi_module iface) (HomeModInfo iface details' emptyHomeModInfoLinkable) ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -18,6 +18,8 @@ module GHC.Iface.Binary ( getSymtabName, CheckHiWay(..), TraceBinIFace(..), + getIfaceWithExtFields, + putIfaceWithExtFields, getWithUserData, putWithUserData, @@ -156,18 +158,25 @@ readBinIface readBinIface profile name_cache checkHiWay traceBinIface hi_path = do (src_hash, bh) <- readBinIfaceHeader profile name_cache checkHiWay traceBinIface hi_path - extFields_p <- get bh - - mod_iface <- getWithUserData name_cache bh - - seekBinReader bh extFields_p - extFields <- get bh + mod_iface <- getIfaceWithExtFields name_cache bh return mod_iface - { mi_ext_fields = extFields - , mi_src_hash = src_hash + { mi_src_hash = src_hash } +getIfaceWithExtFields :: NameCache -> ReadBinHandle -> IO ModIface +getIfaceWithExtFields name_cache bh = do + extFields_p <- get bh + + mod_iface <- getWithUserData name_cache bh + + seekBinReader bh extFields_p + extFields <- get bh + pure mod_iface + { mi_ext_fields = extFields + } + + -- | This performs a get action after reading the dictionary and symbol -- table. It is necessary to run this before trying to deserialise any -- Names or FastStrings. @@ -227,19 +236,17 @@ writeBinIface profile traceBinIface compressionLevel hi_path mod_iface = do put_ bh tag put_ bh (mi_src_hash mod_iface) - extFields_p_p <- tellBinWriter bh - put_ bh extFields_p_p - - putWithUserData traceBinIface compressionLevel bh mod_iface - - extFields_p <- tellBinWriter bh - putAt bh extFields_p_p extFields_p - seekBinWriter bh extFields_p - put_ bh (mi_ext_fields mod_iface) + putIfaceWithExtFields traceBinIface compressionLevel bh mod_iface -- And send the result to the file writeBinMem bh hi_path +-- | Puts the 'ModIface' +putIfaceWithExtFields :: TraceBinIFace -> CompressionIFace -> WriteBinHandle -> ModIface -> IO () +putIfaceWithExtFields traceBinIface compressionLevel bh mod_iface = + forwardPut_ bh (\_ -> put_ bh (mi_ext_fields mod_iface)) $ do + putWithUserData traceBinIface compressionLevel bh mod_iface + -- | Put a piece of data with an initialised `UserData` field. This -- is necessary if you want to serialise Names or FastStrings. -- It also writes a symbol table and the dictionary. ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -69,10 +69,13 @@ import GHC.Types.HpcInfo import GHC.Types.CompleteMatch import GHC.Types.SourceText import GHC.Types.SrcLoc ( unLoc ) +import GHC.Types.Name.Cache import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Logger +import GHC.Utils.Binary +import GHC.Iface.Binary import GHC.Data.FastString import GHC.Data.Maybe @@ -147,8 +150,27 @@ mkFullIface hsc_env partial_iface mb_stg_infos mb_cmm_infos = do let unit_state = hsc_units hsc_env putDumpFileMaybe (hsc_logger hsc_env) Opt_D_dump_hi "FINAL INTERFACE" FormatText (pprModIface unit_state full_iface) + final_iface <- shareIface (hsc_NC hsc_env) (flagsToIfCompression $ hsc_dflags hsc_env) full_iface + putDumpFileMaybe (hsc_logger hsc_env) Opt_D_dump_hi "shared INTERFACE" FormatText + (pprModIface unit_state final_iface) + return final_iface + +shareIface :: NameCache -> CompressionIFace -> ModIface -> IO ModIface +shareIface _ NormalCompression mi = pure mi +shareIface nc compressionLevel mi = do + bh <- openBinMem (1024 * 1024) + start <- tellBinWriter bh + putIfaceWithExtFields QuietBinIFace compressionLevel bh mi + rbh <- shrinkBinBuffer bh + seekBinReader rbh start + res <- getIfaceWithExtFields nc rbh + let resiface = res + { mi_src_hash = mi_src_hash mi + , mi_globals = mi_globals mi + } + forceModIface resiface + return resiface - return full_iface updateDecl :: [IfaceDecl] -> Maybe StgCgInfos -> Maybe CmmCgInfos -> [IfaceDecl] updateDecl decls Nothing Nothing = decls ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -36,6 +36,9 @@ module GHC.Utils.Binary tellBinWriter, castBin, withBinBuffer, + freezeWriteHandle, + shrinkBinBuffer, + thawReadHandle, foldGet, foldGet', @@ -123,7 +126,7 @@ import Foreign hiding (shiftL, shiftR, void) import Data.Array import Data.Array.IO import Data.Array.Unsafe -import Data.ByteString (ByteString) +import Data.ByteString (ByteString, copy) import Data.Coerce import qualified Data.ByteString.Internal as BS import qualified Data.ByteString.Unsafe as BS @@ -327,6 +330,44 @@ openBinMem size , wbm_arr_r = arr_r } +-- | Freeze the given 'WriteBinHandle' and turn it into an equivalent 'ReadBinHandle'. +-- +-- The current offset of the 'WriteBinHandle' is maintained in the new 'ReadBinHandle'. +freezeWriteHandle :: WriteBinHandle -> IO ReadBinHandle +freezeWriteHandle wbm = do + rbm_off_r <- newFastMutInt =<< readFastMutInt (wbm_off_r wbm) + rbm_sz_r <- readFastMutInt (wbm_sz_r wbm) + rbm_arr_r <- readIORef (wbm_arr_r wbm) + pure $ ReadBinMem + { rbm_userData = noReaderUserData + , rbm_off_r = rbm_off_r + , rbm_sz_r = rbm_sz_r + , rbm_arr_r = rbm_arr_r + } + +-- Copy the BinBuffer to a new BinBuffer which is exactly the right size. +-- This performs a copy of the underlying buffer. +-- The buffer may be truncated if the offset is not at the end of the written +-- output. +-- +-- UserData is also discarded during the copy +-- You should just use this when translating a Put handle into a Get handle. +shrinkBinBuffer :: WriteBinHandle -> IO ReadBinHandle +shrinkBinBuffer bh = withBinBuffer bh $ \bs -> do + unsafeUnpackBinBuffer (copy bs) + +thawReadHandle :: ReadBinHandle -> IO WriteBinHandle +thawReadHandle rbm = do + wbm_off_r <- newFastMutInt =<< readFastMutInt (rbm_off_r rbm) + wbm_sz_r <- newFastMutInt (rbm_sz_r rbm) + wbm_arr_r <- newIORef (rbm_arr_r rbm) + pure $ WriteBinMem + { wbm_userData = noWriterUserData + , wbm_off_r = wbm_off_r + , wbm_sz_r = wbm_sz_r + , wbm_arr_r = wbm_arr_r + } + tellBinWriter :: WriteBinHandle -> IO (Bin a) tellBinWriter (WriteBinMem _ r _ _) = do ix <- readFastMutInt r; return (BinPtr ix) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5484fe7639d8990c7552acc2209aeeee09122a87 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5484fe7639d8990c7552acc2209aeeee09122a87 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 08:11:10 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Thu, 02 May 2024 04:11:10 -0400 Subject: [Git][ghc/ghc][wip/fendor/ghc-iface-sharing] Improve sharing of duplicated values in `ModIface` Message-ID: <66334a9ea27c2_3234384213d98479eb@gitlab.mail> Hannes Siebenhandl pushed to branch wip/fendor/ghc-iface-sharing at Glasgow Haskell Compiler / GHC Commits: 4c11762e by Fendor at 2024-05-02T10:10:40+02:00 Improve sharing of duplicated values in `ModIface` As a `ModIface` contains often duplicated values that are not necessarily shared, we improve sharing by serialising the `ModIface` to an in-memory byte array. Serialisation uses deduplication tables, and deserialisation implicitly shares duplicated values. This helps reducing the peak memory usage while compiling in `--make` mode. The peak memory usage is especially reduced when generating interface files with core expressions (`-fwrite-if-simplified-core`). On agda, this reduces the peak memory usage: * `2.2 GB` to `1.9 GB` for a ghci session. On `lib:Cabal`, we report: * `570 MB` to `500 MB` for a ghci session * `790 MB` to `667 MB` for compiling `lib:Cabal` with ghc The execution time is not affected. - - - - - 4 changed files: - compiler/GHC/Driver/Main.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Utils/Binary.hs Changes: ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -966,10 +966,11 @@ loadByteCode iface mod_sum = do -------------------------------------------------------------- + -- Knot tying! See Note [Knot-tying typecheckIface] -- See Note [ModDetails and --make mode] initModDetails :: HscEnv -> ModIface -> IO ModDetails -initModDetails hsc_env iface = +initModDetails hsc_env iface = do fixIO $ \details' -> do let act hpt = addToHpt hpt (moduleName $ mi_module iface) (HomeModInfo iface details' emptyHomeModInfoLinkable) ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -18,6 +18,8 @@ module GHC.Iface.Binary ( getSymtabName, CheckHiWay(..), TraceBinIFace(..), + getIfaceWithExtFields, + putIfaceWithExtFields, getWithUserData, putWithUserData, @@ -156,18 +158,25 @@ readBinIface readBinIface profile name_cache checkHiWay traceBinIface hi_path = do (src_hash, bh) <- readBinIfaceHeader profile name_cache checkHiWay traceBinIface hi_path - extFields_p <- get bh - - mod_iface <- getWithUserData name_cache bh - - seekBinReader bh extFields_p - extFields <- get bh + mod_iface <- getIfaceWithExtFields name_cache bh return mod_iface - { mi_ext_fields = extFields - , mi_src_hash = src_hash + { mi_src_hash = src_hash } +getIfaceWithExtFields :: NameCache -> ReadBinHandle -> IO ModIface +getIfaceWithExtFields name_cache bh = do + extFields_p <- get bh + + mod_iface <- getWithUserData name_cache bh + + seekBinReader bh extFields_p + extFields <- get bh + pure mod_iface + { mi_ext_fields = extFields + } + + -- | This performs a get action after reading the dictionary and symbol -- table. It is necessary to run this before trying to deserialise any -- Names or FastStrings. @@ -227,19 +236,17 @@ writeBinIface profile traceBinIface compressionLevel hi_path mod_iface = do put_ bh tag put_ bh (mi_src_hash mod_iface) - extFields_p_p <- tellBinWriter bh - put_ bh extFields_p_p - - putWithUserData traceBinIface compressionLevel bh mod_iface - - extFields_p <- tellBinWriter bh - putAt bh extFields_p_p extFields_p - seekBinWriter bh extFields_p - put_ bh (mi_ext_fields mod_iface) + putIfaceWithExtFields traceBinIface compressionLevel bh mod_iface -- And send the result to the file writeBinMem bh hi_path +-- | Puts the 'ModIface' +putIfaceWithExtFields :: TraceBinIFace -> CompressionIFace -> WriteBinHandle -> ModIface -> IO () +putIfaceWithExtFields traceBinIface compressionLevel bh mod_iface = + forwardPut_ bh (\_ -> put_ bh (mi_ext_fields mod_iface)) $ do + putWithUserData traceBinIface compressionLevel bh mod_iface + -- | Put a piece of data with an initialised `UserData` field. This -- is necessary if you want to serialise Names or FastStrings. -- It also writes a symbol table and the dictionary. ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -69,10 +69,13 @@ import GHC.Types.HpcInfo import GHC.Types.CompleteMatch import GHC.Types.SourceText import GHC.Types.SrcLoc ( unLoc ) +import GHC.Types.Name.Cache import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Logger +import GHC.Utils.Binary +import GHC.Iface.Binary import GHC.Data.FastString import GHC.Data.Maybe @@ -147,8 +150,25 @@ mkFullIface hsc_env partial_iface mb_stg_infos mb_cmm_infos = do let unit_state = hsc_units hsc_env putDumpFileMaybe (hsc_logger hsc_env) Opt_D_dump_hi "FINAL INTERFACE" FormatText (pprModIface unit_state full_iface) + final_iface <- shareIface (hsc_NC hsc_env) (flagsToIfCompression $ hsc_dflags hsc_env) full_iface + return final_iface + +shareIface :: NameCache -> CompressionIFace -> ModIface -> IO ModIface +shareIface _ NormalCompression mi = pure mi +shareIface nc compressionLevel mi = do + bh <- openBinMem (1024 * 1024) + start <- tellBinWriter bh + putIfaceWithExtFields QuietBinIFace compressionLevel bh mi + rbh <- shrinkBinBuffer bh + seekBinReader rbh start + res <- getIfaceWithExtFields nc rbh + let resiface = res + { mi_src_hash = mi_src_hash mi + , mi_globals = mi_globals mi + } + forceModIface resiface + return resiface - return full_iface updateDecl :: [IfaceDecl] -> Maybe StgCgInfos -> Maybe CmmCgInfos -> [IfaceDecl] updateDecl decls Nothing Nothing = decls ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -36,6 +36,9 @@ module GHC.Utils.Binary tellBinWriter, castBin, withBinBuffer, + freezeWriteHandle, + shrinkBinBuffer, + thawReadHandle, foldGet, foldGet', @@ -123,7 +126,7 @@ import Foreign hiding (shiftL, shiftR, void) import Data.Array import Data.Array.IO import Data.Array.Unsafe -import Data.ByteString (ByteString) +import Data.ByteString (ByteString, copy) import Data.Coerce import qualified Data.ByteString.Internal as BS import qualified Data.ByteString.Unsafe as BS @@ -327,6 +330,44 @@ openBinMem size , wbm_arr_r = arr_r } +-- | Freeze the given 'WriteBinHandle' and turn it into an equivalent 'ReadBinHandle'. +-- +-- The current offset of the 'WriteBinHandle' is maintained in the new 'ReadBinHandle'. +freezeWriteHandle :: WriteBinHandle -> IO ReadBinHandle +freezeWriteHandle wbm = do + rbm_off_r <- newFastMutInt =<< readFastMutInt (wbm_off_r wbm) + rbm_sz_r <- readFastMutInt (wbm_sz_r wbm) + rbm_arr_r <- readIORef (wbm_arr_r wbm) + pure $ ReadBinMem + { rbm_userData = noReaderUserData + , rbm_off_r = rbm_off_r + , rbm_sz_r = rbm_sz_r + , rbm_arr_r = rbm_arr_r + } + +-- Copy the BinBuffer to a new BinBuffer which is exactly the right size. +-- This performs a copy of the underlying buffer. +-- The buffer may be truncated if the offset is not at the end of the written +-- output. +-- +-- UserData is also discarded during the copy +-- You should just use this when translating a Put handle into a Get handle. +shrinkBinBuffer :: WriteBinHandle -> IO ReadBinHandle +shrinkBinBuffer bh = withBinBuffer bh $ \bs -> do + unsafeUnpackBinBuffer (copy bs) + +thawReadHandle :: ReadBinHandle -> IO WriteBinHandle +thawReadHandle rbm = do + wbm_off_r <- newFastMutInt =<< readFastMutInt (rbm_off_r rbm) + wbm_sz_r <- newFastMutInt (rbm_sz_r rbm) + wbm_arr_r <- newIORef (rbm_arr_r rbm) + pure $ WriteBinMem + { wbm_userData = noWriterUserData + , wbm_off_r = wbm_off_r + , wbm_sz_r = wbm_sz_r + , wbm_arr_r = wbm_arr_r + } + tellBinWriter :: WriteBinHandle -> IO (Bin a) tellBinWriter (WriteBinMem _ r _ _) = do ix <- readFastMutInt r; return (BinPtr ix) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4c11762e1cf44673a5da5fda5653daa402e7a6cb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4c11762e1cf44673a5da5fda5653daa402e7a6cb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 08:19:07 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 02 May 2024 04:19:07 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: EPA: Preserve comments for PrefixCon Message-ID: <66334c7bc5e32_32343842d15b450647@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - cf8f2dc9 by Cheng Shao at 2024-05-02T04:18:38-04:00 testsuite: fix req_target_smp predicate - - - - - 517e12e7 by Andreas Klebinger at 2024-05-02T04:18:38-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 593141d6 by Andreas Klebinger at 2024-05-02T04:18:38-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 22eeb478 by Alan Zimmerman at 2024-05-02T04:18:39-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 21 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - hadrian/src/Settings/Builders/RunTest.hs - libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc - rts/Exception.cmm - rts/STM.c - rts/STM.h - rts/Schedule.c - rts/include/stg/SMP.h - testsuite/config/ghc - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/mk/test.mk - testsuite/tests/parser/should_compile/T20846.stderr - testsuite/tests/printer/Makefile - + testsuite/tests/printer/PrefixConComment.hs - + testsuite/tests/printer/Test24748.hs - testsuite/tests/printer/all.T - + testsuite/tests/rts/T24142.hs - + testsuite/tests/rts/T24142.stdout - testsuite/tests/rts/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -2900,10 +2900,10 @@ aexp :: { ECP } [mj AnnLam $1] } | '\\' 'lcase' altslist(pats1) { ECP $ $3 >>= \ $3 -> - mkHsLamPV (comb2 $1 $>) LamCase $3 [mj AnnLam $1,mj AnnCase $2] } + mkHsLamPV (comb3 $1 $2 $>) LamCase $3 [mj AnnLam $1,mj AnnCase $2] } | '\\' 'lcases' altslist(argpats) { ECP $ $3 >>= \ $3 -> - mkHsLamPV (comb2 $1 $>) LamCases $3 [mj AnnLam $1,mj AnnCases $2] } + mkHsLamPV (comb3 $1 $2 $>) LamCases $3 [mj AnnLam $1,mj AnnCases $2] } | 'if' exp optSemi 'then' exp optSemi 'else' exp {% runPV (unECP $2) >>= \ ($2 :: LHsExpr GhcPs) -> return $ ECP $ ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1210,37 +1210,34 @@ checkPattern_details :: ParseContext -> PV (LocatedA (PatBuilder GhcPs)) -> P (L checkPattern_details extraDetails pp = runPV_details extraDetails (pp >>= checkLPat) checkLArgPat :: LocatedA (ArgPatBuilder GhcPs) -> PV (LPat GhcPs) -checkLArgPat (L l (ArgPatBuilderVisPat p)) - = checkPat l (L l p) [] [] +checkLArgPat (L l (ArgPatBuilderVisPat p)) = checkLPat (L l p) checkLArgPat (L l (ArgPatBuilderArgPat p)) = return (L l p) checkLPat :: LocatedA (PatBuilder GhcPs) -> PV (LPat GhcPs) -checkLPat e@(L l _) = checkPat l e [] [] - -checkPat :: SrcSpanAnnA -> LocatedA (PatBuilder GhcPs) -> [HsConPatTyArg GhcPs] -> [LPat GhcPs] - -> PV (LPat GhcPs) -checkPat loc (L l e@(PatBuilderVar (L ln c))) tyargs args - | isRdrDataCon c = do - let (_l', loc') = transferCommentsOnlyA l loc - return . L loc' $ ConPat - { pat_con_ext = noAnn -- AZ: where should this come from? - , pat_con = L ln c - , pat_args = PrefixCon tyargs args - } +checkLPat (L l@(EpAnn anc an _) p) = do + (L l' p', cs) <- checkPat (EpAnn anc an emptyComments) emptyComments (L l p) [] [] + return (L (addCommentsToEpAnn l' cs) p') + +checkPat :: SrcSpanAnnA -> EpAnnComments -> LocatedA (PatBuilder GhcPs) -> [HsConPatTyArg GhcPs] -> [LPat GhcPs] + -> PV (LPat GhcPs, EpAnnComments) +checkPat loc cs (L l e@(PatBuilderVar (L ln c))) tyargs args + | isRdrDataCon c = return (L loc $ ConPat + { pat_con_ext = noAnn -- AZ: where should this come from? + , pat_con = L ln c + , pat_args = PrefixCon tyargs args + }, comments l Semi.<> cs) | (not (null args) && patIsRec c) = do ctx <- askParseContext patFail (locA l) . PsErrInPat e $ PEIP_RecPattern args YesPatIsRecursive ctx -checkPat loc (L _ (PatBuilderAppType (L lf f) at t)) tyargs args = do - let (loc', lf') = transferCommentsOnlyA loc lf - checkPat loc' (L lf' f) (HsConPatTyArg at t : tyargs) args -checkPat loc (L _ (PatBuilderApp f (L le e))) [] args = do - let (loc', le') = transferCommentsOnlyA loc le - p <- checkLPat (L le' e) - checkPat loc' f [] (p : args) -checkPat loc (L l e) [] [] = do +checkPat loc cs (L la (PatBuilderAppType f at t)) tyargs args = + checkPat loc (cs Semi.<> comments la) f (HsConPatTyArg at t : tyargs) args +checkPat loc cs (L la (PatBuilderApp f e)) [] args = do + p <- checkLPat e + checkPat loc (cs Semi.<> comments la) f [] (p : args) +checkPat loc cs (L l e) [] [] = do p <- checkAPat loc e - return (L l p) -checkPat loc e _ _ = do + return (L l p, cs) +checkPat loc _ e _ _ = do details <- fromParseContext <$> askParseContext patFail (locA loc) (PsErrInPat (unLoc e) details) @@ -1349,13 +1346,13 @@ checkFunBind :: SrcStrictness -> [LocatedA (ArgPatBuilder GhcPs)] -> Located (GRHSs GhcPs (LHsExpr GhcPs)) -> P (HsBind GhcPs) -checkFunBind strictness locF ann fun is_infix pats (L _ grhss) +checkFunBind strictness locF ann (L lf fun) is_infix pats (L _ grhss) = do ps <- runPV_details extraDetails (mapM checkLArgPat pats) let match_span = noAnnSrcSpan $ locF - return (makeFunBind fun (L (noAnnSrcSpan $ locA match_span) + return (makeFunBind (L (l2l lf) fun) (L (noAnnSrcSpan $ locA match_span) [L match_span (Match { m_ext = ann , m_ctxt = FunRhs - { mc_fun = fun + { mc_fun = L lf fun , mc_fixity = is_infix , mc_strictness = strictness } , m_pats = ps @@ -1364,7 +1361,7 @@ checkFunBind strictness locF ann fun is_infix pats (L _ grhss) -- That isn't quite right, but it'll do for now. where extraDetails - | Infix <- is_infix = ParseContext (Just $ unLoc fun) NoIncompleteDoBlock + | Infix <- is_infix = ParseContext (Just fun) NoIncompleteDoBlock | otherwise = noParseContext makeFunBind :: LocatedN RdrName -> LocatedL [LMatch GhcPs (LHsExpr GhcPs)] ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -282,7 +282,7 @@ runTestBuilderArgs = builder Testsuite ? do , arg "-e", arg $ asBool "ghc_with_dynamic_rts=" (hasDynamicRts) , arg "-e", arg $ asBool "config.ghc_with_threaded_rts=" (hasThreadedRts) , arg "-e", arg $ asBool "config.have_fast_bignum=" (bignumBackend /= "native" && not bignumCheck) - , arg "-e", arg $ asBool "target_with_smp=" targetWithSMP + , arg "-e", arg $ asBool "config.target_has_smp=" targetWithSMP , arg "-e", arg $ "config.ghc_dynamic=" ++ show hasDynamic , arg "-e", arg $ "config.leading_underscore=" ++ show leadingUnderscore ===================================== libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc ===================================== @@ -380,14 +380,14 @@ data ParFlags = ParFlags -- | Parameters pertaining to Haskell program coverage (HPC) -- --- @since base-4.22.0.0 +-- @since base-4.20.0.0 data HpcFlags = HpcFlags { writeTixFile :: Bool -- ^ Controls whether the @.tix@ file should be -- written after the execution of the program. } - deriving (Show -- ^ @since base-4.22.0.0 - , Generic -- ^ @since base-4.22.0.0 + deriving (Show -- ^ @since base-4.20.0.0 + , Generic -- ^ @since base-4.20.0.0 ) -- | Parameters of the runtime system -- ===================================== rts/Exception.cmm ===================================== @@ -495,7 +495,7 @@ retry_pop_stack: W_ trec, outer; W_ r; trec = StgTSO_trec(CurrentTSO); - (r) = ccall stmValidateNestOfTransactions(MyCapability() "ptr", trec "ptr"); + (r) = ccall stmValidateNestOfTransactions(MyCapability() "ptr", trec "ptr", 0); outer = StgTRecHeader_enclosing_trec(trec); ccall stmAbortTransaction(MyCapability() "ptr", trec "ptr"); ccall stmFreeAbortedTRec(MyCapability() "ptr", trec "ptr"); ===================================== rts/STM.c ===================================== @@ -31,10 +31,8 @@ * interface. In the Haskell RTS this means it is suitable only for * non-THREADED_RTS builds. * - * STM_CG_LOCK uses coarse-grained locking -- a single 'stm lock' is acquired - * during an invocation on the STM interface. Note that this does not mean that - * transactions are simply serialized -- the lock is only held *within* the - * implementation of stmCommitTransaction, stmWait etc. + * STM_CG_LOCK was a historic locking mode using coarse-grained locking + * It has been removed, look at the git history if you are interest in it. * * STM_FG_LOCKS uses fine-grained locking -- locking is done on a per-TVar basis * and, when committing a transaction, no locks are acquired for TVars that have @@ -42,19 +40,14 @@ * * Concurrency control is implemented in the functions: * - * lock_stm - * unlock_stm * lock_tvar / cond_lock_tvar * unlock_tvar * - * The choice between STM_UNIPROC / STM_CG_LOCK / STM_FG_LOCKS affects the + * The choice between STM_UNIPROC / STM_FG_LOCKS affects the * implementation of these functions. * - * lock_stm & unlock_stm are straightforward : they acquire a simple spin-lock - * using STM_CG_LOCK, and otherwise they are no-ops. - * * lock_tvar / cond_lock_tvar and unlock_tvar are more complex because they have - * other effects (present in STM_UNIPROC and STM_CG_LOCK builds) as well as the + * other effects (present in STM_UNIPROC builds) as well as the * actual business of manipulating a lock (present only in STM_FG_LOCKS builds). * This is because locking a TVar is implemented by writing the lock holder's * TRec into the TVar's current_value field: @@ -167,7 +160,6 @@ static int shake(void) { /*......................................................................*/ #define IF_STM_UNIPROC(__X) do { } while (0) -#define IF_STM_CG_LOCK(__X) do { } while (0) #define IF_STM_FG_LOCKS(__X) do { } while (0) #if defined(STM_UNIPROC) @@ -175,14 +167,6 @@ static int shake(void) { #define IF_STM_UNIPROC(__X) do { __X } while (0) static const StgBool config_use_read_phase = false; -static void lock_stm(StgTRecHeader *trec STG_UNUSED) { - TRACE("%p : lock_stm()", trec); -} - -static void unlock_stm(StgTRecHeader *trec STG_UNUSED) { - TRACE("%p : unlock_stm()", trec); -} - static StgClosure *lock_tvar(Capability *cap STG_UNUSED, StgTRecHeader *trec STG_UNUSED, StgTVar *s STG_UNUSED) { @@ -210,64 +194,9 @@ static StgBool cond_lock_tvar(Capability *cap STG_UNUSED, StgTVar *s STG_UNUSED, StgClosure *expected) { StgClosure *result; - TRACE("%p : cond_lock_tvar(%p, %p)", trec, s, expected); - result = ACQUIRE_LOAD(&s->current_value); - TRACE("%p : %s", trec, (result == expected) ? "success" : "failure"); - return (result == expected); -} -#endif - -#if defined(STM_CG_LOCK) /*........................................*/ - -#undef IF_STM_CG_LOCK -#define IF_STM_CG_LOCK(__X) do { __X } while (0) -static const StgBool config_use_read_phase = false; -static volatile StgTRecHeader *smp_locked = NULL; - -static void lock_stm(StgTRecHeader *trec) { - while (cas(&smp_locked, NULL, trec) != NULL) { } - TRACE("%p : lock_stm()", trec); -} - -static void unlock_stm(StgTRecHeader *trec STG_UNUSED) { - TRACE("%p : unlock_stm()", trec); - ASSERT(smp_locked == trec); - RELEASE_STORE(&smp_locked, 0); -} - -static StgClosure *lock_tvar(Capability *cap STG_UNUSED, - StgTRecHeader *trec STG_UNUSED, - StgTVar *s STG_UNUSED) { - StgClosure *result; - TRACE("%p : lock_tvar(%p)", trec, s); - ASSERT(smp_locked == trec); + // TRACE("%p : cond_lock_tvar(%p, %p)", trec, s, expected); result = ACQUIRE_LOAD(&s->current_value); - return result; -} - -static void *unlock_tvar(Capability *cap, - StgTRecHeader *trec STG_UNUSED, - StgTVar *s, - StgClosure *c, - StgBool force_update) { - TRACE("%p : unlock_tvar(%p, %p)", trec, s, c); - ASSERT(smp_locked == trec); - if (force_update) { - StgClosure *old_value = ACQUIRE_LOAD(&s->current_value); - RELEASE_STORE(&s->current_value, c); - dirty_TVAR(cap, s, old_value); - } -} - -static StgBool cond_lock_tvar(Capability *cap STG_UNUSED, - StgTRecHeader *trec STG_UNUSED, - StgTVar *s STG_UNUSED, - StgClosure *expected) { - StgClosure *result; - TRACE("%p : cond_lock_tvar(%p, %p)", trec, s, expected); - ASSERT(smp_locked == trec); - result = ACQUIRE_LOAD(&s->current_value); - TRACE("%p : %d", result ? "success" : "failure"); + // TRACE("%p : %s", trec, (result == expected) ? "success" : "failure"); return (result == expected); } #endif @@ -278,19 +207,11 @@ static StgBool cond_lock_tvar(Capability *cap STG_UNUSED, #define IF_STM_FG_LOCKS(__X) do { __X } while (0) static const StgBool config_use_read_phase = true; -static void lock_stm(StgTRecHeader *trec STG_UNUSED) { - TRACE("%p : lock_stm()", trec); -} - -static void unlock_stm(StgTRecHeader *trec STG_UNUSED) { - TRACE("%p : unlock_stm()", trec); -} - static StgClosure *lock_tvar(Capability *cap, StgTRecHeader *trec, StgTVar *s STG_UNUSED) { StgClosure *result; - TRACE("%p : lock_tvar(%p)", trec, s); + // TRACE("%p : lock_tvar(%p)", trec, s); do { const StgInfoTable *info; do { @@ -313,7 +234,7 @@ static void unlock_tvar(Capability *cap, StgTVar *s, StgClosure *c, StgBool force_update STG_UNUSED) { - TRACE("%p : unlock_tvar(%p, %p)", trec, s, c); + // TRACE("%p : unlock_tvar(%p, %p)", trec, s, c); ASSERT(ACQUIRE_LOAD(&s->current_value) == (StgClosure *)trec); RELEASE_STORE(&s->current_value, c); dirty_TVAR(cap, s, (StgClosure *) trec); @@ -325,14 +246,14 @@ static StgBool cond_lock_tvar(Capability *cap, StgClosure *expected) { StgClosure *result; StgWord w; - TRACE("%p : cond_lock_tvar(%p, %p)", trec, s, expected); + // TRACE("%p : cond_lock_tvar(%p, %p)", trec, s, expected); w = cas((void *)&(s -> current_value), (StgWord)expected, (StgWord)trec); result = (StgClosure *)w; IF_NONMOVING_WRITE_BARRIER_ENABLED { if (result) updateRemembSetPushClosure(cap, expected); } - TRACE("%p : %s", trec, result ? "success" : "failure"); + // TRACE("%p : %s", trec, result ? "success" : "failure"); return (result == expected); } #endif @@ -438,6 +359,8 @@ static StgTRecHeader *new_stg_trec_header(Capability *cap, // Allocation / deallocation functions that retain per-capability lists // of closures that can be re-used +//TODO: I think some of these lack write barriers required by the non-moving gc. + static StgTVarWatchQueue *alloc_stg_tvar_watch_queue(Capability *cap, StgClosure *closure) { StgTVarWatchQueue *result = NULL; @@ -760,6 +683,44 @@ static void revert_ownership(Capability *cap STG_UNUSED, /*......................................................................*/ +// validate_optimistic() +StgBool validate_trec_optimistic (Capability *cap, StgTRecHeader *trec); + +StgBool validate_trec_optimistic (Capability *cap, StgTRecHeader *trec) { + StgBool result; + TRACE("cap %d, trec %p : validate_trec_optimistic", + cap->no, trec); + + if (shake()) { + TRACE("%p : shake, pretending trec is invalid when it may not be", trec); + return false; + } + + ASSERT((trec -> state == TREC_ACTIVE) || + (trec -> state == TREC_WAITING) || + (trec -> state == TREC_CONDEMNED)); + result = !((trec -> state) == TREC_CONDEMNED); + if (result) { + FOR_EACH_ENTRY(trec, e, { + StgTVar *s; + s = e -> tvar; + StgClosure *current = RELAXED_LOAD(&s->current_value); + if(current != e->expected_value && + //If the trec is locked we optimistically assume our trec will still be valid after it's unlocked. + (GET_INFO(UNTAG_CLOSURE(current)) != &stg_TREC_HEADER_info)) + { TRACE("%p : failed optimistic validate %p", trec, s); + result = false; + BREAK_FOR_EACH; + } + }); + } + + + TRACE("%p : validate_trec_optimistic, result: %d", trec, result); + return result; +} + + // validate_and_acquire_ownership : this performs the twin functions // of checking that the TVars referred to by entries in trec hold the // expected values and: @@ -778,6 +739,8 @@ static StgBool validate_and_acquire_ownership (Capability *cap, int acquire_all, int retain_ownership) { StgBool result; + TRACE("cap %d, trec %p : validate_and_acquire_ownership, all: %d, retrain: %d", + cap->no, trec, acquire_all, retain_ownership); if (shake()) { TRACE("%p : shake, pretending trec is invalid when it may not be", trec); @@ -828,6 +791,7 @@ static StgBool validate_and_acquire_ownership (Capability *cap, revert_ownership(cap, trec, acquire_all); } + TRACE("%p : validate_and_acquire_ownership, result: %d", trec, result); return result; } @@ -878,12 +842,10 @@ static StgBool check_read_only(StgTRecHeader *trec STG_UNUSED) { /************************************************************************/ void stmPreGCHook (Capability *cap) { - lock_stm(NO_TREC); TRACE("stmPreGCHook"); cap->free_tvar_watch_queues = END_STM_WATCH_QUEUE; cap->free_trec_chunks = END_STM_CHUNK_LIST; cap->free_trec_headers = NO_TREC; - unlock_stm(NO_TREC); } /************************************************************************/ @@ -959,8 +921,6 @@ void stmAbortTransaction(Capability *cap, (trec -> state == TREC_WAITING) || (trec -> state == TREC_CONDEMNED)); - lock_stm(trec); - et = trec -> enclosing_trec; if (et == NO_TREC) { // We're a top-level transaction: remove any watch queue entries that @@ -984,8 +944,6 @@ void stmAbortTransaction(Capability *cap, } trec -> state = TREC_ABORTED; - unlock_stm(trec); - TRACE("%p : stmAbortTransaction done", trec); } @@ -1013,35 +971,210 @@ void stmCondemnTransaction(Capability *cap, (trec -> state == TREC_WAITING) || (trec -> state == TREC_CONDEMNED)); - lock_stm(trec); if (trec -> state == TREC_WAITING) { ASSERT(trec -> enclosing_trec == NO_TREC); TRACE("%p : stmCondemnTransaction condemning waiting transaction", trec); remove_watch_queue_entries_for_trec(cap, trec); } trec -> state = TREC_CONDEMNED; - unlock_stm(trec); TRACE("%p : stmCondemnTransaction done", trec); } -/*......................................................................*/ - -StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec) { +/*...................................................................... + +Note [STM Validation] +~~~~~~~~~~~~~~~~~~~~~ +To "validate" a transaction means to check that the transaction's log (Trec) is +consistent with the current state of memory; specifically, that any variable +observed (through reads AND writes) by the transaction has the same value in +memory as it did when the transaction read it. + +In some situations we can give ourself some leeway by allowing: +* False positives - The validation check claims the memory state is consistent when it isn't. +* False negatives - The validation check claims memory state is inconsistent when it + is in fact consistent. + +We validate a STM transaction for two purposes: + +(A) Post-run validation runs /after/ the transaction has completed, either during + commit or after an exception has occurred. + + This is done by validate_and_acquire_ownership. The commit process + /absolutely must/ be transactional: that is, it must read a consistent + snapshot of memory, compare with the log, and then atomically commit all the + writes in the log. We do this by locking the TVars. + + For post-run validation we must *never* allow false-positives for correctness + reasons. But we allow for false-negatives, trading occasional spurious retries + for performance in the average case. + + The implementation of performing this update atomically is mostly based on + the 2002 paper "A Practical Multi-Word Compare-and-Swap Operation" + +(B) In-flight validation runs /during/ the execution of the transaction. Suppose a transaction + is long-running, and memory has /already/ changed so that it is inconsistent with the + transaction's log. It is just conceivable that memory might change back again to be + consistent, but very unlikely. It is better to terminate and retry the transaction, + rather than let it run potentially forever as a zombie, and only retry when it attempts to commit. + + This is done by validate_trec_optimistic. Since in-flight validation at most results in early + termination of a transaction we may accept both + * a "false negative" (causing the transaction to retry unnecessarily), and + * a "false positive" (allowing the transaction to continue as a zombie). + + We want to run in-flight validation somewhat frequently to detect invalid + transactions early. We perform in-flight validation whenever a thread returns to + the scheduler, a convenient and regular opportunity. + +Note that in-flight validation is not merely a optimization. Consider transactions +that are in an infinite loop as a result of seeing an inconsistent view of +memory, e.g. + + atomically $ do + [a,b] <- mapM readTVar [ta,tb] + -- a is never equal to b given a consistent view of memory. + when (a == b) loop + +As noted above, post-run validation and commit /must/ be transactional, involving expensive locking. +But in-flight validation can accept false positives and false negatives. While we could lock TVars +during in-flight validation to rule out false positives, we don't have to: +it is much cheaper and very nearly as good simply to read them without locking allowing for +false-postive results. + +Moreover, locking during in-flight validation can cause lack of progress, or livelock (#24446) +through false-negative results. Suppose we have two long-running transactions, each doing successive +in-flight validation using locking. If the validation discovers a locked TVar it aborts and retries. +Now they can each abort the other, forever. +This *can* also happen with post-run validation. But since post-run validation occurs less +frequently it's incredibly unlikely to happen repeatedly compared to in-flight validation. + +Hence: locking during in-flight validation is + * Expensive + * Can lead to livelock-like conditions. + +Conclusion: + * don't use locking during in-flight validation. + * Use locking during post-run validation, where the risk of livelock is comparatively small + compared to the cost of ruling out live-lock completely. + +See below for other design alternatives. + +Design considerations about locking during in flight validation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +All else being equal we would always want to get a precise result for validation. +And indeed for the non-threaded runtime this is reasonably easy to achieve +(see STM paper "Composable Memory Transactions"). +However for SMP things are more difficult, and ruling out false negatives/positives +would come at significant cost in the average case. + +The easiest way to avoid false positives is to lock all relevant tvars during +validation. And indeed that is what we use for post-run validation. +The trade off being that it can lead to false negatives during validation when multiple +threads perform validation in parallel. As long as the false-negative rate is +is reasonably low this is not problematic. + +However in-flight validation can happen multiple times per transaction. +So even a fairly low rate of spurious validation failures will result in a large +performance hit. In the worst case preventing progress alltogether (See #24446). + +We don't want to reduce validation frequency too much to detect invalid +transactions early. So we simply stick with the frequency "on return to scheduler" +that's described in the stm paper. + +However we can improve in-flight validation perf by allowing false positives. +This removes the need for tacking locks which means: + +Benefits +* No lock contention between post-run and in-flight validations operating on the + same tvars. This reduces the false negative rate significantly for both. +* Concurrent in-flight validations won't cause each other to fail spuriously + through lock contention. +* No cas operations for in-flight validation reduces it's overhead significantly. + +Drawbacks: +* We will sometimes fail to recognize invalid trecs as such by assuming locked + tvars contain valid values. + +Why can we simply not lock tvars for in-flight validations? Unlike with post-run +validation if we miss part of an update which would invalidate the trec it will +be either seen by a later validation (at the latest in the post-run validation +which still locks). However there is one exception: Looping transactions. + +If a transaction loops it will *only* be validated optimistically. +The only way for in-flight validation to constantly +result in false-positives is for the conflicting tvar(s) to get constantly locked +for updates by post-run validations. Which seems impossibly unlikely over a long +period of time. So we accept this behaviour. + +Design alternatives to improve in-flight false-postive rate: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +All of these primarily revolve around ways to ensure that we can recognize invalid +looping transactions. However without proof this is a real problem implementing +those seems not worthwhile. + +A1: +Take locks for in-flight validation but don't fail if in-flight validation +encounters already locked tvars. +This would solve lock contention/false positives caused by concurrent in-flight validations. + +But it would still result in in-flight validation causing some false-negatives +during post-run validation by holding locks post-run validation is trying to take. + +It also doesn't *guaranteed* that we recognize looping transaction as invalid. +As the relevant tvars might be locked by other validations when we try to lock +them. So while this would improve over using regular lock tacking for in-flight +transactions it seems straight up worse than not taking locks to me in most +situations. + +A2: +Perform occasional locking in-flight validation for long running transactions. +This would solve the theoretical looping transaction recognition issue at the +cost of some performance and complexity. This could done by adding a counter to +the trec, counting the number of validations it has endured. + +A2.1: +Like A2, but instead of counting the number of validations count the number of +locked tvars we encountered, as these are the only sources of false-positives. +This would give a hard upper bound on the number of false-positives while keeping +the impact on post-run validations lower. + +If the looping transaction issue turns out to be a real problem this might be worth +doing. + +A3: +When locking a tvar for a potential update keep the old value accessible. Then +in-flight validations should never return false-positives. However compared to A2 +this seems like it would come with a non-trivial overhead relative to the likelyhood +of these false-positives causing actual issues. + + +*/ + +// Check if a transaction is possibly invalid by this point. +// Pessimistically - Currently we use this if an exception occured inside a transaction. +// To decide weither or not to abort by checking if the transaction was valid. +// Optimistically - Currently we use this to eagerly abort invalid transactions from the scheduler. +// See Note [STM Validation] +StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec, StgBool optimistically) { StgTRecHeader *t; - TRACE("%p : stmValidateNestOfTransactions", trec); + TRACE("%p : stmValidateNestOfTransactions, %b", trec, optimistically); ASSERT(trec != NO_TREC); ASSERT((trec -> state == TREC_ACTIVE) || (trec -> state == TREC_WAITING) || (trec -> state == TREC_CONDEMNED)); - lock_stm(trec); - t = trec; StgBool result = true; while (t != NO_TREC) { - result &= validate_and_acquire_ownership(cap, t, true, false); + if(optimistically) { + result &= validate_trec_optimistic(cap, t); + + } else { + // TODO: I don't think there is a need to lock all tvars here. + result &= validate_and_acquire_ownership(cap, t, true, false); + } t = t -> enclosing_trec; } @@ -1049,12 +1182,9 @@ StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec) { trec -> state = TREC_CONDEMNED; } - unlock_stm(trec); - TRACE("%p : stmValidateNestOfTransactions()=%d", trec, result); return result; } - /*......................................................................*/ static TRecEntry *get_entry_for(StgTRecHeader *trec, StgTVar *tvar, StgTRecHeader **in) { @@ -1087,8 +1217,6 @@ StgBool stmCommitTransaction(Capability *cap, StgTRecHeader *trec) { TRACE("%p : stmCommitTransaction()", trec); ASSERT(trec != NO_TREC); - lock_stm(trec); - ASSERT(trec -> enclosing_trec == NO_TREC); ASSERT((trec -> state == TREC_ACTIVE) || (trec -> state == TREC_CONDEMNED)); @@ -1112,6 +1240,7 @@ StgBool stmCommitTransaction(Capability *cap, StgTRecHeader *trec) { max_concurrent_commits = ((max_commits_at_end - max_commits_at_start) + (getNumCapabilities() * TOKEN_BATCH_SIZE)); if (((max_concurrent_commits >> 32) > 0) || shake()) { + TRACE("STM - Max commit number exceeded"); result = false; } } @@ -1145,8 +1274,6 @@ StgBool stmCommitTransaction(Capability *cap, StgTRecHeader *trec) { } } - unlock_stm(trec); - free_stg_trec_header(cap, trec); TRACE("%p : stmCommitTransaction()=%d", trec, result); @@ -1162,8 +1289,6 @@ StgBool stmCommitNestedTransaction(Capability *cap, StgTRecHeader *trec) { TRACE("%p : stmCommitNestedTransaction() into %p", trec, trec -> enclosing_trec); ASSERT((trec -> state == TREC_ACTIVE) || (trec -> state == TREC_CONDEMNED)); - lock_stm(trec); - et = trec -> enclosing_trec; bool result = validate_and_acquire_ownership(cap, trec, (!config_use_read_phase), true); if (result) { @@ -1196,8 +1321,6 @@ StgBool stmCommitNestedTransaction(Capability *cap, StgTRecHeader *trec) { } } - unlock_stm(trec); - free_stg_trec_header(cap, trec); TRACE("%p : stmCommitNestedTransaction()=%d", trec, result); @@ -1214,7 +1337,6 @@ StgBool stmWait(Capability *cap, StgTSO *tso, StgTRecHeader *trec) { ASSERT((trec -> state == TREC_ACTIVE) || (trec -> state == TREC_CONDEMNED)); - lock_stm(trec); bool result = validate_and_acquire_ownership(cap, trec, true, true); if (result) { // The transaction is valid so far so we can actually start waiting. @@ -1237,7 +1359,6 @@ StgBool stmWait(Capability *cap, StgTSO *tso, StgTRecHeader *trec) { // TRec. } else { - unlock_stm(trec); free_stg_trec_header(cap, trec); } @@ -1249,7 +1370,6 @@ StgBool stmWait(Capability *cap, StgTSO *tso, StgTRecHeader *trec) { void stmWaitUnlock(Capability *cap, StgTRecHeader *trec) { revert_ownership(cap, trec, true); - unlock_stm(trec); } /*......................................................................*/ @@ -1263,7 +1383,6 @@ StgBool stmReWait(Capability *cap, StgTSO *tso) { ASSERT((trec -> state == TREC_WAITING) || (trec -> state == TREC_CONDEMNED)); - lock_stm(trec); bool result = validate_and_acquire_ownership(cap, trec, true, true); TRACE("%p : validation %s", trec, result ? "succeeded" : "failed"); if (result) { @@ -1280,7 +1399,6 @@ StgBool stmReWait(Capability *cap, StgTSO *tso) { } free_stg_trec_header(cap, trec); } - unlock_stm(trec); TRACE("%p : stmReWait()=%d", trec, result); return result; ===================================== rts/STM.h ===================================== @@ -6,24 +6,21 @@ * *---------------------------------------------------------------------- - STM.h defines the C-level interface to the STM. + STM.h defines the C-level interface to the STM. The design follows that of the PPoPP 2005 paper "Composable memory transactions" extended to include fine-grained locking of TVars. Three different implementations can be built. In overview: - + STM_UNIPROC -- no locking at all: not safe for concurrent invocations - - STM_CG_LOCK -- coarse-grained locking : a single mutex protects all - TVars - + STM_FG_LOCKS -- per-TVar exclusion : each TVar can be owned by at most one TRec at any time. This allows dynamically non-conflicting transactions to commit in parallel. The implementation treats reads optimistically -- - extra versioning information is retained in the - saw_update_by field of the TVars so that they do not + extra versioning information is retained in the + num_updates field of the TVars so that they do not need to be locked for reading. STM.C contains more details about the locking schemes used. @@ -72,7 +69,7 @@ void stmAbortTransaction(Capability *cap, StgTRecHeader *trec); void stmFreeAbortedTRec(Capability *cap, StgTRecHeader *trec); /* - * Ensure that a subsequent commit / validation will fail. We use this + * Ensure that a subsequent commit / validation will fail. We use this * in our current handling of transactions that may have become invalid * and started looping. We strip their stack back to the ATOMICALLY_FRAME, * and, when the thread is next scheduled, discover it to be invalid and @@ -87,16 +84,23 @@ void stmCondemnTransaction(Capability *cap, StgTRecHeader *trec); Validation ---------- - Test whether the specified transaction record, and all those within which - it is nested, are still valid. + Test whether the specified transaction record, and all those within which + it is nested, are still valid. + + stmValidateNestOfTransactions - optimistically + - Can return false positives when tvars are locked. + - Faster + - Does not take any locks + + stmValidateNestOfTransactions - pessimistic + - Can return false negatives. + - Slower + - Takes locks, negatively affecting performance of other threads. + - Most importantly - no false positives! - Note: the caller can assume that once stmValidateTransaction has - returned false for a given trec then that transaction will never - again be valid -- we rely on this in Schedule.c when kicking invalid - threads at GC (in case they are stuck looping) */ -StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec); +StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec, StgBool optimistically); /*---------------------------------------------------------------------- @@ -106,14 +110,14 @@ StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec); These four operations return boolean results which should be interpreted as follows: - true => The transaction record was definitely valid + true => The transaction record was definitely valid false => The transaction record may not have been valid Note that, for nested operations, validity here is solely in terms of the specified trec: it does not say whether those that it may be - nested are themselves valid. Callers can check this with - stmValidateNestOfTransactions. + nested are themselves valid. Callers can check this with + stmValidateNestOfTransactionsPessimistic. The user of the STM should ensure that it is always safe to assume that a transaction context is not valid when in fact it is (i.e. to return false in @@ -151,7 +155,7 @@ StgBool stmCommitNestedTransaction(Capability *cap, StgTRecHeader *trec); * Test whether the current transaction context is valid and, if so, * start the thread waiting for updates to any of the tvars it has * ready from and mark it as blocked. It is an error to call stmWait - * if the thread is already waiting. + * if the thread is already waiting. */ StgBool stmWait(Capability *cap, StgTSO *tso, StgTRecHeader *trec); @@ -180,7 +184,7 @@ StgBool stmReWait(Capability *cap, StgTSO *tso); */ StgClosure *stmReadTVar(Capability *cap, - StgTRecHeader *trec, + StgTRecHeader *trec, StgTVar *tvar); /* Update the logical contents of 'tvar' within the context of the @@ -189,7 +193,7 @@ StgClosure *stmReadTVar(Capability *cap, void stmWriteTVar(Capability *cap, StgTRecHeader *trec, - StgTVar *tvar, + StgTVar *tvar, StgClosure *new_value); /*----------------------------------------------------------------------*/ ===================================== rts/Schedule.c ===================================== @@ -1106,7 +1106,7 @@ schedulePostRunThread (Capability *cap, StgTSO *t) // and a is never equal to b given a consistent view of memory. // if (t -> trec != NO_TREC && t -> why_blocked == NotBlocked) { - if (!stmValidateNestOfTransactions(cap, t -> trec)) { + if (!stmValidateNestOfTransactions(cap, t -> trec, true)) { debugTrace(DEBUG_sched | DEBUG_stm, "trec %p found wasting its time", t); ===================================== rts/include/stg/SMP.h ===================================== @@ -201,14 +201,15 @@ EXTERN_INLINE void busy_wait_nop(void); * - StgWeak: finalizer * - StgMVar: head, tail, value * - StgMVarTSOQueue: link - * - StgTVar: current_value, first_watch_queue_entry - * - StgTVarWatchQueue: {next,prev}_queue_entry - * - StgTRecChunk: TODO * - StgMutArrPtrs: payload * - StgSmallMutArrPtrs: payload * - StgThunk although this is a somewhat special case; see below * - StgInd: indirectee * - StgTSO: block_info + + * - StgTVar: current_value, first_watch_queue_entry + * - StgTVarWatchQueue: {next,prev}_queue_entry + * - StgTRecChunk: TODO * * Finally, non-pointer fields can be safely mutated without barriers as * they do not refer to other memory locations. Technically, concurrent ===================================== testsuite/config/ghc ===================================== @@ -48,8 +48,7 @@ if config.have_interp: # whether the target supports smp if config.ghc_with_threaded_rts: config.run_ways.append('threaded1') - if target_with_smp: - config.target_has_smp = True + if config.target_has_smp: config.run_ways.append('threaded2') if config.speed == 0: config.run_ways.append('nonmoving_thr') ===================================== testsuite/driver/testglobals.py ===================================== @@ -154,7 +154,7 @@ class TestConfig: self.ghc_has_smp = True # Does the target have SMP support? - self.target_has_smp = True + self.target_has_smp = False # Is gdb available? self.have_gdb = False ===================================== testsuite/driver/testlib.py ===================================== @@ -328,11 +328,11 @@ def req_ghc_smp( name, opts ): def req_target_smp( name, opts ): """ Mark a test as requiring smp when run on the target. If the target does - not support smp, then mark the test as an expected fail. Use this when the + not support smp, then skip the test. Use this when the test needs to run with smp support. """ if not config.target_has_smp: - opts.expect = 'fail' + opts.skip = True def req_ghc_with_threaded_rts( name, opts ): if not config.ghc_with_threaded_rts: ===================================== testsuite/mk/test.mk ===================================== @@ -167,9 +167,9 @@ CABAL_PLUGIN_BUILD = --enable-library-vanilla --disable-shared endif ifeq "$(GhcWithSMP)" "YES" -RUNTEST_OPTS += -e target_with_smp=True +RUNTEST_OPTS += -e config.target_has_smp=True else -RUNTEST_OPTS += -e target_with_smp=False +RUNTEST_OPTS += -e config.target_has_smp=False endif ifeq "$(GhcWithRtsLinker)" "YES" ===================================== testsuite/tests/parser/should_compile/T20846.stderr ===================================== @@ -71,11 +71,7 @@ (L (EpAnn (EpaSpan { T20846.hs:4:1-6 }) - (NameAnn - (NameParens) - (EpaSpan { T20846.hs:4:1 }) - (EpaSpan { T20846.hs:4:2-5 }) - (EpaSpan { T20846.hs:4:6 }) + (NameAnnTrailing []) (EpaComments [])) ===================================== testsuite/tests/printer/Makefile ===================================== @@ -837,6 +837,11 @@ MatchPatComments: $(CHECK_PPR) $(LIBDIR) MatchPatComments.hs $(CHECK_EXACT) $(LIBDIR) MatchPatComments.hs +.PHONY: Test24748 +Test24748: + $(CHECK_PPR) $(LIBDIR) Test24748.hs + $(CHECK_EXACT) $(LIBDIR) Test24748.hs + .PHONY: DataDeclShort DataDeclShort: $(CHECK_PPR) $(LIBDIR) DataDeclShort.hs ===================================== testsuite/tests/printer/PrefixConComment.hs ===================================== @@ -0,0 +1,4 @@ +module PrefixConComment where + +fun (Con {- c1 -} a {- c2 -} b {- c3 -}) + = undefined ===================================== testsuite/tests/printer/Test24748.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE LambdaCase #-} +module Test24748 where + +instance SDecide Nat where + SZero %~ (SSucc _) = Disproved (\case) + +foo = (\case) +bar = (\cases) ===================================== testsuite/tests/printer/all.T ===================================== @@ -200,4 +200,5 @@ test('Test24533', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24533']) test('PprLetIn', [ignore_stderr, req_ppr_deps], makefile_test, ['PprLetIn']) test('CaseAltComments', [ignore_stderr, req_ppr_deps], makefile_test, ['CaseAltComments']) test('MatchPatComments', [ignore_stderr, req_ppr_deps], makefile_test, ['MatchPatComments']) +test('Test24748', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24748']) test('DataDeclShort', [ignore_stderr, req_ppr_deps], makefile_test, ['DataDeclShort']) ===================================== testsuite/tests/rts/T24142.hs ===================================== @@ -0,0 +1,63 @@ +{- This test constructs a program that used to trigger an excessive amount of STM retries. -} +{-# LANGUAGE NumericUnderscores #-} +{-# LANGUAGE BangPatterns #-} +module Main where + +import GHC.Conc +import Control.Concurrent (newMVar, newEmptyMVar, takeMVar, putMVar) +import Control.Monad +import Control.Concurrent.STM.TArray +import Data.Array.MArray +import Data.IORef + + +main :: IO () +main = + forM_ [2..40] $ \i -> do + -- Run the test with an increasing number of tvars + let tvar_count = i * 10 + -- print $ "Tvars: " ++ show tvar_count + provokeLivelock tvar_count + + +-- Forks two threads running a STM transactions, both accessing the same tvars but in opposite order. +provokeLivelock :: Int -> IO () +provokeLivelock n = do + -- Use tvar array as a convenient way to bundle up n Tvars. + tvarArray <- atomically $ do + newListArray (0,n) [0.. fromIntegral n :: Integer] :: STM (TArray Int Integer) + m1 <- newEmptyMVar + m2 <- newEmptyMVar + updateCount <- newIORef (0 :: Int) + + let useTvars :: [Int] -> Bool -> IO () + useTvars tvar_order use_writes = atomically $ do + -- Walk the array once in the given order to add all tvars to the transaction log. + unsafeIOToSTM $ atomicModifyIORef' updateCount (\i -> (i+1,())) + mapM_ (\i -> readArray tvarArray i >>= \(!_n) -> return ()) tvar_order + + + -- Then we just enter the scheduler a lot + forM_ tvar_order $ \i -> do + -- when use_writes $ + -- readArray tvarArray i >>= \(!n) -> writeArray tvarArray i (n+1 :: Integer) + unsafeIOToSTM yield + + _ <- forkIO $ do + useTvars [0..n] False + -- print "Thread1 done." + putMVar m1 True + _ <- forkIO $ do + useTvars (reverse [0..n]) False + -- print "Thread1 done." + putMVar m2 True + -- Wait for forked threads. + _ <- takeMVar m1 + _ <- takeMVar m2 + updates <- readIORef updateCount + if updates > n + then putStrLn $ "TVars: " ++ show n ++ ", ERROR: more than " ++ show n ++ " transaction attempts. (" ++ show updates ++")\n" + else putStrLn $ "TVars: " ++ show n ++ ", OK: no more than " ++ show n ++ " transaction attempts." + + return () + ===================================== testsuite/tests/rts/T24142.stdout ===================================== @@ -0,0 +1,39 @@ +TVars: 20, OK: no more than 20 transaction attempts. +TVars: 30, OK: no more than 30 transaction attempts. +TVars: 40, OK: no more than 40 transaction attempts. +TVars: 50, OK: no more than 50 transaction attempts. +TVars: 60, OK: no more than 60 transaction attempts. +TVars: 70, OK: no more than 70 transaction attempts. +TVars: 80, OK: no more than 80 transaction attempts. +TVars: 90, OK: no more than 90 transaction attempts. +TVars: 100, OK: no more than 100 transaction attempts. +TVars: 110, OK: no more than 110 transaction attempts. +TVars: 120, OK: no more than 120 transaction attempts. +TVars: 130, OK: no more than 130 transaction attempts. +TVars: 140, OK: no more than 140 transaction attempts. +TVars: 150, OK: no more than 150 transaction attempts. +TVars: 160, OK: no more than 160 transaction attempts. +TVars: 170, OK: no more than 170 transaction attempts. +TVars: 180, OK: no more than 180 transaction attempts. +TVars: 190, OK: no more than 190 transaction attempts. +TVars: 200, OK: no more than 200 transaction attempts. +TVars: 210, OK: no more than 210 transaction attempts. +TVars: 220, OK: no more than 220 transaction attempts. +TVars: 230, OK: no more than 230 transaction attempts. +TVars: 240, OK: no more than 240 transaction attempts. +TVars: 250, OK: no more than 250 transaction attempts. +TVars: 260, OK: no more than 260 transaction attempts. +TVars: 270, OK: no more than 270 transaction attempts. +TVars: 280, OK: no more than 280 transaction attempts. +TVars: 290, OK: no more than 290 transaction attempts. +TVars: 300, OK: no more than 300 transaction attempts. +TVars: 310, OK: no more than 310 transaction attempts. +TVars: 320, OK: no more than 320 transaction attempts. +TVars: 330, OK: no more than 330 transaction attempts. +TVars: 340, OK: no more than 340 transaction attempts. +TVars: 350, OK: no more than 350 transaction attempts. +TVars: 360, OK: no more than 360 transaction attempts. +TVars: 370, OK: no more than 370 transaction attempts. +TVars: 380, OK: no more than 380 transaction attempts. +TVars: 390, OK: no more than 390 transaction attempts. +TVars: 400, OK: no more than 400 transaction attempts. ===================================== testsuite/tests/rts/all.T ===================================== @@ -609,3 +609,5 @@ test('T23400', [], compile_and_run, ['-with-rtsopts -A8k']) test('IOManager', [js_skip, when(arch('wasm32'), skip), when(opsys('mingw32'), skip), pre_cmd('$MAKE -s --no-print-directory IOManager.hs')], compile_and_run, ['']) + +test('T24142', [req_target_smp], compile_and_run, ['-threaded -with-rtsopts "-N2"']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bfbf86cb853341168949af1f1056401bd4d21224...22eeb478fef276a0f6d7cb758f0463e26f9b1ee8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bfbf86cb853341168949af1f1056401bd4d21224...22eeb478fef276a0f6d7cb758f0463e26f9b1ee8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 08:33:11 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Thu, 02 May 2024 04:33:11 -0400 Subject: [Git][ghc/ghc][wip/fendor/ghc-iface-sharing-avoid-reserialisation] 4 commits: Improve sharing of duplicated values in `ModIface` Message-ID: <66334fc7adc69_2228771d43cc51b7@gitlab.mail> Hannes Siebenhandl pushed to branch wip/fendor/ghc-iface-sharing-avoid-reserialisation at Glasgow Haskell Compiler / GHC Commits: 4c11762e by Fendor at 2024-05-02T10:10:40+02:00 Improve sharing of duplicated values in `ModIface` As a `ModIface` contains often duplicated values that are not necessarily shared, we improve sharing by serialising the `ModIface` to an in-memory byte array. Serialisation uses deduplication tables, and deserialisation implicitly shares duplicated values. This helps reducing the peak memory usage while compiling in `--make` mode. The peak memory usage is especially reduced when generating interface files with core expressions (`-fwrite-if-simplified-core`). On agda, this reduces the peak memory usage: * `2.2 GB` to `1.9 GB` for a ghci session. On `lib:Cabal`, we report: * `570 MB` to `500 MB` for a ghci session * `790 MB` to `667 MB` for compiling `lib:Cabal` with ghc The execution time is not affected. - - - - - d2c3fce4 by Fendor at 2024-05-02T10:21:39+02:00 FullBinData Commit - - - - - c3647267 by Fendor at 2024-05-02T10:21:43+02:00 Avoid unneccessarily re-serialising the `ModIface` To reduce memory usage of `ModIface`, we serialise `ModIface` to an in-memory byte array, which implicitly shares duplicated values. This serailised byte array can be reused to avoid work when we actually write the `ModIface` to disk. We introduce a new field to `ModIface` which allows us to save the byte array, and write it to disk if the `ModIface` wasn't changed after the initial serialisation. This requires us to change absolute offsets, for example to jump to the deduplication table for `Name` or `FastString` with relative offsets, as the deduplication byte array doesn't contain header information, such as fingerprints. To allow us to dump the binary blob to disk, we need to replace all absolute offsets with relative ones. This leads to new primitives for `ModIface`, which help to construct relative offsets. - - - - - e730c3c6 by Fendor at 2024-05-02T10:21:43+02:00 Make sure to always invalidate correctly - - - - - 14 changed files: - compiler/GHC.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Ext/Fields.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Unit/Module/ModIface.hs - compiler/GHC/Utils/Binary.hs Changes: ===================================== compiler/GHC.hs ===================================== @@ -98,7 +98,32 @@ module GHC ( lookupGlobalName, findGlobalAnns, mkNamePprCtxForModule, - ModIface, ModIface_(..), + ModIface, + mi_module, + mi_sig_of, + mi_hsc_src, + mi_src_hash, + mi_hi_bytes, + mi_deps, + mi_usages, + mi_exports, + mi_used_th, + mi_fixities, + mi_warns, + mi_anns, + mi_insts, + mi_fam_insts, + mi_rules, + mi_decls, + mi_extra_decls, + mi_globals, + mi_hpc, + mi_trust, + mi_trust_pkg, + mi_complete_matches, + mi_docs, + mi_final_exts, + mi_ext_fields, SafeHaskellMode(..), -- * Printing ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -966,10 +966,11 @@ loadByteCode iface mod_sum = do -------------------------------------------------------------- + -- Knot tying! See Note [Knot-tying typecheckIface] -- See Note [ModDetails and --make mode] initModDetails :: HscEnv -> ModIface -> IO ModDetails -initModDetails hsc_env iface = +initModDetails hsc_env iface = do fixIO $ \details' -> do let act hpt = addToHpt hpt (moduleName $ mi_module iface) (HomeModInfo iface details' emptyHomeModInfoLinkable) ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -18,6 +18,8 @@ module GHC.Iface.Binary ( getSymtabName, CheckHiWay(..), TraceBinIFace(..), + getIfaceWithExtFields, + putIfaceWithExtFields, getWithUserData, putWithUserData, @@ -61,6 +63,8 @@ import Data.Map.Strict (Map) import Data.Word import System.IO.Unsafe import Data.Typeable (Typeable) +import qualified GHC.Data.Strict as Strict +import Data.Function ((&)) -- --------------------------------------------------------------------------- @@ -156,17 +160,27 @@ readBinIface readBinIface profile name_cache checkHiWay traceBinIface hi_path = do (src_hash, bh) <- readBinIfaceHeader profile name_cache checkHiWay traceBinIface hi_path - extFields_p <- get bh + mod_iface <- getIfaceWithExtFields name_cache bh - mod_iface <- getWithUserData name_cache bh + return $ mod_iface + & addSourceFingerprint src_hash - seekBinReader bh extFields_p - extFields <- get bh - return mod_iface - { mi_ext_fields = extFields - , mi_src_hash = src_hash - } +getIfaceWithExtFields :: NameCache -> ReadBinHandle -> IO ModIface +getIfaceWithExtFields name_cache bh = do + start <- tellBinReader bh + extFields_p_rel <- getRelBin bh + + mod_iface <- getWithUserData name_cache bh + + seekBinReader bh start + seekBinReaderRel bh extFields_p_rel + extFields <- get bh + modIfaceData <- freezeBinHandle2 bh start + pure $ mod_iface + & set_mi_ext_fields extFields + & set_mi_hi_bytes (FullIfaceBinHandle $ Strict.Just modIfaceData) + -- | This performs a get action after reading the dictionary and symbol -- table. It is necessary to run this before trying to deserialise any @@ -195,7 +209,7 @@ getTables name_cache bh = do -- add it to the 'ReaderUserData' of 'ReadBinHandle'. decodeReaderTable :: Typeable a => ReaderTable a -> ReadBinHandle -> IO ReadBinHandle decodeReaderTable tbl bh0 = do - table <- Binary.forwardGet bh (getTable tbl bh0) + table <- Binary.forwardGetRel bh (getTable tbl bh0) let binaryReader = mkReaderFromTable tbl table pure $ addReaderToUserData binaryReader bh0 @@ -227,19 +241,21 @@ writeBinIface profile traceBinIface compressionLevel hi_path mod_iface = do put_ bh tag put_ bh (mi_src_hash mod_iface) - extFields_p_p <- tellBinWriter bh - put_ bh extFields_p_p - - putWithUserData traceBinIface compressionLevel bh mod_iface - - extFields_p <- tellBinWriter bh - putAt bh extFields_p_p extFields_p - seekBinWriter bh extFields_p - put_ bh (mi_ext_fields mod_iface) + putIfaceWithExtFields traceBinIface compressionLevel bh mod_iface -- And send the result to the file writeBinMem bh hi_path +-- | Puts the 'ModIface' +putIfaceWithExtFields :: TraceBinIFace -> CompressionIFace -> WriteBinHandle -> ModIface -> IO () +putIfaceWithExtFields traceBinIface compressionLevel bh mod_iface = + case mi_hi_bytes mod_iface of + -- FullIfaceBinHandle _ -> putWithUserData traceBinIface compressionLevel bh mod_iface + FullIfaceBinHandle Strict.Nothing -> do + forwardPutRel_ bh (\_ -> put_ bh (mi_ext_fields mod_iface)) $ do + putWithUserData traceBinIface compressionLevel bh mod_iface + FullIfaceBinHandle (Strict.Just binData) -> putFullBinData bh binData + -- | Put a piece of data with an initialised `UserData` field. This -- is necessary if you want to serialise Names or FastStrings. -- It also writes a symbol table and the dictionary. @@ -309,7 +325,7 @@ putAllTables _ [] act = do a <- act pure ([], a) putAllTables bh (x : xs) act = do - (r, (res, a)) <- forwardPut bh (const $ putTable x bh) $ do + (r, (res, a)) <- forwardPutRel bh (const $ putTable x bh) $ do putAllTables bh xs act pure (r : res, a) @@ -461,7 +477,7 @@ to the table we need to deserialise first. What deduplication tables exist and the order of serialisation is currently statically specified in 'putWithTables'. 'putWithTables' also takes care of the serialisation of used deduplication tables. The deserialisation of the deduplication tables happens 'getTables', using 'Binary' utility -functions such as 'forwardGet'. +functions such as 'forwardGetRel'. Here, a visualisation of the table structure we currently have (ignoring 'ExtensibleFields'): @@ -522,7 +538,6 @@ initWriteIfaceType compressionLevel = do putGenericSymTab sym_tab bh ty _ -> putIfaceType bh ty - fullIfaceTypeSerialiser sym_tab bh ty = do put_ bh ifaceTypeSharedByte putGenericSymTab sym_tab bh ty ===================================== compiler/GHC/Iface/Ext/Binary.hs ===================================== @@ -235,7 +235,7 @@ readHieFileContents bh0 name_cache = do get bh1 where get_dictionary tbl bin_handle = do - fsTable <- Binary.forwardGet bin_handle (getTable tbl bin_handle) + fsTable <- Binary.forwardGetRel bin_handle (getTable tbl bin_handle) let fsReader = mkReaderFromTable tbl fsTable bhFs = addReaderToUserData fsReader bin_handle ===================================== compiler/GHC/Iface/Ext/Fields.hs ===================================== @@ -41,7 +41,7 @@ instance Binary ExtensibleFields where -- to point to the start of each payload: forM_ header_entries $ \(field_p_p, dat) -> do field_p <- tellBinWriter bh - putAt bh field_p_p field_p + putAtRel bh field_p_p field_p seekBinWriter bh field_p put_ bh dat @@ -50,11 +50,11 @@ instance Binary ExtensibleFields where -- Get the names and field pointers: header_entries <- replicateM n $ - (,) <$> get bh <*> get bh + (,) <$> get bh <*> getRelBin bh -- Seek to and get each field's payload: fields <- forM header_entries $ \(name, field_p) -> do - seekBinReader bh field_p + seekBinReaderRel bh field_p dat <- get bh return (name, dat) ===================================== compiler/GHC/Iface/Load.hs ===================================== @@ -117,6 +117,7 @@ import System.FilePath import System.Directory import GHC.Driver.Env.KnotVars import GHC.Iface.Errors.Types +import Data.Function ((&)) {- ************************************************************************ @@ -515,14 +516,12 @@ loadInterface doc_str mod from ; new_eps_anns <- tcIfaceAnnotations (mi_anns iface) ; new_eps_complete_matches <- tcIfaceCompleteMatches (mi_complete_matches iface) - ; let { final_iface = iface { - mi_decls = panic "No mi_decls in PIT", - mi_insts = panic "No mi_insts in PIT", - mi_fam_insts = panic "No mi_fam_insts in PIT", - mi_rules = panic "No mi_rules in PIT", - mi_anns = panic "No mi_anns in PIT" - } - } + ; let final_iface = iface + & set_mi_decls (panic "No mi_decls in PIT") + & set_mi_insts (panic "No mi_insts in PIT") + & set_mi_fam_insts (panic "No mi_fam_insts in PIT") + & set_mi_rules (panic "No mi_rules in PIT") + & set_mi_anns (panic "No mi_anns in PIT") ; let bad_boot = mi_boot iface == IsBoot && isJust (lookupKnotVars (if_rec_types gbl_env) mod) @@ -1017,13 +1016,13 @@ readIface dflags name_cache wanted_mod file_path = do -- See Note [GHC.Prim] in primops.txt.pp. ghcPrimIface :: ModIface ghcPrimIface - = empty_iface { - mi_exports = ghcPrimExports, - mi_decls = [], - mi_fixities = fixities, - mi_final_exts = (mi_final_exts empty_iface){ mi_fix_fn = mkIfaceFixCache fixities }, - mi_docs = Just ghcPrimDeclDocs -- See Note [GHC.Prim Docs] - } + = empty_iface + & set_mi_exports ghcPrimExports + & set_mi_decls [] + & set_mi_fixities fixities + & set_mi_final_exts ((mi_final_exts empty_iface){ mi_fix_fn = mkIfaceFixCache fixities }) + & set_mi_docs (Just ghcPrimDeclDocs) -- See Note [GHC.Prim Docs] + where empty_iface = emptyFullModIface gHC_PRIM @@ -1107,7 +1106,7 @@ pprModIfaceSimple unit_state iface = -- -- The UnitState is used to pretty-print units pprModIface :: UnitState -> ModIface -> SDoc -pprModIface unit_state iface at ModIface{ mi_final_exts = exts } +pprModIface unit_state iface = vcat [ text "interface" <+> ppr (mi_module iface) <+> pp_hsc_src (mi_hsc_src iface) <+> (if mi_orphan exts then text "[orphan module]" else Outputable.empty) @@ -1148,6 +1147,7 @@ pprModIface unit_state iface at ModIface{ mi_final_exts = exts } , text "extensible fields:" $$ nest 2 (pprExtensibleFields (mi_ext_fields iface)) ] where + exts = mi_final_exts iface pp_hsc_src HsBootFile = text "[boot]" pp_hsc_src HsigFile = text "[hsig]" pp_hsc_src HsSrcFile = Outputable.empty ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -69,10 +69,13 @@ import GHC.Types.HpcInfo import GHC.Types.CompleteMatch import GHC.Types.SourceText import GHC.Types.SrcLoc ( unLoc ) +import GHC.Types.Name.Cache import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Logger +import GHC.Utils.Binary +import GHC.Iface.Binary import GHC.Data.FastString import GHC.Data.Maybe @@ -141,14 +144,43 @@ mkFullIface hsc_env partial_iface mb_stg_infos mb_cmm_infos = do full_iface <- {-# SCC "addFingerprints" #-} - addFingerprints hsc_env partial_iface{ mi_decls = decls } + addFingerprints hsc_env (set_mi_decls decls partial_iface) -- Debug printing let unit_state = hsc_units hsc_env putDumpFileMaybe (hsc_logger hsc_env) Opt_D_dump_hi "FINAL INTERFACE" FormatText (pprModIface unit_state full_iface) + final_iface <- shareIface (hsc_NC hsc_env) (flagsToIfCompression $ hsc_dflags hsc_env) full_iface + return final_iface + +-- | Compress an 'ModIface' and share as many values as possible, depending on the 'CompressionIFace' level. +-- +-- We compress the 'ModIface' by serialising the 'ModIface' to an in-memory byte array, and then deserialising it. +-- The deserialisation will deduplicate certain values depending on the 'CompressionIFace' level. +-- See Note [Deduplication during iface binary serialisation] for how we do that. +-- +-- Additionally, we cache the serialised byte array, so if the 'ModIface' is not modified +-- after calling 'shareIface', 'writeBinIface' will reuse that buffer without serialising the 'ModIface' again. +-- Modifying the 'ModIface' forces us to re-serialise it again. +shareIface :: NameCache -> CompressionIFace -> ModIface -> IO ModIface +shareIface _ NormalCompression mi = do + -- In 'NormalCompression', the sharing isn't reducing the memory usage, as 'Name's and 'FastString's are + -- already shared, and at this compression level, we don't compress/share anything else. + -- Thus, for a brief moment we simply double the memory residency for no reason. + -- Therefore, we only try to share expensive values if the compression mode is higher than + -- 'NormalCompression' + pure mi +shareIface nc compressionLevel mi = do + bh <- openBinMem (1024 * 1024) + start <- tellBinWriter bh + putIfaceWithExtFields QuietBinIFace compressionLevel bh mi + rbh <- shrinkBinBuffer bh + seekBinReader rbh start + res <- getIfaceWithExtFields nc rbh + let resiface = restoreFromOldModIface mi res + forceModIface resiface + return resiface - return full_iface updateDecl :: [IfaceDecl] -> Maybe StgCgInfos -> Maybe CmmCgInfos -> [IfaceDecl] updateDecl decls Nothing Nothing = decls @@ -302,40 +334,40 @@ mkIface_ hsc_env icomplete_matches = map mkIfaceCompleteMatch complete_matches !rdrs = maybeGlobalRdrEnv rdr_env - ModIface { - mi_module = this_mod, + emptyPartialModIface this_mod -- Need to record this because it depends on the -instantiated-with flag -- which could change - mi_sig_of = if semantic_mod == this_mod + & set_mi_sig_of ( if semantic_mod == this_mod then Nothing - else Just semantic_mod, - mi_hsc_src = hsc_src, - mi_deps = deps, - mi_usages = usages, - mi_exports = mkIfaceExports exports, + else Just semantic_mod) + & set_mi_hsc_src ( hsc_src) + & set_mi_deps ( deps) + & set_mi_usages ( usages) + & set_mi_exports ( mkIfaceExports exports) -- Sort these lexicographically, so that -- the result is stable across compilations - mi_insts = sortBy cmp_inst iface_insts, - mi_fam_insts = sortBy cmp_fam_inst iface_fam_insts, - mi_rules = sortBy cmp_rule iface_rules, - - mi_fixities = fixities, - mi_warns = warns, - mi_anns = annotations, - mi_globals = rdrs, - mi_used_th = used_th, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_hpc = isHpcUsed hpc_info, - mi_trust = trust_info, - mi_trust_pkg = pkg_trust_req, - mi_complete_matches = icomplete_matches, - mi_docs = docs, - mi_final_exts = (), - mi_ext_fields = emptyExtensibleFields, - mi_src_hash = ms_hs_hash mod_summary - } + & set_mi_insts ( sortBy cmp_inst iface_insts) + & set_mi_fam_insts ( sortBy cmp_fam_inst iface_fam_insts) + & set_mi_rules ( sortBy cmp_rule iface_rules) + + & set_mi_fixities ( fixities) + & set_mi_warns ( warns) + & set_mi_anns ( annotations) + & set_mi_globals ( rdrs) + & set_mi_used_th ( used_th) + & set_mi_decls ( decls) + & set_mi_extra_decls ( extra_decls) + & set_mi_hpc ( isHpcUsed hpc_info) + & set_mi_trust ( trust_info) + & set_mi_trust_pkg ( pkg_trust_req) + & set_mi_complete_matches ( icomplete_matches) + & set_mi_docs ( docs) + & set_mi_final_exts ( ()) + & set_mi_ext_fields ( emptyExtensibleFields) + & set_mi_src_hash ( ms_hs_hash mod_summary) + & set_mi_hi_bytes ( PartialIfaceBinHandle) + where cmp_rule = lexicalCompareFS `on` ifRuleName -- Compare these lexicographically by OccName, *not* by unique, ===================================== compiler/GHC/Iface/Recomp.hs ===================================== @@ -83,6 +83,7 @@ import Data.Ord import Data.Containers.ListUtils import Data.Bifunctor import GHC.Iface.Errors.Ppr +import qualified GHC.Data.Strict as Strict {- ----------------------------------------------- @@ -1283,7 +1284,9 @@ addFingerprints hsc_env iface0 , mi_fix_fn = fix_fn , mi_hash_fn = lookupOccEnv local_env } - final_iface = iface0 { mi_decls = sorted_decls, mi_extra_decls = sorted_extra_decls, mi_final_exts = final_iface_exts } + final_iface = completePartialModIface iface0 + (sorted_decls) (sorted_extra_decls) (final_iface_exts) + (FullIfaceBinHandle Strict.Nothing) -- return final_iface ===================================== compiler/GHC/Iface/Rename.hs ===================================== @@ -44,6 +44,7 @@ import GHC.Utils.Panic import qualified Data.Traversable as T import Data.IORef +import Data.Function ((&)) tcRnMsgMaybe :: IO (Either (Messages TcRnMessage) a) -> TcM a tcRnMsgMaybe do_this = do @@ -108,13 +109,14 @@ rnModIface hsc_env insts nsubst iface = deps <- rnDependencies (mi_deps iface) -- TODO: -- mi_rules - return iface { mi_module = mod - , mi_sig_of = sig_of - , mi_insts = insts - , mi_fam_insts = fams - , mi_exports = exports - , mi_decls = decls - , mi_deps = deps } + return $ iface + & set_mi_module mod + & set_mi_sig_of sig_of + & set_mi_insts insts + & set_mi_fam_insts fams + & set_mi_exports exports + & set_mi_decls decls + & set_mi_deps deps -- | Rename just the exports of a 'ModIface'. Useful when we're doing -- shaping prior to signature merging. ===================================== compiler/GHC/Tc/Errors/Hole.hs ===================================== @@ -76,7 +76,7 @@ import GHC.Tc.Utils.Unify ( tcSubTypeSigma ) import GHC.HsToCore.Docs ( extractDocs ) import GHC.Hs.Doc -import GHC.Unit.Module.ModIface ( ModIface_(..) ) +import GHC.Unit.Module.ModIface ( mi_docs ) import GHC.Iface.Load ( loadInterfaceForName ) import GHC.Builtin.Utils (knownKeyNames) ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -1562,7 +1562,8 @@ lookupDeclDoc nm = do -- Wasn't in the current module. Try searching other external ones! mIface <- getExternalModIface nm case mIface of - Just ModIface { mi_docs = Just Docs{docs_decls = dmap} } -> + Just iface + | Just Docs{docs_decls = dmap} <- mi_docs iface -> pure $ renderHsDocStrings . map hsDocString <$> lookupUniqMap dmap nm _ -> pure Nothing @@ -1578,7 +1579,8 @@ lookupArgDoc i nm = do Nothing -> do mIface <- getExternalModIface nm case mIface of - Just ModIface { mi_docs = Just Docs{docs_args = amap} } -> + Just iface + | Just Docs{docs_args = amap} <- mi_docs iface-> pure $ renderHsDocString . hsDocString <$> (lookupUniqMap amap nm >>= IntMap.lookup i) _ -> pure Nothing ===================================== compiler/GHC/Tc/Utils/Backpack.hs ===================================== @@ -87,6 +87,7 @@ import Control.Monad import Data.List (find) import GHC.Iface.Errors.Types +import Data.Function ((&)) checkHsigDeclM :: ModIface -> TyThing -> TyThing -> TcRn () checkHsigDeclM sig_iface sig_thing real_thing = do @@ -369,8 +370,8 @@ tcRnMergeSignatures hsc_env hpm orig_tcg_env iface = thinModIface :: [AvailInfo] -> ModIface -> ModIface thinModIface avails iface = - iface { - mi_exports = avails, + iface + & set_mi_exports avails -- mi_fixities = ..., -- mi_warns = ..., -- mi_anns = ..., @@ -378,10 +379,9 @@ thinModIface avails iface = -- perhaps there might be two IfaceTopBndr that are the same -- OccName but different Name. Requires better understanding -- of invariants here. - mi_decls = exported_decls ++ non_exported_decls ++ dfun_decls + & set_mi_decls (exported_decls ++ non_exported_decls ++ dfun_decls) -- mi_insts = ..., -- mi_fam_insts = ..., - } where decl_pred occs decl = nameOccName (ifName decl) `elemOccSet` occs filter_decls occs = filter (decl_pred occs . snd) (mi_decls iface) ===================================== compiler/GHC/Unit/Module/ModIface.hs ===================================== @@ -7,7 +7,61 @@ module GHC.Unit.Module.ModIface ( ModIface - , ModIface_ (..) + , ModIface_ + , restoreFromOldModIface + , addSourceFingerprint + , mi_module + , mi_sig_of + , mi_hsc_src + , mi_src_hash + , mi_hi_bytes + , mi_deps + , mi_usages + , mi_exports + , mi_used_th + , mi_fixities + , mi_warns + , mi_anns + , mi_insts + , mi_fam_insts + , mi_rules + , mi_decls + , mi_extra_decls + , mi_globals + , mi_hpc + , mi_trust + , mi_trust_pkg + , mi_complete_matches + , mi_docs + , mi_final_exts + , mi_ext_fields + , set_mi_module + , set_mi_sig_of + , set_mi_hsc_src + , set_mi_src_hash + , set_mi_hi_bytes + , set_mi_deps + , set_mi_usages + , set_mi_exports + , set_mi_used_th + , set_mi_fixities + , set_mi_warns + , set_mi_anns + , set_mi_insts + , set_mi_fam_insts + , set_mi_rules + , set_mi_decls + , set_mi_extra_decls + , set_mi_globals + , set_mi_hpc + , set_mi_trust + , set_mi_trust_pkg + , set_mi_complete_matches + , set_mi_docs + , set_mi_final_exts + , set_mi_ext_fields + , completePartialModIface + , IfaceBinHandle(..) , PartialModIface , ModIfaceBackend (..) , IfaceDeclExts @@ -58,6 +112,7 @@ import GHC.Utils.Binary import Control.DeepSeq import Control.Exception +import qualified GHC.Data.Strict as Strict {- Note [Interface file stages] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -139,7 +194,9 @@ type family IfaceBackendExts (phase :: ModIfacePhase) = bk | bk -> phase where IfaceBackendExts 'ModIfaceCore = () IfaceBackendExts 'ModIfaceFinal = ModIfaceBackend - +data IfaceBinHandle (phase :: ModIfacePhase) where + PartialIfaceBinHandle :: IfaceBinHandle 'ModIfaceCore + FullIfaceBinHandle :: Strict.Maybe FullBinData -> IfaceBinHandle 'ModIfaceFinal -- | A 'ModIface' plus a 'ModDetails' summarises everything we know -- about a compiled module. The 'ModIface' is the stuff *before* linking, @@ -155,60 +212,60 @@ type family IfaceBackendExts (phase :: ModIfacePhase) = bk | bk -> phase where -- strict and others are not. data ModIface_ (phase :: ModIfacePhase) = ModIface { - mi_module :: !Module, -- ^ Name of the module we are for - mi_sig_of :: !(Maybe Module), -- ^ Are we a sig of another mod? + mi_module_ :: !Module, -- ^ Name of the module we are for + mi_sig_of_ :: !(Maybe Module), -- ^ Are we a sig of another mod? - mi_hsc_src :: !HscSource, -- ^ Boot? Signature? + mi_hsc_src_ :: !HscSource, -- ^ Boot? Signature? - mi_deps :: Dependencies, + mi_deps_ :: Dependencies, -- ^ The dependencies of the module. This is -- consulted for directly-imported modules, but not -- for anything else (hence lazy) - mi_usages :: [Usage], + mi_usages_ :: [Usage], -- ^ Usages; kept sorted so that it's easy to decide -- whether to write a new iface file (changing usages -- doesn't affect the hash of this module) -- NOT STRICT! we read this field lazily from the interface file -- It is *only* consulted by the recompilation checker - mi_exports :: ![IfaceExport], + mi_exports_ :: ![IfaceExport], -- ^ Exports -- Kept sorted by (mod,occ), to make version comparisons easier -- Records the modules that are the declaration points for things -- exported by this module, and the 'OccName's of those things - mi_used_th :: !Bool, + mi_used_th_ :: !Bool, -- ^ Module required TH splices when it was compiled. -- This disables recompilation avoidance (see #481). - mi_fixities :: [(OccName,Fixity)], + mi_fixities_ :: [(OccName,Fixity)], -- ^ Fixities -- NOT STRICT! we read this field lazily from the interface file - mi_warns :: IfaceWarnings, + mi_warns_ :: IfaceWarnings, -- ^ Warnings -- NOT STRICT! we read this field lazily from the interface file - mi_anns :: [IfaceAnnotation], + mi_anns_ :: [IfaceAnnotation], -- ^ Annotations -- NOT STRICT! we read this field lazily from the interface file - mi_decls :: [IfaceDeclExts phase], + mi_decls_ :: [IfaceDeclExts phase], -- ^ Type, class and variable declarations -- The hash of an Id changes if its fixity or deprecations change -- (as well as its type of course) -- Ditto data constructors, class operations, except that -- the hash of the parent class/tycon changes - mi_extra_decls :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo], + mi_extra_decls_ :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo], -- ^ Extra variable definitions which are **NOT** exposed but when -- combined with mi_decls allows us to restart code generation. -- See Note [Interface Files with Core Definitions] and Note [Interface File with Core: Sharing RHSs] - mi_globals :: !(Maybe IfGlobalRdrEnv), + mi_globals_ :: !(Maybe IfGlobalRdrEnv), -- ^ Binds all the things defined at the top level in -- the /original source/ code for this module. which -- is NOT the same as mi_exports, nor mi_decls (which @@ -224,36 +281,36 @@ data ModIface_ (phase :: ModIfacePhase) -- 'HomeModInfo', but that leads to more plumbing. -- Instance declarations and rules - mi_insts :: [IfaceClsInst], -- ^ Sorted class instance - mi_fam_insts :: [IfaceFamInst], -- ^ Sorted family instances - mi_rules :: [IfaceRule], -- ^ Sorted rules + mi_insts_ :: [IfaceClsInst], -- ^ Sorted class instance + mi_fam_insts_ :: [IfaceFamInst], -- ^ Sorted family instances + mi_rules_ :: [IfaceRule], -- ^ Sorted rules - mi_hpc :: !AnyHpcUsage, + mi_hpc_ :: !AnyHpcUsage, -- ^ True if this program uses Hpc at any point in the program. - mi_trust :: !IfaceTrustInfo, + mi_trust_ :: !IfaceTrustInfo, -- ^ Safe Haskell Trust information for this module. - mi_trust_pkg :: !Bool, + mi_trust_pkg_ :: !Bool, -- ^ Do we require the package this module resides in be trusted -- to trust this module? This is used for the situation where a -- module is Safe (so doesn't require the package be trusted -- itself) but imports some trustworthy modules from its own -- package (which does require its own package be trusted). -- See Note [Trust Own Package] in GHC.Rename.Names - mi_complete_matches :: ![IfaceCompleteMatch], + mi_complete_matches_ :: ![IfaceCompleteMatch], - mi_docs :: !(Maybe Docs), + mi_docs_ :: !(Maybe Docs), -- ^ Docstrings and related data for use by haddock, the ghci -- @:doc@ command, and other tools. -- -- @Just _@ @<=>@ the module was built with @-haddock at . - mi_final_exts :: !(IfaceBackendExts phase), + mi_final_exts_ :: !(IfaceBackendExts phase), -- ^ Either `()` or `ModIfaceBackend` for -- a fully instantiated interface. - mi_ext_fields :: !ExtensibleFields, + mi_ext_fields_ :: !ExtensibleFields, -- ^ Additional optional fields, where the Map key represents -- the field name, resulting in a (size, serialized data) pair. -- Because the data is intended to be serialized through the @@ -262,8 +319,9 @@ data ModIface_ (phase :: ModIfacePhase) -- chosen over `ByteString`s. -- - mi_src_hash :: !Fingerprint + mi_src_hash_ :: !Fingerprint, -- ^ Hash of the .hs source, used for recompilation checking. + mi_hi_bytes_ :: !(IfaceBinHandle phase) } {- @@ -343,33 +401,34 @@ renameFreeHoles fhs insts = -- See Note [Strictness in ModIface] about where we use lazyPut vs put instance Binary ModIface where put_ bh (ModIface { - mi_module = mod, - mi_sig_of = sig_of, - mi_hsc_src = hsc_src, - mi_src_hash = _src_hash, -- Don't `put_` this in the instance + mi_module_ = mod, + mi_sig_of_ = sig_of, + mi_hsc_src_ = hsc_src, + mi_src_hash_ = _src_hash, -- Don't `put_` this in the instance -- because we are going to write it -- out separately in the actual file - mi_deps = deps, - mi_usages = usages, - mi_exports = exports, - mi_used_th = used_th, - mi_fixities = fixities, - mi_warns = warns, - mi_anns = anns, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_insts = insts, - mi_fam_insts = fam_insts, - mi_rules = rules, - mi_hpc = hpc_info, - mi_trust = trust, - mi_trust_pkg = trust_pkg, - mi_complete_matches = complete_matches, - mi_docs = docs, - mi_ext_fields = _ext_fields, -- Don't `put_` this in the instance so we + mi_hi_bytes_ = _hi_bytes, -- TODO: explain + mi_deps_ = deps, + mi_usages_ = usages, + mi_exports_ = exports, + mi_used_th_ = used_th, + mi_fixities_ = fixities, + mi_warns_ = warns, + mi_anns_ = anns, + mi_decls_ = decls, + mi_extra_decls_ = extra_decls, + mi_insts_ = insts, + mi_fam_insts_ = fam_insts, + mi_rules_ = rules, + mi_hpc_ = hpc_info, + mi_trust_ = trust, + mi_trust_pkg_ = trust_pkg, + mi_complete_matches_ = complete_matches, + mi_docs_ = docs, + mi_ext_fields_ = _ext_fields, -- Don't `put_` this in the instance so we -- can deal with it's pointer in the header -- when we write the actual file - mi_final_exts = ModIfaceBackend { + mi_final_exts_ = ModIfaceBackend { mi_iface_hash = iface_hash, mi_mod_hash = mod_hash, mi_flag_hash = flag_hash, @@ -444,33 +503,34 @@ instance Binary ModIface where complete_matches <- get bh docs <- lazyGetMaybe bh return (ModIface { - mi_module = mod, - mi_sig_of = sig_of, - mi_hsc_src = hsc_src, - mi_src_hash = fingerprint0, -- placeholder because this is dealt + mi_module_ = mod, + mi_sig_of_ = sig_of, + mi_hsc_src_ = hsc_src, + mi_src_hash_ = fingerprint0, -- placeholder because this is dealt -- with specially when the file is read - mi_deps = deps, - mi_usages = usages, - mi_exports = exports, - mi_used_th = used_th, - mi_anns = anns, - mi_fixities = fixities, - mi_warns = warns, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_globals = Nothing, - mi_insts = insts, - mi_fam_insts = fam_insts, - mi_rules = rules, - mi_hpc = hpc_info, - mi_trust = trust, - mi_trust_pkg = trust_pkg, + mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing, + mi_deps_ = deps, + mi_usages_ = usages, + mi_exports_ = exports, + mi_used_th_ = used_th, + mi_anns_ = anns, + mi_fixities_ = fixities, + mi_warns_ = warns, + mi_decls_ = decls, + mi_extra_decls_ = extra_decls, + mi_globals_ = Nothing, + mi_insts_ = insts, + mi_fam_insts_ = fam_insts, + mi_rules_ = rules, + mi_hpc_ = hpc_info, + mi_trust_ = trust, + mi_trust_pkg_ = trust_pkg, -- And build the cached values - mi_complete_matches = complete_matches, - mi_docs = docs, - mi_ext_fields = emptyExtensibleFields, -- placeholder because this is dealt + mi_complete_matches_ = complete_matches, + mi_docs_ = docs, + mi_ext_fields_ = emptyExtensibleFields, -- placeholder because this is dealt -- with specially when the file is read - mi_final_exts = ModIfaceBackend { + mi_final_exts_ = ModIfaceBackend { mi_iface_hash = iface_hash, mi_mod_hash = mod_hash, mi_flag_hash = flag_hash, @@ -487,42 +547,45 @@ instance Binary ModIface where mi_hash_fn = mkIfaceHashCache decls }}) + -- | The original names declared of a certain module that are exported type IfaceExport = AvailInfo emptyPartialModIface :: Module -> PartialModIface emptyPartialModIface mod - = ModIface { mi_module = mod, - mi_sig_of = Nothing, - mi_hsc_src = HsSrcFile, - mi_src_hash = fingerprint0, - mi_deps = noDependencies, - mi_usages = [], - mi_exports = [], - mi_used_th = False, - mi_fixities = [], - mi_warns = IfWarnSome [] [], - mi_anns = [], - mi_insts = [], - mi_fam_insts = [], - mi_rules = [], - mi_decls = [], - mi_extra_decls = Nothing, - mi_globals = Nothing, - mi_hpc = False, - mi_trust = noIfaceTrustInfo, - mi_trust_pkg = False, - mi_complete_matches = [], - mi_docs = Nothing, - mi_final_exts = (), - mi_ext_fields = emptyExtensibleFields + = ModIface { mi_module_ = mod, + mi_sig_of_ = Nothing, + mi_hsc_src_ = HsSrcFile, + mi_src_hash_ = fingerprint0, + mi_hi_bytes_ = PartialIfaceBinHandle, + mi_deps_ = noDependencies, + mi_usages_ = [], + mi_exports_ = [], + mi_used_th_ = False, + mi_fixities_ = [], + mi_warns_ = IfWarnSome [] [], + mi_anns_ = [], + mi_insts_ = [], + mi_fam_insts_ = [], + mi_rules_ = [], + mi_decls_ = [], + mi_extra_decls_ = Nothing, + mi_globals_ = Nothing, + mi_hpc_ = False, + mi_trust_ = noIfaceTrustInfo, + mi_trust_pkg_ = False, + mi_complete_matches_ = [], + mi_docs_ = Nothing, + mi_final_exts_ = (), + mi_ext_fields_ = emptyExtensibleFields } emptyFullModIface :: Module -> ModIface emptyFullModIface mod = (emptyPartialModIface mod) - { mi_decls = [] - , mi_final_exts = ModIfaceBackend + { mi_decls_ = [] + , mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing + , mi_final_exts_ = ModIfaceBackend { mi_iface_hash = fingerprint0, mi_mod_hash = fingerprint0, mi_flag_hash = fingerprint0, @@ -557,36 +620,36 @@ emptyIfaceHashCache _occ = Nothing instance ( NFData (IfaceBackendExts (phase :: ModIfacePhase)) , NFData (IfaceDeclExts (phase :: ModIfacePhase)) ) => NFData (ModIface_ phase) where - rnf (ModIface{ mi_module, mi_sig_of, mi_hsc_src, mi_deps, mi_usages - , mi_exports, mi_used_th, mi_fixities, mi_warns, mi_anns - , mi_decls, mi_extra_decls, mi_globals, mi_insts - , mi_fam_insts, mi_rules, mi_hpc, mi_trust, mi_trust_pkg - , mi_complete_matches, mi_docs, mi_final_exts - , mi_ext_fields, mi_src_hash }) - = rnf mi_module - `seq` rnf mi_sig_of - `seq` mi_hsc_src - `seq` mi_deps - `seq` mi_usages - `seq` mi_exports - `seq` rnf mi_used_th - `seq` mi_fixities - `seq` rnf mi_warns - `seq` rnf mi_anns - `seq` rnf mi_decls - `seq` rnf mi_extra_decls - `seq` rnf mi_globals - `seq` rnf mi_insts - `seq` rnf mi_fam_insts - `seq` rnf mi_rules - `seq` rnf mi_hpc - `seq` mi_trust - `seq` rnf mi_trust_pkg - `seq` rnf mi_complete_matches - `seq` rnf mi_docs - `seq` mi_final_exts - `seq` mi_ext_fields - `seq` rnf mi_src_hash + rnf (ModIface{ mi_module_, mi_sig_of_, mi_hsc_src_, mi_deps_, mi_usages_ + , mi_exports_, mi_used_th_, mi_fixities_, mi_warns_, mi_anns_ + , mi_decls_, mi_extra_decls_, mi_globals_, mi_insts_ + , mi_fam_insts_, mi_rules_, mi_hpc_, mi_trust_, mi_trust_pkg_ + , mi_complete_matches_, mi_docs_, mi_final_exts_ + , mi_ext_fields_, mi_src_hash_ }) + = rnf mi_module_ + `seq` rnf mi_sig_of_ + `seq` mi_hsc_src_ + `seq` mi_deps_ + `seq` mi_usages_ + `seq` mi_exports_ + `seq` rnf mi_used_th_ + `seq` mi_fixities_ + `seq` rnf mi_warns_ + `seq` rnf mi_anns_ + `seq` rnf mi_decls_ + `seq` rnf mi_extra_decls_ + `seq` rnf mi_globals_ + `seq` rnf mi_insts_ + `seq` rnf mi_fam_insts_ + `seq` rnf mi_rules_ + `seq` rnf mi_hpc_ + `seq` mi_trust_ + `seq` rnf mi_trust_pkg_ + `seq` rnf mi_complete_matches_ + `seq` rnf mi_docs_ + `seq` mi_final_exts_ + `seq` mi_ext_fields_ + `seq` rnf mi_src_hash_ `seq` () instance NFData (ModIfaceBackend) where @@ -626,5 +689,157 @@ type WhetherHasOrphans = Bool -- | Does this module define family instances? type WhetherHasFamInst = Bool +completePartialModIface :: PartialModIface + -> [(Fingerprint, IfaceDecl)] + -> Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] + -> ModIfaceBackend + -> IfaceBinHandle 'ModIfaceFinal + -> ModIface +completePartialModIface partial decls extra_decls final_exts hi_bytes = partial + { mi_decls_ = decls + , mi_extra_decls_ = extra_decls + , mi_final_exts_ = final_exts + , mi_hi_bytes_ = hi_bytes + } + +addSourceFingerprint :: Fingerprint -> ModIface_ 'ModIfaceFinal -> ModIface_ 'ModIfaceFinal +addSourceFingerprint val iface = iface { mi_src_hash_ = val } + +restoreFromOldModIface :: ModIface_ phase -> ModIface_ phase -> ModIface_ phase +restoreFromOldModIface old new = new + { mi_globals_ = mi_globals_ old + , mi_hsc_src_ = mi_hsc_src_ old + } + +set_mi_module :: Module -> ModIface_ phase -> ModIface_ phase +set_mi_module val iface = clear_mi_hi_bytes $ iface { mi_module_ = val } + +set_mi_sig_of :: Maybe Module -> ModIface_ phase -> ModIface_ phase +set_mi_sig_of val iface = clear_mi_hi_bytes $ iface { mi_sig_of_ = val } + +set_mi_hsc_src :: HscSource -> ModIface_ phase -> ModIface_ phase +set_mi_hsc_src val iface = clear_mi_hi_bytes $ iface { mi_hsc_src_ = val } + +set_mi_src_hash :: Fingerprint -> ModIface_ phase -> ModIface_ phase +set_mi_src_hash val iface = clear_mi_hi_bytes $ iface { mi_src_hash_ = val } + +set_mi_hi_bytes :: IfaceBinHandle phase -> ModIface_ phase -> ModIface_ phase +set_mi_hi_bytes val iface = iface { mi_hi_bytes_ = val } + +set_mi_deps :: Dependencies -> ModIface_ phase -> ModIface_ phase +set_mi_deps val iface = clear_mi_hi_bytes $ iface { mi_deps_ = val } + +set_mi_usages :: [Usage] -> ModIface_ phase -> ModIface_ phase +set_mi_usages val iface = clear_mi_hi_bytes $ iface { mi_usages_ = val } + +set_mi_exports :: [IfaceExport] -> ModIface_ phase -> ModIface_ phase +set_mi_exports val iface = clear_mi_hi_bytes $ iface { mi_exports_ = val } + +set_mi_used_th :: Bool -> ModIface_ phase -> ModIface_ phase +set_mi_used_th val iface = clear_mi_hi_bytes $ iface { mi_used_th_ = val } + +set_mi_fixities :: [(OccName, Fixity)] -> ModIface_ phase -> ModIface_ phase +set_mi_fixities val iface = clear_mi_hi_bytes $ iface { mi_fixities_ = val } +set_mi_warns :: IfaceWarnings -> ModIface_ phase -> ModIface_ phase +set_mi_warns val iface = clear_mi_hi_bytes $ iface { mi_warns_ = val } + +set_mi_anns :: [IfaceAnnotation] -> ModIface_ phase -> ModIface_ phase +set_mi_anns val iface = clear_mi_hi_bytes $ iface { mi_anns_ = val } + +set_mi_insts :: [IfaceClsInst] -> ModIface_ phase -> ModIface_ phase +set_mi_insts val iface = clear_mi_hi_bytes $ iface { mi_insts_ = val } + +set_mi_fam_insts :: [IfaceFamInst] -> ModIface_ phase -> ModIface_ phase +set_mi_fam_insts val iface = clear_mi_hi_bytes $ iface { mi_fam_insts_ = val } + +set_mi_rules :: [IfaceRule] -> ModIface_ phase -> ModIface_ phase +set_mi_rules val iface = clear_mi_hi_bytes $ iface { mi_rules_ = val } + +set_mi_decls :: [IfaceDeclExts phase] -> ModIface_ phase -> ModIface_ phase +set_mi_decls val iface = clear_mi_hi_bytes $ iface { mi_decls_ = val } + +set_mi_extra_decls :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] -> ModIface_ phase -> ModIface_ phase +set_mi_extra_decls val iface = clear_mi_hi_bytes $ iface { mi_extra_decls_ = val } + +set_mi_globals :: Maybe IfGlobalRdrEnv -> ModIface_ phase -> ModIface_ phase +set_mi_globals val iface = clear_mi_hi_bytes $ iface { mi_globals_ = val } + +set_mi_hpc :: AnyHpcUsage -> ModIface_ phase -> ModIface_ phase +set_mi_hpc val iface = clear_mi_hi_bytes $ iface { mi_hpc_ = val } + +set_mi_trust :: IfaceTrustInfo -> ModIface_ phase -> ModIface_ phase +set_mi_trust val iface = clear_mi_hi_bytes $ iface { mi_trust_ = val } + +set_mi_trust_pkg :: Bool -> ModIface_ phase -> ModIface_ phase +set_mi_trust_pkg val iface = clear_mi_hi_bytes $ iface { mi_trust_pkg_ = val } + +set_mi_complete_matches :: [IfaceCompleteMatch] -> ModIface_ phase -> ModIface_ phase +set_mi_complete_matches val iface = clear_mi_hi_bytes $ iface { mi_complete_matches_ = val } + +set_mi_docs :: Maybe Docs -> ModIface_ phase -> ModIface_ phase +set_mi_docs val iface = clear_mi_hi_bytes $ iface { mi_docs_ = val } + +set_mi_final_exts :: IfaceBackendExts phase -> ModIface_ phase -> ModIface_ phase +set_mi_final_exts val iface = clear_mi_hi_bytes $ iface { mi_final_exts_ = val } + +set_mi_ext_fields :: ExtensibleFields -> ModIface_ phase -> ModIface_ phase +set_mi_ext_fields val iface = clear_mi_hi_bytes $ iface { mi_ext_fields_ = val } + +clear_mi_hi_bytes :: ModIface_ phase -> ModIface_ phase +clear_mi_hi_bytes iface = iface + { mi_hi_bytes_ = case mi_hi_bytes iface of + PartialIfaceBinHandle -> PartialIfaceBinHandle + FullIfaceBinHandle _ -> FullIfaceBinHandle Strict.Nothing + } +mi_module :: ModIface_ phase -> Module +mi_module = mi_module_ +mi_sig_of :: ModIface_ phase -> Maybe Module +mi_sig_of = mi_sig_of_ +mi_hsc_src :: ModIface_ phase -> HscSource +mi_hsc_src = mi_hsc_src_ +mi_deps :: ModIface_ phase -> Dependencies +mi_deps = mi_deps_ +mi_usages :: ModIface_ phase -> [Usage] +mi_usages = mi_usages_ +mi_exports :: ModIface_ phase -> [IfaceExport] +mi_exports = mi_exports_ +mi_used_th :: ModIface_ phase -> Bool +mi_used_th = mi_used_th_ +mi_fixities :: ModIface_ phase -> [(OccName, Fixity)] +mi_fixities = mi_fixities_ +mi_warns :: ModIface_ phase -> IfaceWarnings +mi_warns = mi_warns_ +mi_anns :: ModIface_ phase -> [IfaceAnnotation] +mi_anns = mi_anns_ +mi_decls :: ModIface_ phase -> [IfaceDeclExts phase] +mi_decls = mi_decls_ +mi_extra_decls :: ModIface_ phase -> Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] +mi_extra_decls = mi_extra_decls_ +mi_globals :: ModIface_ phase -> Maybe IfGlobalRdrEnv +mi_globals = mi_globals_ +mi_insts :: ModIface_ phase -> [IfaceClsInst] +mi_insts = mi_insts_ +mi_fam_insts :: ModIface_ phase -> [IfaceFamInst] +mi_fam_insts = mi_fam_insts_ +mi_rules :: ModIface_ phase -> [IfaceRule] +mi_rules = mi_rules_ +mi_hpc :: ModIface_ phase -> AnyHpcUsage +mi_hpc = mi_hpc_ +mi_trust :: ModIface_ phase -> IfaceTrustInfo +mi_trust = mi_trust_ +mi_trust_pkg :: ModIface_ phase -> Bool +mi_trust_pkg = mi_trust_pkg_ +mi_complete_matches :: ModIface_ phase -> [IfaceCompleteMatch] +mi_complete_matches = mi_complete_matches_ +mi_docs :: ModIface_ phase -> Maybe Docs +mi_docs = mi_docs_ +mi_final_exts :: ModIface_ phase -> IfaceBackendExts phase +mi_final_exts = mi_final_exts_ +mi_ext_fields :: ModIface_ phase -> ExtensibleFields +mi_ext_fields = mi_ext_fields_ +mi_src_hash :: ModIface_ phase -> Fingerprint +mi_src_hash = mi_src_hash_ +mi_hi_bytes :: ModIface_ phase -> IfaceBinHandle phase +mi_hi_bytes = mi_hi_bytes_ ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -19,7 +19,7 @@ -- http://www.cs.york.ac.uk/fp/nhc98/ module GHC.Utils.Binary - ( {-type-} Bin, + ( {-type-} Bin, RelBin(..), getRelBin, {-class-} Binary(..), {-type-} ReadBinHandle, WriteBinHandle, SymbolTable, Dictionary, @@ -32,10 +32,14 @@ module GHC.Utils.Binary seekBinWriter, seekBinReader, + seekBinReaderRel, tellBinReader, tellBinWriter, castBin, withBinBuffer, + freezeWriteHandle, + shrinkBinBuffer, + thawReadHandle, foldGet, foldGet', @@ -44,7 +48,9 @@ module GHC.Utils.Binary readBinMemN, putAt, getAt, + putAtRel, forwardPut, forwardPut_, forwardGet, + forwardPutRel, forwardPutRel_, forwardGetRel, -- * For writing instances putByte, @@ -99,6 +105,9 @@ module GHC.Utils.Binary BindingName(..), simpleBindingNameWriter, simpleBindingNameReader, + FullBinData(..), freezeBinHandle, thawBinHandle, putFullBinData, + freezeBinHandle2, + BinArray, ) where import GHC.Prelude @@ -123,7 +132,7 @@ import Foreign hiding (shiftL, shiftR, void) import Data.Array import Data.Array.IO import Data.Array.Unsafe -import Data.ByteString (ByteString) +import Data.ByteString (ByteString, copy) import Data.Coerce import qualified Data.ByteString.Internal as BS import qualified Data.ByteString.Unsafe as BS @@ -153,7 +162,6 @@ import GHC.ForeignPtr ( unsafeWithForeignPtr ) import Unsafe.Coerce (unsafeCoerce) import GHC.Data.TrieMap - type BinArray = ForeignPtr Word8 #if !MIN_VERSION_base(4,15,0) @@ -193,6 +201,51 @@ dataHandle (BinData size bin) = do handleData :: WriteBinHandle -> IO BinData handleData (WriteBinMem _ ixr _ binr) = BinData <$> readFastMutInt ixr <*> readIORef binr +--------------------------------------------------------------- +-- FullBinData +--------------------------------------------------------------- + +data FullBinData = FullBinData + { fbd_readerUserData :: ReaderUserData + , fbd_off_s :: {-# UNPACK #-} !Int + -- ^ start offset + , fbd_off_e :: {-# UNPACK #-} !Int + -- ^ end offset + , fbd_size :: {-# UNPACK #-} !Int + -- ^ total buffer size + , fbd_buffer :: {-# UNPACK #-} !BinArray + } + +-- Equality and Ord assume that two distinct buffers are different, even if they compare the same things. +instance Eq FullBinData where + (FullBinData _ b c d e) == (FullBinData _ b1 c1 d1 e1) = b == b1 && c == c1 && d == d1 && e == e1 + +instance Ord FullBinData where + compare (FullBinData _ b c d e) (FullBinData _ b1 c1 d1 e1) = + compare b b1 `mappend` compare c c1 `mappend` compare d d1 `mappend` compare e e1 + +putFullBinData :: WriteBinHandle -> FullBinData -> IO () +putFullBinData bh (FullBinData _ o1 o2 _sz ba) = do + let sz = o2 - o1 + putPrim bh sz $ \dest -> + unsafeWithForeignPtr (ba `plusForeignPtr` o1) $ \orig -> + copyBytes dest orig sz + +freezeBinHandle :: Bin () -> ReadBinHandle -> IO FullBinData +freezeBinHandle (BinPtr len) (ReadBinMem user_data ixr sz binr) = do + ix <- readFastMutInt ixr + pure (FullBinData user_data ix len sz binr) + +freezeBinHandle2 :: ReadBinHandle -> Bin () -> IO FullBinData +freezeBinHandle2 (ReadBinMem user_data ixr sz binr) (BinPtr start) = do + ix <- readFastMutInt ixr + pure (FullBinData user_data start ix sz binr) + +thawBinHandle :: FullBinData -> IO ReadBinHandle +thawBinHandle (FullBinData user_data ix _end sz ba) = do + ixr <- newFastMutInt ix + return $ ReadBinMem user_data ixr sz ba + --------------------------------------------------------------- -- BinHandle --------------------------------------------------------------- @@ -286,9 +339,30 @@ unsafeUnpackBinBuffer (BS.BS arr len) = do newtype Bin a = BinPtr Int deriving (Eq, Ord, Show, Bounded) +data RelBin a = RelBin !(Bin a) !(Bin a) + deriving (Eq, Ord, Show, Bounded) + +newtype RelBinPtr a = RelBinPtr (Bin a) + castBin :: Bin a -> Bin b castBin (BinPtr i) = BinPtr i +getRelBin :: ReadBinHandle -> IO (RelBin a) +getRelBin bh = do + start <- tellBinReader bh + off <- get bh + pure $ RelBin start off + +makeAbsoluteBin :: RelBin a -> Bin a +makeAbsoluteBin (RelBin (BinPtr !start) (BinPtr !offset)) = BinPtr (start + offset) + +makeRelativeBin :: RelBin a -> RelBinPtr a +makeRelativeBin (RelBin _ offset) = RelBinPtr offset + +toRelBin :: Bin (RelBinPtr a) -> Bin a -> RelBin a +toRelBin (BinPtr !start) (BinPtr !goal) = + RelBin (BinPtr start) (BinPtr $! goal - start) + --------------------------------------------------------------- -- class Binary --------------------------------------------------------------- @@ -309,6 +383,9 @@ class Binary a where putAt :: Binary a => WriteBinHandle -> Bin a -> a -> IO () putAt bh p x = do seekBinWriter bh p; put_ bh x; return () +putAtRel :: WriteBinHandle -> Bin (RelBinPtr a) -> Bin a -> IO () +putAtRel bh from to = putAt bh from (makeRelativeBin $ toRelBin from to) + getAt :: Binary a => ReadBinHandle -> Bin a -> IO a getAt bh p = do seekBinReader bh p; get bh @@ -327,6 +404,44 @@ openBinMem size , wbm_arr_r = arr_r } +-- | Freeze the given 'WriteBinHandle' and turn it into an equivalent 'ReadBinHandle'. +-- +-- The current offset of the 'WriteBinHandle' is maintained in the new 'ReadBinHandle'. +freezeWriteHandle :: WriteBinHandle -> IO ReadBinHandle +freezeWriteHandle wbm = do + rbm_off_r <- newFastMutInt =<< readFastMutInt (wbm_off_r wbm) + rbm_sz_r <- readFastMutInt (wbm_sz_r wbm) + rbm_arr_r <- readIORef (wbm_arr_r wbm) + pure $ ReadBinMem + { rbm_userData = noReaderUserData + , rbm_off_r = rbm_off_r + , rbm_sz_r = rbm_sz_r + , rbm_arr_r = rbm_arr_r + } + +-- Copy the BinBuffer to a new BinBuffer which is exactly the right size. +-- This performs a copy of the underlying buffer. +-- The buffer may be truncated if the offset is not at the end of the written +-- output. +-- +-- UserData is also discarded during the copy +-- You should just use this when translating a Put handle into a Get handle. +shrinkBinBuffer :: WriteBinHandle -> IO ReadBinHandle +shrinkBinBuffer bh = withBinBuffer bh $ \bs -> do + unsafeUnpackBinBuffer (copy bs) + +thawReadHandle :: ReadBinHandle -> IO WriteBinHandle +thawReadHandle rbm = do + wbm_off_r <- newFastMutInt =<< readFastMutInt (rbm_off_r rbm) + wbm_sz_r <- newFastMutInt (rbm_sz_r rbm) + wbm_arr_r <- newIORef (rbm_arr_r rbm) + pure $ WriteBinMem + { wbm_userData = noWriterUserData + , wbm_off_r = wbm_off_r + , wbm_sz_r = wbm_sz_r + , wbm_arr_r = wbm_arr_r + } + tellBinWriter :: WriteBinHandle -> IO (Bin a) tellBinWriter (WriteBinMem _ r _ _) = do ix <- readFastMutInt r; return (BinPtr ix) @@ -352,12 +467,18 @@ seekBinNoExpandWriter (WriteBinMem _ ix_r sz_r _) (BinPtr !p) = do else writeFastMutInt ix_r p -- | SeekBin but without calling expandBin -seekBinReader :: ReadBinHandle -> Bin a -> IO () +seekBinReader :: HasCallStack => ReadBinHandle -> Bin a -> IO () seekBinReader (ReadBinMem _ ix_r sz_r _) (BinPtr !p) = do if (p > sz_r) then panic "seekBinReader: seek out of range" else writeFastMutInt ix_r p +seekBinReaderRel :: HasCallStack => ReadBinHandle -> RelBin a -> IO () +seekBinReaderRel (ReadBinMem _ ix_r sz_r _) (RelBin (BinPtr !start) (BinPtr !offset)) = do + if (start + offset > sz_r) + then panic "seekBinReaderRel: seek out of range" + else writeFastMutInt ix_r (start + offset) + writeBinMem :: WriteBinHandle -> FilePath -> IO () writeBinMem (WriteBinMem _ ix_r _ arr_r) fn = do h <- openBinaryFile fn WriteMode @@ -1078,6 +1199,11 @@ instance Binary (Bin a) where put_ bh (BinPtr i) = putWord32 bh (fromIntegral i :: Word32) get bh = do i <- getWord32 bh; return (BinPtr (fromIntegral (i :: Word32))) +-- Instance uses fixed-width encoding to allow inserting +-- Bin placeholders in the stream. +instance Binary (RelBinPtr a) where + put_ bh (RelBinPtr i) = put_ bh i + get bh = RelBinPtr <$> get bh -- ----------------------------------------------------------------------------- -- Forward reading/writing @@ -1106,7 +1232,7 @@ forwardPut_ :: WriteBinHandle -> (b -> IO a) -> IO b -> IO () forwardPut_ bh put_A put_B = void $ forwardPut bh put_A put_B -- | Read a value stored using a forward reference -forwardGet :: ReadBinHandle -> IO a -> IO a +forwardGet :: HasCallStack => ReadBinHandle -> IO a -> IO a forwardGet bh get_A = do -- read forward reference p <- get bh -- a BinPtr @@ -1118,6 +1244,43 @@ forwardGet bh get_A = do seekBinReader bh p_a pure r + +-- | "forwardPutRel put_A put_B" outputs A after B but allows A to be read before B +-- by using a forward reference. +forwardPutRel :: WriteBinHandle -> (b -> IO a) -> IO b -> IO (a,b) +forwardPutRel bh put_A put_B = do + -- write placeholder pointer to A + pre_a <- tellBinWriter bh + put_ bh pre_a + + -- write B + r_b <- put_B + + -- update A's pointer + a <- tellBinWriter bh + putAtRel bh pre_a a + seekBinNoExpandWriter bh a + + -- write A + r_a <- put_A r_b + pure (r_a,r_b) + +forwardPutRel_ :: WriteBinHandle -> (b -> IO a) -> IO b -> IO () +forwardPutRel_ bh put_A put_B = void $ forwardPutRel bh put_A put_B + +-- | Read a value stored using a forward reference +forwardGetRel :: ReadBinHandle -> IO a -> IO a +forwardGetRel bh get_A = do + -- read forward reference + p <- getRelBin bh + -- store current position + p_a <- tellBinReader bh + -- go read the forward value, then seek back + seekBinReader bh $ makeAbsoluteBin p + r <- get_A + seekBinReader bh p_a + pure r + -- ----------------------------------------------------------------------------- -- Lazy reading/writing @@ -1127,19 +1290,19 @@ lazyPut = lazyPut' put_ lazyGet :: Binary a => ReadBinHandle -> IO a lazyGet = lazyGet' get -lazyPut' :: HasDebugCallStack => (WriteBinHandle -> a -> IO ()) -> WriteBinHandle -> a -> IO () +lazyPut' :: (WriteBinHandle -> a -> IO ()) -> WriteBinHandle -> a -> IO () lazyPut' f bh a = do -- output the obj with a ptr to skip over it: pre_a <- tellBinWriter bh put_ bh pre_a -- save a slot for the ptr f bh a -- dump the object q <- tellBinWriter bh -- q = ptr to after object - putAt bh pre_a q -- fill in slot before a with ptr to q + putAtRel bh pre_a q -- fill in slot before a with ptr to q seekBinWriter bh q -- finally carry on writing at q lazyGet' :: HasDebugCallStack => (ReadBinHandle -> IO a) -> ReadBinHandle -> IO a lazyGet' f bh = do - p <- get bh -- a BinPtr + p <- getRelBin bh -- a BinPtr p_a <- tellBinReader bh a <- unsafeInterleaveIO $ do -- NB: Use a fresh rbm_off_r variable in the child thread, for thread @@ -1148,7 +1311,7 @@ lazyGet' f bh = do let bh' = bh { rbm_off_r = off_r } seekBinReader bh' p_a f bh' - seekBinReader bh p -- skip over the object for now + seekBinReader bh (makeAbsoluteBin p) -- skip over the object for now return a -- | Serialize the constructor strictly but lazily serialize a value inside a @@ -1442,13 +1605,13 @@ putGenericSymbolTable gen_sym_tab serialiser bh = do mapM_ (\n -> serialiser bh n) (reverse todo) loop snd <$> - (forwardPut bh (const $ readFastMutInt symtab_next >>= put_ bh) $ + (forwardPutRel bh (const $ readFastMutInt symtab_next >>= put_ bh) $ loop) -- | Read the elements of a 'GenericSymbolTable' from disk into a 'SymbolTable'. getGenericSymbolTable :: forall a . (ReadBinHandle -> IO a) -> ReadBinHandle -> IO (SymbolTable a) getGenericSymbolTable deserialiser bh = do - sz <- forwardGet bh (get bh) :: IO Int + sz <- forwardGetRel bh (get bh) :: IO Int mut_arr <- newArray_ (0, sz-1) :: IO (IOArray Int a) forM_ [0..(sz-1)] $ \i -> do f <- deserialiser bh View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6a17f57fbc172195c129561eb250fb5de03b0781...e730c3c648719be203a141a9059149181a4aa282 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6a17f57fbc172195c129561eb250fb5de03b0781...e730c3c648719be203a141a9059149181a4aa282 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 09:02:22 2024 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Thu, 02 May 2024 05:02:22 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24548-2 Message-ID: <6633569e4576e_2228775137a4856@gitlab.mail> Cheng Shao pushed new branch wip/T24548-2 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24548-2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 11:19:11 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Thu, 02 May 2024 07:19:11 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/mksolo-hash] 24 commits: Refactor the Binary serialisation interface Message-ID: <663376af4cbd6_22287721d583819792@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/mksolo-hash at Glasgow Haskell Compiler / GHC Commits: fa03b1fb by Fendor at 2024-04-26T18:03:13-04:00 Refactor the Binary serialisation interface The goal is simplifiy adding deduplication tables to `ModIface` interface serialisation. We identify two main points of interest that make this difficult: 1. UserData hardcodes what `Binary` instances can have deduplication tables. Moreover, it heavily uses partial functions. 2. GHC.Iface.Binary hardcodes the deduplication tables for 'Name' and 'FastString', making it difficult to add more deduplication. Instead of having a single `UserData` record with fields for all the types that can have deduplication tables, we allow to provide custom serialisers for any `Typeable`. These are wrapped in existentials and stored in a `Map` indexed by their respective `TypeRep`. The `Binary` instance of the type to deduplicate still needs to explicitly look up the decoder via `findUserDataReader` and `findUserDataWriter`, which is no worse than the status-quo. `Map` was chosen as microbenchmarks indicate it is the fastest for a small number of keys (< 10). To generalise the deduplication table serialisation mechanism, we introduce the types `ReaderTable` and `WriterTable` which provide a simple interface that is sufficient to implement a general purpose deduplication mechanism for `writeBinIface` and `readBinIface`. This allows us to provide a list of deduplication tables for serialisation that can be extended more easily, for example for `IfaceTyCon`, see the issue https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for more motivation. In addition to this refactoring, we split `UserData` into `ReaderUserData` and `WriterUserData`, to avoid partial functions and reduce overall memory usage, as we need fewer mutable variables. Bump haddock submodule to accomodate for `UserData` split. ------------------------- Metric Increase: MultiLayerModulesTH_Make MultiLayerModulesRecomp T21839c ------------------------- - - - - - bac57298 by Fendor at 2024-04-26T18:03:13-04:00 Split `BinHandle` into `ReadBinHandle` and `WriteBinHandle` A `BinHandle` contains too much information for reading data. For example, it needs to keep a `FastMutInt` and a `IORef BinData`, when the non-mutable variants would suffice. Additionally, this change has the benefit that anyone can immediately tell whether the `BinHandle` is used for reading or writing. Bump haddock submodule BinHandle split. - - - - - 4d6394dd by Simon Peyton Jones at 2024-04-26T18:03:49-04:00 Fix missing escaping-kind check in tcPatSynSig Note [Escaping kind in type signatures] explains how we deal with escaping kinds in type signatures, e.g. f :: forall r (a :: TYPE r). a where the kind of the body is (TYPE r), but `r` is not in scope outside the forall-type. I had missed this subtlety in tcPatSynSig, leading to #24686. This MR fixes it; and a similar bug in tc_top_lhs_type. (The latter is tested by T24686a.) - - - - - 981c2c2c by Alan Zimmerman at 2024-04-26T18:04:25-04:00 EPA: check-exact: check that the roundtrip reproduces the source Closes #24670 - - - - - a8616747 by Andrew Lelechenko at 2024-04-26T18:05:01-04:00 Document that setEnv is not thread-safe - - - - - 1e41de83 by Bryan Richter at 2024-04-26T18:05:37-04:00 CI: Work around frequent Signal 9 errors - - - - - a6d5f9da by Naïm Favier at 2024-04-27T17:52:40-04:00 ghc-internal: add MonadFix instance for (,) Closes https://gitlab.haskell.org/ghc/ghc/-/issues/24288, implements CLC proposal https://github.com/haskell/core-libraries-committee/issues/238. Adds a MonadFix instance for tuples, permitting value recursion in the "native" writer monad and bringing consistency with the existing instance for transformers's WriterT (and, to a lesser extent, for Solo). - - - - - 64feadcd by Rodrigo Mesquita at 2024-04-27T17:53:16-04:00 bindist: Fix xattr cleaning The original fix (725343aa) was incorrect because it used the shell bracket syntax which is the quoting syntax in autoconf, making the test for existence be incorrect and therefore `xattr` was never run. Fixes #24554 - - - - - e2094df3 by damhiya at 2024-04-28T23:52:00+09:00 Make read accepts binary integer formats CLC proposal : https://github.com/haskell/core-libraries-committee/issues/177 - - - - - 1c2fd963 by Alan Zimmerman at 2024-04-29T23:17:00-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 - - - - - 4189d17e by Sylvain Henry at 2024-04-29T23:17:42-04:00 LLVM: better unreachable default destination in Switch (#24717) See added note. Co-authored-by: Siddharth Bhat <siddu.druid at gmail.com> - - - - - a3725c88 by Cheng Shao at 2024-04-29T23:18:20-04:00 ci: enable wasm jobs for MRs with wasm label This patch enables wasm jobs for MRs with wasm label. Previously the wasm label didn't actually have any effect on the CI pipeline, and full-ci needed to be applied to run wasm jobs which was a waste of runners when working on the wasm backend, hence the fix here. - - - - - 702f7964 by Matthew Pickering at 2024-04-29T23:18:56-04:00 Make interface files and object files depend on inplace .conf file A potential fix for #24737 - - - - - 728af21e by Cheng Shao at 2024-04-30T05:30:23-04:00 utils: remove obsolete vagrant scripts Vagrantfile has long been removed in !5288. This commit further removes the obsolete vagrant scripts in the tree. - - - - - 36f2c342 by Cheng Shao at 2024-04-30T05:31:00-04:00 Update autoconf scripts Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 - - - - - ecbf22a6 by Ben Gamari at 2024-04-30T05:31:36-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - 678583c1 by Andrei Borzenkov at 2024-05-02T15:18:43+04:00 Rename Solo# data constructor to MkSolo# (#24673) - data Solo# a = (# a #) + data Solo# a = MkSolo# a And `(# foo #)` syntax now becomes just a syntactic sugar for `MkSolo# a`. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Ext/Fields.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Recomp/Binary.hs - compiler/GHC/Iface/Recomp/Flags.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/StgToJS/Apply.hs - compiler/GHC/StgToJS/Arg.hs - compiler/GHC/StgToJS/Closure.hs - compiler/GHC/StgToJS/CodeGen.hs - compiler/GHC/StgToJS/Expr.hs - compiler/GHC/StgToJS/Heap.hs - compiler/GHC/StgToJS/Object.hs - compiler/GHC/StgToJS/Rts/Rts.hs - compiler/GHC/StgToJS/Stack.hs - compiler/GHC/StgToJS/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Sig.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ee4e2e3ada13db527d2bc69740267b257106e5fc...678583c12a55ff35137d5dd3af0feb4ee6c09663 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ee4e2e3ada13db527d2bc69740267b257106e5fc...678583c12a55ff35137d5dd3af0feb4ee6c09663 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 12:19:45 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 02 May 2024 08:19:45 -0400 Subject: [Git][ghc/ghc][master] 3 commits: testsuite: fix req_target_smp predicate Message-ID: <663384e1930_222877316cdf048046@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 13 changed files: - hadrian/src/Settings/Builders/RunTest.hs - rts/Exception.cmm - rts/STM.c - rts/STM.h - rts/Schedule.c - rts/include/stg/SMP.h - testsuite/config/ghc - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/mk/test.mk - + testsuite/tests/rts/T24142.hs - + testsuite/tests/rts/T24142.stdout - testsuite/tests/rts/all.T Changes: ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -282,7 +282,7 @@ runTestBuilderArgs = builder Testsuite ? do , arg "-e", arg $ asBool "ghc_with_dynamic_rts=" (hasDynamicRts) , arg "-e", arg $ asBool "config.ghc_with_threaded_rts=" (hasThreadedRts) , arg "-e", arg $ asBool "config.have_fast_bignum=" (bignumBackend /= "native" && not bignumCheck) - , arg "-e", arg $ asBool "target_with_smp=" targetWithSMP + , arg "-e", arg $ asBool "config.target_has_smp=" targetWithSMP , arg "-e", arg $ "config.ghc_dynamic=" ++ show hasDynamic , arg "-e", arg $ "config.leading_underscore=" ++ show leadingUnderscore ===================================== rts/Exception.cmm ===================================== @@ -495,7 +495,7 @@ retry_pop_stack: W_ trec, outer; W_ r; trec = StgTSO_trec(CurrentTSO); - (r) = ccall stmValidateNestOfTransactions(MyCapability() "ptr", trec "ptr"); + (r) = ccall stmValidateNestOfTransactions(MyCapability() "ptr", trec "ptr", 0); outer = StgTRecHeader_enclosing_trec(trec); ccall stmAbortTransaction(MyCapability() "ptr", trec "ptr"); ccall stmFreeAbortedTRec(MyCapability() "ptr", trec "ptr"); ===================================== rts/STM.c ===================================== @@ -31,10 +31,8 @@ * interface. In the Haskell RTS this means it is suitable only for * non-THREADED_RTS builds. * - * STM_CG_LOCK uses coarse-grained locking -- a single 'stm lock' is acquired - * during an invocation on the STM interface. Note that this does not mean that - * transactions are simply serialized -- the lock is only held *within* the - * implementation of stmCommitTransaction, stmWait etc. + * STM_CG_LOCK was a historic locking mode using coarse-grained locking + * It has been removed, look at the git history if you are interest in it. * * STM_FG_LOCKS uses fine-grained locking -- locking is done on a per-TVar basis * and, when committing a transaction, no locks are acquired for TVars that have @@ -42,19 +40,14 @@ * * Concurrency control is implemented in the functions: * - * lock_stm - * unlock_stm * lock_tvar / cond_lock_tvar * unlock_tvar * - * The choice between STM_UNIPROC / STM_CG_LOCK / STM_FG_LOCKS affects the + * The choice between STM_UNIPROC / STM_FG_LOCKS affects the * implementation of these functions. * - * lock_stm & unlock_stm are straightforward : they acquire a simple spin-lock - * using STM_CG_LOCK, and otherwise they are no-ops. - * * lock_tvar / cond_lock_tvar and unlock_tvar are more complex because they have - * other effects (present in STM_UNIPROC and STM_CG_LOCK builds) as well as the + * other effects (present in STM_UNIPROC builds) as well as the * actual business of manipulating a lock (present only in STM_FG_LOCKS builds). * This is because locking a TVar is implemented by writing the lock holder's * TRec into the TVar's current_value field: @@ -167,7 +160,6 @@ static int shake(void) { /*......................................................................*/ #define IF_STM_UNIPROC(__X) do { } while (0) -#define IF_STM_CG_LOCK(__X) do { } while (0) #define IF_STM_FG_LOCKS(__X) do { } while (0) #if defined(STM_UNIPROC) @@ -175,14 +167,6 @@ static int shake(void) { #define IF_STM_UNIPROC(__X) do { __X } while (0) static const StgBool config_use_read_phase = false; -static void lock_stm(StgTRecHeader *trec STG_UNUSED) { - TRACE("%p : lock_stm()", trec); -} - -static void unlock_stm(StgTRecHeader *trec STG_UNUSED) { - TRACE("%p : unlock_stm()", trec); -} - static StgClosure *lock_tvar(Capability *cap STG_UNUSED, StgTRecHeader *trec STG_UNUSED, StgTVar *s STG_UNUSED) { @@ -210,64 +194,9 @@ static StgBool cond_lock_tvar(Capability *cap STG_UNUSED, StgTVar *s STG_UNUSED, StgClosure *expected) { StgClosure *result; - TRACE("%p : cond_lock_tvar(%p, %p)", trec, s, expected); - result = ACQUIRE_LOAD(&s->current_value); - TRACE("%p : %s", trec, (result == expected) ? "success" : "failure"); - return (result == expected); -} -#endif - -#if defined(STM_CG_LOCK) /*........................................*/ - -#undef IF_STM_CG_LOCK -#define IF_STM_CG_LOCK(__X) do { __X } while (0) -static const StgBool config_use_read_phase = false; -static volatile StgTRecHeader *smp_locked = NULL; - -static void lock_stm(StgTRecHeader *trec) { - while (cas(&smp_locked, NULL, trec) != NULL) { } - TRACE("%p : lock_stm()", trec); -} - -static void unlock_stm(StgTRecHeader *trec STG_UNUSED) { - TRACE("%p : unlock_stm()", trec); - ASSERT(smp_locked == trec); - RELEASE_STORE(&smp_locked, 0); -} - -static StgClosure *lock_tvar(Capability *cap STG_UNUSED, - StgTRecHeader *trec STG_UNUSED, - StgTVar *s STG_UNUSED) { - StgClosure *result; - TRACE("%p : lock_tvar(%p)", trec, s); - ASSERT(smp_locked == trec); + // TRACE("%p : cond_lock_tvar(%p, %p)", trec, s, expected); result = ACQUIRE_LOAD(&s->current_value); - return result; -} - -static void *unlock_tvar(Capability *cap, - StgTRecHeader *trec STG_UNUSED, - StgTVar *s, - StgClosure *c, - StgBool force_update) { - TRACE("%p : unlock_tvar(%p, %p)", trec, s, c); - ASSERT(smp_locked == trec); - if (force_update) { - StgClosure *old_value = ACQUIRE_LOAD(&s->current_value); - RELEASE_STORE(&s->current_value, c); - dirty_TVAR(cap, s, old_value); - } -} - -static StgBool cond_lock_tvar(Capability *cap STG_UNUSED, - StgTRecHeader *trec STG_UNUSED, - StgTVar *s STG_UNUSED, - StgClosure *expected) { - StgClosure *result; - TRACE("%p : cond_lock_tvar(%p, %p)", trec, s, expected); - ASSERT(smp_locked == trec); - result = ACQUIRE_LOAD(&s->current_value); - TRACE("%p : %d", result ? "success" : "failure"); + // TRACE("%p : %s", trec, (result == expected) ? "success" : "failure"); return (result == expected); } #endif @@ -278,19 +207,11 @@ static StgBool cond_lock_tvar(Capability *cap STG_UNUSED, #define IF_STM_FG_LOCKS(__X) do { __X } while (0) static const StgBool config_use_read_phase = true; -static void lock_stm(StgTRecHeader *trec STG_UNUSED) { - TRACE("%p : lock_stm()", trec); -} - -static void unlock_stm(StgTRecHeader *trec STG_UNUSED) { - TRACE("%p : unlock_stm()", trec); -} - static StgClosure *lock_tvar(Capability *cap, StgTRecHeader *trec, StgTVar *s STG_UNUSED) { StgClosure *result; - TRACE("%p : lock_tvar(%p)", trec, s); + // TRACE("%p : lock_tvar(%p)", trec, s); do { const StgInfoTable *info; do { @@ -313,7 +234,7 @@ static void unlock_tvar(Capability *cap, StgTVar *s, StgClosure *c, StgBool force_update STG_UNUSED) { - TRACE("%p : unlock_tvar(%p, %p)", trec, s, c); + // TRACE("%p : unlock_tvar(%p, %p)", trec, s, c); ASSERT(ACQUIRE_LOAD(&s->current_value) == (StgClosure *)trec); RELEASE_STORE(&s->current_value, c); dirty_TVAR(cap, s, (StgClosure *) trec); @@ -325,14 +246,14 @@ static StgBool cond_lock_tvar(Capability *cap, StgClosure *expected) { StgClosure *result; StgWord w; - TRACE("%p : cond_lock_tvar(%p, %p)", trec, s, expected); + // TRACE("%p : cond_lock_tvar(%p, %p)", trec, s, expected); w = cas((void *)&(s -> current_value), (StgWord)expected, (StgWord)trec); result = (StgClosure *)w; IF_NONMOVING_WRITE_BARRIER_ENABLED { if (result) updateRemembSetPushClosure(cap, expected); } - TRACE("%p : %s", trec, result ? "success" : "failure"); + // TRACE("%p : %s", trec, result ? "success" : "failure"); return (result == expected); } #endif @@ -438,6 +359,8 @@ static StgTRecHeader *new_stg_trec_header(Capability *cap, // Allocation / deallocation functions that retain per-capability lists // of closures that can be re-used +//TODO: I think some of these lack write barriers required by the non-moving gc. + static StgTVarWatchQueue *alloc_stg_tvar_watch_queue(Capability *cap, StgClosure *closure) { StgTVarWatchQueue *result = NULL; @@ -760,6 +683,44 @@ static void revert_ownership(Capability *cap STG_UNUSED, /*......................................................................*/ +// validate_optimistic() +StgBool validate_trec_optimistic (Capability *cap, StgTRecHeader *trec); + +StgBool validate_trec_optimistic (Capability *cap, StgTRecHeader *trec) { + StgBool result; + TRACE("cap %d, trec %p : validate_trec_optimistic", + cap->no, trec); + + if (shake()) { + TRACE("%p : shake, pretending trec is invalid when it may not be", trec); + return false; + } + + ASSERT((trec -> state == TREC_ACTIVE) || + (trec -> state == TREC_WAITING) || + (trec -> state == TREC_CONDEMNED)); + result = !((trec -> state) == TREC_CONDEMNED); + if (result) { + FOR_EACH_ENTRY(trec, e, { + StgTVar *s; + s = e -> tvar; + StgClosure *current = RELAXED_LOAD(&s->current_value); + if(current != e->expected_value && + //If the trec is locked we optimistically assume our trec will still be valid after it's unlocked. + (GET_INFO(UNTAG_CLOSURE(current)) != &stg_TREC_HEADER_info)) + { TRACE("%p : failed optimistic validate %p", trec, s); + result = false; + BREAK_FOR_EACH; + } + }); + } + + + TRACE("%p : validate_trec_optimistic, result: %d", trec, result); + return result; +} + + // validate_and_acquire_ownership : this performs the twin functions // of checking that the TVars referred to by entries in trec hold the // expected values and: @@ -778,6 +739,8 @@ static StgBool validate_and_acquire_ownership (Capability *cap, int acquire_all, int retain_ownership) { StgBool result; + TRACE("cap %d, trec %p : validate_and_acquire_ownership, all: %d, retrain: %d", + cap->no, trec, acquire_all, retain_ownership); if (shake()) { TRACE("%p : shake, pretending trec is invalid when it may not be", trec); @@ -828,6 +791,7 @@ static StgBool validate_and_acquire_ownership (Capability *cap, revert_ownership(cap, trec, acquire_all); } + TRACE("%p : validate_and_acquire_ownership, result: %d", trec, result); return result; } @@ -878,12 +842,10 @@ static StgBool check_read_only(StgTRecHeader *trec STG_UNUSED) { /************************************************************************/ void stmPreGCHook (Capability *cap) { - lock_stm(NO_TREC); TRACE("stmPreGCHook"); cap->free_tvar_watch_queues = END_STM_WATCH_QUEUE; cap->free_trec_chunks = END_STM_CHUNK_LIST; cap->free_trec_headers = NO_TREC; - unlock_stm(NO_TREC); } /************************************************************************/ @@ -959,8 +921,6 @@ void stmAbortTransaction(Capability *cap, (trec -> state == TREC_WAITING) || (trec -> state == TREC_CONDEMNED)); - lock_stm(trec); - et = trec -> enclosing_trec; if (et == NO_TREC) { // We're a top-level transaction: remove any watch queue entries that @@ -984,8 +944,6 @@ void stmAbortTransaction(Capability *cap, } trec -> state = TREC_ABORTED; - unlock_stm(trec); - TRACE("%p : stmAbortTransaction done", trec); } @@ -1013,35 +971,210 @@ void stmCondemnTransaction(Capability *cap, (trec -> state == TREC_WAITING) || (trec -> state == TREC_CONDEMNED)); - lock_stm(trec); if (trec -> state == TREC_WAITING) { ASSERT(trec -> enclosing_trec == NO_TREC); TRACE("%p : stmCondemnTransaction condemning waiting transaction", trec); remove_watch_queue_entries_for_trec(cap, trec); } trec -> state = TREC_CONDEMNED; - unlock_stm(trec); TRACE("%p : stmCondemnTransaction done", trec); } -/*......................................................................*/ - -StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec) { +/*...................................................................... + +Note [STM Validation] +~~~~~~~~~~~~~~~~~~~~~ +To "validate" a transaction means to check that the transaction's log (Trec) is +consistent with the current state of memory; specifically, that any variable +observed (through reads AND writes) by the transaction has the same value in +memory as it did when the transaction read it. + +In some situations we can give ourself some leeway by allowing: +* False positives - The validation check claims the memory state is consistent when it isn't. +* False negatives - The validation check claims memory state is inconsistent when it + is in fact consistent. + +We validate a STM transaction for two purposes: + +(A) Post-run validation runs /after/ the transaction has completed, either during + commit or after an exception has occurred. + + This is done by validate_and_acquire_ownership. The commit process + /absolutely must/ be transactional: that is, it must read a consistent + snapshot of memory, compare with the log, and then atomically commit all the + writes in the log. We do this by locking the TVars. + + For post-run validation we must *never* allow false-positives for correctness + reasons. But we allow for false-negatives, trading occasional spurious retries + for performance in the average case. + + The implementation of performing this update atomically is mostly based on + the 2002 paper "A Practical Multi-Word Compare-and-Swap Operation" + +(B) In-flight validation runs /during/ the execution of the transaction. Suppose a transaction + is long-running, and memory has /already/ changed so that it is inconsistent with the + transaction's log. It is just conceivable that memory might change back again to be + consistent, but very unlikely. It is better to terminate and retry the transaction, + rather than let it run potentially forever as a zombie, and only retry when it attempts to commit. + + This is done by validate_trec_optimistic. Since in-flight validation at most results in early + termination of a transaction we may accept both + * a "false negative" (causing the transaction to retry unnecessarily), and + * a "false positive" (allowing the transaction to continue as a zombie). + + We want to run in-flight validation somewhat frequently to detect invalid + transactions early. We perform in-flight validation whenever a thread returns to + the scheduler, a convenient and regular opportunity. + +Note that in-flight validation is not merely a optimization. Consider transactions +that are in an infinite loop as a result of seeing an inconsistent view of +memory, e.g. + + atomically $ do + [a,b] <- mapM readTVar [ta,tb] + -- a is never equal to b given a consistent view of memory. + when (a == b) loop + +As noted above, post-run validation and commit /must/ be transactional, involving expensive locking. +But in-flight validation can accept false positives and false negatives. While we could lock TVars +during in-flight validation to rule out false positives, we don't have to: +it is much cheaper and very nearly as good simply to read them without locking allowing for +false-postive results. + +Moreover, locking during in-flight validation can cause lack of progress, or livelock (#24446) +through false-negative results. Suppose we have two long-running transactions, each doing successive +in-flight validation using locking. If the validation discovers a locked TVar it aborts and retries. +Now they can each abort the other, forever. +This *can* also happen with post-run validation. But since post-run validation occurs less +frequently it's incredibly unlikely to happen repeatedly compared to in-flight validation. + +Hence: locking during in-flight validation is + * Expensive + * Can lead to livelock-like conditions. + +Conclusion: + * don't use locking during in-flight validation. + * Use locking during post-run validation, where the risk of livelock is comparatively small + compared to the cost of ruling out live-lock completely. + +See below for other design alternatives. + +Design considerations about locking during in flight validation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +All else being equal we would always want to get a precise result for validation. +And indeed for the non-threaded runtime this is reasonably easy to achieve +(see STM paper "Composable Memory Transactions"). +However for SMP things are more difficult, and ruling out false negatives/positives +would come at significant cost in the average case. + +The easiest way to avoid false positives is to lock all relevant tvars during +validation. And indeed that is what we use for post-run validation. +The trade off being that it can lead to false negatives during validation when multiple +threads perform validation in parallel. As long as the false-negative rate is +is reasonably low this is not problematic. + +However in-flight validation can happen multiple times per transaction. +So even a fairly low rate of spurious validation failures will result in a large +performance hit. In the worst case preventing progress alltogether (See #24446). + +We don't want to reduce validation frequency too much to detect invalid +transactions early. So we simply stick with the frequency "on return to scheduler" +that's described in the stm paper. + +However we can improve in-flight validation perf by allowing false positives. +This removes the need for tacking locks which means: + +Benefits +* No lock contention between post-run and in-flight validations operating on the + same tvars. This reduces the false negative rate significantly for both. +* Concurrent in-flight validations won't cause each other to fail spuriously + through lock contention. +* No cas operations for in-flight validation reduces it's overhead significantly. + +Drawbacks: +* We will sometimes fail to recognize invalid trecs as such by assuming locked + tvars contain valid values. + +Why can we simply not lock tvars for in-flight validations? Unlike with post-run +validation if we miss part of an update which would invalidate the trec it will +be either seen by a later validation (at the latest in the post-run validation +which still locks). However there is one exception: Looping transactions. + +If a transaction loops it will *only* be validated optimistically. +The only way for in-flight validation to constantly +result in false-positives is for the conflicting tvar(s) to get constantly locked +for updates by post-run validations. Which seems impossibly unlikely over a long +period of time. So we accept this behaviour. + +Design alternatives to improve in-flight false-postive rate: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +All of these primarily revolve around ways to ensure that we can recognize invalid +looping transactions. However without proof this is a real problem implementing +those seems not worthwhile. + +A1: +Take locks for in-flight validation but don't fail if in-flight validation +encounters already locked tvars. +This would solve lock contention/false positives caused by concurrent in-flight validations. + +But it would still result in in-flight validation causing some false-negatives +during post-run validation by holding locks post-run validation is trying to take. + +It also doesn't *guaranteed* that we recognize looping transaction as invalid. +As the relevant tvars might be locked by other validations when we try to lock +them. So while this would improve over using regular lock tacking for in-flight +transactions it seems straight up worse than not taking locks to me in most +situations. + +A2: +Perform occasional locking in-flight validation for long running transactions. +This would solve the theoretical looping transaction recognition issue at the +cost of some performance and complexity. This could done by adding a counter to +the trec, counting the number of validations it has endured. + +A2.1: +Like A2, but instead of counting the number of validations count the number of +locked tvars we encountered, as these are the only sources of false-positives. +This would give a hard upper bound on the number of false-positives while keeping +the impact on post-run validations lower. + +If the looping transaction issue turns out to be a real problem this might be worth +doing. + +A3: +When locking a tvar for a potential update keep the old value accessible. Then +in-flight validations should never return false-positives. However compared to A2 +this seems like it would come with a non-trivial overhead relative to the likelyhood +of these false-positives causing actual issues. + + +*/ + +// Check if a transaction is possibly invalid by this point. +// Pessimistically - Currently we use this if an exception occured inside a transaction. +// To decide weither or not to abort by checking if the transaction was valid. +// Optimistically - Currently we use this to eagerly abort invalid transactions from the scheduler. +// See Note [STM Validation] +StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec, StgBool optimistically) { StgTRecHeader *t; - TRACE("%p : stmValidateNestOfTransactions", trec); + TRACE("%p : stmValidateNestOfTransactions, %b", trec, optimistically); ASSERT(trec != NO_TREC); ASSERT((trec -> state == TREC_ACTIVE) || (trec -> state == TREC_WAITING) || (trec -> state == TREC_CONDEMNED)); - lock_stm(trec); - t = trec; StgBool result = true; while (t != NO_TREC) { - result &= validate_and_acquire_ownership(cap, t, true, false); + if(optimistically) { + result &= validate_trec_optimistic(cap, t); + + } else { + // TODO: I don't think there is a need to lock all tvars here. + result &= validate_and_acquire_ownership(cap, t, true, false); + } t = t -> enclosing_trec; } @@ -1049,12 +1182,9 @@ StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec) { trec -> state = TREC_CONDEMNED; } - unlock_stm(trec); - TRACE("%p : stmValidateNestOfTransactions()=%d", trec, result); return result; } - /*......................................................................*/ static TRecEntry *get_entry_for(StgTRecHeader *trec, StgTVar *tvar, StgTRecHeader **in) { @@ -1087,8 +1217,6 @@ StgBool stmCommitTransaction(Capability *cap, StgTRecHeader *trec) { TRACE("%p : stmCommitTransaction()", trec); ASSERT(trec != NO_TREC); - lock_stm(trec); - ASSERT(trec -> enclosing_trec == NO_TREC); ASSERT((trec -> state == TREC_ACTIVE) || (trec -> state == TREC_CONDEMNED)); @@ -1112,6 +1240,7 @@ StgBool stmCommitTransaction(Capability *cap, StgTRecHeader *trec) { max_concurrent_commits = ((max_commits_at_end - max_commits_at_start) + (getNumCapabilities() * TOKEN_BATCH_SIZE)); if (((max_concurrent_commits >> 32) > 0) || shake()) { + TRACE("STM - Max commit number exceeded"); result = false; } } @@ -1145,8 +1274,6 @@ StgBool stmCommitTransaction(Capability *cap, StgTRecHeader *trec) { } } - unlock_stm(trec); - free_stg_trec_header(cap, trec); TRACE("%p : stmCommitTransaction()=%d", trec, result); @@ -1162,8 +1289,6 @@ StgBool stmCommitNestedTransaction(Capability *cap, StgTRecHeader *trec) { TRACE("%p : stmCommitNestedTransaction() into %p", trec, trec -> enclosing_trec); ASSERT((trec -> state == TREC_ACTIVE) || (trec -> state == TREC_CONDEMNED)); - lock_stm(trec); - et = trec -> enclosing_trec; bool result = validate_and_acquire_ownership(cap, trec, (!config_use_read_phase), true); if (result) { @@ -1196,8 +1321,6 @@ StgBool stmCommitNestedTransaction(Capability *cap, StgTRecHeader *trec) { } } - unlock_stm(trec); - free_stg_trec_header(cap, trec); TRACE("%p : stmCommitNestedTransaction()=%d", trec, result); @@ -1214,7 +1337,6 @@ StgBool stmWait(Capability *cap, StgTSO *tso, StgTRecHeader *trec) { ASSERT((trec -> state == TREC_ACTIVE) || (trec -> state == TREC_CONDEMNED)); - lock_stm(trec); bool result = validate_and_acquire_ownership(cap, trec, true, true); if (result) { // The transaction is valid so far so we can actually start waiting. @@ -1237,7 +1359,6 @@ StgBool stmWait(Capability *cap, StgTSO *tso, StgTRecHeader *trec) { // TRec. } else { - unlock_stm(trec); free_stg_trec_header(cap, trec); } @@ -1249,7 +1370,6 @@ StgBool stmWait(Capability *cap, StgTSO *tso, StgTRecHeader *trec) { void stmWaitUnlock(Capability *cap, StgTRecHeader *trec) { revert_ownership(cap, trec, true); - unlock_stm(trec); } /*......................................................................*/ @@ -1263,7 +1383,6 @@ StgBool stmReWait(Capability *cap, StgTSO *tso) { ASSERT((trec -> state == TREC_WAITING) || (trec -> state == TREC_CONDEMNED)); - lock_stm(trec); bool result = validate_and_acquire_ownership(cap, trec, true, true); TRACE("%p : validation %s", trec, result ? "succeeded" : "failed"); if (result) { @@ -1280,7 +1399,6 @@ StgBool stmReWait(Capability *cap, StgTSO *tso) { } free_stg_trec_header(cap, trec); } - unlock_stm(trec); TRACE("%p : stmReWait()=%d", trec, result); return result; ===================================== rts/STM.h ===================================== @@ -6,24 +6,21 @@ * *---------------------------------------------------------------------- - STM.h defines the C-level interface to the STM. + STM.h defines the C-level interface to the STM. The design follows that of the PPoPP 2005 paper "Composable memory transactions" extended to include fine-grained locking of TVars. Three different implementations can be built. In overview: - + STM_UNIPROC -- no locking at all: not safe for concurrent invocations - - STM_CG_LOCK -- coarse-grained locking : a single mutex protects all - TVars - + STM_FG_LOCKS -- per-TVar exclusion : each TVar can be owned by at most one TRec at any time. This allows dynamically non-conflicting transactions to commit in parallel. The implementation treats reads optimistically -- - extra versioning information is retained in the - saw_update_by field of the TVars so that they do not + extra versioning information is retained in the + num_updates field of the TVars so that they do not need to be locked for reading. STM.C contains more details about the locking schemes used. @@ -72,7 +69,7 @@ void stmAbortTransaction(Capability *cap, StgTRecHeader *trec); void stmFreeAbortedTRec(Capability *cap, StgTRecHeader *trec); /* - * Ensure that a subsequent commit / validation will fail. We use this + * Ensure that a subsequent commit / validation will fail. We use this * in our current handling of transactions that may have become invalid * and started looping. We strip their stack back to the ATOMICALLY_FRAME, * and, when the thread is next scheduled, discover it to be invalid and @@ -87,16 +84,23 @@ void stmCondemnTransaction(Capability *cap, StgTRecHeader *trec); Validation ---------- - Test whether the specified transaction record, and all those within which - it is nested, are still valid. + Test whether the specified transaction record, and all those within which + it is nested, are still valid. + + stmValidateNestOfTransactions - optimistically + - Can return false positives when tvars are locked. + - Faster + - Does not take any locks + + stmValidateNestOfTransactions - pessimistic + - Can return false negatives. + - Slower + - Takes locks, negatively affecting performance of other threads. + - Most importantly - no false positives! - Note: the caller can assume that once stmValidateTransaction has - returned false for a given trec then that transaction will never - again be valid -- we rely on this in Schedule.c when kicking invalid - threads at GC (in case they are stuck looping) */ -StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec); +StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec, StgBool optimistically); /*---------------------------------------------------------------------- @@ -106,14 +110,14 @@ StgBool stmValidateNestOfTransactions(Capability *cap, StgTRecHeader *trec); These four operations return boolean results which should be interpreted as follows: - true => The transaction record was definitely valid + true => The transaction record was definitely valid false => The transaction record may not have been valid Note that, for nested operations, validity here is solely in terms of the specified trec: it does not say whether those that it may be - nested are themselves valid. Callers can check this with - stmValidateNestOfTransactions. + nested are themselves valid. Callers can check this with + stmValidateNestOfTransactionsPessimistic. The user of the STM should ensure that it is always safe to assume that a transaction context is not valid when in fact it is (i.e. to return false in @@ -151,7 +155,7 @@ StgBool stmCommitNestedTransaction(Capability *cap, StgTRecHeader *trec); * Test whether the current transaction context is valid and, if so, * start the thread waiting for updates to any of the tvars it has * ready from and mark it as blocked. It is an error to call stmWait - * if the thread is already waiting. + * if the thread is already waiting. */ StgBool stmWait(Capability *cap, StgTSO *tso, StgTRecHeader *trec); @@ -180,7 +184,7 @@ StgBool stmReWait(Capability *cap, StgTSO *tso); */ StgClosure *stmReadTVar(Capability *cap, - StgTRecHeader *trec, + StgTRecHeader *trec, StgTVar *tvar); /* Update the logical contents of 'tvar' within the context of the @@ -189,7 +193,7 @@ StgClosure *stmReadTVar(Capability *cap, void stmWriteTVar(Capability *cap, StgTRecHeader *trec, - StgTVar *tvar, + StgTVar *tvar, StgClosure *new_value); /*----------------------------------------------------------------------*/ ===================================== rts/Schedule.c ===================================== @@ -1106,7 +1106,7 @@ schedulePostRunThread (Capability *cap, StgTSO *t) // and a is never equal to b given a consistent view of memory. // if (t -> trec != NO_TREC && t -> why_blocked == NotBlocked) { - if (!stmValidateNestOfTransactions(cap, t -> trec)) { + if (!stmValidateNestOfTransactions(cap, t -> trec, true)) { debugTrace(DEBUG_sched | DEBUG_stm, "trec %p found wasting its time", t); ===================================== rts/include/stg/SMP.h ===================================== @@ -201,14 +201,15 @@ EXTERN_INLINE void busy_wait_nop(void); * - StgWeak: finalizer * - StgMVar: head, tail, value * - StgMVarTSOQueue: link - * - StgTVar: current_value, first_watch_queue_entry - * - StgTVarWatchQueue: {next,prev}_queue_entry - * - StgTRecChunk: TODO * - StgMutArrPtrs: payload * - StgSmallMutArrPtrs: payload * - StgThunk although this is a somewhat special case; see below * - StgInd: indirectee * - StgTSO: block_info + + * - StgTVar: current_value, first_watch_queue_entry + * - StgTVarWatchQueue: {next,prev}_queue_entry + * - StgTRecChunk: TODO * * Finally, non-pointer fields can be safely mutated without barriers as * they do not refer to other memory locations. Technically, concurrent ===================================== testsuite/config/ghc ===================================== @@ -48,8 +48,7 @@ if config.have_interp: # whether the target supports smp if config.ghc_with_threaded_rts: config.run_ways.append('threaded1') - if target_with_smp: - config.target_has_smp = True + if config.target_has_smp: config.run_ways.append('threaded2') if config.speed == 0: config.run_ways.append('nonmoving_thr') ===================================== testsuite/driver/testglobals.py ===================================== @@ -154,7 +154,7 @@ class TestConfig: self.ghc_has_smp = True # Does the target have SMP support? - self.target_has_smp = True + self.target_has_smp = False # Is gdb available? self.have_gdb = False ===================================== testsuite/driver/testlib.py ===================================== @@ -328,11 +328,11 @@ def req_ghc_smp( name, opts ): def req_target_smp( name, opts ): """ Mark a test as requiring smp when run on the target. If the target does - not support smp, then mark the test as an expected fail. Use this when the + not support smp, then skip the test. Use this when the test needs to run with smp support. """ if not config.target_has_smp: - opts.expect = 'fail' + opts.skip = True def req_ghc_with_threaded_rts( name, opts ): if not config.ghc_with_threaded_rts: ===================================== testsuite/mk/test.mk ===================================== @@ -167,9 +167,9 @@ CABAL_PLUGIN_BUILD = --enable-library-vanilla --disable-shared endif ifeq "$(GhcWithSMP)" "YES" -RUNTEST_OPTS += -e target_with_smp=True +RUNTEST_OPTS += -e config.target_has_smp=True else -RUNTEST_OPTS += -e target_with_smp=False +RUNTEST_OPTS += -e config.target_has_smp=False endif ifeq "$(GhcWithRtsLinker)" "YES" ===================================== testsuite/tests/rts/T24142.hs ===================================== @@ -0,0 +1,63 @@ +{- This test constructs a program that used to trigger an excessive amount of STM retries. -} +{-# LANGUAGE NumericUnderscores #-} +{-# LANGUAGE BangPatterns #-} +module Main where + +import GHC.Conc +import Control.Concurrent (newMVar, newEmptyMVar, takeMVar, putMVar) +import Control.Monad +import Control.Concurrent.STM.TArray +import Data.Array.MArray +import Data.IORef + + +main :: IO () +main = + forM_ [2..40] $ \i -> do + -- Run the test with an increasing number of tvars + let tvar_count = i * 10 + -- print $ "Tvars: " ++ show tvar_count + provokeLivelock tvar_count + + +-- Forks two threads running a STM transactions, both accessing the same tvars but in opposite order. +provokeLivelock :: Int -> IO () +provokeLivelock n = do + -- Use tvar array as a convenient way to bundle up n Tvars. + tvarArray <- atomically $ do + newListArray (0,n) [0.. fromIntegral n :: Integer] :: STM (TArray Int Integer) + m1 <- newEmptyMVar + m2 <- newEmptyMVar + updateCount <- newIORef (0 :: Int) + + let useTvars :: [Int] -> Bool -> IO () + useTvars tvar_order use_writes = atomically $ do + -- Walk the array once in the given order to add all tvars to the transaction log. + unsafeIOToSTM $ atomicModifyIORef' updateCount (\i -> (i+1,())) + mapM_ (\i -> readArray tvarArray i >>= \(!_n) -> return ()) tvar_order + + + -- Then we just enter the scheduler a lot + forM_ tvar_order $ \i -> do + -- when use_writes $ + -- readArray tvarArray i >>= \(!n) -> writeArray tvarArray i (n+1 :: Integer) + unsafeIOToSTM yield + + _ <- forkIO $ do + useTvars [0..n] False + -- print "Thread1 done." + putMVar m1 True + _ <- forkIO $ do + useTvars (reverse [0..n]) False + -- print "Thread1 done." + putMVar m2 True + -- Wait for forked threads. + _ <- takeMVar m1 + _ <- takeMVar m2 + updates <- readIORef updateCount + if updates > n + then putStrLn $ "TVars: " ++ show n ++ ", ERROR: more than " ++ show n ++ " transaction attempts. (" ++ show updates ++")\n" + else putStrLn $ "TVars: " ++ show n ++ ", OK: no more than " ++ show n ++ " transaction attempts." + + return () + ===================================== testsuite/tests/rts/T24142.stdout ===================================== @@ -0,0 +1,39 @@ +TVars: 20, OK: no more than 20 transaction attempts. +TVars: 30, OK: no more than 30 transaction attempts. +TVars: 40, OK: no more than 40 transaction attempts. +TVars: 50, OK: no more than 50 transaction attempts. +TVars: 60, OK: no more than 60 transaction attempts. +TVars: 70, OK: no more than 70 transaction attempts. +TVars: 80, OK: no more than 80 transaction attempts. +TVars: 90, OK: no more than 90 transaction attempts. +TVars: 100, OK: no more than 100 transaction attempts. +TVars: 110, OK: no more than 110 transaction attempts. +TVars: 120, OK: no more than 120 transaction attempts. +TVars: 130, OK: no more than 130 transaction attempts. +TVars: 140, OK: no more than 140 transaction attempts. +TVars: 150, OK: no more than 150 transaction attempts. +TVars: 160, OK: no more than 160 transaction attempts. +TVars: 170, OK: no more than 170 transaction attempts. +TVars: 180, OK: no more than 180 transaction attempts. +TVars: 190, OK: no more than 190 transaction attempts. +TVars: 200, OK: no more than 200 transaction attempts. +TVars: 210, OK: no more than 210 transaction attempts. +TVars: 220, OK: no more than 220 transaction attempts. +TVars: 230, OK: no more than 230 transaction attempts. +TVars: 240, OK: no more than 240 transaction attempts. +TVars: 250, OK: no more than 250 transaction attempts. +TVars: 260, OK: no more than 260 transaction attempts. +TVars: 270, OK: no more than 270 transaction attempts. +TVars: 280, OK: no more than 280 transaction attempts. +TVars: 290, OK: no more than 290 transaction attempts. +TVars: 300, OK: no more than 300 transaction attempts. +TVars: 310, OK: no more than 310 transaction attempts. +TVars: 320, OK: no more than 320 transaction attempts. +TVars: 330, OK: no more than 330 transaction attempts. +TVars: 340, OK: no more than 340 transaction attempts. +TVars: 350, OK: no more than 350 transaction attempts. +TVars: 360, OK: no more than 360 transaction attempts. +TVars: 370, OK: no more than 370 transaction attempts. +TVars: 380, OK: no more than 380 transaction attempts. +TVars: 390, OK: no more than 390 transaction attempts. +TVars: 400, OK: no more than 400 transaction attempts. ===================================== testsuite/tests/rts/all.T ===================================== @@ -609,3 +609,5 @@ test('T23400', [], compile_and_run, ['-with-rtsopts -A8k']) test('IOManager', [js_skip, when(arch('wasm32'), skip), when(opsys('mingw32'), skip), pre_cmd('$MAKE -s --no-print-directory IOManager.hs')], compile_and_run, ['']) + +test('T24142', [req_target_smp], compile_and_run, ['-threaded -with-rtsopts "-N2"']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9213478931b18402998c18f5c4e6f0ee09054b18...917ef81b214e4678d6eec89aec2fe1fbc4c2876e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9213478931b18402998c18f5c4e6f0ee09054b18...917ef81b214e4678d6eec89aec2fe1fbc4c2876e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 12:20:49 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 02 May 2024 08:20:49 -0400 Subject: [Git][ghc/ghc][master] EPA: fix span for empty \case(s) Message-ID: <663385219461e_222877330bef45402b@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 4 changed files: - compiler/GHC/Parser.y - testsuite/tests/printer/Makefile - + testsuite/tests/printer/Test24748.hs - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -2900,10 +2900,10 @@ aexp :: { ECP } [mj AnnLam $1] } | '\\' 'lcase' altslist(pats1) { ECP $ $3 >>= \ $3 -> - mkHsLamPV (comb2 $1 $>) LamCase $3 [mj AnnLam $1,mj AnnCase $2] } + mkHsLamPV (comb3 $1 $2 $>) LamCase $3 [mj AnnLam $1,mj AnnCase $2] } | '\\' 'lcases' altslist(argpats) { ECP $ $3 >>= \ $3 -> - mkHsLamPV (comb2 $1 $>) LamCases $3 [mj AnnLam $1,mj AnnCases $2] } + mkHsLamPV (comb3 $1 $2 $>) LamCases $3 [mj AnnLam $1,mj AnnCases $2] } | 'if' exp optSemi 'then' exp optSemi 'else' exp {% runPV (unECP $2) >>= \ ($2 :: LHsExpr GhcPs) -> return $ ECP $ ===================================== testsuite/tests/printer/Makefile ===================================== @@ -837,6 +837,11 @@ MatchPatComments: $(CHECK_PPR) $(LIBDIR) MatchPatComments.hs $(CHECK_EXACT) $(LIBDIR) MatchPatComments.hs +.PHONY: Test24748 +Test24748: + $(CHECK_PPR) $(LIBDIR) Test24748.hs + $(CHECK_EXACT) $(LIBDIR) Test24748.hs + .PHONY: DataDeclShort DataDeclShort: $(CHECK_PPR) $(LIBDIR) DataDeclShort.hs ===================================== testsuite/tests/printer/Test24748.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE LambdaCase #-} +module Test24748 where + +instance SDecide Nat where + SZero %~ (SSucc _) = Disproved (\case) + +foo = (\case) +bar = (\cases) ===================================== testsuite/tests/printer/all.T ===================================== @@ -200,4 +200,5 @@ test('Test24533', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24533']) test('PprLetIn', [ignore_stderr, req_ppr_deps], makefile_test, ['PprLetIn']) test('CaseAltComments', [ignore_stderr, req_ppr_deps], makefile_test, ['CaseAltComments']) test('MatchPatComments', [ignore_stderr, req_ppr_deps], makefile_test, ['MatchPatComments']) +test('Test24748', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24748']) test('DataDeclShort', [ignore_stderr, req_ppr_deps], makefile_test, ['DataDeclShort']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/167a56a003106ed84742e3970cc2189ffb98b0c7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/167a56a003106ed84742e3970cc2189ffb98b0c7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 12:51:02 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 02 May 2024 08:51:02 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: testsuite: fix req_target_smp predicate Message-ID: <66338c364c8c8_1a3d2435d4dc321bc@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 3bd38579 by doyougnu at 2024-05-02T08:50:51-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - 62eebf29 by Sylvain Henry at 2024-05-02T08:50:54-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Parser.y - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Eval/Types.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/StgToByteCode.hs - − compiler/GHC/Types/BreakInfo.hs - + compiler/GHC/Types/Breakpoint.hs - compiler/ghc.cabal.in - ghc/GHCi/UI.hs - hadrian/src/Settings/Builders/RunTest.hs - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/Run.hs - rts/Exception.cmm - rts/Interpreter.c - rts/STM.c - rts/STM.h - rts/Schedule.c - rts/include/stg/SMP.h - testsuite/config/ghc - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/mk/test.mk - + testsuite/tests/ghci.debugger/scripts/T24712.hs - + testsuite/tests/ghci.debugger/scripts/T24712.script - + testsuite/tests/ghci.debugger/scripts/T24712.stdout - testsuite/tests/ghci.debugger/scripts/all.T - testsuite/tests/ghci.debugger/scripts/break021.stdout The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/22eeb478fef276a0f6d7cb758f0463e26f9b1ee8...62eebf298d19726821f1a7b9edf3964dce0eab6b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/22eeb478fef276a0f6d7cb758f0463e26f9b1ee8...62eebf298d19726821f1a7b9edf3964dce0eab6b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 12:58:02 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 02 May 2024 08:58:02 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/late_casts Message-ID: <66338dda59a8f_1a3d244eb1283839e@gitlab.mail> Andreas Klebinger pushed new branch wip/andreask/late_casts at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/late_casts You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 13:21:13 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Thu, 02 May 2024 09:21:13 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/sand-witch/improve-pat-to-ty Message-ID: <6633934992e73_1a3d2487c83c481de@gitlab.mail> Andrei Borzenkov pushed new branch wip/sand-witch/improve-pat-to-ty at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/sand-witch/improve-pat-to-ty You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 13:25:51 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Thu, 02 May 2024 09:25:51 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/improve-pat-to-ty] Improve pattern to type pattern transformation (23739) Message-ID: <6633945f1cc_1a3d2491bdb0483bc@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/improve-pat-to-ty at Glasgow Haskell Compiler / GHC Commits: bce3ca67 by Andrei Borzenkov at 2024-05-02T17:23:54+04:00 Improve pattern to type pattern transformation (23739) `pat_to_type_pat` function now can handle more patterns: - TuplePat - ListPat - LitPat - NPat - ConPat Allowing these new constructors in type patterns significantly increases possible shapes of type patterns without `type` keyword. This patch also changes how lookups in `lookupOccRnConstr` are performed, because we need to fall back into types when we didn't find a constructor on data level to perform `ConPat` to type transformation properly. - - - - - 14 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Utils/Env.hs - testsuite/tests/rename/should_fail/T19843c.stderr - testsuite/tests/type-data/should_fail/TDPattern.stderr - + testsuite/tests/typecheck/should_compile/T23739a.hs - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T23739b.hs - + testsuite/tests/typecheck/should_fail/T23739b.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -245,6 +245,14 @@ data HsTyPatRn = HsTPRn } deriving Data +instance Semigroup HsTyPatRn where + HsTPRn nwcs1 imp_tvs1 exp_tvs1 <> + HsTPRn nwcs2 imp_tvs2 exp_tvs2 = + HsTPRn (nwcs1 ++ nwcs2) (imp_tvs1 ++ imp_tvs2) (exp_tvs1 ++ exp_tvs2) + +instance Monoid HsTyPatRn where + mempty = HsTPRn [] [] [] + type instance XXHsPatSigType (GhcPass _) = DataConCantHappen type instance XXHsTyPat (GhcPass _) = DataConCantHappen ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -1032,7 +1032,15 @@ lookupOccRn = lookupOccRn' WL_Anything -- lookupOccRnConstr looks up an occurrence of a RdrName and displays -- constructors and pattern synonyms as suggestions if it is not in scope lookupOccRnConstr :: RdrName -> RnM Name -lookupOccRnConstr = lookupOccRn' WL_Constructor +lookupOccRnConstr rdr_name + = do { mb_gre <- lookupOccRn_maybe rdr_name + ; case mb_gre of + Just gre -> return $ greName gre + Nothing -> do + { mb_ty_gre <- lookup_promoted rdr_name + ; case mb_ty_gre of + Just gre -> return $ greName gre + Nothing -> reportUnboundName' WL_Constructor rdr_name} } -- lookupOccRnRecField looks up an occurrence of a RdrName and displays -- record fields as suggestions if it is not in scope ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -56,7 +56,6 @@ import GHC.Types.Name.Env import GHC.Types.Name.Reader import GHC.Types.SrcLoc import GHC.Types.Var.Env ( emptyTidyEnv, mkInScopeSet ) -import GHC.Types.SourceText import GHC.Data.Maybe import GHC.Utils.Misc import GHC.Utils.Outputable as Outputable @@ -899,18 +898,12 @@ expr_to_type earg = where unwrap_op_tv (L _ (HsTyVar _ _ op_id)) = return op_id unwrap_op_tv _ = failWith $ TcRnIllformedTypeArgument (L l e) - go (L l e@(HsOverLit _ lit)) = - do { tylit <- case ol_val lit of - HsIntegral n -> return $ HsNumTy NoSourceText (il_value n) - HsIsString _ s -> return $ HsStrTy NoSourceText s - HsFractional _ -> failWith $ TcRnIllformedTypeArgument (L l e) - ; return (L l (HsTyLit noExtField tylit)) } - go (L l e@(HsLit _ lit)) = - do { tylit <- case lit of - HsChar _ c -> return $ HsCharTy NoSourceText c - HsString _ s -> return $ HsStrTy NoSourceText s - _ -> failWith $ TcRnIllformedTypeArgument (L l e) - ; return (L l (HsTyLit noExtField tylit)) } + go (L l (HsOverLit _ lit)) + | Just tylit <- tyLitFromOverloadedLit (ol_val lit) + = return (L l (HsTyLit noExtField tylit)) + go (L l (HsLit _ lit)) + | Just tylit <- tyLitFromLit lit + = return (L l (HsTyLit noExtField tylit)) go (L l (ExplicitTuple _ tup_args boxity)) -- Neither unboxed tuples (#e1,e2#) nor tuple sections (e1,,e2,) can be promoted | isBoxed boxity ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -37,8 +37,6 @@ import GHC.Hs import GHC.Hs.Syn.Type import GHC.Tc.Gen.HsType -import GHC.Rename.Unbound ( unknownNameSuggestions, WhatLooking(..) ) - import GHC.Tc.Gen.Bind( chooseInferredQuantifiers ) import GHC.Tc.Gen.Sig( tcUserTypeSig, tcInstSig ) import GHC.Tc.TyCl.PatSyn( patSynBuilderOcc ) @@ -78,12 +76,10 @@ import GHC.Builtin.Types( multiplicityTy ) import GHC.Builtin.Names import GHC.Builtin.Names.TH( liftStringName, liftName ) -import GHC.Driver.Env import GHC.Driver.DynFlags import GHC.Utils.Misc import GHC.Utils.Outputable as Outputable import GHC.Utils.Panic -import qualified GHC.LanguageExtensions as LangExt import GHC.Data.Maybe import Control.Monad @@ -1164,46 +1160,11 @@ tc_infer_id id_name AGlobal (AConLike (RealDataCon con)) -> tcInferDataCon con AGlobal (AConLike (PatSynCon ps)) -> tcInferPatSyn id_name ps - (tcTyThingTyCon_maybe -> Just tc) -> fail_tycon tc -- TyCon or TcTyCon - ATyVar name _ -> fail_tyvar name + (tcTyThingTyCon_maybe -> Just tc) -> failIllegalTyCon tc -- TyCon or TcTyCon + ATyVar name _ -> failIllegalTyVal name _ -> failWithTc $ TcRnExpectedValueId thing } where - fail_tycon tc = do - gre <- getGlobalRdrEnv - let nm = tyConName tc - pprov = case lookupGRE_Name gre nm of - Just gre -> nest 2 (pprNameProvenance gre) - Nothing -> empty - err | isClassTyCon tc = ClassTE - | otherwise = TyConTE - fail_with_msg dataName nm pprov err - - fail_tyvar nm = - let pprov = nest 2 (text "bound at" <+> ppr (getSrcLoc nm)) - in fail_with_msg varName nm pprov TyVarTE - - fail_with_msg whatName nm pprov err = do - (import_errs, hints) <- get_suggestions whatName - unit_state <- hsc_units <$> getTopEnv - let - -- TODO: unfortunate to have to convert to SDoc here. - -- This should go away once we refactor ErrInfo. - hint_msg = vcat $ map ppr hints - import_err_msg = vcat $ map ppr import_errs - info = ErrInfo { errInfoContext = pprov, errInfoSupplementary = import_err_msg $$ hint_msg } - failWithTc $ TcRnMessageWithInfo unit_state ( - mkDetailedMessage info (TcRnIllegalTermLevelUse nm err)) - - get_suggestions ns = do - required_type_arguments <- xoptM LangExt.RequiredTypeArguments - if required_type_arguments && isVarNameSpace ns - then return ([], []) -- See Note [Suppress hints with RequiredTypeArguments] - else do - let occ = mkOccNameFS ns (occNameFS (occName id_name)) - lcl_env <- getLocalRdrEnv - unknownNameSuggestions lcl_env WL_Anything (mkRdrUnqual occ) - return_id id = return (HsVar noExtField (noLocA id), idType id) {- Note [Suppress hints with RequiredTypeArguments] ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -73,7 +73,10 @@ module GHC.Tc.Gen.HsType ( HoleMode(..), -- Error messages - funAppCtxt, addTyConFlavCtxt + funAppCtxt, addTyConFlavCtxt, + + -- Utils + tyLitFromLit, tyLitFromOverloadedLit, ) where import GHC.Prelude hiding ( head, init, last, tail ) @@ -140,6 +143,7 @@ import qualified Data.List.NonEmpty as NE import Data.List ( mapAccumL ) import Control.Monad import Data.Tuple( swap ) +import GHC.Types.SourceText {- ---------------------------- @@ -4689,3 +4693,22 @@ addTyConFlavCtxt :: Name -> TyConFlavour tc -> TcM a -> TcM a addTyConFlavCtxt name flav = addErrCtxt $ hsep [ text "In the", ppr flav , text "declaration for", quotes (ppr name) ] + +{- +************************************************************************ +* * + Utils for constructing TyLit +* * +************************************************************************ +-} + + +tyLitFromLit :: HsLit GhcRn -> Maybe (HsTyLit GhcRn) +tyLitFromLit (HsString x str) = Just (HsStrTy x str) +tyLitFromLit (HsChar x char) = Just (HsCharTy x char) +tyLitFromLit _ = Nothing + +tyLitFromOverloadedLit :: OverLitVal -> Maybe (HsTyLit GhcRn) +tyLitFromOverloadedLit (HsIntegral n) = Just $ HsNumTy NoSourceText (il_value n) +tyLitFromOverloadedLit (HsIsString _ s) = Just $ HsStrTy NoSourceText s +tyLitFromOverloadedLit HsFractional{} = Nothing ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -504,6 +504,14 @@ tc_forall_pat tv _ pat thing_inside ; let pat' = XPat $ ExpansionPat pat (EmbTyPat arg_ty tp) ; return (pat', result) } +lpats_to_type_pats :: [LPat GhcRn] -> TcM (HsTyPatRn, [LHsType GhcRn]) +lpats_to_type_pats = foldr step nil where + nil = pure (mempty, []) + step pat acc = + do { HsTP x t <- pat_to_type_pat (unLoc pat) + ; (xs, tys) <- acc + ; pure (x `mappend` xs, t : tys) } + -- Convert a Pat into the equivalent HsTyPat. -- See `expr_to_type` (GHC.Tc.Gen.App) for the HsExpr counterpart. -- The `TcM` monad is only used to fail on ill-formed type patterns. @@ -539,6 +547,41 @@ pat_to_type_pat (ParPat _ pat) pat_to_type_pat (SplicePat (HsUntypedSpliceTop mod_finalizers pat) splice) = do { HsTP x t <- pat_to_type_pat pat ; return (HsTP x (noLocA (HsSpliceTy (HsUntypedSpliceTop mod_finalizers t) splice))) } + +pat_to_type_pat (TuplePat NoExtField pats Boxed) + = do { (x, tys) <- lpats_to_type_pats pats + ; let t = noLocA (HsExplicitTupleTy noExtField tys) + ; pure (HsTP x t) } +pat_to_type_pat (ListPat NoExtField pats) + = do { (x, tys) <- lpats_to_type_pats pats + ; let t = noLocA (HsExplicitListTy NoExtField NotPromoted tys) + ; pure (HsTP x t) } + +pat_to_type_pat (LitPat NoExtField lit) + | Just ty_lit <- tyLitFromLit lit + = do { let t = noLocA (HsTyLit noExtField ty_lit) + ; pure (HsTP mempty t) } +pat_to_type_pat (NPat _ (L _ lit) _ _) + | Just ty_lit <- tyLitFromOverloadedLit (ol_val lit) + = do { let t = noLocA (HsTyLit noExtField ty_lit) + ; pure (HsTP mempty t)} + +pat_to_type_pat (ConPat _ lname (InfixCon left right)) + = do { HsTP xl lty <- pat_to_type_pat (unLoc left) + ; HsTP xr rty <- pat_to_type_pat (unLoc right) + ; let { t = noLocA (HsOpTy noAnn NotPromoted lty lname rty)} + ; pure (HsTP (xl `mappend` xr) t) } +pat_to_type_pat (ConPat _ lname (PrefixCon invis_args vis_args)) + = do { let { appHead = noLocA (HsTyVar noAnn NotPromoted lname) + ; (HsTP x_invis ty_invis) = foldl' apply_invis_arg (HsTP mempty appHead) invis_args } + ; (x_vis, tys_vis) <- lpats_to_type_pats vis_args + ; let t = foldl' (\x y -> noLocA (HsAppTy noExtField x y)) ty_invis tys_vis + ; pure (HsTP (x_invis `mempty` x_vis) t) } + where + apply_invis_arg :: HsTyPat GhcRn -> HsConPatTyArg GhcRn -> HsTyPat GhcRn + apply_invis_arg (HsTP !hx !h) (HsConPatTyArg _ (HsTP argx arg)) + = HsTP (hx `mappend` argx) (noLocA (HsAppKindTy noExtField h arg)) + pat_to_type_pat pat = -- There are other cases to handle (ConPat, ListPat, TuplePat, etc), but these -- would always be rejected by the unification in `tcHsTyPat`, so it's fine to ===================================== compiler/GHC/Tc/Utils/Env.hs ===================================== @@ -28,6 +28,7 @@ module GHC.Tc.Utils.Env( tcLookupLocatedClass, tcLookupAxiom, lookupGlobal, lookupGlobal_maybe, addTypecheckedBinds, + failIllegalTyCon, failIllegalTyVal, -- Local environment tcExtendKindEnv, tcExtendKindEnvList, @@ -137,6 +138,7 @@ import Data.List ( intercalate ) import Control.Monad import GHC.Iface.Errors.Types import GHC.Types.Error +import GHC.Rename.Unbound ( unknownNameSuggestions, WhatLooking(..) ) {- ********************************************************************* * * @@ -278,6 +280,7 @@ tcLookupConLike name = do thing <- tcLookupGlobal name case thing of AConLike cl -> return cl + ATyCon tc -> failIllegalTyCon tc _ -> wrongThingErr WrongThingConLike (AGlobal thing) name tcLookupRecSelParent :: HsRecUpdParent GhcRn -> TcM RecSelParent @@ -349,6 +352,45 @@ tcGetInstEnvs = do { eps <- getEps instance MonadThings (IOEnv (Env TcGblEnv TcLclEnv)) where lookupThing = tcLookupGlobal +-- Illegal term-level use of type things +failIllegalTyCon :: TyCon -> TcM a +failIllegalTyVal :: Name -> TcM a +(failIllegalTyCon, failIllegalTyVal) = (fail_tycon, fail_tyvar) + where + fail_tycon tc = do + gre <- getGlobalRdrEnv + let nm = tyConName tc + pprov = case lookupGRE_Name gre nm of + Just gre -> nest 2 (pprNameProvenance gre) + Nothing -> empty + err | isClassTyCon tc = ClassTE + | otherwise = TyConTE + fail_with_msg dataName nm pprov err + + fail_tyvar nm = + let pprov = nest 2 (text "bound at" <+> ppr (getSrcLoc nm)) + in fail_with_msg varName nm pprov TyVarTE + + fail_with_msg whatName nm pprov err = do + (import_errs, hints) <- get_suggestions whatName nm + unit_state <- hsc_units <$> getTopEnv + let + -- TODO: unfortunate to have to convert to SDoc here. + -- This should go away once we refactor ErrInfo. + hint_msg = vcat $ map ppr hints + import_err_msg = vcat $ map ppr import_errs + info = ErrInfo { errInfoContext = pprov, errInfoSupplementary = import_err_msg $$ hint_msg } + failWithTc $ TcRnMessageWithInfo unit_state ( + mkDetailedMessage info (TcRnIllegalTermLevelUse nm err)) + + get_suggestions ns nm = do + required_type_arguments <- xoptM LangExt.RequiredTypeArguments + if required_type_arguments && isVarNameSpace ns + then return ([], []) -- See Note [Suppress hints with RequiredTypeArguments] + else do + let occ = mkOccNameFS ns (occNameFS (occName nm)) + lcl_env <- getLocalRdrEnv + unknownNameSuggestions lcl_env WL_Constructor (mkRdrUnqual occ) {- ************************************************************************ * * ===================================== testsuite/tests/rename/should_fail/T19843c.stderr ===================================== @@ -1,4 +1,7 @@ +T19843c.hs:6:6: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Map’ + • imported from ‘Data.Map’ at T19843c.hs:3:1-22 + (and originally defined in ‘Data.Map.Internal’) + • In the pattern: Map k v + In an equation for ‘foo’: foo (Map k v) = undefined -T19843c.hs:6:6: error: [GHC-76037] - Not in scope: data constructor ‘Map.Map’ - NB: the module ‘Data.Map’ does not export ‘Map’. ===================================== testsuite/tests/type-data/should_fail/TDPattern.stderr ===================================== @@ -1,3 +1,6 @@ +TDPattern.hs:7:3: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Zero’ + • defined at TDPattern.hs:4:17 + • In the pattern: Zero + In an equation for ‘f’: f Zero = 0 -TDPattern.hs:7:3: [GHC-76037] - Not in scope: data constructor ‘Zero’ ===================================== testsuite/tests/typecheck/should_compile/T23739a.hs ===================================== @@ -0,0 +1,49 @@ +{-# LANGUAGE TypeAbstractions, + ExplicitNamespaces, + RequiredTypeArguments, + DataKinds, + NoListTuplePuns, + OverloadedStrings #-} + +module T where + +import Data.Tuple.Experimental +import GHC.TypeLits + +f1 :: forall a -> a ~ (Int, Bool) => Unit +f1 (b,c) = () + +f2 :: forall a -> a ~ (Int : Bool : Double : []) => Unit +f2 [a,b,c] = () + +f3 :: forall a -> a ~ [Int, Bool, Double] => Unit +f3 [a,b,c] = () + +f4 :: forall a -> a ~ [Int, Bool, Double] => Unit +f4 (a : b : c : []) = () + +f5 :: forall a -> a ~ "blah" => Unit +f5 "blah" = () + +f6 :: forall a -> a ~ 'c' => Unit +f6 'c' = () + +f7 :: forall a -> a ~ UnconsSymbol "blah" => Unit +f7 (Just ('b', "lah")) = () + +f8 :: forall a -> Unit +f8 _ = () + +f9 :: forall a -> a ~ 42 => Unit +f9 42 = () + +f10 :: forall a -> a ~ () => Unit +f10 () = () + +f11 :: forall a -> a ~ Int => Unit +f11 Int = () + +data Tup a = MkTup a a + +f12 :: forall a -> a ~ (Int, MkTup 'f' 'g', 42, True, [1,2,3,4,5], (), "blah", "wombat", 'd', UnconsSymbol "corner") => Unit +f12 (Int, 'f' `MkTup` 'g', 42, True, 1 : 2 : 3 : [4,5], () ,"blah", x, 'd', Just ('c', "orner")) = () ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -915,3 +915,4 @@ test('WarnDefaultedExceptionContext', normal, compile, ['-Wdefaulted-exception-c test('T24470b', normal, compile, ['']) test('T24566', [], makefile_test, []) test('T23764', normal, compile, ['']) +test('T23739a', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T23739b.hs ===================================== @@ -0,0 +1,14 @@ + +module T23739b where + +import Data.Tuple.Experimental +import GHC.TypeLits + +g1 :: Int -> Unit +g1 Int = () + +g2 :: Int +g2 = Int{} + +g3 :: Int +g3 = Int ===================================== testsuite/tests/typecheck/should_fail/T23739b.stderr ===================================== @@ -0,0 +1,21 @@ +T23739b.hs:8:4: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Int’ + • imported from ‘Prelude’ at T23739b.hs:2:8-14 + (and originally defined in ‘GHC.Types’) + • In the pattern: Int + In an equation for ‘g1’: g1 Int = () + +T23739b.hs:11:6: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Int’ + • imported from ‘Prelude’ at T23739b.hs:2:8-14 + (and originally defined in ‘GHC.Types’) + • In the expression: Int {} + In an equation for ‘g2’: g2 = Int {} + +T23739b.hs:14:6: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Int’ + • imported from ‘Prelude’ at T23739b.hs:2:8-14 + (and originally defined in ‘GHC.Types’) + • In the expression: Int + In an equation for ‘g3’: g3 = Int + ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -725,4 +725,4 @@ test('T17594g', normal, compile_fail, ['']) test('T24470a', normal, compile_fail, ['']) test('T24553', normal, compile_fail, ['']) - +test('T23739b', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bce3ca671a6f6da6df207cb06b9a9b04c3d51f48 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bce3ca671a6f6da6df207cb06b9a9b04c3d51f48 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 17:38:13 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Thu, 02 May 2024 13:38:13 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/az/T24749-epa-comments-patsynsig Message-ID: <6633cf854fa2c_1a3d242bdbb48124516@gitlab.mail> Alan Zimmerman pushed new branch wip/az/T24749-epa-comments-patsynsig at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/T24749-epa-comments-patsynsig You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 17:55:54 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 02 May 2024 13:55:54 -0400 Subject: [Git][ghc/ghc][wip/andreask/late_workfree] 6 commits: ghc-bignum: remove obsolete ln script Message-ID: <6633d3aaceb5_1a3d242eb4568129255@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/late_workfree at Glasgow Haskell Compiler / GHC Commits: c62dc317 by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: remove obsolete ln script This commit removes an obsolete ln script in ghc-bignum/gmp. See 060251c24ad160264ae8553efecbb8bed2f06360 for its original intention, but it's been obsolete for a long time, especially since the removal of the make build system. Hence the house cleaning. - - - - - 6399d52b by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: update gmp to 6.3.0 This patch bumps the gmp-tarballs submodule and updates gmp to 6.3.0. The tarball format is now xz, and gmpsrc.patch has been patched into the tarball so hadrian no longer needs to deal with patching logic when building in-tree GMP. - - - - - 65b4b92f by Cheng Shao at 2024-04-25T01:32:02-04:00 hadrian: remove obsolete Patch logic This commit removes obsolete Patch logic from hadrian, given we no longer need to patch the gmp tarball when building in-tree GMP. - - - - - 71f28958 by Cheng Shao at 2024-04-25T01:32:02-04:00 autoconf: remove obsolete patch detection This commit removes obsolete deletection logic of the patch command from autoconf scripts, given we no longer need to patch anything in the GHC build process. - - - - - daeda834 by Sylvain Henry at 2024-04-25T01:32:43-04:00 JS: correctly handle RUBBISH literals (#24664) - - - - - dc1664c8 by Andreas Klebinger at 2024-05-02T19:55:17+02:00 -fprof-late: Only insert cost centres on functions/non-workfree cafs. They are usually useless and doing so for data values comes with a large compile time/code size overhead. Fixes #24103 - - - - - 17 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/LateCC.hs - compiler/GHC/Core/LateCC/TopLevelBinds.hs - compiler/GHC/Core/LateCC/Types.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/StgToJS/Literal.hs - compiler/GHC/Types/RepType.hs - configure.ac - docs/users_guide/9.12.1-notes.rst - docs/users_guide/profiling.rst - hadrian/cfg/system.config.in - hadrian/src/Builder.hs - hadrian/src/Rules/Gmp.hs - libraries/ghc-bignum/gmp/gmp-tarballs - − libraries/ghc-bignum/gmp/gmpsrc.patch - − libraries/ghc-bignum/gmp/ln Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -94,7 +94,7 @@ module GHC.Core ( import GHC.Prelude import GHC.Platform -import GHC.Types.Var.Env( InScopeSet ) +import GHC.Types.Var.Env( InScopeSet, emptyInScopeSet ) import GHC.Types.Var import GHC.Core.Type import GHC.Core.Coercion ===================================== compiler/GHC/Core/LateCC.hs ===================================== @@ -21,6 +21,7 @@ import GHC.Types.SrcLoc import GHC.Utils.Error import GHC.Utils.Logger import GHC.Utils.Outputable +import GHC.Types.RepType (mightBeFunTy) -- | Late cost center insertion logic used by the driver addLateCostCenters :: @@ -78,8 +79,11 @@ addLateCostCenters logger LateCCConfig{..} core_binds = do top_level_cc_pred :: CoreExpr -> Bool top_level_cc_pred = case lateCCConfig_whichBinds of - LateCCAllBinds -> - const True + LateCCBinds -> \rhs -> + -- Make sure we record any functions. Even if it's something like `f = g`. + mightBeFunTy (exprType rhs) || + -- If the RHS is a CAF doing work also insert a CC. + not (exprIsWorkFree rhs) LateCCOverloadedBinds -> isOverloadedTy . exprType LateCCNone -> ===================================== compiler/GHC/Core/LateCC/TopLevelBinds.hs ===================================== @@ -3,16 +3,18 @@ module GHC.Core.LateCC.TopLevelBinds where import GHC.Prelude -import GHC.Core --- import GHC.Core.LateCC import GHC.Core.LateCC.Types import GHC.Core.LateCC.Utils + +import GHC.Core import GHC.Core.Opt.Monad import GHC.Driver.DynFlags import GHC.Types.Id import GHC.Types.Name import GHC.Unit.Module.ModGuts +import Data.Maybe + {- Note [Collecting late cost centres] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Usually cost centres defined by a module are collected @@ -89,15 +91,20 @@ topLevelBindsCC pred core_bind = doBndr :: Id -> CoreExpr -> LateCCM s CoreExpr doBndr bndr rhs - -- Cost centres on constructor workers are pretty much useless - -- so we don't emit them if we are looking at the rhs of a constructor - -- binding. - | Just _ <- isDataConId_maybe bndr = pure rhs - | otherwise = if pred rhs then addCC bndr rhs else pure rhs + -- Not a constructor worker. + -- Cost centres on constructor workers are pretty much useless so we don't emit them + -- if we are looking at the rhs of a constructor binding. + | isNothing (isDataConId_maybe bndr) + , pred rhs + = addCC bndr rhs + | otherwise = pure rhs -- We want to put the cost centre below the lambda as we only care about - -- executions of the RHS. + -- executions of the RHS. Note that the lambdas might be hidden under ticks + -- or casts. So look through these as well. addCC :: Id -> CoreExpr -> LateCCM s CoreExpr + addCC bndr (Cast rhs co) = pure Cast <*> addCC bndr rhs <*> pure co + addCC bndr (Tick t rhs) = (Tick t) <$> addCC bndr rhs addCC bndr (Lam b rhs) = Lam b <$> addCC bndr rhs addCC bndr rhs = do let name = idName bndr ===================================== compiler/GHC/Core/LateCC/Types.hs ===================================== @@ -34,7 +34,7 @@ data LateCCConfig = -- | The types of top-level bindings we support adding cost centers to. data LateCCBindSpec = LateCCNone - | LateCCAllBinds + | LateCCBinds | LateCCOverloadedBinds -- | Late cost centre insertion environment ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -1954,6 +1954,8 @@ isPiTy ty = case coreFullView ty of _ -> False -- | Is this a function? +-- Note: `forall {b}. Show b => b -> IO b` will not be considered a function by this function. +-- It would merely be a forall wrapping a function type. isFunTy :: Type -> Bool isFunTy ty | FunTy {} <- coreFullView ty = True ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -1805,7 +1805,7 @@ hscGenHardCode hsc_env cgguts location output_filename = do if gopt Opt_ProfLateInlineCcs dflags then LateCCNone else if gopt Opt_ProfLateCcs dflags then - LateCCAllBinds + LateCCBinds else if gopt Opt_ProfLateOverloadedCcs dflags then LateCCOverloadedBinds else ===================================== compiler/GHC/StgToJS/Literal.hs ===================================== @@ -22,6 +22,7 @@ import GHC.StgToJS.Symbols import GHC.Data.FastString import GHC.Types.Literal import GHC.Types.Basic +import GHC.Types.RepType import GHC.Utils.Misc import GHC.Utils.Panic import GHC.Utils.Outputable @@ -68,7 +69,27 @@ genLit = \case | otherwise -> return [ toJExpr (global (mkRawSymbol True name)) , ValExpr (JInt 0) ] - LitRubbish {} -> return [ null_ ] + LitRubbish _ rr_ty -> + -- Generate appropriate rubbish literals, otherwise it might trip up the + -- code generator when a primop is applied to a rubbish literal (see #24664) + let reps = runtimeRepPrimRep (text "GHC.StgToJS.Literal.genLit") rr_ty + rub = \case + BoxedRep _ -> [ null_ ] + AddrRep -> [ null_, ValExpr (JInt 0) ] + WordRep -> [ ValExpr (JInt 0) ] + Word8Rep -> [ ValExpr (JInt 0) ] + Word16Rep -> [ ValExpr (JInt 0) ] + Word32Rep -> [ ValExpr (JInt 0) ] + Word64Rep -> [ ValExpr (JInt 0), ValExpr (JInt 0) ] + IntRep -> [ ValExpr (JInt 0) ] + Int8Rep -> [ ValExpr (JInt 0) ] + Int16Rep -> [ ValExpr (JInt 0) ] + Int32Rep -> [ ValExpr (JInt 0) ] + Int64Rep -> [ ValExpr (JInt 0), ValExpr (JInt 0) ] + DoubleRep -> [ ValExpr (JInt 0) ] + FloatRep -> [ ValExpr (JInt 0) ] + VecRep _ _ -> panic "GHC.StgToJS.Literal.genLit: VecRep unsupported" + in return (concatMap rub reps) -- | generate a literal for the static init tables genStaticLit :: Literal -> G [StaticLit] ===================================== compiler/GHC/Types/RepType.hs ===================================== @@ -693,6 +693,9 @@ mightBeFunTy :: Type -> Bool -- AK: It would be nice to figure out and document the difference -- between this and isFunTy at some point. mightBeFunTy ty + -- Currently ghc has no unlifted functions. + | definitelyUnliftedType ty + = False | [BoxedRep _] <- typePrimRep ty , Just tc <- tyConAppTyCon_maybe (unwrapType ty) , isDataTyCon tc ===================================== configure.ac ===================================== @@ -740,10 +740,6 @@ dnl ** check for tar dnl if GNU tar is named gtar, look for it first. AC_PATH_PROGS(TarCmd,gnutar gtar tar,tar) -dnl ** check for patch -dnl if GNU patch is named gpatch, look for it first -AC_PATH_PROGS(PatchCmd,gpatch patch, patch) - dnl ** check for autoreconf AC_PATH_PROG(AutoreconfCmd, autoreconf, autoreconf) ===================================== docs/users_guide/9.12.1-notes.rst ===================================== @@ -26,6 +26,16 @@ Language Compiler ~~~~~~~~ +- The flag `-fprof-late` will no longer prevent top level constructors from being statically allocated. + + It used to be the case that we would add a cost centre for bindings like `foo = Just bar`. + This turned the binding into a caf that would allocate the constructor on first evaluation. + + However without the cost centre `foo` can be allocated at compile time. This reduces code-bloat and + reduces overhead for short-running applications. + + The tradeoff is that calling `whoCreated` on top level value definitions like `foo` will be less informative. + GHCi ~~~~ ===================================== docs/users_guide/profiling.rst ===================================== @@ -483,10 +483,12 @@ of your profiled program will be different to that of the unprofiled one. :since: 9.4.1 - Adds an automatic ``SCC`` annotation to all top level bindings late in the compilation pipeline after - the optimizer has run and unfoldings have been created. This means these cost centres will not interfere with core-level optimizations + Adds an automatic ``SCC`` annotation to all top level bindings which might perform work. + This is done late in the compilation pipeline after the optimizer has run and unfoldings have been created. + This means these cost centres will not interfere with core-level optimizations and the resulting profile will be closer to the performance profile of an optimized non-profiled executable. + While the results of this are generally informative, some of the compiler internal names will leak into the profile. Further if a function is inlined into a use site it's costs will be counted against the caller's cost center. ===================================== hadrian/cfg/system.config.in ===================================== @@ -17,7 +17,6 @@ sphinx-build = @SPHINXBUILD@ system-ghc = @WithGhc@ system-ghc-pkg = @GhcPkgCmd@ tar = @TarCmd@ -patch = @PatchCmd@ xelatex = @XELATEX@ makeindex = @MAKEINDEX@ makeinfo = @MAKEINFO@ ===================================== hadrian/src/Builder.hs ===================================== @@ -8,10 +8,7 @@ module Builder ( -- * Builder properties builderProvenance, systemBuilderPath, builderPath, isSpecified, needBuilders, runBuilder, runBuilderWith, runBuilderWithCmdOptions, getBuilderPath, - builderEnvironment, - - -- * Ad hoc builder invocation - applyPatch + builderEnvironment ) where import Control.Exception.Extra (Partial) @@ -184,7 +181,6 @@ data Builder = Alex | MergeObjects Stage -- ^ linker to be used to merge object files. | Nm | Objdump - | Patch | Python | Ranlib | Testsuite TestMode @@ -443,7 +439,6 @@ systemBuilderPath builder = case builder of Makeinfo -> fromKey "makeinfo" Nm -> fromTargetTC "nm" (Toolchain.nmProgram . tgtNm) Objdump -> fromKey "objdump" - Patch -> fromKey "patch" Python -> fromKey "python" Ranlib -> fromTargetTC "ranlib" (maybeProg Toolchain.ranlibProgram . tgtRanlib) Testsuite _ -> fromKey "python" @@ -511,15 +506,6 @@ systemBuilderPath builder = case builder of isSpecified :: Builder -> Action Bool isSpecified = fmap (not . null) . systemBuilderPath --- | Apply a patch by executing the 'Patch' builder in a given directory. -applyPatch :: FilePath -> FilePath -> Action () -applyPatch dir patch = do - let file = dir -/- patch - needBuilders [Patch] - path <- builderPath Patch - putBuild $ "| Apply patch " ++ file - quietly $ cmd' [Cwd dir, FileStdin file] [path, "-p0"] - -- Note [cmd wrapper] -- ~~~~~~~~~~~~~~~~~~ -- `cmd'` is a wrapper for Shake's `cmd` that allows us to customize what is ===================================== hadrian/src/Rules/Gmp.hs ===================================== @@ -143,23 +143,18 @@ gmpRules = do gmpP = takeDirectory gmpBuildP ctx <- makeGmpPathContext gmpP removeDirectory gmpBuildP - -- Note: We use a tarball like gmp-4.2.4-nodoc.tar.bz2, which is - -- gmp-4.2.4.tar.bz2 repacked without the doc/ directory contents. + -- Note: We use a tarball like gmp-4.2.4-nodoc.tar.xz, which is + -- gmp-4.2.4.tar.xz repacked without the doc/ directory contents. -- That's because the doc/ directory contents are under the GFDL, -- which causes problems for Debian. tarball <- unifyPath . fromSingleton "Exactly one GMP tarball is expected" - <$> getDirectoryFiles top [gmpBase -/- "gmp-tarballs/gmp*.tar.bz2"] + <$> getDirectoryFiles top [gmpBase -/- "gmp-tarballs/gmp*.tar.xz"] withTempDir $ \dir -> do let tmp = unifyPath dir need [top -/- tarball] build $ target ctx (Tar Extract) [top -/- tarball] [tmp] - let patch = gmpBase -/- "gmpsrc.patch" - patchName = takeFileName patch - copyFile patch $ tmp -/- patchName - applyPatch tmp patchName - let name = dropExtension . dropExtension $ takeFileName tarball unpack = fromMaybe . error $ "gmpRules: expected suffix " ++ "-nodoc (found: " ++ name ++ ")." ===================================== libraries/ghc-bignum/gmp/gmp-tarballs ===================================== @@ -1 +1 @@ -Subproject commit 4f26049af40afb380eaf033ab91404cd2e214919 +Subproject commit 01149ce3471128e9fe0feca607579981f4b64395 ===================================== libraries/ghc-bignum/gmp/gmpsrc.patch deleted ===================================== @@ -1,44 +0,0 @@ -diff -Naur gmp-6.2.1/Makefile.am gmpbuild/Makefile.am ---- gmp-6.2.1/Makefile.am 2020-11-15 02:45:09.000000000 +0800 -+++ gmpbuild/Makefile.am 2021-01-09 22:56:14.571708858 +0800 -@@ -112,7 +112,7 @@ - LIBGMPXX_LT_AGE = 6 - - --SUBDIRS = tests mpn mpz mpq mpf printf scanf rand cxx demos tune doc -+SUBDIRS = tests mpn mpz mpq mpf printf scanf rand cxx demos tune - - EXTRA_DIST = configfsf.guess configfsf.sub .gdbinit INSTALL.autoconf \ - COPYING.LESSERv3 COPYINGv2 COPYINGv3 -diff -Naur gmp-6.2.1/Makefile.in gmpbuild/Makefile.in ---- gmp-6.2.1/Makefile.in 2020-11-15 02:45:16.000000000 +0800 -+++ gmpbuild/Makefile.in 2021-01-10 16:15:37.387670402 +0800 -@@ -572,7 +572,7 @@ - LIBGMPXX_LT_CURRENT = 10 - LIBGMPXX_LT_REVISION = 1 - LIBGMPXX_LT_AGE = 6 --SUBDIRS = tests mpn mpz mpq mpf printf scanf rand cxx demos tune doc -+SUBDIRS = tests mpn mpz mpq mpf printf scanf rand cxx demos tune - - # Put asl.h here for now. - -diff -Naur gmp-6.2.1/configure gmpbuild/configure ---- gmp-6.2.1/configure 2020-11-15 02:45:15.000000000 +0800 -+++ gmpbuild/configure 2021-01-10 16:13:59.196004951 +0800 -@@ -27985,7 +27985,7 @@ - # FIXME: Upcoming version of autoconf/automake may not like broken lines. - # Right now automake isn't accepting the new AC_CONFIG_FILES scheme. - --ac_config_files="$ac_config_files Makefile mpf/Makefile mpn/Makefile mpq/Makefile mpz/Makefile printf/Makefile scanf/Makefile rand/Makefile cxx/Makefile tests/Makefile tests/devel/Makefile tests/mpf/Makefile tests/mpn/Makefile tests/mpq/Makefile tests/mpz/Makefile tests/rand/Makefile tests/misc/Makefile tests/cxx/Makefile doc/Makefile tune/Makefile demos/Makefile demos/calc/Makefile demos/expr/Makefile gmp.h:gmp-h.in gmp.pc:gmp.pc.in gmpxx.pc:gmpxx.pc.in" -+ac_config_files="$ac_config_files Makefile mpf/Makefile mpn/Makefile mpq/Makefile mpz/Makefile printf/Makefile scanf/Makefile rand/Makefile cxx/Makefile tests/Makefile tests/devel/Makefile tests/mpf/Makefile tests/mpn/Makefile tests/mpq/Makefile tests/mpz/Makefile tests/rand/Makefile tests/misc/Makefile tests/cxx/Makefile tune/Makefile demos/Makefile demos/calc/Makefile demos/expr/Makefile gmp.h:gmp-h.in gmp.pc:gmp.pc.in gmpxx.pc:gmpxx.pc.in" - - cat >confcache <<\_ACEOF - # This file is a shell script that caches the results of configure -@@ -29129,7 +29129,6 @@ - "tests/rand/Makefile") CONFIG_FILES="$CONFIG_FILES tests/rand/Makefile" ;; - "tests/misc/Makefile") CONFIG_FILES="$CONFIG_FILES tests/misc/Makefile" ;; - "tests/cxx/Makefile") CONFIG_FILES="$CONFIG_FILES tests/cxx/Makefile" ;; -- "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; - "tune/Makefile") CONFIG_FILES="$CONFIG_FILES tune/Makefile" ;; - "demos/Makefile") CONFIG_FILES="$CONFIG_FILES demos/Makefile" ;; - "demos/calc/Makefile") CONFIG_FILES="$CONFIG_FILES demos/calc/Makefile" ;; ===================================== libraries/ghc-bignum/gmp/ln deleted ===================================== @@ -1,3 +0,0 @@ -#!/bin/sh -exit 1 - View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5171a4e4abb06730367b47834761be9bf830d761...dc1664c88cee8bddbcee911ea991492e7d19ed31 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5171a4e4abb06730367b47834761be9bf830d761...dc1664c88cee8bddbcee911ea991492e7d19ed31 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 18:13:31 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Thu, 02 May 2024 14:13:31 -0400 Subject: [Git][ghc/ghc][wip/romes/egraphs-pmc-2] 19 commits: Add e-graphs submodule (hegg) Message-ID: <6633d7cbe71e1_1a3d24316ffc8131332@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/egraphs-pmc-2 at Glasgow Haskell Compiler / GHC Commits: 7176c8f5 by Rodrigo Mesquita at 2023-10-31T16:56:04+00:00 Add e-graphs submodule (hegg) - - - - - 1f669af4 by Rodrigo Mesquita at 2023-10-31T16:56:05+00:00 Create Core.Equality module This module defines CoreExprF -- the base functor of CoreExpr, and equality and ordering operations on the debruijnized CoreExprF. Furthermore, it provides a function to represent a CoreExpr in an e-graph. This is a requirement to represent, reason about equality, and manipulate CoreExprs in e-graphs. E-graphs are going to be used in the pattern match checker (#19272), and potentially for type family rewriting (#TODO) -- amongst other oportunities that are unlocked by having them available. - - - - - 8397368f by Rodrigo Mesquita at 2023-10-31T16:56:05+00:00 Drop GHC.Types.Unique.SDFM in favour of e-graphs - - - - - 014285e7 by Rodrigo Mesquita at 2023-10-31T16:56:05+00:00 The rest of the owl - - - - - b14510a1 by Rodrigo Mesquita at 2023-10-31T16:56:05+00:00 Drawing of multiple owls - - - - - 80946d3c by Rodrigo Mesquita at 2023-10-31T16:56:05+00:00 Keep drawing - - - - - e7fd39f3 by Rodrigo Mesquita at 2023-10-31T16:56:05+00:00 WIP MORE - - - - - 8fcb5cff by Rodrigo Mesquita at 2023-10-31T16:56:05+00:00 WIP ALMOST - - - - - b8786444 by Rodrigo Mesquita at 2023-10-31T16:56:05+00:00 WIP... - - - - - 67836a67 by Rodrigo Mesquita at 2023-10-31T16:56:05+00:00 WIP.; - - - - - 460cf336 by Rodrigo Mesquita at 2023-10-31T16:56:06+00:00 whitsepac - - - - - 2664f641 by Rodrigo Mesquita at 2023-10-31T16:56:06+00:00 Ww - - - - - 1fd37591 by Rodrigo Mesquita at 2023-10-31T16:56:06+00:00 Better Outputable instance - - - - - 86bb09f7 by Rodrigo Mesquita at 2023-10-31T16:56:06+00:00 mergeNotConCt can't use implications only now...? - - - - - aba1488f by Rodrigo Mesquita at 2023-10-31T16:56:06+00:00 Sometimes we can omit implied nalts - - - - - 67027c8d by Rodrigo Mesquita at 2023-10-31T16:56:06+00:00 Fixes + debugging - - - - - 5b097a0c by Rodrigo Mesquita at 2023-10-31T16:56:06+00:00 STAGE 1 BUILDS WITHOUT FAILURES. - - - - - c23d98db by Rodrigo Mesquita at 2023-10-31T16:56:30+00:00 depstest - - - - - af60b03e by Rodrigo Mesquita at 2024-05-02T19:12:46+01:00 submodule update - - - - - 17 changed files: - .gitmodules - + TODO - compiler/GHC/Core.hs - + compiler/GHC/Core/Equality.hs - compiler/GHC/Core/Map/Expr.hs - compiler/GHC/Core/Map/Type.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/HsToCore/Pmc/Solver.hs - compiler/GHC/HsToCore/Pmc/Solver/Types.hs - − compiler/GHC/Types/Unique/SDFM.hs - compiler/ghc.cabal.in - hadrian/src/Packages.hs - hadrian/src/Rules/ToolArgs.hs - hadrian/src/Settings/Default.hs - + libraries/hegg - packages - testsuite/tests/count-deps/CountDepsParser.stdout Changes: ===================================== .gitmodules ===================================== @@ -117,3 +117,6 @@ [submodule "utils/hpc"] path = utils/hpc url = https://gitlab.haskell.org/hpc/hpc-bin.git +[submodule "libraries/hegg"] + path = libraries/hegg + url = https://github.com/alt-romes/hegg.git ===================================== TODO ===================================== @@ -0,0 +1,9 @@ +The current failures might be because congruence isn't being maintained properly downwards, I think...? +Instead, we might do this manually for merging positive constructor info in the e-graphs analysis modify function? + +If this works, the major todos are +* Propagating strictness annotations to underlying newtypes (likely modify analysis) +* Clean up equality + * How to do Ord Type? +* Clean up solver + * Merge args of data cons when merging by congruence (likely modify analysis as well) ===================================== compiler/GHC/Core.hs ===================================== @@ -294,6 +294,7 @@ data AltCon -- The instance adheres to the order described in Note [Case expression invariants] instance Ord AltCon where compare (DataAlt con1) (DataAlt con2) = + -- ROMES:TODO: Couldn't simply do this right by comparing the dataConName of the cons? assert (dataConTyCon con1 == dataConTyCon con2) $ compare (dataConTag con1) (dataConTag con2) compare (DataAlt _) _ = GT ===================================== compiler/GHC/Core/Equality.hs ===================================== @@ -0,0 +1,188 @@ +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE DerivingVia #-} + +-- TODO: Rename to GHC.HsToCore.CoreEquality or something +module GHC.Core.Equality where + +import GHC.Prelude + +-- import GHC.Types.Name (Name) +import GHC.Core +import GHC.Core.DataCon +import GHC.Core.TyCo.Rep +import GHC.Core.Map.Type +import GHC.Types.Var +import GHC.Types.Literal + +import Data.Equality.Graph as EG +import Data.Equality.Analysis.Monadic +import qualified Data.Equality.Graph.Monad as EGM +import GHC.Utils.Outputable +import GHC.Core.Coercion (coercionType) + +import Control.Monad.Trans.Class +import Control.Monad.Trans.Reader + +-- Important to note the binders are also represented by $a$ +-- This is because in the e-graph we will represent binders with the +-- equivalence class id of things equivalent to it. +-- +-- Unfortunately type binders are still not correctly accounted for. +-- Perhaps it'd really be better to make DeBruijn work over these types + +-- In the pattern match checker, expressions will always be kind of shallow. +-- In practice, no-one writes gigantic lambda expressions in guards and view patterns + +data AltF a + = AltF AltCon' [()] a -- [()] tells us the number of constructors..., bad representation TODO + deriving (Functor, Foldable, Traversable, Eq, Ord) + +data BindF a + = NonRecF a + | RecF [a] + deriving (Functor, Foldable, Traversable, Eq, Ord, Show) + +type BoundVar = Int +-- If we use this datatype specifically for representing HsToCore.Pmc, we may +-- be able to drop the coercion field, and add a specific one for constructor +-- application +data ExprF r + = VarF BoundVar + -- ROMES:TODO: what about using Names for comparison? Since this is only for equality purposes... + -- It makes it possible to use the ConLikeName as the FreeVar Name, since there is conLikeName for PmAltConLike + | FreeVarF Id + | LitF Literal + | AppF r r + | LamF r + | LetF (BindF r) r + | CaseF r [AltF r] -- can we drop the case type for expr equality? we don't need them back, we just need to check equality. (perhaps this specialization makes this more suitable in the Pmc namespace) + + -- | CastF a (DeBruijn CoercionR) -- can we drop this + -- | TickF CoreTickish a -- this, when representing expressions for equality? + -- but it'll be pretty hard to trigger any bug related to equality matching wrt coercions and casts on view and guard patterns solely + | TypeF DBType + | CoercionF DBCoercion + deriving (Functor, Foldable, Traversable, Eq, Ord) + +newtype DBType = DBT (DeBruijn Type) deriving Eq +instance Ord DBType where + compare (DBT dt) (DBT dt') = cmpDeBruijnType dt dt' +newtype DBCoercion = DBC (DeBruijn Coercion) deriving Eq +instance Ord DBCoercion where + compare (DBC dt) (DBC dt') = cmpDeBruijnCoercion dt dt' + +newtype AltCon' = AC' AltCon deriving Eq + deriving Outputable via AltCon + +instance Ord AltCon' where + compare (AC' (DataAlt a)) (AC' (DataAlt b)) + = case compare (dataConName a) (dataConName b) of + LT -> LT + EQ -> compare (DataAlt a) (DataAlt b) -- AltCon's Ord instance only works for same datatypes + GT -> GT + compare (AC' a) (AC' b) = compare a b + +-- this makes perfect sense, if we already have to represent this in the e-graph +-- we might as well make it a better suited representation for the e-graph... +-- keeping the on-fly debruijn is harder +representCoreExprEgr :: forall a m + . Analysis m a CoreExprF + => CoreExpr + -> EGraph a CoreExprF + -> m (ClassId, EGraph a CoreExprF) +representCoreExprEgr expr egr = EGM.runEGraphMT egr (runReaderT (go expr) emptyCME) where + go :: CoreExpr -> ReaderT CmEnv (EGM.EGraphMT a CoreExprF m) ClassId + go = \case + Var v -> do + env <- ask + case lookupCME env v of + -- Nothing -> addE (FreeVarF $ varName v) + Nothing -> addE (FreeVarF v) + Just i -> addE (VarF i) + Lit lit -> addE (LitF lit) + Type t -> addE (TypeF (DBT $ deBruijnize t)) + Coercion c -> addE (CoercionF (DBC $ deBruijnize c)) + Tick _ e -> go e -- bypass ticks! + Cast e _ -> go e -- bypass casts! ouch? TODO + App f a -> do + f' <- go f + a' <- go a + addE (AppF f' a') + Lam b e -> do + e' <- local (`extendCME` b) $ go e + addE (LamF e') + Let (NonRec v r) e -> do + r' <- go r + e' <- local (`extendCME` v) $ go e + addE (LetF (NonRecF r') e') + Let (Rec (unzip -> (bs,rs))) e -> do + rs' <- traverse (local (`extendCMEs` bs) . go) rs + e' <- local (`extendCMEs` bs) $ go e + addE (LetF (RecF rs') e') + Case e b _t as -> do + e' <- go e + as' <- traverse (local (`extendCME` b) . goAlt) as + addE (CaseF e' as') + + goAlt :: CoreAlt -> ReaderT CmEnv (EGM.EGraphMT a CoreExprF m) (CoreAltF ClassId) + goAlt (Alt c bs e) = do + e' <- local (`extendCMEs` bs) $ go e + return (AltF (AC' c) (map (const ()) bs) e') + + addE :: Analysis m a CoreExprF => CoreExprF ClassId -> ReaderT CmEnv (EGM.EGraphMT a CoreExprF m) ClassId + addE e = lift $ EGM.addM $ Node e +{-# INLINEABLE representCoreExprEgr #-} + +type CoreExprF = ExprF +type CoreAltF = AltF +type CoreBindF = BindF + +instance Outputable (EG.ENode CoreExprF) where + ppr (EG.Node n) = text (show n) + +-- cmpDeBruijnTickish :: DeBruijn CoreTickish -> DeBruijn CoreTickish -> Ordering +-- cmpDeBruijnTickish (D env1 t1) (D env2 t2) = go t1 t2 where +-- go (Breakpoint lext lid lids _) (Breakpoint rext rid rids _) +-- = case compare lid rid of +-- LT -> LT +-- EQ -> case compare (D env1 lids) (D env2 rids) of +-- LT -> LT +-- EQ -> compare lext rext +-- GT -> GT +-- GT -> GT +-- go l r = compare l r + +cmpDeBruijnType :: DeBruijn Type -> DeBruijn Type -> Ordering +cmpDeBruijnType d1@(D _ t1) d2@(D _ t2) + = if eqDeBruijnType d1 d2 + then EQ + -- ROMES:TODO: This definitely does not look OK. + -- ROMES:TODO: This hurts performance a lot (50% of regression is basically this) + else compare (showPprUnsafe t1) (showPprUnsafe t2) + +cmpDeBruijnCoercion :: DeBruijn Coercion -> DeBruijn Coercion -> Ordering +cmpDeBruijnCoercion (D env1 co1) (D env2 co2) + = cmpDeBruijnType (D env1 (coercionType co1)) (D env2 (coercionType co2)) + +-- -- instances for debugging purposes +instance Show a => Show (CoreExprF a) where + show (VarF id) = showPprUnsafe $ text "VarF" <+> ppr id + show (FreeVarF id) = showPprUnsafe $ ppr id + show (LitF lit) = showPprUnsafe $ text "LitF" <+> ppr lit + show (AppF a b) = "AppF " ++ show a ++ " " ++ show b + show (LamF a) = "LamF " ++ show a + show (LetF b a) = "LetF " ++ show b ++ " " ++ show a + show (CaseF a alts) = "CaseF " ++ show a ++ show alts + + -- show (CastF _a _cor) = "CastF" + -- show (TickF _cotick _a) = "Tick" + show (TypeF (DBT (D _ t))) = "TypeF " ++ showPprUnsafe (ppr t) + show (CoercionF (DBC (D _ co))) = "CoercionF " ++ showPprUnsafe co + +instance Show a => Show (AltF a) where + show (AltF alt bs a) = "AltF " ++ showPprUnsafe (ppr alt <+> ppr bs) ++ show a + ===================================== compiler/GHC/Core/Map/Expr.hs ===================================== @@ -18,6 +18,8 @@ module GHC.Core.Map.Expr ( CoreMap, emptyCoreMap, extendCoreMap, lookupCoreMap, foldCoreMap, -- * Alpha equality eqDeBruijnExpr, eqCoreExpr, + -- ** Exports for CoreExprF instances + eqDeBruijnTickish, eqDeBruijnVar, -- * 'TrieMap' class reexports TrieMap(..), insertTM, deleteTM, lkDFreeVar, xtDFreeVar, ===================================== compiler/GHC/Core/Map/Type.hs ===================================== @@ -6,6 +6,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE DeriveTraversable #-} module GHC.Core.Map.Type ( -- * Re-export generic interface @@ -22,6 +23,7 @@ module GHC.Core.Map.Type ( TypeMapG, CoercionMapG, DeBruijn(..), deBruijnize, eqDeBruijnType, eqDeBruijnVar, + cmpDeBruijnVar, BndrMap, xtBndr, lkBndr, VarMap, xtVar, lkVar, lkDFreeVar, xtDFreeVar, @@ -282,6 +284,9 @@ eqDeBruijnType env_t1@(D env1 t1) env_t2@(D env2 t2) = instance Eq (DeBruijn Var) where (==) = eqDeBruijnVar +instance Ord (DeBruijn Var) where + compare = cmpDeBruijnVar + eqDeBruijnVar :: DeBruijn Var -> DeBruijn Var -> Bool eqDeBruijnVar (D env1 v1) (D env2 v2) = case (lookupCME env1 v1, lookupCME env2 v2) of @@ -289,6 +294,13 @@ eqDeBruijnVar (D env1 v1) (D env2 v2) = (Nothing, Nothing) -> v1 == v2 _ -> False +cmpDeBruijnVar :: DeBruijn Var -> DeBruijn Var -> Ordering +cmpDeBruijnVar (D env1 v1) (D env2 v2) = + case (lookupCME env1 v1, lookupCME env2 v2) of + (Just b1, Just b2) -> compare b1 b2 + (Nothing, Nothing) -> compare v1 v2 + (z,w) -> compare z w -- Compare Maybes on whether they're Just or Nothing + instance {-# OVERLAPPING #-} Outputable a => Outputable (TypeMapG a) where ppr m = text "TypeMap elts" <+> ppr (foldTM (:) m []) @@ -512,6 +524,7 @@ lookupCME (CME { cme_env = env }) v = lookupVarEnv env v -- export the constructor. Make a helper function if you find yourself -- needing it. data DeBruijn a = D CmEnv a + deriving (Functor, Foldable, Traversable) -- romes:TODO: for internal use only! -- | Synthesizes a @DeBruijn a@ from an @a@, by assuming that there are no -- bound binders (an empty 'CmEnv'). This is usually what you want if there @@ -525,6 +538,15 @@ instance Eq (DeBruijn a) => Eq (DeBruijn [a]) where D env xs == D env' xs' _ == _ = False +instance Ord (DeBruijn a) => Ord (DeBruijn [a]) where + D _ [] `compare` D _ [] = EQ + D env (x:xs) `compare` D env' (x':xs') = case D env x `compare` D env' x' of + LT -> LT + EQ -> D env xs `compare` D env' xs' + GT -> GT + D _ [] `compare` D _ (_:_) = LT + D _ (_:_) `compare` D _ [] = GT + instance Eq (DeBruijn a) => Eq (DeBruijn (Maybe a)) where D _ Nothing == D _ Nothing = True D env (Just x) == D env' (Just x') = D env x == D env' x' ===================================== compiler/GHC/HsToCore/Pmc.hs ===================================== @@ -278,7 +278,6 @@ pmcRecSel _ _ = return () {- Note [pmcPatBind doesn't warn on pattern guards] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @pmcPatBind@'s main purpose is to check vanilla pattern bindings, like ->>>>>>> 8760510af3 (This MR is an implementation of the proposal #516.) @x :: Int; Just x = e@, which is in a @PatBindRhs@ context. But its caller is also called for individual pattern guards in a @StmtCtxt at . For example, both pattern guards in @f x y | True <- x, False <- y = ...@ will ===================================== compiler/GHC/HsToCore/Pmc/Solver.hs ===================================== @@ -1,6 +1,13 @@ -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE TupleSections #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE MultiWayIf #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE RankNTypes, GADTs #-} +{-# OPTIONS_GHC -Wno-orphans #-} -- Analysis........ {- Authors: George Karachalias @@ -48,22 +55,22 @@ import GHC.Data.Bag import GHC.Types.CompleteMatch import GHC.Types.Unique.Set import GHC.Types.Unique.DSet -import GHC.Types.Unique.SDFM import GHC.Types.Id import GHC.Types.Name import GHC.Types.Var (EvVar) import GHC.Types.Var.Env -import GHC.Types.Var.Set import GHC.Types.Unique.Supply import GHC.Core +import GHC.Core.Equality import GHC.Core.FVs (exprFreeVars) import GHC.Core.TyCo.Compare( eqType ) -import GHC.Core.Map.Expr +import GHC.Core.Map.Type (deBruijnize) import GHC.Core.Predicate (typeDeterminesValue) import GHC.Core.SimpleOpt (simpleOptExpr, exprIsConApp_maybe) import GHC.Core.Utils (exprType) -import GHC.Core.Make (mkListExpr, mkCharExpr, mkImpossibleExpr) +import GHC.Core.Make (mkListExpr, mkCharExpr, mkImpossibleExpr, mkCoreApp) +import GHC.Types.Id.Make (unboxedUnitExpr) import GHC.Data.FastString import GHC.Types.SrcLoc @@ -97,6 +104,14 @@ import Data.List (sortBy, find) import qualified Data.List.NonEmpty as NE import Data.Ord (comparing) +import Data.Equality.Analysis.Monadic +import Data.Equality.Graph (ClassId) +import Data.Equality.Graph.Lens +import qualified Data.Equality.Graph as EG +import qualified Data.Equality.Graph.Monad as EGM +import Data.Function ((&)) +import qualified Data.IntSet as IS + -- -- * Main exports -- @@ -602,8 +617,10 @@ addPhiCts :: Nabla -> PhiCts -> DsM (Maybe Nabla) -- See Note [TmState invariants]. addPhiCts nabla cts = runMaybeT $ do let (ty_cts, tm_cts) = partitionPhiCts cts - nabla' <- addTyCts nabla (listToBag ty_cts) + nabla' <- addTyCts nabla (listToBag ty_cts) nabla'' <- foldlM addPhiTmCt nabla' (listToBag tm_cts) + lift $ tracePm "addPhiCts, doing inhabitationTest" (ppr nabla'') + -- ROMES:TODO: Should the ty_st be nabla' or nabla'' !? inhabitationTest initFuel (nabla_ty_st nabla) nabla'' partitionPhiCts :: PhiCts -> ([PredType], [PhiCt]) @@ -666,7 +683,7 @@ addPhiTmCt nabla (PhiConCt x con tvs dicts args) = do -- PhiConCt correspond to the higher-level φ constraints from the paper with -- bindings semantics. It disperses into lower-level δ constraints that the -- 'add*Ct' functions correspond to. - nabla' <- addTyCts nabla (listToBag dicts) + nabla' <- addTyCts nabla (listToBag dicts) nabla'' <- addConCt nabla' x con tvs args foldlM addNotBotCt nabla'' (filterUnliftedFields con args) addPhiTmCt nabla (PhiNotConCt x con) = addNotConCt nabla x con @@ -682,33 +699,68 @@ filterUnliftedFields con args = -- surely diverges. Quite similar to 'addConCt', only that it only cares about -- ⊥. addBotCt :: Nabla -> Id -> MaybeT DsM Nabla -addBotCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ ts_facts=env } } x = do - let (y, vi at VI { vi_bot = bot }) = lookupVarInfoNT (nabla_tm_st nabla) x - case bot of - IsNotBot -> mzero -- There was x ≁ ⊥. Contradiction! - IsBot -> pure nabla -- There already is x ~ ⊥. Nothing left to do - MaybeBot -- We add x ~ ⊥ - | definitelyUnliftedType (idType x) - -- Case (3) in Note [Strict fields and variables of unlifted type] - -> mzero -- unlifted vars can never be ⊥ - | otherwise - -> do - let vi' = vi{ vi_bot = IsBot } - pure nabla{ nabla_tm_st = ts{ts_facts = addToUSDFM env y vi' } } +addBotCt nabla0 at MkNabla{nabla_tm_st = ts0} x = do + let (y, vi at VI { vi_bot = bot0 }) = lookupVarInfoNT ts0 x + -- NOTE FOR REVIEWER: + -- we were previously using the idType of |x|, but I think it should rather + -- be |y|, since, if y /= x, then x is a newtype and newtypes cannot be + -- unlifted + bot1 <- mergeBots (idType y) IsBot bot0 + let vi' = vi{ vi_bot = bot1 } + + (yid, nabla1) <- representId y nabla0 + + pure (nabla1 & nabla_egr._class yid._data .~ Just vi') -- | Adds the constraint @x ~/ ⊥@ to 'Nabla'. Quite similar to 'addNotConCt', -- but only cares for the ⊥ "constructor". addNotBotCt :: Nabla -> Id -> MaybeT DsM Nabla -addNotBotCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ts_facts=env} } x = do - let (y, vi at VI { vi_bot = bot }) = lookupVarInfoNT (nabla_tm_st nabla) x - case bot of - IsBot -> mzero -- There was x ~ ⊥. Contradiction! - IsNotBot -> pure nabla -- There already is x ≁ ⊥. Nothing left to do - MaybeBot -> do -- We add x ≁ ⊥ and test if x is still inhabited - -- Mark dirty for a delayed inhabitation test - let vi' = vi{ vi_bot = IsNotBot} - pure $ markDirty y - $ nabla{ nabla_tm_st = ts{ ts_facts = addToUSDFM env y vi' } } +addNotBotCt nabla0 at MkNabla{ nabla_tm_st = ts0 } x = do + let (y, vi at VI { vi_bot = bot0 }) = lookupVarInfoNT ts0 x + bot1 <- mergeBots (idType y) IsNotBot bot0 + let vi' = vi{ vi_bot = bot1 } + + (yid, nabla1) <- representId y nabla0 + let + marked + = case bot0 of + -- Mark dirty for a delayed inhabitation test (see comment in 'mergeBots' as well) + MaybeBot -> markDirty y + _ -> id + return $ + marked + (nabla1 & nabla_egr._class yid._data .~ Just vi') + +mergeBots :: Type + -- ^ The type of the pattern whose 'BotInfo's are being merged + -> BotInfo + -> BotInfo + -> MaybeT DsM BotInfo +-- There already is x ~ ⊥. Nothing left to do +mergeBots _ IsBot IsBot = pure IsBot +-- There was x ≁ ⊥. Contradiction! +mergeBots _ IsBot IsNotBot = mzero +-- We add x ~ ⊥ +mergeBots t IsBot MaybeBot + | definitelyUnliftedType t + -- Case (3) in Note [Strict fields and variables of unlifted type] + -- (unlifted vars can never be ⊥) + = mzero + | otherwise + = pure IsBot +-- There was x ~ ⊥. Contradiction! +mergeBots _ IsNotBot IsBot = mzero +-- There already is x ≁ ⊥. Nothing left to do +mergeBots _ IsNotBot IsNotBot = pure IsNotBot +-- We add x ≁ ⊥ and will need to test if x is still inhabited (see addNotBotCt) +-- romes:todo: We don't have the dirty set in the e-graph, so +-- congruence-fueled merging won't mark anything as dirty... hmm... +mergeBots _ IsNotBot MaybeBot = pure IsNotBot +-- Commutativity of 'mergeBots', +-- and trivially merging MaybeBots +mergeBots x MaybeBot IsBot = mergeBots x IsBot MaybeBot +mergeBots x MaybeBot IsNotBot = mergeBots x IsNotBot MaybeBot +mergeBots _ MaybeBot MaybeBot = pure MaybeBot -- | Record a @x ~/ K@ constraint, e.g. that a particular 'Id' @x@ can't -- take the shape of a 'PmAltCon' @K@ in the 'Nabla' and return @Nothing@ if @@ -717,41 +769,44 @@ addNotBotCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ts_facts=env} } x = do addNotConCt :: Nabla -> Id -> PmAltCon -> MaybeT DsM Nabla addNotConCt _ _ (PmAltConLike (RealDataCon dc)) | isNewDataCon dc = mzero -- (3) in Note [Coverage checking Newtype matches] -addNotConCt nabla x nalt = do - (mb_mark_dirty, nabla') <- trvVarInfo go nabla x +addNotConCt nabla0 x nalt = do + (xid, nabla1) <- representId x nabla0 + (mb_mark_dirty, nabla2) <- trvVarInfo (`mergeNotConCt` nalt) nabla1 (xid, x) pure $ case mb_mark_dirty of - Just x -> markDirty x nabla' - Nothing -> nabla' - where - -- Update `x`'s 'VarInfo' entry. Fail ('MaybeT') if contradiction, - -- otherwise return updated entry and `Just x'` if `x` should be marked dirty, - -- where `x'` is the representative of `x`. - go :: VarInfo -> MaybeT DsM (Maybe Id, VarInfo) - go vi@(VI x' pos neg _ rcm) = do - -- 1. Bail out quickly when nalt contradicts a solution - let contradicts nalt sol = eqPmAltCon (paca_con sol) nalt == Equal - guard (not (any (contradicts nalt) pos)) - -- 2. Only record the new fact when it's not already implied by one of the - -- solutions - let implies nalt sol = eqPmAltCon (paca_con sol) nalt == Disjoint - let neg' - | any (implies nalt) pos = neg - -- See Note [Completeness checking with required Thetas] - | hasRequiredTheta nalt = neg - | otherwise = extendPmAltConSet neg nalt - massert (isPmAltConMatchStrict nalt) - let vi' = vi{ vi_neg = neg', vi_bot = IsNotBot } - -- 3. Make sure there's at least one other possible constructor - mb_rcm' <- lift (markMatched nalt rcm) - pure $ case mb_rcm' of - -- If nalt could be removed from a COMPLETE set, we'll get back Just and - -- have to mark x dirty, by returning Just x'. - Just rcm' -> (Just x', vi'{ vi_rcm = rcm' }) - -- Otherwise, nalt didn't occur in any residual COMPLETE set and we - -- don't have to mark it dirty. So we return Nothing, which in the case - -- above would have compromised precision. - -- See Note [Shortcutting the inhabitation test], grep for T17836. - Nothing -> (Nothing, vi') + Just x -> markDirty x nabla2 + Nothing -> nabla2 + +-- Update `x`'s 'VarInfo' entry. Fail ('MaybeT') if contradiction, +-- otherwise return updated entry and `Just x'` if `x` should be marked dirty, +-- where `x'` is the representative of `x`. +mergeNotConCt :: VarInfo -> PmAltCon -> MaybeT DsM (Maybe Id, VarInfo) +mergeNotConCt vi@(VI x' pos neg _ rcm) nalt = do + lift $ tracePm "mergeNotConCt vi nalt" (ppr vi <+> ppr nalt) + -- 1. Bail out quickly when nalt contradicts a solution + let contradicts nalt sol = eqPmAltCon (paca_con sol) nalt == Equal + guard (not (any (contradicts nalt) pos)) + -- 2. Only record the new fact when it's not already implied by one of the + -- solutions + let implies nalt sol = eqPmAltCon (paca_con sol) nalt == Disjoint + let neg' + | any (implies nalt) pos = neg + -- See Note [Completeness checking with required Thetas] + | hasRequiredTheta nalt = neg + | otherwise = extendPmAltConSet neg nalt + massert (isPmAltConMatchStrict nalt) + let vi' = vi{ vi_neg = neg', vi_bot = IsNotBot } + -- 3. Make sure there's at least one other possible constructor + mb_rcm' <- lift (markMatched nalt rcm) + lift $ tracePm "mergeNotConCt vi' (no upd. rcm)" (ppr vi') + pure $ case mb_rcm' of + -- If nalt could be removed from a COMPLETE set, we'll get back Just and + -- have to mark x dirty, by returning Just x'. + Just rcm' -> (Just x', vi'{ vi_rcm = rcm' }) + -- Otherwise, nalt didn't occur in any residual COMPLETE set and we + -- don't have to mark it dirty. So we return Nothing, which in the case + -- above would have compromised precision. + -- See Note [Shortcutting the inhabitation test], grep for T17836. + Nothing -> (Nothing, vi') hasRequiredTheta :: PmAltCon -> Bool hasRequiredTheta (PmAltConLike cl) = notNull req_theta @@ -759,6 +814,10 @@ hasRequiredTheta (PmAltConLike cl) = notNull req_theta (_,_,_,_,req_theta,_,_) = conLikeFullSig cl hasRequiredTheta _ = False +-- | Worth making a lens from Nabla to EGraph, to make changing data operations much easier +nabla_egr :: Functor f => (TmEGraph -> f TmEGraph) -> (Nabla -> f Nabla) +nabla_egr f (MkNabla tyst ts at TmSt{ts_facts=egr}) = (\egr' -> MkNabla tyst ts{ts_facts=egr'}) <$> f egr + -- | Add a @x ~ K tvs args ts@ constraint. -- @addConCt x K tvs args ts@ extends the substitution with a solution -- @x :-> (K, tvs, args)@ if compatible with the negative and positive info we @@ -766,8 +825,42 @@ hasRequiredTheta _ = False -- -- See Note [TmState invariants]. addConCt :: Nabla -> Id -> PmAltCon -> [TyVar] -> [Id] -> MaybeT DsM Nabla -addConCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ ts_facts=env } } x alt tvs args = do - let vi@(VI _ pos neg bot _) = lookupVarInfo ts x +addConCt nabla0 x alt tvs args = do + (xid, nabla1) <- representId x nabla0 + let vi_x = lookupVarInfo (nabla_tm_st nabla1) x + (kid, nabla2) <- fromMaybe (xid, nabla1) <$> representPattern vi_x alt tvs args nabla1 -- VarInfo contains K data in pos info + let k_vi = (emptyVarInfo x){vi_pos=[PACA alt tvs args]} + + nabla3 <- case (alt, args) of + (PmAltConLike (RealDataCon dc), [y]) | isNewDataCon dc -> do + (_yid, nabla3) <- representId y nabla2 + + -- A newtype con and the underlying var are in the same e-class + -- nabla4 <- mergeVarIds xid yid nabla3 + + -- Return the nabla3 and set the k_vi unchanged + pure (nabla3 & nabla_egr._class kid._data .~ Just k_vi) + + -- If the merging y and N y thing works, we won't need this. + -- (UPDT: It didn't work (looped, i Think. Try uncommenting that line above). + -- That means we're not currently moving the strictness information from the NT pattern to the underlying variable. + -- We need to.) + -- Also, if we do that manually here, that means we won't add strictness + -- annotations to underlying NT representatives if merging is done by + -- congruence instead of by manually calling 'addConCt' + -- case bot of + -- MaybeBot -> pure (nabla_with MaybeBot) + -- IsBot -> addBotCt (nabla_with IsBot) y + -- IsNotBot -> addNotBotCt (nabla_with IsNotBot) y + + _ -> assert (isPmAltConMatchStrict alt) + -- Return the nabla2 and set the k_vi with additional IsNotBot info + pure (nabla2 & nabla_egr._class kid._data .~ Just k_vi{vi_bot=IsNotBot}) -- strict match ==> not ⊥ + + mergeVarIds xid kid nabla3 + +mergeConCt :: VarInfo -> PmAltConApp -> StateT TyState (MaybeT DsM) VarInfo +mergeConCt vi@(VI _ pos neg _bot _) paca@(PACA alt tvs _args) = StateT $ \tyst -> do -- First try to refute with a negative fact guard (not (elemPmAltConSet alt neg)) -- Then see if any of the other solutions (remember: each of them is an @@ -777,25 +870,19 @@ addConCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ ts_facts=env } } x alt tvs args = -- Now we should be good! Add (alt, tvs, args) as a possible solution, or -- refine an existing one case find ((== Equal) . eqPmAltCon alt . paca_con) pos of - Just (PACA _con other_tvs other_args) -> do + Just (PACA _con other_tvs _other_args) -> do -- We must unify existentially bound ty vars and arguments! + -- + -- The arguments are handled automatically by representing K in + -- the e-class...! all equivalent things will be merged. + -- + -- So we treat the ty vars: let ty_cts = equateTys (map mkTyVarTy tvs) (map mkTyVarTy other_tvs) - nabla' <- MaybeT $ addPhiCts nabla (listToBag ty_cts) - let add_var_ct nabla (a, b) = addVarCt nabla a b - foldlM add_var_ct nabla' $ zipEqual "addConCt" args other_args + tyst' <- MaybeT (tyOracle tyst (listToBag $ map (\case (PhiTyCt pred) -> pred; _ -> error "impossible") ty_cts)) + return (vi, tyst') -- All good, and we get no new term information. Nothing -> do - let pos' = PACA alt tvs args : pos - let nabla_with bot' = - nabla{ nabla_tm_st = ts{ts_facts = addToUSDFM env x (vi{vi_pos = pos', vi_bot = bot'})} } - -- Do (2) in Note [Coverage checking Newtype matches] - case (alt, args) of - (PmAltConLike (RealDataCon dc), [y]) | isNewDataCon dc -> - case bot of - MaybeBot -> pure (nabla_with MaybeBot) - IsBot -> addBotCt (nabla_with MaybeBot) y - IsNotBot -> addNotBotCt (nabla_with MaybeBot) y - _ -> assert (isPmAltConMatchStrict alt ) - pure (nabla_with IsNotBot) -- strict match ==> not ⊥ + -- Add new con info + return (vi{vi_pos = paca:pos}, tyst) equateTys :: [Type] -> [Type] -> [PhiCt] equateTys ts us = @@ -815,18 +902,22 @@ equateTys ts us = -- -- See Note [TmState invariants]. addVarCt :: Nabla -> Id -> Id -> MaybeT DsM Nabla -addVarCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ ts_facts = env } } x y = - case equateUSDFM env x y of - (Nothing, env') -> pure (nabla{ nabla_tm_st = ts{ ts_facts = env' } }) - -- Add the constraints we had for x to y - (Just vi_x, env') -> do - let nabla_equated = nabla{ nabla_tm_st = ts{ts_facts = env'} } - -- and then gradually merge every positive fact we have on x into y - let add_pos nabla (PACA cl tvs args) = addConCt nabla y cl tvs args - nabla_pos <- foldlM add_pos nabla_equated (vi_pos vi_x) - -- Do the same for negative info - let add_neg nabla nalt = addNotConCt nabla y nalt - foldlM add_neg nabla_pos (pmAltConSetElems (vi_neg vi_x)) +addVarCt nabla0 x y = do + + -- We'd really rather ([xid, yid], nabla1) <- representIds [x,y] nabla0, but that's not exhaustive... + ((xid, yid), nabla1) + <- runStateT ((,) <$> StateT (representId x) <*> StateT (representId y)) nabla0 + + mergeVarIds xid yid nabla1 + +mergeVarIds :: ClassId -> ClassId -> Nabla -> MaybeT DsM Nabla +mergeVarIds xid yid (MkNabla tyst0 (TmSt egr0 is)) = do + + -- @merge env x y@ makes @x@ and @y@ point to the same entry, + -- thereby merging @x@'s class with @y@'s. + (egr1, tyst1) <- runStateT (EG.mergeM xid yid egr0 >>= EG.rebuildM . snd) tyst0 + + return (MkNabla tyst1 (TmSt egr1 is)) -- | Inspects a 'PmCoreCt' @let x = e@ by recording constraints for @x@ based -- on the shape of the 'CoreExpr' @e at . Examples: @@ -894,9 +985,11 @@ addCoreCt nabla x e = do -- @x ~ y at . equate_with_similar_expr :: Id -> CoreExpr -> StateT Nabla (MaybeT DsM) () equate_with_similar_expr x e = do - rep <- StateT $ \nabla -> lift (representCoreExpr nabla e) + rep <- StateT $ \nabla -> representCoreExpr nabla e -- Note that @rep == x@ if we encountered @e@ for the first time. - modifyT (\nabla -> addVarCt nabla x rep) + modifyT (\nabla0 -> do + (xid, nabla1) <- representId x nabla0 + mergeVarIds xid rep nabla1) bind_expr :: CoreExpr -> StateT Nabla (MaybeT DsM) Id bind_expr e = do @@ -951,14 +1044,13 @@ modifyT f = StateT $ fmap ((,) ()) . f -- Which is the @x@ of a @let x = e'@ constraint (with @e@ semantically -- equivalent to @e'@) we encountered earlier, or a fresh identifier if -- there weren't any such constraints. -representCoreExpr :: Nabla -> CoreExpr -> DsM (Id, Nabla) -representCoreExpr nabla at MkNabla{ nabla_tm_st = ts at TmSt{ ts_reps = reps } } e - | Just rep <- lookupCoreMap reps key = pure (rep, nabla) - | otherwise = do - rep <- mkPmId (exprType e) - let reps' = extendCoreMap reps key rep - let nabla' = nabla{ nabla_tm_st = ts{ ts_reps = reps' } } - pure (rep, nabla') +representCoreExpr :: Nabla -> CoreExpr -> MaybeT DsM (ClassId, Nabla) +representCoreExpr (MkNabla tyst ts at TmSt{ ts_facts = egraph }) e = do + ((xid, egr''), tysty') <- (`runStateT` tyst) $ do + (xid, egr') <- representCoreExprEgr key egraph + egr'' <- EG.rebuildM egr' + return (xid, egr'') + return (xid, MkNabla tysty' ts{ts_facts = egr''}) where key = makeDictsCoherent e -- Use a key in which dictionaries for the same type become equal. @@ -969,6 +1061,8 @@ representCoreExpr nabla at MkNabla{ nabla_tm_st = ts at TmSt{ ts_reps = reps } } e -- are considered equal when building a 'CoreMap'. -- -- See Note [Unique dictionaries in the TmOracle CoreMap] +-- ROMES:TODO: I suppose this should be taken into account by the Eq instance of DeBruijnF CoreExprF +-- if we do that there then we're sure that EG.represent takes that into account. makeDictsCoherent :: CoreExpr -> CoreExpr makeDictsCoherent var@(Var v) | let ty = idType v @@ -1271,21 +1365,30 @@ tyStateRefined a b = ty_st_n a /= ty_st_n b markDirty :: Id -> Nabla -> Nabla markDirty x nabla at MkNabla{nabla_tm_st = ts at TmSt{ts_dirty = dirty} } = - nabla{ nabla_tm_st = ts{ ts_dirty = extendDVarSet dirty x } } + case lookupId ts x of + Nothing -> error "Marking as dirty an Id that is not represented in the Nabla" + Just xid -> + nabla{ nabla_tm_st = ts{ ts_dirty = IS.insert xid dirty } } traverseDirty :: Monad m => (VarInfo -> m VarInfo) -> TmState -> m TmState traverseDirty f ts at TmSt{ts_facts = env, ts_dirty = dirty} = - go (uniqDSetToList dirty) env + go (IS.elems dirty) env where go [] env = pure ts{ts_facts=env} - go (x:xs) !env = do - vi' <- f (lookupVarInfo ts x) - go xs (addToUSDFM env x vi') + go (xid:xs) !env = do + vi' <- f' (env ^._class xid._data) + go xs (env & _class xid._data .~ vi') + + f' Nothing = pure Nothing + f' (Just x) = Just <$> f x traverseAll :: Monad m => (VarInfo -> m VarInfo) -> TmState -> m TmState traverseAll f ts at TmSt{ts_facts = env} = do - env' <- traverseUSDFM f env + env' <- (_classes._data) f' env pure ts{ts_facts = env'} + where + f' Nothing = pure Nothing + f' (Just x) = Just <$> f x -- | Makes sure the given 'Nabla' is still inhabited, by trying to instantiate -- all dirty variables (or all variables when the 'TyState' changed) to concrete @@ -1296,48 +1399,50 @@ traverseAll f ts at TmSt{ts_facts = env} = do inhabitationTest :: Int -> TyState -> Nabla -> MaybeT DsM Nabla inhabitationTest 0 _ nabla = pure nabla inhabitationTest fuel old_ty_st nabla at MkNabla{ nabla_tm_st = ts } = {-# SCC "inhabitationTest" #-} do - -- lift $ tracePm "inhabitation test" $ vcat - -- [ ppr fuel - -- , ppr old_ty_st - -- , ppr nabla - -- , text "tyStateRefined:" <+> ppr (tyStateRefined old_ty_st (nabla_ty_st nabla)) - -- ] + lift $ tracePm "inhabitation test" $ vcat + [ ppr fuel + , ppr old_ty_st + , ppr nabla + , text "tyStateRefined:" <+> ppr (tyStateRefined old_ty_st (nabla_ty_st nabla)) + ] -- When type state didn't change, we only need to traverse dirty VarInfos ts' <- if tyStateRefined old_ty_st (nabla_ty_st nabla) then traverseAll test_one ts else traverseDirty test_one ts - pure nabla{ nabla_tm_st = ts'{ts_dirty=emptyDVarSet}} + pure nabla{ nabla_tm_st = ts'{ts_dirty=IS.empty}} where - nabla_not_dirty = nabla{ nabla_tm_st = ts{ts_dirty=emptyDVarSet} } + nabla_not_dirty = nabla{ nabla_tm_st = ts{ts_dirty=IS.empty} } test_one :: VarInfo -> MaybeT DsM VarInfo - test_one vi = + test_one vi = do lift (varNeedsTesting old_ty_st nabla vi) >>= \case True -> do - -- lift $ tracePm "test_one" (ppr vi) + lift $ tracePm "test_one" (ppr vi) -- No solution yet and needs testing -- We have to test with a Nabla where all dirty bits are cleared instantiate (fuel-1) nabla_not_dirty vi - _ -> pure vi + _ -> do + lift $ tracePm "test_one needs no testing" (ppr vi) + pure vi -- | Checks whether the given 'VarInfo' needs to be tested for inhabitants. -- Returns `False` when we can skip the inhabitation test, presuming it would -- say "yes" anyway. See Note [Shortcutting the inhabitation test]. varNeedsTesting :: TyState -> Nabla -> VarInfo -> DsM Bool -varNeedsTesting _ MkNabla{nabla_tm_st=tm_st} vi - | elemDVarSet (vi_id vi) (ts_dirty tm_st) = pure True -varNeedsTesting _ _ vi - | notNull (vi_pos vi) = pure False -varNeedsTesting old_ty_st MkNabla{nabla_ty_st=new_ty_st} _ - -- Same type state => still inhabited - | not (tyStateRefined old_ty_st new_ty_st) = pure False -varNeedsTesting old_ty_st MkNabla{nabla_ty_st=new_ty_st} vi = do - -- These normalisations are relatively expensive, but still better than having - -- to perform a full inhabitation test - (_, _, old_norm_ty) <- tntrGuts <$> pmTopNormaliseType old_ty_st (idType $ vi_id vi) - (_, _, new_norm_ty) <- tntrGuts <$> pmTopNormaliseType new_ty_st (idType $ vi_id vi) - if old_norm_ty `eqType` new_norm_ty - then pure False - else pure True +varNeedsTesting old_ty_st n at MkNabla{nabla_ty_st=new_ty_st,nabla_tm_st=tm_st} vi + = do + Just (xid, _) <- runMaybeT $ representId (vi_id vi) n + if | IS.member xid (IS.map (`EG.find` ts_facts tm_st) $ ts_dirty tm_st) -> pure True + | notNull (vi_pos vi) -> pure False + -- Same type state => still inhabited + | not (tyStateRefined old_ty_st new_ty_st) -> pure False + -- These normalisations are relatively expensive, but still better than having + -- to perform a full inhabitation test + | otherwise -> do + (_, _, old_norm_ty) <- tntrGuts <$> pmTopNormaliseType old_ty_st (idType $ vi_id vi) + (_, _, new_norm_ty) <- tntrGuts <$> pmTopNormaliseType new_ty_st (idType $ vi_id vi) + if old_norm_ty `eqType` new_norm_ty + then pure False + else pure True -- | Returns (Just vi) if at least one member of each ConLike in the COMPLETE -- set satisfies the oracle @@ -1358,8 +1463,10 @@ instBot _fuel nabla vi = {-# SCC "instBot" #-} do pure vi addNormalisedTypeMatches :: Nabla -> Id -> DsM (ResidualCompleteMatches, Nabla) -addNormalisedTypeMatches nabla at MkNabla{ nabla_ty_st = ty_st } x - = trvVarInfo add_matches nabla x +addNormalisedTypeMatches nabla at MkNabla{ nabla_ty_st = ty_st, nabla_tm_st = ts } x + = case lookupId ts x of + Just xid -> trvVarInfo add_matches nabla (xid, x) + Nothing -> error "An Id with a VarInfo (see call site) is not represented in the e-graph..." where add_matches vi at VI{ vi_rcm = rcm } -- important common case, shaving down allocations of PmSeriesG by -5% @@ -2080,3 +2187,135 @@ Note that for -XEmptyCase, we don't want to emit a minimal cover. We arrange that by passing 'CaseSplitTopLevel' to 'generateInhabitingPatterns'. We detect the -XEmptyCase case in 'reportWarnings' by looking for 'ReportEmptyCase'. -} + +------------------------------------------------ +-- * E-graphs for pattern match checking + +representPattern :: VarInfo + -- ^ Var info of e-class in which this pattern is going to be represented... + -- The things we are doing with this should rather be done as + -- an e-graph analysis modify to "downwards" merge in the e-graph the sub-nodes + -- A bit weird that the e-graph doesn't do this, but it seems like it doesn't... (see egraphs zulip discussion) + -> PmAltCon -> [TyVar] -> [Id] -> Nabla -> MaybeT DsM (Maybe (ClassId, Nabla)) +-- We don't need to do anything in the case of PmAltLit. +-- The Constructor information is recorded in the positive info e-class +-- it is represented in, so when we merge we take care of handling this +-- equality right. +-- If we did this even more ideally, we'd just represent PmAltLit in the e-graph and it would fail on merge without having to edit the e-class. +-- Wait, is it even safe to edit the e-class? Won't that *NOT* trigger the merging?? +-- Here I suppose we're creating the e-class. So we can add information at will. When we eventually merge this class with another one, we can do things. +-- But we could definitely check whether the information we're adding isn't colliding with the existing one. +representPattern _ (PmAltLit _) _ _ _ = return Nothing + -- We might need represent patterns alongside expressions -- then we can use the "real" equality instances for the patterns (e.g. eqPmLit) +representPattern (VI _ pos _ _ _) alt@(PmAltConLike conLike) tvs args nab00 = do + (args', nab01) <- representIds args nab00 + + -- rOMES: It is very akward that this is being done here... perhaps it would be best as a modify method in the analysis + -- it certainly won't work for things we learn by congruence... + MkNabla tyst0 ts at TmSt{ts_facts=egr0} <- + case find ((== Equal) . eqPmAltCon alt . paca_con) pos of + Just (PACA _con _other_tvs other_args) -> do + let add_var_ct nabla (a, b) = addVarCt nabla a b + foldlM add_var_ct nab01 $ zipEqual "addConCt" args other_args + Nothing -> pure nab01 + + ((cid, egr1), tyst1) <- (`runStateT` tyst0) $ EGM.runEGraphMT egr0 $ do + -- We must represent the constructor application in the e-graph to make + -- sure the children are recursively merged against other children of + -- other constructors represneted in the same e-class. + -- We need to represent the constructor correctly to ensure existing + -- constructors match or not the new one + -- dsHsConLike basically implements the logic we want. + -- ROMES:TODO: Nevermind, the dsHsConLike won't work because we want to + -- talk about pattern synonyms in their "matching" form, and converting + -- them with dsHsConLike assumes they are used as a constructor, + -- meaning we will fail for unidirectional patterns + desugaredCon <- lift . lift . lift $ ds_hs_con_like_pat conLike -- DsM action to desugar the conlike into the expression we'll represent for this constructor + conLikeId <- StateT $ representCoreExprEgr desugaredCon + tvs' <- mapM (EGM.addM . EG.Node . TypeF . DBT . deBruijnize . TyVarTy) tvs -- ugh... + foldlM (\acc i -> EGM.addM (EG.Node $ AppF acc i)) conLikeId (tvs' ++ args') + return (Just (cid, MkNabla tyst1 ts{ts_facts=egr1})) + where + -- TODO: do something cleaner than the following inlined thing... + + -- We inlined dsHsConLike but use patSynMatcher instead of patSynBuilder + ds_hs_con_like_pat :: ConLike -> DsM CoreExpr + ds_hs_con_like_pat (RealDataCon dc) + = return (varToCoreExpr (dataConWrapId dc)) + ds_hs_con_like_pat (PatSynCon ps) + | (builder_name, _, add_void) <- patSynMatcher ps + = do { builder_id <- dsLookupGlobalId builder_name + ; return (if add_void + then mkCoreApp (text "dsConLike" <+> ppr ps) + (Var builder_id) unboxedUnitExpr + else Var builder_id) } + +representId :: Id -> Nabla -> MaybeT DsM (ClassId, Nabla) +representId x (MkNabla tyst tmst at TmSt{ts_facts=eg0}) + = do + ((xid, tmst'),tyst') <- (`runStateT` tyst) $ do + (xid, eg1) <- EG.addM (EG.Node (FreeVarF x)) eg0 + eg2 <- EG.rebuildM eg1 -- why do this here? I guess a good place as any, and should be cheap anyway (workload is not something like eqsat) + return (xid, tmst{ts_facts=eg2}) + return (xid, MkNabla tyst' tmst') + +representIds :: [Id] -> Nabla -> MaybeT DsM ([ClassId], Nabla) +representIds xs = runStateT (mapM (StateT . representId) xs) + +-- There are too many cycles for this to be in Solver.Types... +-- We need the TyState to check insoluble constraints while merging VarInfos +instance Analysis (StateT TyState (MaybeT DsM)) (Maybe VarInfo) ExprF where + {-# INLINE makeA #-} + + -- When an e-class is created for a variable, we create an VarInfo from it. + -- It doesn't matter if this variable is bound or free, since it's the first + -- variable in this e-class (and all others would have to be equivalent to + -- it) + -- + -- Also, the Eq instance for DeBruijn Vars will ensure that two free + -- variables with the same Id are equal and so they will be represented in + -- the same e-class + -- + -- It would be good if we didn't do this always... It might be a bit expensive + makeA (FreeVarF x) = pure $ Just $ emptyVarInfo x + makeA _ = pure $ Nothing + + joinA Nothing Nothing = pure $ Nothing + joinA Nothing (Just b) = pure $ Just b + joinA (Just a) Nothing = pure $ Just a + + -- Merge the 'VarInfo's from @x@ and @y@ + joinA (Just vi_x at VI{ vi_id=_id_x + , vi_pos=pos_x + , vi_neg=neg_x + , vi_bot=bot_x + , vi_rcm=_rcm_x + }) + (Just vi_y) = do + lift . lift $ tracePm "merging vi_x and vi_y" (ppr vi_x <+> ppr vi_y) + -- If we can merge x ~ N y with y too, then we no longer need to worry + -- about propagating the bottomness information, since it will always be + -- right... though I'm not sure if that would be correct + + -- Gradually merge every positive fact we have on x into y + -- The args are merged by congruence, since we represent the + -- constructor in the e-graph in addConCt. + vi_res1 <- foldlM mergeConCt vi_y pos_x + + -- Do the same for negative info + let add_neg vi nalt = lift $ snd <$> mergeNotConCt vi nalt + vi_res2 <- foldlM add_neg vi_res1 (pmAltConSetElems neg_x) + + -- We previously were not merging the bottom information, but now we do. + -- TODO: We don't need to do it yet if we are only trying to be as good as before, but not better + -- Although it might not be so simple if we consider one of the classes is a newtype? + -- (No, I think that situation can occur) + bot_res <- lift $ + mergeBots (idType (vi_id vi_res2)) + bot_x (vi_bot vi_y) + let vi_res3 = vi_res2{vi_bot = bot_res} + + lift . lift $ tracePm "result of merging vi_x and vi_y" (ppr vi_res3) + return (Just vi_res3) + + ===================================== compiler/GHC/HsToCore/Pmc/Solver/Types.hs ===================================== @@ -1,7 +1,11 @@ {-# LANGUAGE ApplicativeDo #-} +{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE MultiWayIf #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeApplications #-} -- | Domain types used in "GHC.HsToCore.Pmc.Solver". -- The ultimate goal is to define 'Nabla', which models normalised refinement @@ -10,13 +14,16 @@ module GHC.HsToCore.Pmc.Solver.Types ( -- * Normalised refinement types - BotInfo(..), PmAltConApp(..), VarInfo(..), TmState(..), TyState(..), - Nabla(..), Nablas(..), initNablas, + BotInfo(..), PmAltConApp(..), VarInfo(..), TmState(..), TyState(..), TmEGraph, + Nabla(..), Nablas(..), initNablas, emptyVarInfo, lookupRefuts, lookupSolution, -- ** Looking up 'VarInfo' lookupVarInfo, lookupVarInfoNT, trvVarInfo, + -- *** Looking up 'ClassId' + lookupId, + -- ** Caching residual COMPLETE sets CompleteMatch, ResidualCompleteMatches(..), getRcm, isRcmInitialised, @@ -42,9 +49,7 @@ import GHC.Prelude import GHC.Data.Bag import GHC.Data.FastString import GHC.Types.Id -import GHC.Types.Var.Set import GHC.Types.Unique.DSet -import GHC.Types.Unique.SDFM import GHC.Types.Name import GHC.Core.DataCon import GHC.Core.ConLike @@ -58,7 +63,6 @@ import GHC.Core.TyCon import GHC.Types.Literal import GHC.Core import GHC.Core.TyCo.Compare( eqType ) -import GHC.Core.Map.Expr import GHC.Core.Utils (exprType) import GHC.Builtin.Names import GHC.Builtin.Types @@ -75,6 +79,18 @@ import Data.Ratio import GHC.Real (Ratio(..)) import qualified Data.Semigroup as Semi +import GHC.Core.Equality +import Data.Functor.Const +import Data.Functor.Compose +import Data.Equality.Graph (EGraph, ClassId) +import Data.Equality.Graph.Lens +import qualified Data.Equality.Graph.Nodes as EGN +import qualified Data.Equality.Graph as EG +import qualified Data.Equality.Graph.Internal as EGI +import Data.IntSet (IntSet) +import qualified Data.IntSet as IS (empty, toList) +import Data.Bifunctor (second) + -- import GHC.Driver.Ppr -- @@ -138,14 +154,12 @@ initTyState = TySt 0 emptyInert -- See Note [TmState invariants] in "GHC.HsToCore.Pmc.Solver". data TmState = TmSt - { ts_facts :: !(UniqSDFM Id VarInfo) - -- ^ Facts about term variables. Deterministic env, so that we generate - -- deterministic error messages. - , ts_reps :: !(CoreMap Id) - -- ^ An environment for looking up whether we already encountered semantically - -- equivalent expressions that we want to represent by the same 'Id' - -- representative. - , ts_dirty :: !DIdSet + { ts_facts :: !TmEGraph + -- ^ Facts about term variables. + + -- ROMES:TODO: ts_dirty looks a bit to me like the bookkeeping done by the + -- analysis rebuilding mechanism, so perhaps we can get rid of it too + , ts_dirty :: !IntSet -- ^ Which 'VarInfo' needs to be checked for inhabitants because of new -- negative constraints (e.g. @x ≁ ⊥@ or @x ≁ K@). } @@ -161,6 +175,7 @@ data VarInfo { vi_id :: !Id -- ^ The 'Id' in question. Important for adding new constraints relative to -- this 'VarInfo' when we don't easily have the 'Id' available. + -- ROMES:TODO: Do we still need this? , vi_pos :: ![PmAltConApp] -- ^ Positive info: 'PmAltCon' apps it is (i.e. @x ~ [Just y, PatSyn z]@), all @@ -168,7 +183,7 @@ data VarInfo -- pattern matches involving pattern synonym -- case x of { Just y -> case x of PatSyn z -> ... } -- However, no more than one RealDataCon in the list, otherwise contradiction - -- because of generativity. + -- because of generativity (which would violate Invariant 1 from the paper). , vi_neg :: !PmAltConSet -- ^ Negative info: A list of 'PmAltCon's that it cannot match. @@ -227,7 +242,13 @@ instance Outputable BotInfo where -- | Not user-facing. instance Outputable TmState where - ppr (TmSt state reps dirty) = ppr state $$ ppr reps $$ ppr dirty + ppr (TmSt state dirty) = + (vcat $ getConst $ _iclasses (\(i,cl) -> Const [ppr i <> text ":" <+> ppr cl]) state) + $$ ppr (IS.toList dirty) + + +instance Outputable (EG.EClass (Maybe VarInfo) CoreExprF) where + ppr cl = ppr (cl^._nodes) $$ ppr (cl^._data) -- | Not user-facing. instance Outputable VarInfo where @@ -248,7 +269,7 @@ instance Outputable VarInfo where -- | Initial state of the term oracle. initTmState :: TmState -initTmState = TmSt emptyUSDFM emptyCoreMap emptyDVarSet +initTmState = TmSt EG.emptyEGraph IS.empty -- | A data type that caches for the 'VarInfo' of @x@ the results of querying -- 'dsGetCompleteMatches' and then striking out all occurrences of @K@ for @@ -302,7 +323,9 @@ emptyVarInfo x lookupVarInfo :: TmState -> Id -> VarInfo -- (lookupVarInfo tms x) tells what we know about 'x' -lookupVarInfo (TmSt env _ _) x = fromMaybe (emptyVarInfo x) (lookupUSDFM env x) +lookupVarInfo ts@(TmSt env _) x = fromMaybe (emptyVarInfo x) $ do + xid <- lookupId ts x + env ^. _class xid . _data -- | Like @lookupVarInfo ts x@, but @lookupVarInfo ts x = (y, vi)@ also looks -- through newtype constructors. We have @x ~ N1 (... (Nk y))@ such that the @@ -324,12 +347,27 @@ lookupVarInfoNT ts x = case lookupVarInfo ts x of | isNewDataCon dc = Just y go _ = Nothing -trvVarInfo :: Functor f => (VarInfo -> f (a, VarInfo)) -> Nabla -> Id -> f (a, Nabla) -trvVarInfo f nabla at MkNabla{ nabla_tm_st = ts at TmSt{ts_facts = env} } x - = set_vi <$> f (lookupVarInfo ts x) +trvVarInfo :: forall f a. Functor f => (VarInfo -> f (a, VarInfo)) -> Nabla + -> (ClassId,Id) + -- ^ The ClassId of the VarInfo to traverse, and the Id represented + -- to get it, to determine the empty var info in case it isn't available. + -- ... Feels a bit weird, but let's see if it works at all + -> f (a, Nabla) +trvVarInfo f nabla at MkNabla{ nabla_tm_st = ts at TmSt{ts_facts = env} } (xid,x) + = second (\g -> nabla{nabla_tm_st = ts{ts_facts=g}}) <$> + updateAccum (_class xid._data.defaultEmpty) f env where - set_vi (a, vi') = - (a, nabla{ nabla_tm_st = ts{ ts_facts = addToUSDFM env (vi_id vi') vi' } }) + updateAccum :: forall f a s c. Functor f => Lens' s a -> (a -> f (c,a)) -> s -> f (c,s) + updateAccum lens g = getCompose . lens @(Compose f ((,) c)) (Compose . g) + + defaultEmpty :: Lens' (Maybe VarInfo) VarInfo + defaultEmpty f s = Just <$> (f (fromMaybe (emptyVarInfo x) s)) + +------------------------------------------ +-- * Utility for looking up Ids in 'Nabla' + +lookupId :: TmState -> Id -> Maybe ClassId +lookupId TmSt{ts_facts = eg0} x = EGN.lookupNM (EG.Node (FreeVarF x)) (EGI.memo eg0) ------------------------------------------------ -- * Exported utility functions querying 'Nabla' @@ -797,3 +835,19 @@ instance Outputable PmAltCon where instance Outputable PmEquality where ppr = text . show + +----------------------------------------------------- +-- * E-graphs to represent normalised refinment types + +type TmEGraph = EGraph (Maybe VarInfo) CoreExprF + +-- TODO delete orphans for showing TmEGraph for debugging reasons +instance Show VarInfo where + show = showPprUnsafe . ppr + +-- | This instance is seriously wrong for general purpose, it's just required for instancing Analysis. +-- There ought to be a better way. +-- ROMES:TODO: +instance Eq VarInfo where + (==) a b = vi_id a == vi_id b -- ROMES:TODO: The rest of the equality comparisons + ===================================== compiler/GHC/Types/Unique/SDFM.hs deleted ===================================== @@ -1,121 +0,0 @@ -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE ApplicativeDo #-} -{-# OPTIONS_GHC -Wall #-} - --- | Like a 'UniqDFM', but maintains equivalence classes of keys sharing the --- same entry. See 'UniqSDFM'. -module GHC.Types.Unique.SDFM ( - -- * Unique-keyed, /shared/, deterministic mappings - UniqSDFM, - - emptyUSDFM, - lookupUSDFM, - equateUSDFM, addToUSDFM, - traverseUSDFM - ) where - -import GHC.Prelude - -import GHC.Types.Unique -import GHC.Types.Unique.DFM -import GHC.Utils.Outputable - --- | Either @Indirect x@, meaning the value is represented by that of @x@, or --- an @Entry@ containing containing the actual value it represents. -data Shared key ele - = Indirect !key - | Entry !ele - --- | A 'UniqDFM' whose domain is /sets/ of 'Unique's, each of which share a --- common value of type @ele at . --- Every such set (\"equivalence class\") has a distinct representative --- 'Unique'. Supports merging the entries of multiple such sets in a union-find --- like fashion. --- --- An accurate model is that of @[(Set key, Maybe ele)]@: A finite mapping from --- sets of @key at s to possibly absent entries @ele@, where the sets don't overlap. --- Example: --- @ --- m = [({u1,u3}, Just ele1), ({u2}, Just ele2), ({u4,u7}, Nothing)] --- @ --- On this model we support the following main operations: --- --- * @'lookupUSDFM' m u3 == Just ele1@, @'lookupUSDFM' m u4 == Nothing@, --- @'lookupUSDFM' m u5 == Nothing at . --- * @'equateUSDFM' m u1 u3@ is a no-op, but --- @'equateUSDFM' m u1 u2@ merges @{u1,u3}@ and @{u2}@ to point to --- @Just ele2@ and returns the old entry of @{u1,u3}@, @Just ele1 at . --- * @'addToUSDFM' m u3 ele4@ sets the entry of @{u1,u3}@ to @Just ele4 at . --- --- As well as a few means for traversal/conversion to list. -newtype UniqSDFM key ele - = USDFM { unUSDFM :: UniqDFM key (Shared key ele) } - -emptyUSDFM :: UniqSDFM key ele -emptyUSDFM = USDFM emptyUDFM - -lookupReprAndEntryUSDFM :: Uniquable key => UniqSDFM key ele -> key -> (key, Maybe ele) -lookupReprAndEntryUSDFM (USDFM env) = go - where - go x = case lookupUDFM env x of - Nothing -> (x, Nothing) - Just (Indirect y) -> go y - Just (Entry ele) -> (x, Just ele) - --- | @lookupSUDFM env x@ looks up an entry for @x@, looking through all --- 'Indirect's until it finds a shared 'Entry'. --- --- Examples in terms of the model (see 'UniqSDFM'): --- >>> lookupUSDFM [({u1,u3}, Just ele1), ({u2}, Just ele2)] u3 == Just ele1 --- >>> lookupUSDFM [({u1,u3}, Just ele1), ({u2}, Just ele2)] u4 == Nothing --- >>> lookupUSDFM [({u1,u3}, Just ele1), ({u2}, Nothing)] u2 == Nothing -lookupUSDFM :: Uniquable key => UniqSDFM key ele -> key -> Maybe ele -lookupUSDFM usdfm x = snd (lookupReprAndEntryUSDFM usdfm x) - --- | @equateUSDFM env x y@ makes @x@ and @y@ point to the same entry, --- thereby merging @x@'s class with @y@'s. --- If both @x@ and @y@ are in the domain of the map, then @y@'s entry will be --- chosen as the new entry and @x@'s old entry will be returned. --- --- Examples in terms of the model (see 'UniqSDFM'): --- >>> equateUSDFM [] u1 u2 == (Nothing, [({u1,u2}, Nothing)]) --- >>> equateUSDFM [({u1,u3}, Just ele1)] u3 u4 == (Nothing, [({u1,u3,u4}, Just ele1)]) --- >>> equateUSDFM [({u1,u3}, Just ele1)] u4 u3 == (Nothing, [({u1,u3,u4}, Just ele1)]) --- >>> equateUSDFM [({u1,u3}, Just ele1), ({u2}, Just ele2)] u3 u2 == (Just ele1, [({u2,u1,u3}, Just ele2)]) -equateUSDFM - :: Uniquable key => UniqSDFM key ele -> key -> key -> (Maybe ele, UniqSDFM key ele) -equateUSDFM usdfm@(USDFM env) x y = - case (lu x, lu y) of - ((x', _) , (y', _)) - | getUnique x' == getUnique y' -> (Nothing, usdfm) -- nothing to do - ((x', _) , (y', Nothing)) -> (Nothing, set_indirect y' x') - ((x', mb_ex), (y', _)) -> (mb_ex, set_indirect x' y') - where - lu = lookupReprAndEntryUSDFM usdfm - set_indirect a b = USDFM $ addToUDFM env a (Indirect b) - --- | @addToUSDFM env x a@ sets the entry @x@ is associated with to @a@, --- thereby modifying its whole equivalence class. --- --- Examples in terms of the model (see 'UniqSDFM'): --- >>> addToUSDFM [] u1 ele1 == [({u1}, Just ele1)] --- >>> addToUSDFM [({u1,u3}, Just ele1)] u3 ele2 == [({u1,u3}, Just ele2)] -addToUSDFM :: Uniquable key => UniqSDFM key ele -> key -> ele -> UniqSDFM key ele -addToUSDFM usdfm@(USDFM env) x v = - USDFM $ addToUDFM env (fst (lookupReprAndEntryUSDFM usdfm x)) (Entry v) - -traverseUSDFM :: forall key a b f. Applicative f => (a -> f b) -> UniqSDFM key a -> f (UniqSDFM key b) -traverseUSDFM f = fmap (USDFM . listToUDFM_Directly) . traverse g . udfmToList . unUSDFM - where - g :: (Unique, Shared key a) -> f (Unique, Shared key b) - g (u, Indirect y) = pure (u,Indirect y) - g (u, Entry a) = do - a' <- f a - pure (u,Entry a') - -instance (Outputable key, Outputable ele) => Outputable (Shared key ele) where - ppr (Indirect x) = ppr x - ppr (Entry a) = ppr a - -instance (Outputable key, Outputable ele) => Outputable (UniqSDFM key ele) where - ppr (USDFM env) = ppr env ===================================== compiler/ghc.cabal.in ===================================== @@ -114,6 +114,7 @@ Library filepath >= 1 && < 1.5, template-haskell == 2.21.*, hpc >= 0.6 && < 0.8, + hegg, transformers >= 0.5 && < 0.7, exceptions == 0.10.*, semaphore-compat, @@ -328,6 +329,7 @@ Library GHC.Core.ConLike GHC.Core.DataCon GHC.Core.FamInstEnv + GHC.Core.Equality GHC.Core.FVs GHC.Core.InstEnv GHC.Core.Lint @@ -865,7 +867,6 @@ Library GHC.Types.Unique.FM GHC.Types.Unique.Map GHC.Types.Unique.MemoFun - GHC.Types.Unique.SDFM GHC.Types.Unique.Set GHC.Types.Unique.Supply GHC.Types.Var ===================================== hadrian/src/Packages.hs ===================================== @@ -6,7 +6,7 @@ module Packages ( compareSizes, compiler, containers, deepseq, deriveConstants, directory, dumpDecls, exceptions, filepath, genapply, genprimopcode, ghc, ghcBignum, ghcBoot, ghcBootTh, ghcPlatform, ghcCompact, ghcConfig, ghcExperimental, ghcHeap, ghcInternal, ghci, ghciWrapper, ghcPkg, ghcPrim, - ghcToolchain, ghcToolchainBin, haddock, haskeline, + ghcToolchain, ghcToolchainBin, haddock, haskeline, hegg, hsc2hs, hp2ps, hpc, hpcBin, integerGmp, integerSimple, iserv, iservProxy, libffi, mtl, parsec, pretty, primitive, process, remoteIserv, rts, runGhc, semaphoreCompat, stm, templateHaskell, terminfo, text, time, timeout, touchy, @@ -39,7 +39,7 @@ ghcPackages = , compareSizes, compiler, containers, deepseq, deriveConstants, directory, dumpDecls , exceptions, filepath, genapply, genprimopcode, ghc, ghcBignum, ghcBoot, ghcBootTh, ghcPlatform , ghcCompact, ghcConfig, ghcExperimental, ghcHeap, ghcInternal, ghci, ghciWrapper, ghcPkg, ghcPrim - , ghcToolchain, ghcToolchainBin, haddock, haskeline, hsc2hs + , ghcToolchain, ghcToolchainBin, haddock, haskeline, hsc2hs, hegg , hp2ps, hpc, hpcBin, integerGmp, integerSimple, iserv, libffi, mtl , parsec, pretty, process, rts, runGhc, stm, semaphoreCompat, templateHaskell , terminfo, text, time, touchy, transformers, unlit, unix, win32, xhtml @@ -56,7 +56,7 @@ array, base, binary, bytestring, cabalSyntax, cabal, checkPpr, checkExact, count compareSizes, compiler, containers, deepseq, deriveConstants, directory, dumpDecls, exceptions, filepath, genapply, genprimopcode, ghc, ghcBignum, ghcBoot, ghcBootTh, ghcPlatform, ghcCompact, ghcConfig, ghcExperimental, ghcHeap, ghci, ghcInternal, ghciWrapper, ghcPkg, ghcPrim, - ghcToolchain, ghcToolchainBin, haddock, haskeline, hsc2hs, + ghcToolchain, ghcToolchainBin, haddock, haskeline, hsc2hs, hegg, hp2ps, hpc, hpcBin, integerGmp, integerSimple, iserv, iservProxy, remoteIserv, libffi, mtl, parsec, pretty, primitive, process, rts, runGhc, semaphoreCompat, stm, templateHaskell, terminfo, text, time, touchy, transformers, unlit, unix, win32, xhtml, @@ -102,6 +102,7 @@ ghcToolchain = lib "ghc-toolchain" `setPath` "utils/ghc-toolchain" ghcToolchainBin = prg "ghc-toolchain-bin" `setPath` "utils/ghc-toolchain/exe" -- workaround for #23690 haddock = util "haddock" haskeline = lib "haskeline" +hegg = lib "hegg" hsc2hs = util "hsc2hs" hp2ps = util "hp2ps" hpc = lib "hpc" ===================================== hadrian/src/Rules/ToolArgs.hs ===================================== @@ -165,6 +165,7 @@ toolTargets = [ binary , ghci , ghcPkg -- # executable -- , haddock -- # depends on ghc library + , hegg , hsc2hs -- # executable , hpc , hpcBin -- # executable ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -99,6 +99,7 @@ stage0Packages = do , ghci , ghcPkg , haddock + , hegg , hsc2hs , hpc , hpcBin @@ -149,6 +150,7 @@ stage1Packages = do , ghcPkg , ghcPrim , haskeline + , hegg , hp2ps , hsc2hs , integerGmp ===================================== libraries/hegg ===================================== @@ -0,0 +1 @@ +Subproject commit e124cb2a999c0058b6cca283142ac18b289416f2 ===================================== packages ===================================== @@ -51,6 +51,7 @@ libraries/deepseq - - ssh://g libraries/directory - - ssh://git at github.com/haskell/directory.git libraries/filepath - - ssh://git at github.com/haskell/filepath.git libraries/haskeline - - https://github.com/judah/haskeline.git +libraries/hegg - - https://github.com/alt-romes/hegg.git libraries/hpc - - - libraries/mtl - - https://github.com/haskell/mtl.git libraries/parsec - - https://github.com/haskell/parsec.git ===================================== testsuite/tests/count-deps/CountDepsParser.stdout ===================================== @@ -21,11 +21,11 @@ GHC.Core.Coercion.Axiom GHC.Core.Coercion.Opt GHC.Core.ConLike GHC.Core.DataCon +GHC.Core.Equality GHC.Core.FVs GHC.Core.FamInstEnv GHC.Core.InstEnv GHC.Core.Make -GHC.Core.Map.Expr GHC.Core.Map.Type GHC.Core.Multiplicity GHC.Core.Opt.Arity @@ -194,7 +194,6 @@ GHC.Types.Unique.DFM GHC.Types.Unique.DSet GHC.Types.Unique.FM GHC.Types.Unique.Map -GHC.Types.Unique.SDFM GHC.Types.Unique.Set GHC.Types.Unique.Supply GHC.Types.Var View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1917b37fc1df990caf61fbda0a05dddfc9775914...af60b03e6638d951282f59eab14b92da5046192a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1917b37fc1df990caf61fbda0a05dddfc9775914...af60b03e6638d951282f59eab14b92da5046192a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 19:17:08 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Thu, 02 May 2024 15:17:08 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/az/T24754-epa-stmtlist-semi-span Message-ID: <6633e6b3f3f5b_1a3d2438f3efc1352b2@gitlab.mail> Alan Zimmerman pushed new branch wip/az/T24754-epa-stmtlist-semi-span at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/T24754-epa-stmtlist-semi-span You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 19:21:46 2024 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Thu, 02 May 2024 15:21:46 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24664-tests Message-ID: <6633e7cae56fd_1a3d243a62ec813998b@gitlab.mail> Matthew Craven pushed new branch wip/T24664-tests at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24664-tests You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 19:41:49 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 02 May 2024 15:41:49 -0400 Subject: [Git][ghc/ghc][master] testsuite: expand size testing infrastructure Message-ID: <6633ec7dd452e_1a3d243eca52415311f@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - 3 changed files: - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/tests/perf/size/all.T Changes: ===================================== testsuite/driver/testglobals.py ===================================== @@ -221,6 +221,10 @@ class TestConfig: # I have no idea what this does self.package_conf_cache_file = None # type: Optional[Path] + # the libdir for the test compiler. Set by hadrian, see + # Setting.Builders.RunTest + self.libdir = '' + # The extra hadrian dependencies we need for all configured tests self.hadrian_deps = set() # type: Set[str] ===================================== testsuite/driver/testlib.py ===================================== @@ -143,6 +143,15 @@ def js_skip( name, opts ): if js_arch(): skip(name,opts) +# disable test on WASM arch +def wasm_skip( name, opts ): + if wasm_arch(): + skip(name,opts) + +def windows_skip(name,opts): + if on_windows(): + skip(name,opts) + # expect broken for the JS backend def js_broken( bug: IssueNumber ): if js_arch(): @@ -239,6 +248,15 @@ def req_dynamic_hs( name, opts ): if not config.supports_dynamic_hs: opts.expect = 'fail' +def req_dynamic_ghc( name, opts ): + ''' + Require that the GHC is dynamically linked, if static then skip. + See tests/perf/size/all.T, specifically foo.so tests for use case + and example + ''' + if not config.ghc_dynamic: + skip(name,opts) + def req_interp( name, opts ): if not config.have_interp or needsTargetWrapper(): opts.expect = 'fail' @@ -611,15 +629,24 @@ def collect_size ( deviation, path ): def get_dir_size(path): total = 0 - with os.scandir(path) as it: - for entry in it: - if entry.is_file(): - total += entry.stat().st_size - elif entry.is_dir(): - total += get_dir_size(entry.path) - return total + try: + with os.scandir(path) as it: + for entry in it: + if entry.is_file(): + total += entry.stat().st_size + elif entry.is_dir(): + total += get_dir_size(entry.path) + return total + except FileNotFoundError: + print("Exception: Could not find: " + path) def collect_size_dir ( deviation, path ): + + ## os.path.join joins the path with slashes (not backslashes) on windows + ## CI...for some reason, so we manually detect it here + sep = r"/" + if on_windows(): + sep = r"\\" return collect_generic_stat ( 'size', deviation, lambda way: get_dir_size(path) ) # Read a number from a specific file @@ -636,6 +663,91 @@ def collect_generic_stats ( metric_info ): return _collect_generic_stat(name, opts, metric_info) return f +# wrap the call to collect_size_dir with path_from_ghcPkg in a function. Python +# is call-by-value so if we placed the call in an all.T file then the python +# interpreter would evaluate the call to path_from_ghcPkg +def collect_size_ghc_pkg (deviation, library): + return collect_size_dir(deviation, path_from_ghcPkg(library, "library-dirs")) + +# same for collect_size and find_so +def collect_object_size (deviation, library, use_non_inplace=False): + if use_non_inplace: + return collect_size(deviation, find_non_inplace_so(library)) + else: + return collect_size(deviation, find_so(library)) + +def path_from_ghcPkg (library, field): + """Find the field as a path for a library via a call to ghc-pkg. This is a + testsuite wrapper around a call to ghc-pkg field {library} {field}. + """ + + ### example output from ghc-pkg: + ### $ ./ghc-pkg field Cabal library-dirs + ### library-dirs: /home/doyougnu/programming/haskell/ghc/_build/stage1/lib/../lib/x86_64-linux-ghc-9.11.20240424/Cabal-3.11.0.0-inplace + ### so we split the string and drop the 'library-dirs' + ghcPkgCmd = fr"{config.ghc_pkg} field {library} {field}" + + try: + result = subprocess.run(ghcPkgCmd, capture_output=True, shell=True) + + # check_returncode throws an exception if the return code is not 0. + result.check_returncode() + + # if we get here then the call worked and we have the path we split by + # whitespace and then return the path which becomes the second element + # in the array + return re.split(r'\s+', result.stdout.decode("utf-8"))[1] + except Exception as e: + message = f""" + Attempt to find {field} of {library} using ghc-pkg failed. + ghc-pkg path: {config.ghc_pkg} + error" {e} + """ + print(message) + + +def _find_so(lib, directory, in_place): + """Find a shared object file (.so) for lib in directory. We deliberately + keep the regex simple, just removing the ghc version and project version. + Example: + + _find_so("Cabal-syntax-3.11.0.0", path-from-ghc-pkg, True) ==> + /builds/ghc/ghc/_build/install/lib/ghc-9.11.20240410/lib/x86_64-linux-ghc-9.11.20240410/libHSCabal-syntax-3.11.0.0-inplace-ghc9.11.20240410.so + """ + + # produce the suffix for the CI operating system + suffix = "so" + if config.os == "mingw32": + suffix = "dll" + elif config.os == "darwin": + suffix = "dylib" + + # Most artfacts are of the form foo-inplace, except for the rts. + if in_place: + to_match = r'libHS{}-\d+(\.\d+)+-inplace-\S+\.' + suffix + else: + to_match = r'libHS{}-\d+(\.\d+)+\S+\.' + suffix + + matches = [] + # wrap this in some exception handling, hadrian test will error out because + # these files don't exist yet, so we pass when this occurs + try: + for f in os.listdir(directory): + if f.endswith(suffix): + pattern = re.compile(to_match.format(re.escape(lib))) + match = re.match(pattern, f) + if match: + matches.append(match.group()) + return os.path.join(directory, matches[0]) + except: + failBecause('Could not find shared object file: ' + lib) + +def find_so(lib): + return _find_so(lib,path_from_ghcPkg(lib, "dynamic-library-dirs"),True) + +def find_non_inplace_so(lib): + return _find_so(lib,path_from_ghcPkg(lib, "dynamic-library-dirs"),False) + # Define the a generic stat test, which computes the statistic by calling the function # given as the third argument. def collect_generic_stat ( metric, deviation, get_stat ): @@ -804,9 +916,9 @@ KNOWN_OPERATING_SYSTEMS = set([ ]) def exe_extension() -> str: - if config.arch == 'wasm32': + if wasm_arch(): return '.wasm' - elif config.os == "mingw32": + elif on_windows(): return '.exe' return '' @@ -829,6 +941,9 @@ def cygwin( ) -> bool: def js_arch() -> bool: return arch("javascript"); +def on_windows() -> bool: + return config.os == "mingw32" + def wasm_arch() -> bool: return arch("wasm32") ===================================== testsuite/tests/perf/size/all.T ===================================== @@ -3,4 +3,77 @@ test('size_hello_obj', [collect_size(5, 'size_hello_obj.o')], compile, ['']) test('size_hello_artifact', [collect_size(5, 'size_hello_artifact' + exe_extension())], compile_artifact, ['']) -test('libdir',[collect_size_dir(10, config.libdir)], static_stats, [] ) +test('array_dir' ,[collect_size_ghc_pkg(5 , 'array')] , static_stats , [] ) +test('base_dir' ,[collect_size_ghc_pkg(5 , 'base')] , static_stats , [] ) +test('binary_dir' ,[collect_size_ghc_pkg(5 , 'binary')] , static_stats , [] ) +test('bytestring_dir' ,[collect_size_ghc_pkg(5 , 'bytestring')] , static_stats , [] ) +test('cabal_dir' ,[collect_size_ghc_pkg(5 , 'Cabal')] , static_stats , [] ) +test('cabal_syntax_dir' ,[collect_size_ghc_pkg(5 , 'Cabal-syntax')] , static_stats , [] ) +test('containers_dir' ,[collect_size_ghc_pkg(5 , 'containers')] , static_stats , [] ) +test('deepseq_dir' ,[collect_size_ghc_pkg(5 , 'deepseq')] , static_stats , [] ) +test('directory_dir' ,[collect_size_ghc_pkg(5 , 'directory')] , static_stats , [] ) +test('exceptions_dir' ,[collect_size_ghc_pkg(5 , 'exceptions')] , static_stats , [] ) +test('ghc_bignum_dir' ,[collect_size_ghc_pkg(5 , 'ghc-bignum')] , static_stats , [] ) +test('ghc_boot_dir' ,[collect_size_ghc_pkg(5 , 'ghc-boot')] , static_stats , [] ) +test('ghc_boot_th_dir' ,[collect_size_ghc_pkg(5 , 'ghc-boot-th')] , static_stats , [] ) +test('ghc_compact_dir' ,[collect_size_ghc_pkg(5 , 'ghc-compact')] , static_stats , [] ) +test('ghc_dir' ,[collect_size_ghc_pkg(5 , 'ghc')] , static_stats , [] ) +test('ghc_experimental_dir',[collect_size_ghc_pkg(5 , 'ghc-experimental')], static_stats , [] ) +test('ghc_heap_dir' ,[collect_size_ghc_pkg(5 , 'ghc-heap')] , static_stats , [] ) +test('ghc_internal_dir' ,[collect_size_ghc_pkg(5 , 'ghc-internal')] , static_stats , [] ) +test('ghc_platform_dir' ,[collect_size_ghc_pkg(5 , 'ghc-platform')] , static_stats , [] ) +test('ghc_prim_dir' ,[collect_size_ghc_pkg(5 , 'ghc-prim')] , static_stats , [] ) +test('ghc_toolchain_dir' ,[collect_size_ghc_pkg(5 , 'ghc-toolchain')] , static_stats , [] ) +test('haskeline_dir' ,[collect_size_ghc_pkg(5 , 'haskeline')] , static_stats , [] ) +test('hpc_dir' ,[collect_size_ghc_pkg(5 , 'hpc')] , static_stats , [] ) +test('integer_gmp_dir' ,[collect_size_ghc_pkg(5 , 'integer-gmp')] , static_stats , [] ) +test('mtl_dir' ,[collect_size_ghc_pkg(5 , 'mtl')] , static_stats , [] ) +test('os_string_dir' ,[collect_size_ghc_pkg(5 , 'os-string')] , static_stats , [] ) +test('parsec_dir' ,[collect_size_ghc_pkg(5 , 'parsec')] , static_stats , [] ) +test('pretty_dir' ,[collect_size_ghc_pkg(5 , 'pretty')] , static_stats , [] ) +test('process_dir' ,[collect_size_ghc_pkg(5 , 'process')] , static_stats , [] ) +test('time_dir' ,[collect_size_ghc_pkg(5 , 'time')] , static_stats , [] ) +test('xhtml_dir' ,[collect_size_ghc_pkg(5 , 'xhtml')] , static_stats , [] ) + +# size of the entire libdir +test('libdir' ,[collect_size_dir(10, config.libdir)] , static_stats , [] ) + +# skip these on windows +test('unix_dir' ,[windows_skip, collect_size_ghc_pkg(5, 'unix')] , static_stats, [] ) +test('terminfo_dir' ,[windows_skip, js_skip, collect_size_ghc_pkg(5, 'terminfo')], static_stats, [] ) + +# skip the shared object file tests on windows +test('array_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "array")] , static_stats, [] ) +test('base_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "base")] , static_stats, [] ) +test('binary_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "binary")] , static_stats, [] ) +test('bytestring_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "bytestring")] , static_stats, [] ) +test('cabal_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "Cabal")] , static_stats, [] ) +test('cabal_syntax_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "Cabal-syntax")] , static_stats, [] ) +test('containers_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "containers")] , static_stats, [] ) +test('deepseq_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "deepseq")] , static_stats, [] ) +test('directory_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "directory")] , static_stats, [] ) +test('exceptions_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "exceptions")] , static_stats, [] ) +test('filepath_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "filepath")] , static_stats, [] ) +test('ghc_bignum_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-bignum")] , static_stats, [] ) +test('ghc_boot_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-boot")] , static_stats, [] ) +test('ghc_boot_th_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-boot-th")] , static_stats, [] ) +test('ghc_experimental_so',[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-experimental")] , static_stats, [] ) +test('ghc_heap_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-heap")] , static_stats, [] ) +test('ghc_platform_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-platform")] , static_stats, [] ) +test('ghc_prim_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-prim")] , static_stats, [] ) +test('ghc_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc")] , static_stats, [] ) +test('ghc_toolchain_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-toolchain")] , static_stats, [] ) +test('ghci_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghci")] , static_stats, [] ) +test('haskeline_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "haskeline")] , static_stats, [] ) +test('hpc_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "hpc")] , static_stats, [] ) +test('mtl_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "mtl")] , static_stats, [] ) +test('os_string_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "os-string")] , static_stats, [] ) +test('parsec_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "parsec")] , static_stats, [] ) +test('process_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "process")] , static_stats, [] ) +test('rts_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "rts", True)] , static_stats, [] ) +test('template_haskell_so',[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "template-haskell")] , static_stats, [] ) +test('terminfo_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "terminfo")] , static_stats, [] ) +test('text_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "text")] , static_stats, [] ) +test('time_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "time")] , static_stats, [] ) +test('transformers_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "transformers")] , static_stats, [] ) +test('xhtml_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "xhtml")] , static_stats, [] ) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9bae34d87f6c978e03031c549920071857c9080c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9bae34d87f6c978e03031c549920071857c9080c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 19:42:37 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 02 May 2024 15:42:37 -0400 Subject: [Git][ghc/ghc][master] GHCi: support inlining breakpoints (#24712) Message-ID: <6633ecadec6b2_1a3d24402e7bc15607b@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 20 changed files: - compiler/GHC.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Eval/Types.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/StgToByteCode.hs - − compiler/GHC/Types/BreakInfo.hs - + compiler/GHC/Types/Breakpoint.hs - compiler/ghc.cabal.in - ghc/GHCi/UI.hs - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/Run.hs - rts/Exception.cmm - rts/Interpreter.c - + testsuite/tests/ghci.debugger/scripts/T24712.hs - + testsuite/tests/ghci.debugger/scripts/T24712.script - + testsuite/tests/ghci.debugger/scripts/T24712.stdout - testsuite/tests/ghci.debugger/scripts/all.T - testsuite/tests/ghci.debugger/scripts/break021.stdout Changes: ===================================== compiler/GHC.hs ===================================== @@ -157,14 +157,14 @@ module GHC ( -- ** The debugger SingleStep(..), Resume(..), - History(historyBreakInfo, historyEnclosingDecls), + History(historyBreakpointId, historyEnclosingDecls), GHC.getHistorySpan, getHistoryModule, abandon, abandonAll, getResumeContext, GHC.obtainTermFromId, GHC.obtainTermFromVal, reconstructType, modInfoModBreaks, ModBreaks(..), BreakIndex, - BreakInfo(..), + BreakpointId(..), InternalBreakpointId(..), GHC.Runtime.Eval.back, GHC.Runtime.Eval.forward, GHC.Runtime.Eval.setupBreakpoint, @@ -392,7 +392,7 @@ import GHC.Types.TyThing import GHC.Types.Name.Env import GHC.Types.Name.Ppr import GHC.Types.TypeEnv -import GHC.Types.BreakInfo +import GHC.Types.Breakpoint import GHC.Types.PkgQual import GHC.Types.Unique.FM ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -514,11 +514,16 @@ assembleI platform i = case i of CCALL off m_addr i -> do np <- addr m_addr emit bci_CCALL [wOp off, Op np, SmallOp i] PRIMCALL -> emit bci_PRIMCALL [] - BRK_FUN arr index mod cc -> do p1 <- ptr (BCOPtrBreakArray arr) - m <- addr mod + BRK_FUN arr tick_mod tickx info_mod infox cc -> + do p1 <- ptr (BCOPtrBreakArray arr) + tick_addr <- addr tick_mod + info_addr <- addr info_mod np <- addr cc - emit bci_BRK_FUN [Op p1, SmallOp index, - Op m, Op np] + emit bci_BRK_FUN [ Op p1 + , Op tick_addr, Op info_addr + , SmallOp tickx, SmallOp infox + , Op np + ] where literal (LitLabel fs (Just sz) _) ===================================== compiler/GHC/ByteCode/Instr.hs ===================================== @@ -206,7 +206,11 @@ data BCInstr -- Note [unboxed tuple bytecodes and tuple_BCO] in GHC.StgToByteCode -- Breakpoints - | BRK_FUN (ForeignRef BreakArray) !Word16 (RemotePtr ModuleName) + | BRK_FUN (ForeignRef BreakArray) + (RemotePtr ModuleName) -- breakpoint tick module + !Word16 -- breakpoint tick index + (RemotePtr ModuleName) -- breakpoint info module + !Word16 -- breakpoint info index (RemotePtr CostCentre) -- ----------------------------------------------------------------------------- @@ -358,8 +362,11 @@ instance Outputable BCInstr where ppr ENTER = text "ENTER" ppr (RETURN pk) = text "RETURN " <+> ppr pk ppr (RETURN_TUPLE) = text "RETURN_TUPLE" - ppr (BRK_FUN _ index _ _) = text "BRK_FUN" <+> text "" - <+> ppr index <+> text "" <+> text "" + ppr (BRK_FUN _ _tick_mod tickx _info_mod infox _) + = text "BRK_FUN" <+> text "" + <+> text "" <+> ppr tickx + <+> text "" <+> ppr infox + <+> text "" ===================================== compiler/GHC/Runtime/Eval.hs ===================================== @@ -107,7 +107,7 @@ import GHC.Types.Unique import GHC.Types.Unique.Supply import GHC.Types.Unique.DSet import GHC.Types.TyThing -import GHC.Types.BreakInfo +import GHC.Types.Breakpoint import GHC.Types.Unique.Map import GHC.Unit @@ -143,29 +143,27 @@ import Unsafe.Coerce ( unsafeCoerce ) getResumeContext :: GhcMonad m => m [Resume] getResumeContext = withSession (return . ic_resume . hsc_IC) -mkHistory :: HscEnv -> ForeignHValue -> BreakInfo -> History -mkHistory hsc_env hval bi = History hval bi (findEnclosingDecls hsc_env bi) +mkHistory :: HscEnv -> ForeignHValue -> InternalBreakpointId -> History +mkHistory hsc_env hval ibi = History hval ibi (findEnclosingDecls hsc_env ibi) getHistoryModule :: History -> Module -getHistoryModule = breakInfo_module . historyBreakInfo +getHistoryModule = ibi_tick_mod . historyBreakpointId getHistorySpan :: HscEnv -> History -> SrcSpan -getHistorySpan hsc_env History{..} = - let BreakInfo{..} = historyBreakInfo in - case lookupHugByModule breakInfo_module (hsc_HUG hsc_env) of - Just hmi -> modBreaks_locs (getModBreaks hmi) ! breakInfo_number +getHistorySpan hsc_env hist = + let ibi = historyBreakpointId hist in + case lookupHugByModule (ibi_tick_mod ibi) (hsc_HUG hsc_env) of + Just hmi -> modBreaks_locs (getModBreaks hmi) ! ibi_tick_index ibi _ -> panic "getHistorySpan" {- | Finds the enclosing top level function name -} -- ToDo: a better way to do this would be to keep hold of the decl_path computed -- by the coverage pass, which gives the list of lexically-enclosing bindings -- for each tick. -findEnclosingDecls :: HscEnv -> BreakInfo -> [String] -findEnclosingDecls hsc_env (BreakInfo modl ix) = - let hmi = expectJust "findEnclosingDecls" $ - lookupHugByModule modl (hsc_HUG hsc_env) - mb = getModBreaks hmi - in modBreaks_decls mb ! ix +findEnclosingDecls :: HscEnv -> InternalBreakpointId -> [String] +findEnclosingDecls hsc_env ibi = + let hmi = expectJust "findEnclosingDecls" $ lookupHugByModule (ibi_tick_mod ibi) (hsc_HUG hsc_env) + in modBreaks_decls (getModBreaks hmi) ! ibi_tick_index ibi -- | Update fixity environment in the current interactive context. updateFixityEnv :: GhcMonad m => FixityEnv -> m () @@ -324,27 +322,24 @@ handleRunStatus step expr bindings final_ids status history | otherwise = not_tracing where tracing - | EvalBreak apStack_ref maybe_break resume_ctxt _ccs <- status - , Just (EvalBreakpoint ix mod_name) <- maybe_break + | EvalBreak apStack_ref (Just eval_break) resume_ctxt _ccs <- status = do hsc_env <- getSession let interp = hscInterp hsc_env let dflags = hsc_dflags hsc_env - let hmi = expectJust "handleRunStatus" $ - lookupHpt (hsc_HPT hsc_env) (mkModuleName mod_name) - modl = mi_module (hm_iface hmi) + let ibi = evalBreakpointToId (hsc_HPT hsc_env) eval_break + let hmi = expectJust "handleRunStatus" $ lookupHpt (hsc_HPT hsc_env) (moduleName (ibi_tick_mod ibi)) breaks = getModBreaks hmi b <- liftIO $ - breakpointStatus interp (modBreaks_flags breaks) ix + breakpointStatus interp (modBreaks_flags breaks) (ibi_tick_index ibi) if b then not_tracing -- This breakpoint is explicitly enabled; we want to stop -- instead of just logging it. else do apStack_fhv <- liftIO $ mkFinalizedHValue interp apStack_ref - let bi = BreakInfo modl ix - !history' = mkHistory hsc_env apStack_fhv bi `consBL` history + let !history' = mkHistory hsc_env apStack_fhv ibi `consBL` history -- history is strict, otherwise our BoundedList is pointless. fhv <- liftIO $ mkFinalizedHValue interp resume_ctxt let eval_opts = initEvalOpts dflags True @@ -362,23 +357,27 @@ handleRunStatus step expr bindings final_ids status history let interp = hscInterp hsc_env resume_ctxt_fhv <- liftIO $ mkFinalizedHValue interp resume_ctxt apStack_fhv <- liftIO $ mkFinalizedHValue interp apStack_ref - let bp = evalBreakInfo (hsc_HPT hsc_env) <$> maybe_break + let ibi = evalBreakpointToId (hsc_HPT hsc_env) <$> maybe_break (hsc_env1, names, span, decl) <- liftIO $ - bindLocalsAtBreakpoint hsc_env apStack_fhv bp + bindLocalsAtBreakpoint hsc_env apStack_fhv ibi let resume = Resume - { resumeStmt = expr, resumeContext = resume_ctxt_fhv - , resumeBindings = bindings, resumeFinalIds = final_ids + { resumeStmt = expr + , resumeContext = resume_ctxt_fhv + , resumeBindings = bindings + , resumeFinalIds = final_ids , resumeApStack = apStack_fhv - , resumeBreakInfo = bp - , resumeSpan = span, resumeHistory = toListBL history + , resumeBreakpointId = ibi + , resumeSpan = span + , resumeHistory = toListBL history , resumeDecl = decl , resumeCCS = ccs - , resumeHistoryIx = 0 } + , resumeHistoryIx = 0 + } hsc_env2 = pushResume hsc_env1 resume setSession hsc_env2 - return (ExecBreak names bp) + return (ExecBreak names ibi) -- Completed successfully | EvalComplete allocs (EvalSuccess hvals) <- status @@ -428,16 +427,21 @@ resumeExec canLogSpan step mbCnt liftIO $ Loader.deleteFromLoadedEnv interp new_names case r of - Resume { resumeStmt = expr, resumeContext = fhv - , resumeBindings = bindings, resumeFinalIds = final_ids - , resumeApStack = apStack, resumeBreakInfo = mb_brkpt + Resume { resumeStmt = expr + , resumeContext = fhv + , resumeBindings = bindings + , resumeFinalIds = final_ids + , resumeApStack = apStack + , resumeBreakpointId = mb_brkpt , resumeSpan = span , resumeHistory = hist } -> withVirtualCWD $ do - when (isJust mb_brkpt && isJust mbCnt) $ do - setupBreakpoint hsc_env (fromJust mb_brkpt) (fromJust mbCnt) - -- When the user specified a break ignore count, set it - -- in the interpreter + -- When the user specified a break ignore count, set it + -- in the interpreter + case (mb_brkpt, mbCnt) of + (Just brkpt, Just cnt) -> setupBreakpoint hsc_env (toBreakpointId brkpt) cnt + _ -> return () + let eval_opts = initEvalOpts dflags (isStep step) status <- liftIO $ GHCi.resumeStmt interp eval_opts fhv let prevHistoryLst = fromListBL 50 hist @@ -449,16 +453,15 @@ resumeExec canLogSpan step mbCnt fromListBL 50 hist handleRunStatus step expr bindings final_ids status hist' -setupBreakpoint :: GhcMonad m => HscEnv -> BreakInfo -> Int -> m () -- #19157 -setupBreakpoint hsc_env brkInfo cnt = do - let modl :: Module = breakInfo_module brkInfo +setupBreakpoint :: GhcMonad m => HscEnv -> BreakpointId -> Int -> m () -- #19157 +setupBreakpoint hsc_env bi cnt = do + let modl = bi_tick_mod bi breaks hsc_env modl = getModBreaks $ expectJust "setupBreakpoint" $ lookupHpt (hsc_HPT hsc_env) (moduleName modl) - ix = breakInfo_number brkInfo modBreaks = breaks hsc_env modl breakarray = modBreaks_flags modBreaks interp = hscInterp hsc_env - _ <- liftIO $ GHCi.storeBreakpoint interp breakarray ix cnt + _ <- liftIO $ GHCi.storeBreakpoint interp breakarray (bi_tick_index bi) cnt pure () back :: GhcMonad m => Int -> m ([Name], Int, SrcSpan, String) @@ -501,11 +504,11 @@ moveHist fn = do if new_ix == 0 then case r of Resume { resumeApStack = apStack, - resumeBreakInfo = mb_brkpt } -> + resumeBreakpointId = mb_brkpt } -> update_ic apStack mb_brkpt else case history !! (new_ix - 1) of History{..} -> - update_ic historyApStack (Just historyBreakInfo) + update_ic historyApStack (Just historyBreakpointId) -- ----------------------------------------------------------------------------- @@ -517,7 +520,7 @@ result_fs = fsLit "_result" bindLocalsAtBreakpoint :: HscEnv -> ForeignHValue - -> Maybe BreakInfo + -> Maybe InternalBreakpointId -> IO (HscEnv, [Name], SrcSpan, String) -- Nothing case: we stopped when an exception was raised, not at a @@ -543,25 +546,28 @@ bindLocalsAtBreakpoint hsc_env apStack Nothing = do -- Just case: we stopped at a breakpoint, we have information about the location -- of the breakpoint and the free variables of the expression. -bindLocalsAtBreakpoint hsc_env apStack_fhv (Just BreakInfo{..}) = do +bindLocalsAtBreakpoint hsc_env apStack_fhv (Just ibi) = do let - hmi = expectJust "bindLocalsAtBreakpoint" $ - lookupHpt (hsc_HPT hsc_env) (moduleName breakInfo_module) interp = hscInterp hsc_env - breaks = getModBreaks hmi - info = expectJust "bindLocalsAtBreakpoint2" $ - IntMap.lookup breakInfo_number (modBreaks_breakInfo breaks) - occs = modBreaks_vars breaks ! breakInfo_number - span = modBreaks_locs breaks ! breakInfo_number - decl = intercalate "." $ modBreaks_decls breaks ! breakInfo_number + + info_mod = ibi_info_mod ibi + info_hmi = expectJust "bindLocalsAtBreakpoint" $ lookupHpt (hsc_HPT hsc_env) (moduleName info_mod) + info_brks = getModBreaks info_hmi + info = expectJust "bindLocalsAtBreakpoint2" $ IntMap.lookup (ibi_info_index ibi) (modBreaks_breakInfo info_brks) + + tick_mod = ibi_tick_mod ibi + tick_hmi = expectJust "bindLocalsAtBreakpoint" $ lookupHpt (hsc_HPT hsc_env) (moduleName tick_mod) + tick_brks = getModBreaks tick_hmi + occs = modBreaks_vars tick_brks ! ibi_tick_index ibi + span = modBreaks_locs tick_brks ! ibi_tick_index ibi + decl = intercalate "." $ modBreaks_decls tick_brks ! ibi_tick_index ibi -- Rehydrate to understand the breakpoint info relative to the current environment. -- This design is critical to preventing leaks (#22530) (mbVars, result_ty) <- initIfaceLoad hsc_env - $ initIfaceLcl breakInfo_module (text "debugger") NotBoot + $ initIfaceLcl info_mod (text "debugger") NotBoot $ hydrateCgBreakInfo info - let -- Filter out any unboxed ids by changing them to Nothings; ===================================== compiler/GHC/Runtime/Eval/Types.hs ===================================== @@ -19,7 +19,7 @@ import GHCi.Message (EvalExpr, ResumeContext) import GHC.Types.Id import GHC.Types.Name import GHC.Types.TyThing -import GHC.Types.BreakInfo +import GHC.Types.Breakpoint import GHC.Types.Name.Reader import GHC.Types.SrcLoc import GHC.Utils.Exception @@ -50,8 +50,8 @@ data ExecResult , execAllocation :: Word64 } | ExecBreak - { breakNames :: [Name] - , breakInfo :: Maybe BreakInfo + { breakNames :: [Name] + , breakPointId :: Maybe InternalBreakpointId } -- | Essentially a GlobalRdrEnv, but with additional cached values to allow @@ -73,11 +73,10 @@ data Resume = Resume , resumeFinalIds :: [Id] -- [Id] to bind on completion , resumeApStack :: ForeignHValue -- The object from which we can get -- value of the free variables. - , resumeBreakInfo :: Maybe BreakInfo - -- the breakpoint we stopped at - -- (module, index) + , resumeBreakpointId :: Maybe InternalBreakpointId + -- ^ the breakpoint we stopped at -- (Nothing <=> exception) - , resumeSpan :: SrcSpan -- just a copy of the SrcSpan + , resumeSpan :: SrcSpan -- just a copy of the SrcSpan -- from the ModBreaks, -- otherwise it's a pain to -- fetch the ModDetails & @@ -90,9 +89,8 @@ data Resume = Resume type ResumeBindings = ([TyThing], IcGlobalRdrEnv) -data History - = History { - historyApStack :: ForeignHValue, - historyBreakInfo :: BreakInfo, - historyEnclosingDecls :: [String] -- declarations enclosing the breakpoint - } +data History = History + { historyApStack :: ForeignHValue + , historyBreakpointId :: InternalBreakpointId -- ^ breakpoint identifier + , historyEnclosingDecls :: [String] -- ^ declarations enclosing the breakpoint + } ===================================== compiler/GHC/Runtime/Interpreter.hs ===================================== @@ -1,5 +1,4 @@ {-# LANGUAGE CPP #-} -{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE LambdaCase #-} -- | Interacting with the iserv interpreter, whether it is running on an @@ -28,7 +27,7 @@ module GHC.Runtime.Interpreter , getClosure , getModBreaks , seqHValue - , evalBreakInfo + , evalBreakpointToId , interpreterDynamic , interpreterProfiled @@ -74,7 +73,7 @@ import GHCi.Message import GHCi.RemoteTypes import GHCi.ResolvedBCO import GHCi.BreakArray (BreakArray) -import GHC.Types.BreakInfo (BreakInfo(..)) +import GHC.Types.Breakpoint import GHC.ByteCode.Types import GHC.Linker.Types @@ -395,14 +394,15 @@ seqHValue interp unit_env ref = status <- interpCmd interp (Seq hval) handleSeqHValueStatus interp unit_env status -evalBreakInfo :: HomePackageTable -> EvalBreakpoint -> BreakInfo -evalBreakInfo hpt (EvalBreakpoint ix mod_name) = - BreakInfo modl ix - where - modl = mi_module $ - hm_iface $ - expectJust "evalBreakInfo" $ - lookupHpt hpt (mkModuleName mod_name) +evalBreakpointToId :: HomePackageTable -> EvalBreakpoint -> InternalBreakpointId +evalBreakpointToId hpt eval_break = + let load_mod x = mi_module $ hm_iface $ expectJust "evalBreakpointToId" $ lookupHpt hpt (mkModuleName x) + in InternalBreakpointId + { ibi_tick_mod = load_mod (eb_tick_mod eval_break) + , ibi_tick_index = eb_tick_index eval_break + , ibi_info_mod = load_mod (eb_info_mod eval_break) + , ibi_info_index = eb_info_index eval_break + } -- | Process the result of a Seq or ResumeSeq message. #2950 handleSeqHValueStatus :: Interp -> UnitEnv -> EvalStatus () -> IO (EvalResult ()) @@ -412,7 +412,7 @@ handleSeqHValueStatus interp unit_env eval_status = -- A breakpoint was hit; inform the user and tell them -- which breakpoint was hit. resume_ctxt_fhv <- liftIO $ mkFinalizedHValue interp resume_ctxt - let bp = evalBreakInfo (ue_hpt unit_env) <$> maybe_break + let bp = evalBreakpointToId (ue_hpt unit_env) <$> maybe_break sdocBpLoc = brackets . ppr . getSeqBpSpan putStrLn ("*** Ignoring breakpoint " ++ (showSDocUnsafe $ sdocBpLoc bp)) @@ -422,14 +422,15 @@ handleSeqHValueStatus interp unit_env eval_status = handleSeqHValueStatus interp unit_env status (EvalComplete _ r) -> return r where - getSeqBpSpan :: Maybe BreakInfo -> SrcSpan - -- Just case: Stopped at a breakpoint, extract SrcSpan information - -- from the breakpoint. - getSeqBpSpan (Just BreakInfo{..}) = - (modBreaks_locs (breaks breakInfo_module)) ! breakInfo_number - -- Nothing case - should not occur! - -- Reason: Setting of flags in libraries/ghci/GHCi/Run.hs:evalOptsSeq - getSeqBpSpan Nothing = mkGeneralSrcSpan (fsLit "") + getSeqBpSpan :: Maybe InternalBreakpointId -> SrcSpan + getSeqBpSpan = \case + Just bi -> (modBreaks_locs (breaks (ibi_tick_mod bi))) ! ibi_tick_index bi + -- Just case: Stopped at a breakpoint, extract SrcSpan information + -- from the breakpoint. + Nothing -> mkGeneralSrcSpan (fsLit "") + -- Nothing case - should not occur! + -- Reason: Setting of flags in libraries/ghci/GHCi/Run.hs:evalOptsSeq + -- breaks mod = getModBreaks $ expectJust "getSeqBpSpan" $ lookupHpt (ue_hpt unit_env) (moduleName mod) ===================================== compiler/GHC/StgToByteCode.hs ===================================== @@ -384,27 +384,40 @@ schemeR_wrk fvs nm original_body (args, body) -- | Introduce break instructions for ticked expressions. -- If no breakpoint information is available, the instruction is omitted. schemeER_wrk :: StackDepth -> BCEnv -> CgStgExpr -> BcM BCInstrList -schemeER_wrk d p (StgTick (Breakpoint tick_ty tick_no fvs mod) rhs) = do +schemeER_wrk d p (StgTick (Breakpoint tick_ty tick_no fvs tick_mod) rhs) = do code <- schemeE d 0 p rhs hsc_env <- getHscEnv current_mod <- getCurrentModule - current_mod_breaks <- getCurrentModBreaks - case break_info hsc_env mod current_mod current_mod_breaks of + mb_current_mod_breaks <- getCurrentModBreaks + case mb_current_mod_breaks of + -- if we're not generating ModBreaks for this module for some reason, we + -- can't store breakpoint occurrence information. Nothing -> pure code - Just ModBreaks {modBreaks_flags = breaks, modBreaks_module = mod_ptr, modBreaks_ccs = cc_arr} -> do - platform <- profilePlatform <$> getProfile - let idOffSets = getVarOffSets platform d p fvs - ty_vars = tyCoVarsOfTypesWellScoped (tick_ty:map idType fvs) - toWord :: Maybe (Id, WordOff) -> Maybe (Id, Word) - toWord = fmap (\(i, wo) -> (i, fromIntegral wo)) - breakInfo = dehydrateCgBreakInfo ty_vars (map toWord idOffSets) tick_ty - newBreakInfo tick_no breakInfo - let cc | Just interp <- hsc_interp hsc_env - , interpreterProfiled interp - = cc_arr ! tick_no - | otherwise = toRemotePtr nullPtr - breakInstr = BRK_FUN breaks (fromIntegral tick_no) mod_ptr cc - return $ breakInstr `consOL` code + Just current_mod_breaks -> case break_info hsc_env tick_mod current_mod mb_current_mod_breaks of + Nothing -> pure code + Just ModBreaks {modBreaks_flags = breaks, modBreaks_module = tick_mod_ptr, modBreaks_ccs = cc_arr} -> do + platform <- profilePlatform <$> getProfile + let idOffSets = getVarOffSets platform d p fvs + ty_vars = tyCoVarsOfTypesWellScoped (tick_ty:map idType fvs) + toWord :: Maybe (Id, WordOff) -> Maybe (Id, Word) + toWord = fmap (\(i, wo) -> (i, fromIntegral wo)) + breakInfo = dehydrateCgBreakInfo ty_vars (map toWord idOffSets) tick_ty + + let info_mod_ptr = modBreaks_module current_mod_breaks + infox <- newBreakInfo breakInfo + + let cc | Just interp <- hsc_interp hsc_env + , interpreterProfiled interp + = cc_arr ! tick_no + | otherwise = toRemotePtr nullPtr + + let -- cast that checks that round-tripping through Word16 doesn't change the value + toW16 x = let r = fromIntegral x :: Word16 + in if fromIntegral r == x + then r + else pprPanic "schemeER_wrk: breakpoint tick/info index too large!" (ppr x) + breakInstr = BRK_FUN breaks tick_mod_ptr (toW16 tick_no) info_mod_ptr (toW16 infox) cc + return $ breakInstr `consOL` code schemeER_wrk d p rhs = schemeE d 0 p rhs -- | Determine the GHCi-allocated 'BreakArray' and module pointer for the module @@ -2189,7 +2202,12 @@ data BcM_State , ffis :: [FFIInfo] -- ffi info blocks, to free later -- Should be free()d when it is GCd , modBreaks :: Maybe ModBreaks -- info about breakpoints - , breakInfo :: IntMap CgBreakInfo + + , breakInfo :: IntMap CgBreakInfo -- ^ Info at breakpoint occurrence. + -- Indexed with breakpoint *info* index. + -- See Note [Breakpoint identifiers] + -- in GHC.Types.Breakpoint + , breakInfoIdx :: !Int -- ^ Next index for breakInfo array } newtype BcM r = BcM (BcM_State -> IO (BcM_State, r)) deriving (Functor) @@ -2203,7 +2221,7 @@ runBc :: HscEnv -> Module -> Maybe ModBreaks -> BcM r -> IO (BcM_State, r) runBc hsc_env this_mod modBreaks (BcM m) - = m (BcM_State hsc_env this_mod 0 [] modBreaks IntMap.empty) + = m (BcM_State hsc_env this_mod 0 [] modBreaks IntMap.empty 0) thenBc :: BcM a -> (a -> BcM b) -> BcM b thenBc (BcM expr) cont = BcM $ \st0 -> do @@ -2259,9 +2277,14 @@ getLabelsBc n = BcM $ \st -> let ctr = nextlabel st in return (st{nextlabel = ctr+n}, coerce [ctr .. ctr+n-1]) -newBreakInfo :: BreakIndex -> CgBreakInfo -> BcM () -newBreakInfo ix info = BcM $ \st -> - return (st{breakInfo = IntMap.insert ix info (breakInfo st)}, ()) +newBreakInfo :: CgBreakInfo -> BcM Int +newBreakInfo info = BcM $ \st -> + let ix = breakInfoIdx st + st' = st + { breakInfo = IntMap.insert ix info (breakInfo st) + , breakInfoIdx = ix + 1 + } + in return (st', ix) getCurrentModule :: BcM Module getCurrentModule = BcM $ \st -> return (st, thisModule st) ===================================== compiler/GHC/Types/BreakInfo.hs deleted ===================================== @@ -1,12 +0,0 @@ --- | A module for the BreakInfo type. Used by both the GHC.Runtime.Eval and --- GHC.Runtime.Interpreter hierarchy, so put here to have a less deep module --- dependency tree -module GHC.Types.BreakInfo (BreakInfo(..)) where - -import GHC.Prelude -import GHC.Unit.Module - -data BreakInfo = BreakInfo - { breakInfo_module :: Module - , breakInfo_number :: Int - } ===================================== compiler/GHC/Types/Breakpoint.hs ===================================== @@ -0,0 +1,53 @@ +-- | Breakpoint related types +module GHC.Types.Breakpoint + ( BreakpointId (..) + , InternalBreakpointId (..) + , toBreakpointId + ) +where + +import GHC.Prelude +import GHC.Unit.Module + +-- | Breakpoint identifier. +-- +-- See Note [Breakpoint identifiers] +data BreakpointId = BreakpointId + { bi_tick_mod :: !Module -- ^ Breakpoint tick module + , bi_tick_index :: !Int -- ^ Breakpoint tick index + } + +-- | Internal breakpoint identifier +-- +-- See Note [Breakpoint identifiers] +data InternalBreakpointId = InternalBreakpointId + { ibi_tick_mod :: !Module -- ^ Breakpoint tick module + , ibi_tick_index :: !Int -- ^ Breakpoint tick index + , ibi_info_mod :: !Module -- ^ Breakpoint info module + , ibi_info_index :: !Int -- ^ Breakpoint info index + } + +toBreakpointId :: InternalBreakpointId -> BreakpointId +toBreakpointId ibi = BreakpointId + { bi_tick_mod = ibi_tick_mod ibi + , bi_tick_index = ibi_tick_index ibi + } + + +-- Note [Breakpoint identifiers] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- +-- Before optimization a breakpoint is identified uniquely with a tick module +-- and a tick index. See BreakpointId. A tick module contains an array, indexed +-- with the tick indexes, which indicates breakpoint status. +-- +-- When we generate ByteCode, we collect information for every breakpoint at +-- their *occurrence sites* (see CgBreakInfo in GHC.ByteCode.Types) and these info +-- are stored in the ModIface of the occurrence module. Because of inlining, we +-- can't reuse the tick index to uniquely identify an occurrence; because of +-- cross-module inlining, we can't assume that the occurrence module is the same +-- as the tick module (#24712). +-- +-- So every breakpoint occurrence gets assigned a module-unique *info index* and +-- we store it alongside the occurrence module (*info module*) in the +-- InternalBreakpointId datatype. ===================================== compiler/ghc.cabal.in ===================================== @@ -844,7 +844,7 @@ Library GHC.Types.Annotations GHC.Types.Avail GHC.Types.Basic - GHC.Types.BreakInfo + GHC.Types.Breakpoint GHC.Types.CompleteMatch GHC.Types.CostCentre GHC.Types.CostCentre.State ===================================== ghc/GHCi/UI.hs ===================================== @@ -72,6 +72,7 @@ import GHC.Core.TyCo.Ppr import GHC.Types.SafeHaskell ( getSafeMode ) import GHC.Types.SourceError ( SourceError ) import GHC.Types.Name +import GHC.Types.Breakpoint import GHC.Types.Var ( varType ) import GHC.Iface.Syntax ( showToHeader ) import GHC.Builtin.Names @@ -1408,15 +1409,13 @@ runAllocs m = do _ -> Nothing toBreakIdAndLocation :: GhciMonad m - => Maybe GHC.BreakInfo -> m (Maybe (Int, BreakLocation)) + => Maybe GHC.InternalBreakpointId -> m (Maybe (Int, BreakLocation)) toBreakIdAndLocation Nothing = return Nothing toBreakIdAndLocation (Just inf) = do - let md = GHC.breakInfo_module inf - nm = GHC.breakInfo_number inf st <- getGHCiState return $ listToMaybe [ id_loc | id_loc@(_,loc) <- IntMap.assocs (breaks st), - breakModule loc == md, - breakTick loc == nm ] + breakModule loc == ibi_tick_mod inf, + breakTick loc == ibi_tick_index inf ] printStoppedAtBreakInfo :: GHC.GhcMonad m => Resume -> [Name] -> m () printStoppedAtBreakInfo res names = do @@ -1544,15 +1543,11 @@ getCallStackAtCurrentBreakpoint = do getCurrentBreakModule :: GHC.GhcMonad m => m (Maybe Module) getCurrentBreakModule = do resumes <- GHC.getResumeContext - case resumes of - [] -> return Nothing - (r:_) -> do - let ix = GHC.resumeHistoryIx r - if ix == 0 - then return (GHC.breakInfo_module `liftM` GHC.resumeBreakInfo r) - else do - let hist = GHC.resumeHistory r !! (ix-1) - return $ Just $ GHC.getHistoryModule hist + return $ case resumes of + [] -> Nothing + (r:_) -> case GHC.resumeHistoryIx r of + 0 -> ibi_tick_mod <$> GHC.resumeBreakpointId r + ix -> Just $ GHC.getHistoryModule $ GHC.resumeHistory r !! (ix-1) ----------------------------------------------------------------------------- -- @@ -3474,7 +3469,7 @@ pprStopped res = <> text (GHC.resumeDecl res)) <> char ',' <+> ppr (GHC.resumeSpan res) where - mb_mod_name = moduleName <$> GHC.breakInfo_module <$> GHC.resumeBreakInfo res + mb_mod_name = moduleName <$> ibi_tick_mod <$> GHC.resumeBreakpointId res showUnits :: GHC.GhcMonad m => m () showUnits = do @@ -4035,8 +4030,11 @@ ignoreCmd argLine = withSandboxOnly ":ignore" $ do case result of Left sdoc -> printForUser sdoc Right (loc, count) -> do - let breakInfo = GHC.BreakInfo (breakModule loc) (breakTick loc) - setupBreakpoint breakInfo count + let bi = GHC.BreakpointId + { bi_tick_mod = breakModule loc + , bi_tick_index = breakTick loc + } + setupBreakpoint bi count ignoreSwitch :: GhciMonad m => [String] -> m (Either SDoc (BreakLocation, Int)) ignoreSwitch [break, count] = do @@ -4053,7 +4051,7 @@ getIgnoreCount str = where sdocIgnore = text "Ignore count" <+> quotes (text str) -setupBreakpoint :: GhciMonad m => GHC.BreakInfo -> Int -> m() +setupBreakpoint :: GhciMonad m => GHC.BreakpointId -> Int -> m() setupBreakpoint loc count = do hsc_env <- GHC.getSession GHC.setupBreakpoint hsc_env loc count @@ -4542,7 +4540,7 @@ setBreakFlag :: GhciMonad m => Module -> Int -> Bool ->m () setBreakFlag md ix enaDisa = do let enaDisaToCount True = breakOn enaDisaToCount False = breakOff - setupBreakpoint (GHC.BreakInfo md ix) $ enaDisaToCount enaDisa + setupBreakpoint (GHC.BreakpointId md ix) $ enaDisaToCount enaDisa -- --------------------------------------------------------------------------- -- User code exception handling ===================================== libraries/ghci/GHCi/Message.hs ===================================== @@ -398,10 +398,12 @@ data EvalStatus_ a b instance Binary a => Binary (EvalStatus_ a b) -data EvalBreakpoint = - EvalBreakpoint - Int -- ^ break index - String -- ^ ModuleName +data EvalBreakpoint = EvalBreakpoint + { eb_tick_mod :: String -- ^ Breakpoint tick module + , eb_tick_index :: Int -- ^ Breakpoint tick index + , eb_info_mod :: String -- ^ Breakpoint info module + , eb_info_index :: Int -- ^ Breakpoint info index + } deriving (Generic, Show) instance Binary EvalBreakpoint ===================================== libraries/ghci/GHCi/Run.hs ===================================== @@ -329,7 +329,7 @@ withBreakAction opts breakMVar statusMVar act -- as soon as it is hit, or in resetBreakAction below. onBreak :: BreakpointCallback - onBreak ix# mod_name# is_exception apStack = do + onBreak tick_mod# tickx# info_mod# infox# is_exception apStack = do tid <- myThreadId let resume = ResumeContext { resumeBreakMVar = breakMVar @@ -342,8 +342,9 @@ withBreakAction opts breakMVar statusMVar act if is_exception then pure Nothing else do - mod_name <- peekCString (Ptr mod_name#) - pure (Just (EvalBreakpoint (I# ix#) mod_name)) + tick_mod <- peekCString (Ptr tick_mod#) + info_mod <- peekCString (Ptr info_mod#) + pure (Just (EvalBreakpoint tick_mod (I# tickx#) info_mod (I# infox#))) putMVar statusMVar $ EvalBreak apStack_r breakpoint resume_r ccs takeMVar breakMVar @@ -392,8 +393,10 @@ resetStepFlag :: IO () resetStepFlag = poke stepFlag 0 type BreakpointCallback - = Int# -- the breakpoint index - -> Addr# -- pointer to the module name + = Addr# -- pointer to the breakpoint tick module name + -> Int# -- breakpoint tick index + -> Addr# -- pointer to the breakpoint info module name + -> Int# -- breakpoint info index -> Bool -- exception? -> HValue -- the AP_STACK, or exception -> IO () @@ -405,8 +408,8 @@ noBreakStablePtr :: StablePtr BreakpointCallback noBreakStablePtr = unsafePerformIO $ newStablePtr noBreakAction noBreakAction :: BreakpointCallback -noBreakAction _ _ False _ = putStrLn "*** Ignoring breakpoint" -noBreakAction _ _ True _ = return () -- exception: just continue +noBreakAction _ _ _ _ False _ = putStrLn "*** Ignoring breakpoint" +noBreakAction _ _ _ _ True _ = return () -- exception: just continue -- Malloc and copy the bytes. We don't have any way to monitor the -- lifetime of this memory, so it just leaks. ===================================== rts/Exception.cmm ===================================== @@ -535,15 +535,19 @@ retry_pop_stack: // be per-thread. CInt[rts_stop_on_exception] = 0; ("ptr" ioAction) = ccall deRefStablePtr (W_[rts_breakpoint_io_action] "ptr"); - Sp = Sp - WDS(9); - Sp(8) = exception; - Sp(7) = stg_raise_ret_info; - Sp(6) = exception; - Sp(5) = ghczmprim_GHCziTypes_True_closure; // True <=> an exception - Sp(4) = stg_ap_ppv_info; - Sp(3) = 0; - Sp(2) = stg_ap_n_info; - Sp(1) = 0; + Sp = Sp - WDS(13); + Sp(12) = exception; + Sp(11) = stg_raise_ret_info; + Sp(10) = exception; + Sp(9) = ghczmprim_GHCziTypes_True_closure; // True <=> an exception + Sp(8) = stg_ap_ppv_info; + Sp(7) = 0; + Sp(6) = stg_ap_n_info; + Sp(5) = 0; + Sp(4) = stg_ap_n_info; + Sp(3) = 0; + Sp(2) = stg_ap_n_info; + Sp(1) = 0; R1 = ioAction; jump RET_LBL(stg_ap_n) [R1]; } ===================================== rts/Interpreter.c ===================================== @@ -1089,9 +1089,9 @@ run_BCO: /* check for a breakpoint on the beginning of a let binding */ case bci_BRK_FUN: { - int arg1_brk_array, arg2_array_index, arg3_module_name; + int arg1_brk_array, arg2_tick_mod, arg3_info_mod, arg4_tick_index, arg5_info_index; #if defined(PROFILING) - int arg4_cc; + int arg6_cc; #endif StgArrBytes *breakPoints; int returning_from_break; @@ -1106,10 +1106,12 @@ run_BCO: int size_words; arg1_brk_array = BCO_GET_LARGE_ARG; - arg2_array_index = BCO_NEXT; - arg3_module_name = BCO_GET_LARGE_ARG; + arg2_tick_mod = BCO_GET_LARGE_ARG; + arg3_info_mod = BCO_GET_LARGE_ARG; + arg4_tick_index = BCO_NEXT; + arg5_info_index = BCO_NEXT; #if defined(PROFILING) - arg4_cc = BCO_GET_LARGE_ARG; + arg6_cc = BCO_GET_LARGE_ARG; #else BCO_GET_LARGE_ARG; #endif @@ -1122,7 +1124,7 @@ run_BCO: #if defined(PROFILING) cap->r.rCCCS = pushCostCentre(cap->r.rCCCS, - (CostCentre*)BCO_LIT(arg4_cc)); + (CostCentre*)BCO_LIT(arg6_cc)); #endif // if we are returning from a break then skip this section @@ -1134,11 +1136,11 @@ run_BCO: // stop the current thread if either the // "rts_stop_next_breakpoint" flag is true OR if the // ignore count for this particular breakpoint is zero - StgInt ignore_count = ((StgInt*)breakPoints->payload)[arg2_array_index]; + StgInt ignore_count = ((StgInt*)breakPoints->payload)[arg4_tick_index]; if (rts_stop_next_breakpoint == false && ignore_count > 0) { // decrement and write back ignore count - ((StgInt*)breakPoints->payload)[arg2_array_index] = --ignore_count; + ((StgInt*)breakPoints->payload)[arg4_tick_index] = --ignore_count; } else if (rts_stop_next_breakpoint == true || ignore_count == 0) { @@ -1171,8 +1173,10 @@ run_BCO: // Arrange the stack to call the breakpoint IO action, and // continue execution of this BCO when the IO action returns. // - // ioAction :: Int# -- the breakpoint index - // -> Addr# -- the breakpoint module + // ioAction :: Addr# -- the breakpoint tick module + // -> Int# -- the breakpoint tick index + // -> Addr# -- the breakpoint info module + // -> Int# -- the breakpoint info index // -> Bool -- exception? // -> HValue -- the AP_STACK, or exception // -> IO () @@ -1180,15 +1184,19 @@ run_BCO: ioAction = (StgClosure *) deRefStablePtr ( rts_breakpoint_io_action); - Sp_subW(11); - SpW(10) = (W_)obj; - SpW(9) = (W_)&stg_apply_interp_info; - SpW(8) = (W_)new_aps; - SpW(7) = (W_)False_closure; // True <=> an exception - SpW(6) = (W_)&stg_ap_ppv_info; - SpW(5) = (W_)BCO_LIT(arg3_module_name); + Sp_subW(15); + SpW(14) = (W_)obj; + SpW(13) = (W_)&stg_apply_interp_info; + SpW(12) = (W_)new_aps; + SpW(11) = (W_)False_closure; // True <=> an exception + SpW(10) = (W_)&stg_ap_ppv_info; + SpW(9) = (W_)arg5_info_index; + SpW(8) = (W_)&stg_ap_n_info; + SpW(7) = (W_)BCO_LIT(arg3_info_mod); + SpW(6) = (W_)&stg_ap_n_info; + SpW(5) = (W_)arg4_tick_index; SpW(4) = (W_)&stg_ap_n_info; - SpW(3) = (W_)arg2_array_index; + SpW(3) = (W_)BCO_LIT(arg2_tick_mod); SpW(2) = (W_)&stg_ap_n_info; SpW(1) = (W_)ioAction; SpW(0) = (W_)&stg_enter_info; ===================================== testsuite/tests/ghci.debugger/scripts/T24712.hs ===================================== @@ -0,0 +1,2 @@ +main = foo 123 +foo n = print n ===================================== testsuite/tests/ghci.debugger/scripts/T24712.script ===================================== @@ -0,0 +1,3 @@ +:l T24712.hs +:b foo +main ===================================== testsuite/tests/ghci.debugger/scripts/T24712.stdout ===================================== @@ -0,0 +1,4 @@ +Breakpoint 0 activated at T24712.hs:2:9-15 +Stopped in Main.foo, T24712.hs:2:9-15 +_result :: IO () = _ +n :: Integer = 123 ===================================== testsuite/tests/ghci.debugger/scripts/all.T ===================================== @@ -141,3 +141,4 @@ test('break030', ) test('T23057', [only_ghci, extra_hc_opts('-fno-break-points')], ghci_script, ['T23057.script']) test('T24306', normal, ghci_script, ['T24306.script']) +test('T24712', normal, ghci_script, ['T24712.script']) ===================================== testsuite/tests/ghci.debugger/scripts/break021.stdout ===================================== @@ -17,7 +17,7 @@ _result :: IO () = _ ^^^^^^^ 11 line2 0 Stopped in Main.line1, break020.hs:3:11-19 -_result :: m () = _ +_result :: IO () = _ 2 3 line1 _ = return () ^^^^^^^^^ @@ -29,7 +29,7 @@ _result :: IO () = _ ^^^^^^^ 12 in_another_decl 0 Stopped in Main.line2, break020.hs:4:11-19 -_result :: m () = _ +_result :: IO () = _ 3 line1 _ = return () 4 line2 _ = return () ^^^^^^^^^ @@ -41,7 +41,7 @@ _result :: IO () = _ ^^^^^^^^^^^^^^^^^ 13 in_another_module 0 Stopped in Main.in_another_decl, break020.hs:(6,21)-(7,30) -_result :: m () = _ +_result :: IO () = _ 5 vv 6 in_another_decl _ = do line1 0 @@ -49,25 +49,25 @@ _result :: m () = _ ^^ 8 Stopped in Main.in_another_decl, break020.hs:6:24-30 -_result :: m () = _ +_result :: IO () = _ 5 6 in_another_decl _ = do line1 0 ^^^^^^^ 7 line2 0 Stopped in Main.line1, break020.hs:3:11-19 -_result :: m () = _ +_result :: IO () = _ 2 3 line1 _ = return () ^^^^^^^^^ 4 line2 _ = return () Stopped in Main.in_another_decl, break020.hs:7:24-30 -_result :: m () = _ +_result :: IO () = _ 6 in_another_decl _ = do line1 0 7 line2 0 ^^^^^^^ 8 Stopped in Main.line2, break020.hs:4:11-19 -_result :: m () = _ +_result :: IO () = _ 3 line1 _ = return () 4 line2 _ = return () ^^^^^^^^^ @@ -85,7 +85,7 @@ _result :: IO () = _ ^^^^^^^ 15 return () Stopped in Main.line2, break020.hs:4:11-19 -_result :: m () = _ +_result :: IO () = _ 3 line1 _ = return () 4 line2 _ = return () ^^^^^^^^^ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b85b11994e0130ff2401dd4bbdf52330e0bcf776 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b85b11994e0130ff2401dd4bbdf52330e0bcf776 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 19:53:31 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Thu, 02 May 2024 15:53:31 -0400 Subject: [Git][ghc/ghc][wip/romes/egraphs-pmc-2] 727 commits: Move function checks to RTS configure Message-ID: <6633ef3baa9b2_1a3d2442efdac1568dd@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/egraphs-pmc-2 at Glasgow Haskell Compiler / GHC Commits: 02efc181 by John Ericson at 2023-10-22T02:48:55-04:00 Move function checks to RTS configure Some of these functions are used in `base` too, but we can copy the checks over to its configure if that's an issue. - - - - - 5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00 Move over a number of C-style checks to RTS configure - - - - - 5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00 Move/Copy more `AC_DEFINE` to RTS config Only exception is the LLVM version macros, which are used for GHC itself. - - - - - b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00 Define `TABLES_NEXT_TO_CODE` in the RTS configure We create a new cabal flag to facilitate this. - - - - - 4a40271e by John Ericson at 2023-10-22T02:48:55-04:00 Configure scripts: `checkOS`: Make a bit more robust `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This allows us to cope with configs/triples that we haven't normalized extra being what GNU `config.sub` does. - - - - - 16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00 Generate `ghcplatform.h` from RTS configure We create a new cabal flag to facilitate this. - - - - - 7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00 Get rid of all mention of `mk/config.h` The RTS configure script is now solely responsible for managing its headers; the top level configure script does not help. - - - - - c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00 rts: drop stale mentions of MIN_UPD_SIZE We used to have MIN_UPD_SIZE macro that describes the minimum reserved size for thunks, so that the thunk can be overwritten in place as indirections or blackholes. However, this macro has not been actually defined or used anywhere since a long time ago; StgThunkHeader already reserves a padding word for this purpose. Hence this patch which drops stale mentions of MIN_UPD_SIZE. - - - - - d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00 base changelog: move non-backported entries from 4.19 section to 4.20 Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational) nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip) were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section. Also minor stylistic changes to other entries, bringing them to a uniform form. - - - - - de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00 EPA Some tweaks to annotations - Fix span for GRHS - Move TrailingAnns from last match to FunBind - Fix GADT 'where' clause span - Capture full range for a CaseAlt Match - - - - - d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00 Update primitives.rst - - - - - 4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00 JS/userguide: add explanation of writing jsbits - - - - - 07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00 testsuite: increase timeout of ghc-api tests for wasm32 ghc-api tests for wasm32 are more likely to timeout due to the large wasm module sizes, especially when testing with wasm native tail calls, given wasmtime's handling of tail call opcodes are suboptimal at the moment. It makes sense to increase timeout specifically for these tests on wasm32. This doesn't affect other targets, and for wasm32 we don't increase timeout for all tests, so not to risk letting major performance regressions slip through the testsuite. - - - - - 0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00 Explicitly require RLIMIT_AS before use in OSMem.c This is done elsewhere in the source tree. It also suddenly is required on OpenBSD. - - - - - 9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00 Modularity: modularize external linker Decouple runLink from DynFlags to allow calling runLink more easily. This is preliminary work for calling Emscripten's linker (emcc) from our JavaScript linker. - - - - - e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00 js: add JStg IR, remove unsaturated constructor - Major step towards #22736 and adding the optimizer in #22261 - - - - - 35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00 Fix a bug in tail calls with ticks See #24078 for the diagnosis. The change affects only the Tick case of occurrence analysis. It's a bit hard to test, so no regression test (yet anyway). - - - - - 9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00 Teach tag-inference about SeqOp/seq# Fixes the STG/tag-inference analogue of #15226. Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00 [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra 48e391952c17ff7eab10b0b1456e3f2a2af28a9b introduced `SYM_TYPE_DUP_DISCARD` to the bitfield. The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value. Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions. - - - - - 5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00 Fix and test for issue #24111, TH.Ppr output of pattern synonyms - - - - - 723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00 EPA: print doc comments as normal comments And ignore the ones allocated in haddock processing. It does not guarantee that every original haddock-like comment appears in the output, as it discards ones that have no legal attachment point. closes #23459 - - - - - 21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00 Fix non-termination bug in equality solver constraint left-to-right then right to left, forever. Easily fixed. - - - - - 270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00 ghc-toolchain: build with `-package-env=-` (#24131) Otherwise globally installed libraries (via `cabal install --lib`) break the build. Fixes #24131. - - - - - 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - cc1c7c54 by Duncan Coutts at 2023-11-05T00:23:44-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 2e448f98 by Cheng Shao at 2023-11-05T00:23:44-04:00 Skip the IOManager test on wasm32 arch. The test relies on the sockets API which are not (yet) available. - - - - - fe50eb35 by Cheng Shao at 2023-11-05T00:24:20-04:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - af771148 by Cheng Shao at 2023-11-05T00:24:20-04:00 testsuite: fix optasm tests for wasm32 - - - - - 1b90735c by Matthew Pickering at 2023-11-05T00:24:20-04:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - db9a6496 by Alan Zimmerman at 2023-11-05T00:24:55-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 833e250c by Simon Peyton Jones at 2023-11-05T00:25:31-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - e451139f by Andreas Klebinger at 2023-11-05T00:26:07-04:00 Remove an accidental git conflict marker from a comment. - - - - - 30baac7a by Tobias Haslop at 2023-11-06T10:50:32+00:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - df626f00 by Tobias Haslop at 2023-11-07T02:20:37-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 8217acb8 by Alan Zimmerman at 2023-11-07T02:21:12-05:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - dd88a260 by Luite Stegeman at 2023-11-07T02:21:53-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - 455524a2 by Matthew Craven at 2023-11-09T08:41:59-05:00 Create specially-solved DataToTag class Closes #20532. This implements CLC proposal 104: https://github.com/haskell/core-libraries-committee/issues/104 The design is explained in Note [DataToTag overview] in GHC.Tc.Instance.Class. This replaces the existing `dataToTag#` primop. These metric changes are not "real"; they represent Unique-related flukes triggering on a different set of jobs than they did previously. See also #19414. Metric Decrease: T13386 T8095 Metric Increase: T13386 T8095 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - a05f4554 by Alan Zimmerman at 2023-11-09T08:42:35-05:00 EPA: get rid of glRR and friends in GHC/Parser.y With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead Metric Decrease: MultiLayerModulesTH_Make - - - - - 18498538 by Cheng Shao at 2023-11-09T16:58:12+00:00 ci: bump ci-images for wasi-sdk upgrade - - - - - 52c0fc69 by PHO at 2023-11-09T19:16:22-05:00 Don't assume the current locale is *.UTF-8, set the encoding explicitly primops.txt contains Unicode characters: > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226) Hadrian must also avoid using readFile' to read primops.txt because it tries to decode the file with a locale-specific encoding. - - - - - 7233b3b1 by PHO at 2023-11-09T19:17:01-05:00 Use '[' instead of '[[' because the latter is a Bash-ism It doesn't work on platforms where /bin/sh is something other than Bash. - - - - - 6dbab180 by Simon Peyton Jones at 2023-11-09T19:17:36-05:00 Add an extra check in kcCheckDeclHeader_sig Fix #24083 by checking for a implicitly-scoped type variable that is not actually bound. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures. Metric Decrease: MultiLayerModulesTH_Make - - - - - 22551364 by Sven Tennie at 2023-11-11T06:35:22-05:00 AArch64: Delete unused LDATA pseudo-instruction Though there were consuming functions for LDATA, there were no producers. Thus, the removed code was "dead". - - - - - 2a0ec8eb by Alan Zimmerman at 2023-11-11T06:35:59-05:00 EPA: harmonise acsa and acsA in GHC/Parser.y With the HasLoc class, we can remove the acsa helper function, using acsA instead. - - - - - 7ae517a0 by Teo Camarasu at 2023-11-12T08:04:12-05:00 nofib: bump submodule This includes changes that: - fix building a benchmark with HEAD - remove a Makefile-ism that causes errors in bash scripts Resolves #24178 - - - - - 3f0036ec by Alan Zimmerman at 2023-11-12T08:04:47-05:00 EPA: Replace Anchor with EpaLocation An Anchor has a location and an operation, which is either that it is unchanged or that it has moved with a DeltaPos data Anchor = Anchor { anchor :: RealSrcSpan , anchor_op :: AnchorOperation } An EpaLocation also has either a location or a DeltaPos data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] Now that we do not care about always having a location in the anchor, we remove Anchor and replace it with EpaLocation We do this with a type alias initially, to ease the transition. The alias will be removed in time. We also have helpers to reconstruct the AnchorOperation from an EpaLocation. This is also temporary. Updates Haddock submodule - - - - - a7492048 by Alan Zimmerman at 2023-11-12T13:43:07+00:00 EPA: get rid of AnchorOperation Now that the Anchor type is an alias for EpaLocation, remove AnchorOperation. Updates haddock submodule - - - - - 0745c34d by Andrew Lelechenko at 2023-11-13T16:25:07-05:00 Add since annotation for showHFloat - - - - - e98051a5 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 Suppress duplicate librares linker warning of new macOS linker Fixes #24167 XCode 15 introduced a new linker which warns on duplicate libraries being linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as suggested by Brad King in CMake issue #25297. This flag isn't necessarily available to other linkers on darwin, so we must only configure it into the CC linker arguments if valid. - - - - - c411c431 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Encoding test witnesses recent iconv bug is fragile A regression in the new iconv() distributed with XCode 15 and MacOS Sonoma causes the test 'encoding004' to fail in the CP936 roundrip. We mark this test as fragile until this is fixed upstream (rather than broken, since previous versions of iconv pass the test) See #24161 - - - - - ce7fe5a9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Update to LC_ALL=C no longer being ignored in darwin MacOS seems to have fixed an issue where it used to ignore the variable `LC_ALL` in program invocations and default to using Unicode. Since the behaviour seems to be fixed to account for the locale variable, we mark tests that were previously broken in spite of it as fragile (since they now pass in recent macOS distributions) See #24161 - - - - - e6c803f7 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 929ba2f9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Skip MultiLayerModulesTH_Make on darwin The recent toolchain upgrade on darwin machines resulted in the MultiLayerModulesTH_Make test metrics varying too much from the baseline, ultimately blocking the CI pipelines. This commit skips the test on darwin to temporarily avoid failures due to the environment change in the runners. However, the metrics divergence is being investigated still (tracked in #24177) - - - - - af261ccd by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 configure: check target (not build) understands -no_compact_unwind Previously, we were branching on whether the build system was darwin to shortcut this check, but we really want to branch on whether the target system (which is what we are configuring ld_prog for) is darwin. - - - - - 2125c176 by Luite Stegeman at 2023-11-15T13:19:38-05:00 JS: Fix missing variable declarations The JStg IR update was missing some local variable declarations that were present earlier, causing global variables to be used implicitly (or an error in JavaScript strict mode). This adds the local variable declarations again. - - - - - 99ced73b by Krzysztof Gogolewski at 2023-11-15T13:20:14-05:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - 2aff2361 by Zubin Duggal at 2023-11-15T13:20:50-05:00 users-guide: Fix links to libraries from the users-guide. The unit-ids generated in c1a3ecde720b3bddc2c8616daaa06ee324e602ab include the package name, so we don't need to explicitly add it to the links. Fixes #24151 - - - - - 27981fac by Alan Zimmerman at 2023-11-15T13:21:25-05:00 EPA: splitLHsForAllTyInvis does not return ann We did not use the annotations returned from splitLHsForAllTyInvis, so do not return them. - - - - - a6467834 by Krzysztof Gogolewski at 2023-11-15T22:22:59-05:00 Document defaulting of RuntimeReps Fixes #24099 - - - - - 2776920e by Simon Peyton Jones at 2023-11-15T22:23:35-05:00 Second fix to #24083 My earlier fix turns out to be too aggressive for data/type families See wrinkle (DTV1) in Note [Disconnected type variables] - - - - - cee81370 by Sylvain Henry at 2023-11-16T09:57:46-05:00 Fix unusable units and module reexport interaction (#21097) This commit fixes an issue with ModUnusable introduced in df0f148feae. In mkUnusableModuleNameProvidersMap we traverse the list of unusable units and generate ModUnusable origin for all the modules they contain: exposed modules, hidden modules, and also re-exported modules. To do this we have a two-level map: ModuleName -> Unit:ModuleName (aka Module) -> ModuleOrigin So for each module name "M" in broken unit "u" we have: "M" -> u:M -> ModUnusable reason However in the case of module reexports we were using the *target* module as a key. E.g. if "u:M" is a reexport for "X" from unit "o": "M" -> o:X -> ModUnusable reason Case 1: suppose a reexport without module renaming (u:M -> o:M) from unusable unit u: "M" -> o:M -> ModUnusable reason Here it's claiming that the import of M is unusable because a reexport from u is unusable. But if unit o isn't unusable we could also have in the map: "M" -> o:M -> ModOrigin ... Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModOrigin) Case 2: similarly we could have 2 unusable units reexporting the same module without renaming, say (u:M -> o:M) and (v:M -> o:M) with u and v unusable. It gives: "M" -> o:M -> ModUnusable ... (for u) "M" -> o:M -> ModUnusable ... (for v) Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModUnusable). This led to #21097, #16996, #11050. To fix this, in this commit we make ModUnusable track whether the module used as key is a reexport or not (for better error messages) and we use the re-export module as key. E.g. if "u:M" is a reexport for "o:X" and u is unusable, we now record: "M" -> u:M -> ModUnusable reason reexported=True So now, we have two cases for a reexport u:M -> o:X: - u unusable: "M" -> u:M -> ModUnusable ... reexported=True - u usable: "M" -> o:X -> ModOrigin ... reexportedFrom=u:M The second case is indexed with o:X because in this case the Semigroup instance of ModOrigin is used to combine valid expositions of a module (directly or via reexports). Note that module lookup functions select usable modules first (those who have a ModOrigin value), so it doesn't matter if we add new ModUnusable entries in the map like this: "M" -> { u:M -> ModUnusable ... reexported=True o:M -> ModOrigin ... } The ModOrigin one will be used. Only if there is no ModOrigin or ModHidden entry will the ModUnusable error be printed. See T21097 for an example printing several reasons why an import is unusable. - - - - - 3e606230 by Krzysztof Gogolewski at 2023-11-16T09:58:22-05:00 Fix IPE test A helper function was defined in a different module than used. To reproduce: ./hadrian/build test --test-root-dirs=testsuite/tests/rts/ipe - - - - - 49f5264b by Andreas Klebinger at 2023-11-16T20:52:11-05:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Use rep size rather than rep count to compute the size. Fixes #22309 - - - - - b4f84e4b by James Henri Haydon at 2023-11-16T20:52:53-05:00 Explicit methods for Alternative Compose Explicitly define some and many in Alternative instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/181 - - - - - 9bc0dd1f by Ignat Insarov at 2023-11-16T20:53:34-05:00 Add permutations for non-empty lists. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 5643ecf9 by Andrew Lelechenko at 2023-11-16T20:53:34-05:00 Update changelog and since annotations for Data.List.NonEmpty.permutations Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 94ff2134 by Oleg Alexander at 2023-11-16T20:54:15-05:00 Update doc string for traceShow Updated doc string for traceShow. - - - - - faff671a by Luite Stegeman at 2023-11-17T14:12:51+01:00 JS: clean up some foreign imports - - - - - 856e0a4e by Sven Tennie at 2023-11-18T06:54:11-05:00 AArch64: Remove unused instructions As these aren't ever emitted, we don't even know if they work or will ever be used. If one of them is needed in future, we may easily re-add it. Deleted instructions are: - CMN - ANDS - BIC - BICS - EON - ORN - ROR - TST - STP - LDP - DMBSY - - - - - 615441ef by Alan Zimmerman at 2023-11-18T06:54:46-05:00 EPA: Replace Monoid with NoAnn Remove the final Monoid instances in the exact print infrastructure. For Windows CI Metric Decrease: T5205 - - - - - 5a6c49d4 by David Feuer at 2023-11-20T18:53:18-05:00 Speed up stimes in instance Semigroup Endo As discussed at https://github.com/haskell/core-libraries-committee/issues/4 - - - - - cf9da4b3 by Andrew Lelechenko at 2023-11-20T18:53:18-05:00 base: reflect latest changes in the changelog - - - - - 48bf364e by Alan Zimmerman at 2023-11-20T18:53:54-05:00 EPA: Use SrcSpan in EpaSpan This is more natural, since we already need to deal with invalid RealSrcSpans, and that is exactly what SrcSpan.UnhelpfulSpan is for. Updates haddock submodule. - - - - - 97ec37cc by Sebastian Graf at 2023-11-20T18:54:31-05:00 Add regression test for #6070 Fixes #6070. - - - - - e9d5ae41 by Owen Shepherd at 2023-11-21T18:32:23-05:00 chore: Correct typo in the gitlab MR template [skip ci] - - - - - f158a8d0 by Rodrigo Mesquita at 2023-11-21T18:32:59-05:00 Improve error message when reading invalid `.target` files A `.target` file generated by ghc-toolchain or by configure can become invalid if the target representation (`Toolchain.Target`) is changed while the files are not re-generated by calling `./configure` or `ghc-toolchain` again. There is also the issue of hadrian caching the dependencies on `.target` files, which makes parsing fail when reading reading the cached value if the representation has been updated. This patch provides a better error message in both situations, moving away from a terrible `Prelude.read: no parse` error that you would get otherwise. Fixes #24199 - - - - - 955520c6 by Ben Gamari at 2023-11-21T18:33:34-05:00 users guide: Note that QuantifiedConstraints implies ExplicitForAll Fixes #24025. - - - - - 17ec3e97 by Owen Shepherd at 2023-11-22T09:37:28+01:00 fix: Change type signatures in NonEmpty export comments to reflect reality This fixes several typos in the comments of Data.List.NonEmpty export list items. - - - - - 2fd78f9f by Samuel Thibault at 2023-11-22T11:49:13-05:00 Fix the platform string for GNU/Hurd As commited in Cargo https://github.com/haskell/cabal/pull/9434 there is confusion between "gnu" and "hurd". This got fixed in Cargo, we need the converse in Hadrian. Fixes #24180 - - - - - a79960fe by Alan Zimmerman at 2023-11-22T11:49:48-05:00 EPA: Tuple Present no longer has annotation The Present constructor for a Tuple argument will never have an exact print annotation. So make this impossible. - - - - - 121c9ab7 by David Binder at 2023-11-22T21:12:29-05:00 Unify the hpc testsuites The hpc testsuite was split between testsuite/tests/hpc and the submodule libraries/hpc/test. This commit unifies the two testsuites in the GHC repository in the directory testsuite/tests/hpc. - - - - - d2733a05 by Alan Zimmerman at 2023-11-22T21:13:05-05:00 EPA: empty tup_tail has noAnn In Parser.y, the tup_tail rule had the following option | {- empty -} %shift { return [Left noAnn] } Once this works through PostProcess.hs, it means we add an extra Missing constructor if the last item was a comma. Change the annotation type to a Bool to indicate this, and use the EpAnn Anchor for the print location for the others. - - - - - fa576eb8 by Andreas Klebinger at 2023-11-24T08:29:13-05:00 Fix FMA primops generating broken assembly on x86. `genFMA3Code` assumed that we had to take extra precations to avoid overwriting the result of `getNonClobberedReg`. One of these special cases caused a bug resulting in broken assembly. I believe we don't need to hadle these cases specially at all, which means this MR simply deletes the special cases to fix the bug. Fixes #24160 - - - - - 34d86315 by Alan Zimmerman at 2023-11-24T08:29:49-05:00 EPA: Remove parenthesizeHsType This is called from PostProcess.hs, and adds spurious parens. With the looser version of exact printing we had before we could tolerate this, as they would be swallowed by the original at the same place. But with the next change (remove EpAnnNotUsed) they result in duplicates in the output. For Darwin build: Metric Increase: MultiLayerModulesTH_OneShot - - - - - 3ede659d by Vladislav Zavialov at 2023-11-26T06:43:32-05:00 Add name for -Wdeprecated-type-abstractions (#24154) This warning had no name or flag and was triggered unconditionally. Now it is part of -Wcompat. - - - - - 7902ebf8 by Alan Zimmerman at 2023-11-26T06:44:08-05:00 EPA: Remove EpAnnNotUsed We no longer need the EpAnnNotUsed constructor for EpAnn, as we can represent an unused annotation with an anchor having a EpaDelta of zero, and empty comments and annotations. This simplifies code handling annotations considerably. Updates haddock submodule Metric Increase: parsing001 - - - - - 471b2672 by Mario Blažević at 2023-11-26T06:44:48-05:00 Bumped the upper bound of text to <2.2 - - - - - d1bf25c7 by Vladislav Zavialov at 2023-11-26T11:45:49-05:00 Term variable capture (#23740) This patch changes type variable lookup rules (lookupTypeOccRn) and implicit quantification rules (filterInScope) so that variables bound in the term namespace can be captured at the type level {-# LANGUAGE RequiredTypeArguments #-} f1 x = g1 @x -- `x` used in a type application f2 x = g2 (undefined :: x) -- `x` used in a type annotation f3 x = g3 (type x) -- `x` used in an embedded type f4 x = ... where g4 :: x -> x -- `x` used in a type signature g4 = ... This change alone does not allow us to accept examples shown above, but at least it gets them past the renamer. - - - - - da863d15 by Vladislav Zavialov at 2023-11-26T11:46:26-05:00 Update Note [hsScopedTvs and visible foralls] The Note was written before GHC gained support for visible forall in types of terms. Rewrite a few sentences and use a better example. - - - - - b5213542 by Matthew Pickering at 2023-11-27T12:53:59-05:00 testsuite: Add mechanism to collect generic metrics * Generalise the metric logic by adding an additional field which allows you to specify how to query for the actual value. Previously the method of querying the baseline value was abstracted (but always set to the same thing). * This requires rejigging how the stat collection works slightly but now it's more uniform and hopefully simpler. * Introduce some new "generic" helper functions for writing generic stats tests. - collect_size ( deviation, path ) Record the size of the file as a metric - stat_from_file ( metric, deviation, path ) Read a value from the given path, and store that as a metric - collect_generic_stat ( metric, deviation, get_stat) Provide your own `get_stat` function, `lambda way: <Int>`, which can be used to establish the current value of the metric. - collect_generic_stats ( metric_info ): Like collect_generic_stat but provide the whole dictionary of metric definitions. { metric: { deviation: <Int> current: lambda way: <Int> } } * Introduce two new "size" metrics for keeping track of build products. - `size_hello_obj` - The size of `hello.o` from compiling hello.hs - `libdir` - The total size of the `libdir` folder. * Track the number of modules in the AST tests - CountDepsAst - CountDepsParser This lays the infrastructure for #24191 #22256 #17129 - - - - - 7d9a2e44 by ARATA Mizuki at 2023-11-27T12:54:39-05:00 x86: Don't require -mavx2 when using 256-bit floating-point SIMD primitives Fixes #24222 - - - - - 4e5ff6a4 by Alan Zimmerman at 2023-11-27T12:55:15-05:00 EPA: Remove SrcSpanAnn Now that we only have a single constructor for EpAnn, And it uses a SrcSpan for its location, we can do away with SrcSpanAnn completely. It only existed to wrap the original SrcSpan in a location, and provide a place for the exact print annotation. For darwin only: Metric Increase: MultiLayerModulesTH_OneShot Updates haddock submodule - - - - - e05bca39 by Krzysztof Gogolewski at 2023-11-28T08:00:55-05:00 testsuite: don't initialize testdir to '.' The test directory is removed during cleanup, if there's an interrupt that could remove the entire repository. Fixes #24219 - - - - - af881674 by Alan Zimmerman at 2023-11-28T08:01:30-05:00 EPA: Clean up mkScope in Ast.hs Now that we have HasLoc we can get rid of all the custom variants of mkScope For deb10-numa Metric Increase: libdir - - - - - 292983c8 by Ben Gamari at 2023-11-28T22:44:28-05:00 distrib: Rediscover otool and install_name_tool on Darwin In the bindist configure script we must rediscover the `otool` and `install_name_tool`s since they may be different from the build environment. Fixes #24211. - - - - - dfe1c354 by Stefan Schulze Frielinghaus at 2023-11-28T22:45:04-05:00 llvmGen: Align objects in the data section Objects in the data section may be referenced via tagged pointers. Thus, align those objects to a 4- or 8-byte boundary for 32- or 64-bit platforms, respectively. Note, this may need to be reconsidered if objects with a greater natural alignment requirement are emitted as e.g. 128-bit atomics. Fixes #24163. - - - - - f6c486c3 by Matthew Pickering at 2023-11-29T11:08:13-05:00 metrics: Widen libdir and size_hello_obj acceptance window af8816740d9b8759be1a22af8adcb5f13edeb61d shows that the libdir size can fluctuate quite significantly even when the change is quite small. Therefore we widen the acceptance window to 10%. - - - - - 99a6a49c by Alan Zimmerman at 2023-11-29T11:08:49-05:00 EPA: Clean up TC Monad Utils We no longer need the alternative variant of addLocM (addLocMA) nor wrapLocAM, wrapLocSndMA. aarch64-darwin Metric Increase: MultiLayerModulesTH_OneShot deb10-numa-slow Metric Decrease: libdir - - - - - cbc03fa0 by Sebastian Graf at 2023-11-30T12:37:21-05:00 perf tests: Move comments into new `Note [Sensitivity to unique increment]` (#19414) And additionally to T12545, link from T8095, T13386 to this new Note. - - - - - c7623b22 by Alan Zimmerman at 2023-11-30T12:37:56-05:00 EPA: EpaDelta for comment has no comments EpaLocation is used to position things. It has two constructors, EpaSpan holding a SrcSpan, and EpaDelta with a delta position and a possible list of comments. The comment list is needed because the location in EpaDelta has no absolute information to decide which comments should be emitted before them when printing. But it is also used for specifying the position of a comment. To prevent the absurdity of a comment position having a list of comments in it, we make EpaLocation parameterisable, using comments for the normal case and a constant for within comments. Updates haddock submodule. aarch64-darwin Metric Decrease: MultiLayerModulesTH_OneShot - - - - - bd8acc0c by Krzysztof Gogolewski at 2023-11-30T12:38:32-05:00 Kind-check body of a required forall We now require that in 'forall a -> ty', ty has kind TYPE r for some r. Fixes #24176 - - - - - 010fb784 by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Remove incorrect haddock link quotes in code block - - - - - cda9c12d by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Remove cycle from group haddock example - - - - - 495265b9 by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Use repl haddock syntax in group docs - - - - - d134d1de by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Use list [] notation in group haddock - - - - - dfcf629c by Owen Shepherd at 2023-12-03T00:10:10-05:00 docs(NonEmpty/group): Specify final property of group function in haddock - - - - - cad3b734 by Owen Shepherd at 2023-12-03T00:10:10-05:00 fix: Add missing property of List.group - - - - - bad37656 by Matthew Pickering at 2023-12-03T00:10:46-05:00 testsuite: Fix T21097b test with make 4.1 (deb9) cee81370cd6ef256f66035e3116878d4cb82e28b recently added a test which failed on deb9 because the version of make was emitting the recipe failure to stdout rather than stderr. One way to fix this is to be more precise in the test about which part of the output we care about inspecting. - - - - - 5efdf421 by Matthew Pickering at 2023-12-03T00:11:21-05:00 testsuite: Track size of libdir in bytes For consistency it's better if we track all size metrics in bytes. Metric Increase: libdir - - - - - f5eb0f29 by Matthew Pickering at 2023-12-03T00:11:22-05:00 testsuite: Remove rogue trace in testsuite I accidentally left a trace in the generics metric patch. - - - - - d5610737 by Claudio Bley at 2023-12-06T16:13:33-05:00 Only exit ghci in -e mode when :add command fails Previously, when running `ghci -e ':add Sample.hs'` the process would exit with exit code 1 if the file exists and could be loaded. Fixes #24115 - - - - - 0f0c53a5 by Vladislav Zavialov at 2023-12-06T16:14:09-05:00 T2T in Patterns (#23739) This patch implements the T2T (term-to-type) transformation in patterns. Patterns that are checked against a visible forall can now be written without the `type` keyword: \(type t) (x :: t) -> ... -- old \t (x :: t) -> ... -- new The `t` binder is parsed and renamed as a term pattern (Pat), but then undergoes a conversion to a type pattern (HsTyPat). See the new function pat_to_type_pat in compiler/GHC/Tc/Gen/Pat.hs - - - - - 10a1a6c6 by Sebastian Graf at 2023-12-06T16:14:45-05:00 Pmc: Fix SrcLoc and warning for incomplete irrefutable pats (#24234) Before, the source location would point at the surrounding function definition, causing the confusion in #24234. I also took the opportunity to introduce a new `LazyPatCtx :: HsMatchContext _` to make the warning message say "irrefutable pattern" instead of "pattern binding". - - - - - 36b9a38c by Matthew Pickering at 2023-12-06T16:15:21-05:00 libraries: Bump filepath to 1.4.200.1 and unix to 2.8.4.0 Updates filepath submodule Updates unix submodule Fixes #24240 - - - - - 91ff0971 by Matthew Pickering at 2023-12-06T16:15:21-05:00 Submodule linter: Allow references to tags We modify the submodule linter so that if the bumped commit is a specific tag then the commit is accepted. Fixes #24241 - - - - - 86f652dc by Zubin Duggal at 2023-12-06T16:15:21-05:00 hadrian: set -Wno-deprecations for directory and Win32 The filepath bump to 1.4.200.1 introduces a deprecation warning. See https://gitlab.haskell.org/ghc/ghc/-/issues/24240 https://github.com/haskell/filepath/pull/206 - - - - - 7ac6006e by Sylvain Henry at 2023-12-06T16:16:02-05:00 Zap OccInfo on case binders during StgCse #14895 #24233 StgCse can revive dead binders: case foo of dead { Foo x y -> Foo x y; ... } ===> case foo of dead { Foo x y -> dead; ... } -- dead is no longer dead So we must zap occurrence information on case binders. Fix #14895 and #24233 - - - - - 57c391c4 by Sebastian Graf at 2023-12-06T16:16:37-05:00 Cpr: Turn an assertion into a check to deal with some dead code (#23862) See the new `Note [Dead code may contain type confusions]`. Fixes #23862. - - - - - c1c8abf8 by Zubin Duggal at 2023-12-08T02:25:07-05:00 testsuite: add test for #23944 - - - - - 6329d308 by Zubin Duggal at 2023-12-08T02:25:07-05:00 driver: Only run a dynamic-too pipeline if object files are going to be generated Otherwise we run into a panic in hscMaybeWriteIface: "Unexpected DT_Dyn state when writing simple interface" when dynamic-too is enabled We could remove the panic and just write the interface even if the state is `DT_Dyn`, but it seems pointless to run the pipeline twice when `hscMaybeWriteIface` is already designed to write both `hi` and `dyn_hi` files if dynamic-too is enabled. Fixes #23944. - - - - - 28811f88 by Simon Peyton Jones at 2023-12-08T05:47:18-05:00 Improve duplicate elimination in SpecConstr This partially fixes #24229. See the new Note [Pattern duplicate elimination] in SpecConstr - - - - - fec7894f by Simon Peyton Jones at 2023-12-08T05:47:18-05:00 Make SpecConstr deal with casts better This patch does two things, to fix #23209: * It improves SpecConstr so that it no longer quantifies over coercion variables. See Note [SpecConstr and casts] * It improves the rule matcher to deal nicely with the case where the rule does not quantify over coercion variables, but the the template has a cast in it. See Note [Casts in the template] - - - - - 8db8d2fd by Zubin Duggal at 2023-12-08T05:47:54-05:00 driver: Don't lose track of nodes when we fail to resolve cycles The nodes that take part in a cycle should include both hs-boot and hs files, but when we fail to resolve a cycle, we were only counting the nodes from the graph without boot files. Fixes #24196 - - - - - c5b4efd3 by Zubin Duggal at 2023-12-08T05:48:30-05:00 testsuite: Skip MultiLayerModulesTH_OneShot on darwin See #24177 - - - - - fae472a9 by Wendao Lee at 2023-12-08T05:49:12-05:00 docs(Data.Char):Add more detailed descriptions for some functions Related changed function's docs: -GHC.Unicode.isAlpha -GHC.Unicode.isPrint -GHC.Unicode.isAlphaNum Add more details for what the function will return. Co-authored-by: Bodigrim <andrew.lelechenko at gmail.com> - - - - - ca7510e4 by Malik Ammar Faisal at 2023-12-08T05:49:55-05:00 Fix float parsing in GHC Cmm Lexer Add test case for bug #24224 - - - - - d8baa1bd by Simon Peyton Jones at 2023-12-08T15:40:37+00:00 Take care when simplifying unfoldings This MR fixes a very subtle bug exposed by #24242. See Note [Environment for simplLetUnfolding]. I also updated a bunch of Notes on shadowing - - - - - 03ca551d by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Comments only in FloatIn Relevant to #3458 - - - - - 50c78779 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Comments only in SpecConstr - - - - - 9431e195 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Add test for #22238 - - - - - d9e4c597 by Vladislav Zavialov at 2023-12-11T04:19:34-05:00 Make forall a keyword (#23719) Before this change, GHC used to accept `forall` as a term-level identifier: -- from constraints-0.13 forall :: forall p. (forall a. Dict (p a)) -> Dict (Forall p) forall d = ... Now it is a parse error. The -Wforall-identifier warning has served its purpose and is now a deprecated no-op. - - - - - 58d56644 by Zubin Duggal at 2023-12-11T04:20:10-05:00 driver: Ensure we actually clear the interactive context before reloading Previously we called discardIC, but immediately after set the session back to an old HscEnv that still contained the IC Partially addresses #24107 Fixes #23405 - - - - - 8e5745a0 by Zubin Duggal at 2023-12-11T04:20:10-05:00 driver: Ensure we force the lookup of old build artifacts before returning the build plan This prevents us from retaining all previous build artifacts in memory until a recompile finishes, instead only retaining the exact artifacts we need. Fixes #24118 - - - - - 105c370c by Zubin Duggal at 2023-12-11T04:20:10-05:00 testsuite: add test for #24118 and #24107 MultiLayerModulesDefsGhci was not able to catch the leak because it uses :l which discards the previous environment. Using :r catches both of these leaks - - - - - e822ff88 by Zubin Duggal at 2023-12-11T04:20:10-05:00 compiler: Add some strictness annotations to ImportSpec and related constructors This prevents us from retaining entire HscEnvs. Force these ImportSpecs when forcing the GlobalRdrEltX Adds an NFData instance for Bag Fixes #24107 - - - - - 522c12a4 by Zubin Duggal at 2023-12-11T04:20:10-05:00 compiler: Force IfGlobalRdrEnv in NFData instance. - - - - - 188b280d by Arnaud Spiwack at 2023-12-11T15:33:31+01:00 LinearTypes => MonoLocalBinds - - - - - 8e0446df by Arnaud Spiwack at 2023-12-11T15:44:28+01:00 Linear let and where bindings For expediency, the initial implementation of linear types in GHC made it so that let and where binders would always be considered unrestricted. This was rather unpleasant, and probably a big obstacle to adoption. At any rate, this was not how the proposal was designed. This patch fixes this infelicity. It was surprisingly difficult to build, which explains, in part, why it took so long to materialise. As of this patch, let or where bindings marked with %1 will be linear (respectively %p for an arbitrary multiplicity p). Unmarked let will infer their multiplicity. Here is a prototypical example of program that used to be rejected and is accepted with this patch: ```haskell f :: A %1 -> B g :: B %1 -> C h :: A %1 -> C h x = g y where y = f x ``` Exceptions: - Recursive let are unrestricted, as there isn't a clear semantics of what a linear recursive binding would be. - Destructive lets with lazy bindings are unrestricted, as their desugaring isn't linear (see also #23461). - (Strict) destructive lets with inferred polymorphic type are unrestricted. Because the desugaring isn't linear (See #18461 down-thread). Closes #18461 and #18739 Co-authored-by: @jackohughes - - - - - effa7e2d by Matthew Craven at 2023-12-12T04:37:20-05:00 Introduce `dataToTagSmall#` primop (closes #21710) ...and use it to generate slightly better code when dataToTag# is used at a "small data type" where there is no need to mess with "is_too_big_tag" or potentially look at an info table. Metric Decrease: T18304 - - - - - 35c7aef6 by Matthew Craven at 2023-12-12T04:37:20-05:00 Fix formatting of Note [alg-alt heap check] - - - - - 7397c784 by Oleg Grenrus at 2023-12-12T04:37:56-05:00 Allow untyped brackets in typed splices and vice versa. Resolves #24190 Apparently the check was essentially always (as far as I can trace back: d0d47ba76f8f0501cf3c4966bc83966ab38cac27), and while it does catch some mismatches, the type-checker will catch them too. OTOH, it prevents writing completely reasonable programs. - - - - - a3ee3b99 by Moritz Angermann at 2023-12-12T19:50:58-05:00 Drop hard Xcode dependency XCODE_VERSION calls out to `xcodebuild`, which is only available when having `Xcode` installed. The CommandLineTools are not sufficient. To install Xcode, you must have an apple id to download the Xcode.xip from apple. We do not use xcodebuild anywhere in our build explicilty. At best it appears to be a proxy for checking the linker or the compiler. These should rather be done with ``` xcrun ld -version ``` or similar, and not by proxy through Xcode. The CLR should be sufficient for building software on macOS. - - - - - 1c9496e0 by Vladislav Zavialov at 2023-12-12T19:51:34-05:00 docs: update information on RequiredTypeArguments Update the User's Guide and Release Notes to account for the recent progress in the implementation of RequiredTypeArguments. - - - - - d0b17576 by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Fix off-by-one in assertion Previously we failed to account for the NULL terminator `postString` asserted that there is enough room in the buffer for the string. - - - - - a10f9b9b by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Honor result of ensureRoomForVariableEvent is Previously we would keep plugging along, even if isn't enough room for the event. - - - - - 0e0f41c0 by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Avoid truncating event sizes Previously ensureRoomForVariableEvent would truncate the desired size to 16-bits, resulting in #24197. Fixes #24197. - - - - - 64e724c8 by Artin Ghasivand at 2023-12-13T06:34:20-05:00 Remove the "Derived Constraint" argument of TcPluginSolver, docs - - - - - fe6d97dd by Vladislav Zavialov at 2023-12-13T06:34:56-05:00 EPA: Move tokens into GhcPs extension fields (#23447) Summary of changes * Remove Language.Haskell.Syntax.Concrete * Move all tokens into GhcPs extension fields (LHsToken -> EpToken) * Create new TTG extension fields as needed * Drop the MultAnn wrapper Updates the haddock submodule. Co-authored-by: Alan Zimmerman <alan.zimm at gmail.com> - - - - - 8106e695 by Zubin Duggal at 2023-12-13T06:35:34-05:00 testsuite: use copy_files in T23405 This prevents the tree from being dirtied when the file is modified. - - - - - ed0e4099 by Bryan Richter at 2023-12-14T04:30:53-05:00 Document ghc package's PVP-noncompliance This changes nothing, it just makes the status quo explicit. - - - - - 8bef8d9f by Luite Stegeman at 2023-12-14T04:31:33-05:00 JS: Mark spurious CI failures js_fragile(24259) This marks the spurious test failures on the JS platform as js_fragile(24259), so we don't hold up merge requests while fixing the underlying issues. See #24259 - - - - - 1c79526a by Finley McIlwaine at 2023-12-15T12:24:40-08:00 Late plugins - - - - - 000c3302 by Finley McIlwaine at 2023-12-15T12:24:40-08:00 withTiming on LateCCs and late plugins - - - - - be4551ac by Finley McIlwaine at 2023-12-15T12:24:40-08:00 add test for late plugins - - - - - 7c29da9f by Finley McIlwaine at 2023-12-15T12:24:40-08:00 Document late plugins - - - - - 9a52ae46 by Ben Gamari at 2023-12-20T07:07:26-05:00 Fix thunk update ordering Previously we attempted to ensure soundness of concurrent thunk update by synchronizing on the access of the thunk's info table pointer field. This was believed to be sufficient since the indirectee (which may expose a closure allocated by another core) would not be examined until the info table pointer update is complete. However, it turns out that this can result in data races in the presence of multiple threads racing a update a single thunk. For instance, consider this interleaving under the old scheme: Thread A Thread B --------- --------- t=0 Enter t 1 Push update frame 2 Begin evaluation 4 Pause thread 5 t.indirectee=tso 6 Release t.info=BLACKHOLE 7 ... (e.g. GC) 8 Resume thread 9 Finish evaluation 10 Relaxed t.indirectee=x 11 Load t.info 12 Acquire fence 13 Inspect t.indirectee 14 Release t.info=BLACKHOLE Here Thread A enters thunk `t` but is soon paused, resulting in `t` being lazily blackholed at t=6. Then, at t=10 Thread A finishes evaluation and updates `t.indirectee` with a relaxed store. Meanwhile, Thread B enters the blackhole. Under the old scheme this would introduce an acquire-fence but this would only synchronize with Thread A at t=6. Consequently, the result of the evaluation, `x`, is not visible to Thread B, introducing a data race. We fix this by treating the `indirectee` field as we do all other mutable fields. This means we must always access this field with acquire-loads and release-stores. See #23185. - - - - - f4b53538 by Vladislav Zavialov at 2023-12-20T07:08:02-05:00 docs: Fix link to 051-ghc-base-libraries.rst The proposal is no longer available at the previous URL. - - - - - f7e21fab by Matthew Pickering at 2023-12-21T14:57:40+00:00 hadrian: Build all executables in bin/ folder In the end the bindist creation logic copies them all into the bin folder. There is no benefit to building a specific few binaries in the lib/bin folder anymore. This also removes the ad-hoc logic to copy the touchy and unlit executables from stage0 into stage1. It takes <1s to build so we might as well just build it. - - - - - 0038d052 by Zubin Duggal at 2023-12-22T23:28:00-05:00 testsuite: mark jspace as fragile on i386. This test has been flaky for some time and has been failing consistently on i386-linux since 8e0446df landed. See #24261 - - - - - dfd670a0 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 609e6225 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 865513b2 by Ömer Sinan Ağacan at 2023-12-24T10:11:13-05:00 Fix BNF in user manual 6.6.8.2: formal syntax for instance declarations - - - - - c247b6be by Zubin Duggal at 2023-12-25T16:01:23-05:00 docs: document permissibility of -XOverloadedLabels (#24249) Document the permissibility introduced by https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - e5b7eb59 by Ömer Sinan Ağacan at 2023-12-25T16:02:03-05:00 Fix a code block syntax in user manual sec. 6.8.8.6 - - - - - 2db11c08 by Ben Gamari at 2023-12-29T15:35:48-05:00 genSym: Reimplement via CAS on 32-bit platforms Previously the remaining use of the C implementation on 32-bit platforms resulted in a subtle bug, #24261. This was due to the C object (which used the RTS's `atomic_inc64` macro) being compiled without `-threaded` yet later being used in a threaded compiler. Side-step this issue by using the pure Haskell `genSym` implementation on all platforms. This required implementing `fetchAddWord64Addr#` in terms of CAS on 64-bit platforms. - - - - - 19328a8c by Xiaoyan Ren at 2023-12-29T15:36:30-05:00 Do not color the diagnostic code in error messages (#24172) - - - - - 685b467c by Krzysztof Gogolewski at 2023-12-29T15:37:06-05:00 Enforce that bindings of implicit parameters are lifted Fixes #24298 - - - - - bc4d67b7 by Matthew Craven at 2023-12-31T06:15:42-05:00 StgToCmm: Detect some no-op case-continuations ...and generate no code for them. Fixes #24264. - - - - - 5b603139 by Krzysztof Gogolewski at 2023-12-31T06:16:18-05:00 Revert "testsuite: mark jspace as fragile on i386." This reverts commit 0038d052c8c80b4b430bb2aa1c66d5280be1aa95. The atomicity bug should be fixed by !11802. - - - - - d55216ad by Krzysztof Gogolewski at 2024-01-01T12:05:49-05:00 Refactor: store [[PrimRep]] rather than [Type] in STG StgConApp stored a list of types. This list was used exclusively during unarisation of unboxed sums (mkUbxSum). However, this is at a wrong level of abstraction: STG shouldn't be concerned with Haskell types, only PrimReps. Update the code to store a [[PrimRep]]. Also, there's no point in storing this list when we're not dealing with an unboxed sum. - - - - - 8b340bc7 by Ömer Sinan Ağacan at 2024-01-01T12:06:29-05:00 Kind signatures docs: mention that they're allowed in newtypes - - - - - 989bf8e5 by Zubin Duggal at 2024-01-03T20:08:47-05:00 ci: Ensure we use the correct bindist name for the test artifact when generating release ghcup metadata Fixes #24268 - - - - - 89299a89 by Krzysztof Gogolewski at 2024-01-03T20:09:23-05:00 Refactor: remove calls to typePrimRepArgs The function typePrimRepArgs is just a thin wrapper around typePrimRep, adding a VoidRep if the list is empty. However, in StgToByteCode, we were discarding that VoidRep anyway, so there's no point in calling it. - - - - - c7be0c68 by mmzk1526 at 2024-01-03T20:10:07-05:00 Use "-V" for alex version check for better backward compatibility Fixes #24302. In recent versions of alex, "-v" is used for "--verbose" instead of "-version". - - - - - 67dbcc0a by Krzysztof Gogolewski at 2024-01-05T02:07:18-05:00 Fix VoidRep handling in ghci debugger 'go' inside extractSubTerms was giving a bad result given a VoidRep, attempting to round towards the next multiple of 0. I don't understand much about the debugger but the code should be better than it was. Fixes #24306 - - - - - 90ea574e by Krzysztof Gogolewski at 2024-01-05T02:07:54-05:00 VoidRep-related refactor * In GHC.StgToByteCode, replace bcIdPrimId with idPrimRep, bcIdArgRep with idArgRep, atomPrimRep with stgArgRep1. All of them were duplicates. * In GHC.Stg.Unarise, we were converting a PrimRep to a Type and back to PrimRep. Remove the calls to primRepToType and typePrimRep1 which cancel out. * In GHC.STG.Lint, GHC.StgToCmm, GHC.Types.RepType we were filtering out VoidRep from the result of typePrimRep. But typePrimRep never returns VoidRep - remove the filtering. - - - - - eaf72479 by brian at 2024-01-06T23:03:09-05:00 Add unaligned Addr# primops Implements CLC proposal #154: https://github.com/haskell/core-libraries-committee/issues/154 * add unaligned addr primops * add tests * accept tests * add documentation * fix js primops * uncomment in access ops * use Word64 in tests * apply suggestions * remove extra file * move docs * remove random options * use setByteArray# primop * better naming * update base-exports test * add base-exports for other architectures - - - - - d471d445 by Krzysztof Gogolewski at 2024-01-06T23:03:47-05:00 Remove VoidRep from PrimRep, introduce PrimOrVoidRep This introduces data PrimOrVoidRep = VoidRep | NVRep PrimRep changes typePrimRep1 to return PrimOrVoidRep, and adds a new function typePrimRepU to be used when the argument is definitely non-void. Details in Note [VoidRep] in GHC.Types.RepType. Fixes #19520 - - - - - 48720a07 by Matthew Craven at 2024-01-08T18:57:36-05:00 Apply Note [Sensitivity to unique increment] to LargeRecord - - - - - 9e2e180f by Sebastian Graf at 2024-01-08T18:58:13-05:00 Debugging: Add diffUFM for convenient diffing between UniqFMs - - - - - 948f3e35 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Rename Opt_D_dump_stranal to Opt_D_dump_dmdanal ... and Opt_D_dump_str_signatures to Opt_D_dump_dmd_signatures - - - - - 4e217e3e by Sebastian Graf at 2024-01-08T18:58:13-05:00 Deprecate -ddump-stranal and -ddump-str-signatures ... and suggest -ddump-dmdanal and -ddump-dmd-signatures instead - - - - - 6c613c90 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Move testsuite/tests/stranal to testsuite/tests/dmdanal A separate commit so that the rename is obvious to Git(Lab) - - - - - c929f02b by Sebastian Graf at 2024-01-08T18:58:13-05:00 CoreSubst: Stricten `substBndr` and `cloneBndr` Doing so reduced allocations of `cloneBndr` by about 25%. ``` T9233(normal) ghc/alloc 672,488,656 663,083,216 -1.4% GOOD T9675(optasm) ghc/alloc 423,029,256 415,812,200 -1.7% geo. mean -0.1% minimum -1.7% maximum +0.1% ``` Metric Decrease: T9233 - - - - - e3ca78f3 by Krzysztof Gogolewski at 2024-01-10T17:35:59-05:00 Deprecate -Wsemigroup This warning was used to prepare for Semigroup becoming a superclass of Monoid, and for (<>) being exported from Prelude. This happened in GHC 8.4 in 8ae263ceb3566 and feac0a3bc69fd3. The leftover logic for (<>) has been removed in GHC 9.8, 4d29ecdfcc79. Now the warning does nothing at all and can be deprecated. - - - - - 08d14925 by amesgen at 2024-01-10T17:36:42-05:00 WASM metadata: use correct GHC version - - - - - 7a808419 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Allow SCC declarations in TH (#24081) - - - - - 28827c51 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Fix prettyprinting of SCC pragmas - - - - - ae9cc1a8 by Matthew Craven at 2024-01-10T17:38:01-05:00 Fix loopification in the presence of void arguments This also removes Note [Void arguments in self-recursive tail calls], which was just misleading. It's important to count void args both in the function's arity and at the call site. Fixes #24295. - - - - - b718b145 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: Teach testsuite driver about c++ sources - - - - - 09cb57ad by Zubin Duggal at 2024-01-10T17:38:36-05:00 driver: Set -DPROFILING when compiling C++ sources with profiling Earlier, we used to pass all preprocessor flags to the c++ compiler. This meant that -DPROFILING was passed to the c++ compiler because it was a part of C++ flags However, this was incorrect and the behaviour was changed in 8ff3134ed4aa323b0199ad683f72165e51a59ab6. See #21291. But that commit exposed this bug where -DPROFILING was no longer being passed when compiling c++ sources. The fix is to explicitly include -DPROFILING in `opt_cxx` when profiling is enabled to ensure we pass the correct options for the way to both C and C++ compilers Fixes #24286 - - - - - 2cf9dd96 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: rename objcpp -> objcxx To avoid confusion with C Pre Processsor - - - - - af6932d6 by Simon Peyton Jones at 2024-01-10T17:39:12-05:00 Make TYPE and CONSTRAINT not-apart Issue #24279 showed up a bug in the logic in GHC.Core.Unify.unify_ty which is supposed to make TYPE and CONSTRAINT be not-apart. Easily fixed. - - - - - 4a39b5ff by Zubin Duggal at 2024-01-10T17:39:48-05:00 ci: Fix typo in mk_ghcup_metadata.py There was a missing colon in the fix to #24268 in 989bf8e53c08eb22de716901b914b3607bc8dd08 - - - - - 13503451 by Zubin Duggal at 2024-01-10T17:40:24-05:00 release-ci: remove release-x86_64-linux-deb11-release+boot_nonmoving_gc job There is no reason to have this release build or distribute this variation. This configuration is for testing purposes only. - - - - - afca46a4 by Sebastian Graf at 2024-01-10T17:41:00-05:00 Parser: Add a Note detailing why we need happy's `error` to implement layout - - - - - eaf8a06d by Krzysztof Gogolewski at 2024-01-11T00:43:17+01:00 Turn -Wtype-equality-out-of-scope on by default Also remove -Wnoncanonical-{monoid,monad}-instances from -Wcompat, since they are enabled by default. Refresh wcompat-warnings/ test with new -Wcompat warnings. Part of #24267 Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 42bee5aa by Sebastian Graf at 2024-01-12T21:16:21-05:00 Arity: Require called *exactly once* for eta exp with -fpedantic-bottoms (#24296) In #24296, we had a program in which we eta expanded away an error despite the presence of `-fpedantic-bottoms`. This was caused by turning called *at least once* lambdas into one-shot lambdas, while with `-fpedantic-bottoms` it is only sound to eta expand over lambdas that are called *exactly* once. An example can be found in `Note [Combining arity type with demand info]`. Fixes #24296. - - - - - 7e95f738 by Andreas Klebinger at 2024-01-12T21:16:57-05:00 Aarch64: Enable -mfma by default. Fixes #24311 - - - - - e43788d0 by Jason Shipman at 2024-01-14T12:47:38-05:00 Add more instances for Compose: Fractional, RealFrac, Floating, RealFloat CLC proposal #226 https://github.com/haskell/core-libraries-committee/issues/226 - - - - - ae6d8cd2 by Sebastian Graf at 2024-01-14T12:48:15-05:00 Pmc: COMPLETE pragmas associated with Family TyCons should apply to representation TyCons as well (#24326) Fixes #24326. - - - - - c5fc7304 by sheaf at 2024-01-15T14:15:29-05:00 Use lookupOccRn_maybe in TH.lookupName When looking up a value, we want to be able to find both variables and record fields. So we should not use the lookupSameOccRn_maybe function, as we can't know ahead of time which record field namespace a record field with the given textual name will belong to. Fixes #24293 - - - - - da908790 by Krzysztof Gogolewski at 2024-01-15T14:16:05-05:00 Make the build more strict on documentation errors * Detect undefined labels. This can be tested by adding :ref:`nonexistent` to a documentation rst file; attempting to build docs will fail. Fixed the undefined label in `9.8.1-notes.rst`. * Detect errors. While we have plenty of warnings, we can at least enforce that Sphinx does not report errors. Fixed the error in `required_type_arguments.rst`. Unrelated change: I have documented that the `-dlint` enables `-fcatch-nonexhaustive-cases`, as can be verified by checking `enableDLint`. - - - - - 5077416e by Javier Sagredo at 2024-01-16T15:40:06-05:00 Profiling: Adds an option to not start time profiling at startup Using the functionality provided by d89deeba47ce04a5198a71fa4cbc203fe2c90794, this patch creates a new rts flag `--no-automatic-time-samples` which disables the time profiling when starting a program. It is then expected that the user starts it whenever it is needed. Fixes #24337 - - - - - 5776008c by Matthew Pickering at 2024-01-16T15:40:42-05:00 eventlog: Fix off-by-one error in postIPE We were missing the extra_comma from the calculation of the size of the payload of postIPE. This was causing assertion failures when the event would overflow the buffer by one byte, as ensureRoomForVariable event would report there was enough space for `n` bytes but then we would write `n + 1` bytes into the buffer. Fixes #24287 - - - - - 66dc09b1 by Simon Peyton Jones at 2024-01-16T15:41:18-05:00 Improve SpecConstr (esp nofib/spectral/ansi) This MR makes three improvements to SpecConstr: see #24282 * It fixes an outright (and recently-introduced) bug in `betterPat`, which was wrongly forgetting to compare the lengths of the argument lists. * It enhances ConVal to inclue a boolean for work-free-ness, so that the envt can contain non-work-free constructor applications, so that we can do more: see Note [ConVal work-free-ness] * It rejigs `subsumePats` so that it doesn't reverse the list. This can make a difference because, when patterns overlap, we arbitrarily pick the first. There is no "right" way, but this retains the old pre-subsumePats behaviour, thereby "fixing" the regression in #24282. Nofib results +======================================== | spectral/ansi -21.14% | spectral/hartel/comp_lab_zift -0.12% | spectral/hartel/parstof +0.09% | spectral/last-piece -2.32% | spectral/multiplier +6.03% | spectral/para +0.60% | spectral/simple -0.26% +======================================== | geom mean -0.18% +---------------------------------------- The regression in `multiplier` is sad, but it simply replicates GHC's previous behaviour (e.g. GHC 9.6). - - - - - 65da79b3 by Matthew Pickering at 2024-01-16T15:41:54-05:00 hadrian: Reduce Cabal verbosity The comment claims that `simpleUserHooks` decrease verbosity, and it does, but only for the `postConf` phase. The other phases are too verbose with `-V`. At the moment > 5000 lines of the build log are devoted to output from `cabal copy`. So I take the simple approach and just decrease the verbosity level again. If the output of `postConf` is essential then it would be better to implement our own `UserHooks` which doesn't decrease the verbosity for `postConf`. Fixes #24338 - - - - - 16414d7d by Matthew Pickering at 2024-01-17T10:54:59-05:00 Stop retaining old ModGuts throughout subsequent simplifier phases Each phase of the simplifier typically rewrites the majority of ModGuts, so we want to be able to release the old ModGuts as soon as possible. `name_ppr_ctxt` lives throught the whole optimiser phase and it was retaining a reference to `ModGuts`, so we were failing to release the old `ModGuts` until the end of the phase (potentially doubling peak memory usage for that particular phase). This was discovered using eras profiling (#24332) Fixes #24328 - - - - - 7f0879e1 by Matthew Pickering at 2024-01-17T10:55:35-05:00 Update nofib submodule - - - - - 320454d3 by Cheng Shao at 2024-01-17T23:02:40+00:00 ci: bump ci-images for updated wasm image - - - - - 2eca52b4 by Cheng Shao at 2024-01-17T23:06:44+00:00 base: treat all FDs as "nonblocking" on wasm On posix platforms, when performing read/write on FDs, we check the nonblocking flag first. For FDs without this flag (e.g. stdout), we call fdReady() first, which in turn calls poll() to wait for I/O to be available on that FD. This is problematic for wasm32-wasi: although select()/poll() is supported via the poll_oneoff() wasi syscall, that syscall is rather heavyweight and runtime behavior differs in different wasi implementations. The issue is even worse when targeting browsers, given there's no satisfactory way to implement async I/O as a synchronous syscall, so existing JS polyfills for wasi often give up and simply return ENOSYS. Before we have a proper I/O manager that avoids poll_oneoff() for async I/O on wasm, this patch improves the status quo a lot by merely pretending all FDs are "nonblocking". Read/write on FDs will directly invoke read()/write(), which are much more reliably handled in existing wasi implementations, especially those in browsers. Fixes #23275 and the following test cases: T7773 isEOF001 openFile009 T4808 cgrun025 Approved by CLC proposal #234: https://github.com/haskell/core-libraries-committee/issues/234 - - - - - 83c6c710 by Andrew Lelechenko at 2024-01-18T05:21:49-05:00 base: clarify how to disable warnings about partiality of Data.List.{head,tail} - - - - - c4078f2f by Simon Peyton Jones at 2024-01-18T05:22:25-05:00 Fix four bug in handling of (forall cv. body_ty) These bugs are all described in #24335 It's not easy to provoke the bug, hence no test case. - - - - - 119586ea by Alexis King at 2024-01-19T00:08:00-05:00 Always refresh profiling CCSes after running pending initializers Fixes #24171. - - - - - 9718d970 by Oleg Grenrus at 2024-01-19T00:08:36-05:00 Set default-language: GHC2021 in ghc library Go through compiler/ sources, and remove all BangPatterns (and other GHC2021 enabled extensions in these files). - - - - - 3ef71669 by Matthew Pickering at 2024-01-19T21:55:16-05:00 testsuite: Remove unused have_library function Also remove the hence unused testsuite option `--test-package-db`. Fixes #24342 - - - - - 5b7fa20c by Jade at 2024-01-19T21:55:53-05:00 Fix Spelling in the compiler Tracking: #16591 - - - - - 09875f48 by Matthew Pickering at 2024-01-20T12:20:44-05:00 testsuite: Implement `isInTreeCompiler` in a more robust way Just a small refactoring to avoid redundantly specifying the same strings in two different places. - - - - - 0d12b987 by Jade at 2024-01-20T12:21:20-05:00 Change maintainer email from cvs-ghc at haskell.org to ghc-devs at haskell.org. Fixes #22142 - - - - - 1fa1c00c by Jade at 2024-01-23T19:17:03-05:00 Enhance Documentation of functions exported by Data.Function This patch aims to improve the documentation of functions exported in Data.Function Tracking: #17929 Fixes: #10065 - - - - - ab47a43d by Jade at 2024-01-23T19:17:39-05:00 Improve documentation of hGetLine. - Add explanation for whether a newline is returned - Add examples Fixes #14804 - - - - - dd4af0e5 by Cheng Shao at 2024-01-23T19:18:17-05:00 Fix genapply for cross-compilation by nuking fragile CPP logic This commit fixes incorrectly built genapply when cross compiling (#24347) by nuking all fragile CPP logic in it from the orbit. All target-specific info are now read from DerivedConstants.h at runtime, see added note for details. Also removes a legacy Makefile and adds haskell language server support for genapply. - - - - - 0cda2b8b by Cheng Shao at 2024-01-23T19:18:17-05:00 rts: enable wasm32 register mapping The wasm backend didn't properly make use of all Cmm global registers due to #24347. Now that it is fixed, this patch re-enables full register mapping for wasm32, and we can now generate smaller & faster wasm modules that doesn't always spill arguments onto the stack. Fixes #22460 #24152. - - - - - 0325a6e5 by Greg Steuck at 2024-01-24T01:29:44-05:00 Avoid utf8 in primops.txt.pp comments They don't make it through readFile' without explicitly setting the encoding. See https://gitlab.haskell.org/ghc/ghc/-/issues/17755 - - - - - 1aaf0bd8 by David Binder at 2024-01-24T01:30:20-05:00 Bump hpc and hpc-bin submodule Bump hpc to 0.7.0.1 Bump hpc-bin to commit d1780eb2 - - - - - e693a4e8 by Ben Gamari at 2024-01-24T01:30:56-05:00 testsuite: Ignore stderr in T8089 Otherwise spurious "Killed: 9" messages to stderr may cause the test to fail. Fixes #24361. - - - - - a40f4ab2 by sheaf at 2024-01-24T14:04:33-05:00 Fix FMA instruction on LLVM We were emitting the wrong instructions for fused multiply-add operations on LLVM: - the instruction name is "llvm.fma.f32" or "llvm.fma.f64", not "fmadd" - LLVM does not support other instructions such as "fmsub"; instead we implement these by flipping signs of some arguments - the instruction is an LLVM intrinsic, which requires handling it like a normal function call instead of a machine instruction Fixes #24223 - - - - - 69abc786 by Andrei Borzenkov at 2024-01-24T14:05:09-05:00 Add changelog entry for renaming tuples from (,,...,,) to Tuple<n> (24291) - - - - - 0ac8f385 by Cheng Shao at 2024-01-25T00:27:48-05:00 compiler: remove unused GHC.Linker module The GHC.Linker module is empty and unused, other than as a hack for the make build system. We can remove it now that make is long gone; the note is moved to GHC.Linker.Loader instead. - - - - - 699da01b by Hécate Moonlight at 2024-01-25T00:28:27-05:00 Clarification for newtype constructors when using `coerce` - - - - - b2d8cd85 by Matt Walker at 2024-01-26T09:50:08-05:00 Fix #24308 Add tests for semicolon separated where clauses - - - - - 0da490a1 by Ben Gamari at 2024-01-26T17:34:41-05:00 hsc2hs: Bump submodule - - - - - 3f442fd2 by Ben Gamari at 2024-01-26T17:34:41-05:00 Bump containers submodule to 0.7 - - - - - 82a1c656 by Sebastian Nagel at 2024-01-29T02:32:40-05:00 base: with{Binary}File{Blocking} only annotates own exceptions Fixes #20886 This ensures that inner, unrelated exceptions are not misleadingly annotated with the opened file. - - - - - 9294a086 by Andreas Klebinger at 2024-01-29T02:33:15-05:00 Fix fma warning when using llvm on aarch64. On aarch64 fma is always on so the +fma flag doesn't exist for that target. Hence no need to try and pass +fma to llvm. Fixes #24379 - - - - - ced2e731 by sheaf at 2024-01-29T17:27:12-05:00 No shadowing warnings for NoFieldSelector fields This commit ensures we don't emit shadowing warnings when a user shadows a field defined with NoFieldSelectors. Fixes #24381 - - - - - 8eeadfad by Patrick at 2024-01-29T17:27:51-05:00 Fix bug wrong span of nested_doc_comment #24378 close #24378 1. Update the start position of span in `nested_doc_comment` correctly. and hence the spans of identifiers of haddoc can be computed correctly. 2. add test `HaddockSpanIssueT24378`. - - - - - a557580f by Alexey Radkov at 2024-01-30T19:41:52-05:00 Fix irrelevant dodgy-foreign-imports warning on import f-pointers by value A test *сс018* is attached (not sure about the naming convention though). Note that without the fix, the test fails with the *dodgy-foreign-imports* warning passed to stderr. The warning disappears after the fix. GHC shouldn't warn on imports of natural function pointers from C by value (which is feasible with CApiFFI), such as ```haskell foreign import capi "cc018.h value f" f :: FunPtr (Int -> IO ()) ``` where ```c void (*f)(int); ``` See a related real-world use-case [here](https://gitlab.com/daniel-casanueva/pcre-light/-/merge_requests/17). There, GHC warns on import of C function pointer `pcre_free`. - - - - - ca99efaf by Alexey Radkov at 2024-01-30T19:41:53-05:00 Rename test cc018 -> T24034 - - - - - 88c38dd5 by Ben Gamari at 2024-01-30T19:42:28-05:00 rts/TraverseHeap.c: Ensure that PosixSource.h is included first - - - - - ca2e919e by Simon Peyton Jones at 2024-01-31T09:29:45+00:00 Make decomposeRuleLhs a bit more clever This fixes #24370 by making decomposeRuleLhs undertand dictionary /functions/ as well as plain /dictionaries/ - - - - - 94ce031d by Teo Camarasu at 2024-02-01T05:49:49-05:00 doc: Add -Dn flag to user guide Resolves #24394 - - - - - 31553b11 by Ben Gamari at 2024-02-01T12:21:29-05:00 cmm: Introduce MO_RelaxedRead In hand-written Cmm it can sometimes be necessary to atomically load from memory deep within an expression (e.g. see the `CHECK_GC` macro). This MachOp provides a convenient way to do so without breaking the expression into multiple statements. - - - - - 0785cf81 by Ben Gamari at 2024-02-01T12:21:29-05:00 codeGen: Use relaxed accesses in ticky bumping - - - - - be423dda by Ben Gamari at 2024-02-01T12:21:29-05:00 base: use atomic write when updating timer manager - - - - - 8a310e35 by Ben Gamari at 2024-02-01T12:21:29-05:00 Use relaxed atomics to manipulate TSO status fields - - - - - d6809ee4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Add necessary barriers when manipulating TSO owner - - - - - 39e3ac5d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Use `switch` to branch on why_blocked This is a semantics-preserving refactoring. - - - - - 515eb33d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix synchronization on thread blocking state We now use a release barrier whenever we update a thread's blocking state. This required widening StgTSO.why_blocked as AArch64 does not support atomic writes on 16-bit values. - - - - - eb38812e by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadPaused This only affects an assertion in the debug RTS and only needs relaxed ordering. - - - - - 26c48dd6 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadStatus# - - - - - 6af43ab4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in Interpreter's preemption check - - - - - 9502ad3c by Ben Gamari at 2024-02-01T12:21:29-05:00 rts/Messages: Fix data race - - - - - 60802db5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts/Prof: Fix data race - - - - - ef8ccef5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use relaxed ordering on dirty/clean info tables updates When changing the dirty/clean state of a mutable object we needn't have any particular ordering. - - - - - 76fe2b75 by Ben Gamari at 2024-02-01T12:21:30-05:00 codeGen: Use relaxed-read in closureInfoPtr - - - - - a6316eb4 by Ben Gamari at 2024-02-01T12:21:30-05:00 STM: Use acquire loads when possible Full sequential consistency is not needed here. - - - - - 6bddfd3d by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use fence rather than redundant load Previously we would use an atomic load to ensure acquire ordering. However, we now have `ACQUIRE_FENCE_ON`, which allows us to express this more directly. - - - - - 55c65dbc by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Fix data races in profiling timer - - - - - 856b5e75 by Ben Gamari at 2024-02-01T12:21:30-05:00 Add Note [C11 memory model] - - - - - 6534da24 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: move generic cmm optimization logic in NCG to a standalone module This commit moves GHC.CmmToAsm.cmmToCmm to a standalone module, GHC.Cmm.GenericOpt. The main motivation is enabling this logic to be run in the wasm backend NCG code, which is defined in other modules that's imported by GHC.CmmToAsm, causing a cyclic dependency issue. - - - - - 87e34888 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: explicitly disable PIC in wasm32 NCG This commit explicitly disables the ncgPIC flag for the wasm32 target. The wasm backend doesn't support PIC for the time being. - - - - - c6ce242e by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: enable generic cmm optimizations in wasm backend NCG This commit enables the generic cmm optimizations in other NCGs to be run in the wasm backend as well, followed by a late cmm control-flow optimization pass. The added optimizations do catch some corner cases not handled by the pre-NCG cmm pipeline and are useful in generating smaller CFGs. - - - - - 151dda4e by Andrei Borzenkov at 2024-02-01T12:22:43-05:00 Namespacing for WARNING/DEPRECATED pragmas (#24396) New syntax for WARNING and DEPRECATED pragmas was added, namely namespace specifierss: namespace_spec ::= 'type' | 'data' | {- empty -} warning ::= warning_category namespace_spec namelist strings deprecation ::= namespace_spec namelist strings A new data type was introduced to represent these namespace specifiers: data NamespaceSpecifier = NoSpecifier | TypeNamespaceSpecifier (EpToken "type") | DataNamespaceSpecifier (EpToken "data") Extension field XWarning now contains this NamespaceSpecifier. lookupBindGroupOcc function was changed: it now takes NamespaceSpecifier and checks that the namespace of the found names matches the passed flag. With this change {-# WARNING data D "..." #-} pragma will only affect value namespace and {-# WARNING type D "..." #-} will only affect type namespace. The same logic is applicable to DEPRECATED pragmas. Finding duplicated warnings inside rnSrcWarnDecls now takes into consideration NamespaceSpecifier flag to allow warnings with the same names that refer to different namespaces. - - - - - 38c3afb6 by Bryan Richter at 2024-02-01T12:23:19-05:00 CI: Disable the test-cabal-reinstall job Fixes #24363 - - - - - 27020458 by Matthew Craven at 2024-02-03T01:53:26-05:00 Bump bytestring submodule to something closer to 0.12.1 ...mostly so that 16d6b7e835ffdcf9b894e79f933dd52348dedd0c (which reworks unaligned writes in Builder) and the stuff in https://github.com/haskell/bytestring/pull/631 can see wider testing. The less-terrible code for unaligned writes used in Builder on hosts not known to be ulaigned-friendly also takes less effort for GHC to compile, resulting in a metric decrease for T21839c on some platforms. The metric increase on T21839r is caused by the unrelated commit 750dac33465e7b59100698a330b44de7049a345c. It perhaps warrants further analysis and discussion (see #23822) but is not critical. Metric Decrease: T21839c Metric Increase: T21839r - - - - - cdddeb0f by Rodrigo Mesquita at 2024-02-03T01:54:02-05:00 Work around autotools setting C11 standard in CC/CXX In autoconf >=2.70, C11 is set by default for $CC and $CXX via the -std=...11 flag. In this patch, we split the "-std" flag out of the $CC and $CXX variables, which we traditionally assume to be just the executable name/path, and move it to $CFLAGS/$CXXFLAGS instead. Fixes #24324 - - - - - 5ff7cc26 by Apoorv Ingle at 2024-02-03T13:14:46-06:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - The change is detailed in - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` - Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - Adds new datatypes: - `GHC.Hs.Expr.XXExprGhcRn`: new datatype makes this expansion work easier 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - Ensures warnings such as 1. Pattern match checks 2. Failable patterns 3. non-() return in body statements are preserved - Kill `HsMatchCtxt` in favor of `TcMatchAltChecker` - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) Also repoint haddock to the right submodule so that the test (haddockHypsrcTest) pass Metric Increase 'compile_time/bytes allocated': T9020 The testcase is a pathalogical example of a `do`-block with many statements that do nothing. Given that we are expanding the statements into function binds, we will have to bear a (small) 2% cost upfront in the compiler to unroll the statements. - - - - - 0df8ce27 by Vladislav Zavialov at 2024-02-04T03:55:14-05:00 Reduce parser allocations in allocateCommentsP In the most common case, the comment queue is empty, so we can skip the work of processing it. This reduces allocations by about 10% in the parsing001 test. Metric Decrease: MultiLayerModulesRecomp parsing001 - - - - - cfd68290 by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Stop dropping a case whose binder is demanded This MR fixes #24251. See Note [Case-to-let for strictly-used binders] in GHC.Core.Opt.Simplify.Iteration, plus #24251, for lots of discussion. Final Nofib changes over 0.1%: +----------------------------------------- | imaginary/digits-of-e2 -2.16% | imaginary/rfib -0.15% | real/fluid -0.10% | real/gamteb -1.47% | real/gg -0.20% | real/maillist +0.19% | real/pic -0.23% | real/scs -0.43% | shootout/n-body -0.41% | shootout/spectral-norm -0.12% +======================================== | geom mean -0.05% Pleasingly, overall executable size is down by just over 1%. Compile times (in perf/compiler) wobble around a bit +/- 0.5%, but the geometric mean is -0.1% which seems good. - - - - - e4d137bb by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Add Note [Bangs in Integer functions] ...to document the bangs in the functions in GHC.Num.Integer - - - - - ce90f12f by Andrei Borzenkov at 2024-02-05T17:59:09-05:00 Hide WARNING/DEPRECATED namespacing under -XExplicitNamespaces (#24396) - - - - - e2ea933f by Simon Peyton Jones at 2024-02-06T10:12:04-05:00 Refactoring in preparation for lazy skolemisation * Make HsMatchContext and HsStmtContext be parameterised over the function name itself, rather than over the pass. See [mc_fun field of FunRhs] in Language.Haskell.Syntax.Expr - Replace types HsMatchContext GhcPs --> HsMatchContextPs HsMatchContext GhcRn --> HsMatchContextRn HsMatchContext GhcTc --> HsMatchContextRn (sic! not Tc) HsStmtContext GhcRn --> HsStmtContextRn - Kill off convertHsMatchCtxt * Split GHC.Tc.Type.BasicTypes.TcSigInfo so that TcCompleteSig (describing a complete user-supplied signature) is its own data type. - Split TcIdSigInfo(CompleteSig, PartialSig) into TcCompleteSig(CSig) TcPartialSig(PSig) - Use TcCompleteSig in tcPolyCheck, CheckGen - Rename types and data constructors: TcIdSigInfo --> TcIdSig TcPatSynInfo(TPSI) --> TcPatSynSig(PatSig) - Shuffle around helper functions: tcSigInfoName (moved to GHC.Tc.Types.BasicTypes) completeSigPolyId_maybe (moved to GHC.Tc.Types.BasicTypes) tcIdSigName (inlined and removed) tcIdSigLoc (introduced) - Rearrange the pattern match in chooseInferredQuantifiers * Rename functions and types: tcMatchesCase --> tcCaseMatches tcMatchesFun --> tcFunBindMatches tcMatchLambda --> tcLambdaMatches tcPats --> tcMatchPats matchActualFunTysRho --> matchActualFunTys matchActualFunTySigma --> matchActualFunTy * Add HasDebugCallStack constraints to: mkBigCoreVarTupTy, mkBigCoreTupTy, boxTy, mkPiTy, mkPiTys, splitAppTys, splitTyConAppNoView_maybe * Use `penv` from the outer context in the inner loop of GHC.Tc.Gen.Pat.tcMultiple * Move tcMkVisFunTy, tcMkInvisFunTy, tcMkScaledFunTys down the file, factor out and export tcMkScaledFunTy. * Move isPatSigCtxt down the file. * Formatting and comments Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - f5d3e03c by Andrei Borzenkov at 2024-02-06T10:12:04-05:00 Lazy skolemisation for @a-binders (#17594) This patch is a preparation for @a-binders implementation. The main changes are: * Skolemisation is now prepared to deal with @binders. See Note [Skolemisation overview] in GHC.Tc.Utils.Unify. Most of the action is in - Utils.Unify.matchExpectedFunTys - Gen.Pat.tcMatchPats - Gen.Expr.tcPolyExprCheck - Gen.Binds.tcPolyCheck Some accompanying refactoring: * I found that funTyConAppTy_maybe was doing a lot of allocation, and rejigged userTypeError_maybe to avoid calling it. - - - - - 532993c8 by Zubin Duggal at 2024-02-06T10:12:41-05:00 driver: Really don't lose track of nodes when we fail to resolve cycles This fixes a bug in 8db8d2fd1c881032b1b360c032b6d9d072c11723, where we could lose track of acyclic components at the start of an unresolved cycle. We now ensure we never loose track of any of these components. As T24275 demonstrates, a "cyclic" SCC might not really be a true SCC: When viewed without boot files, we have a single SCC ``` [REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A [main:T24275A {-# SOURCE #-}]] ``` But with boot files this turns into ``` [NONREC main:T24275B {-# SOURCE #-} [], REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A {-# SOURCE #-} [main:T24275B], NONREC main:T24275A [main:T24275A {-# SOURCE #-}]] ``` Note that this is truly not an SCC, as no nodes are reachable from T24275B.hs-boot. However, we treat this entire group as a single "SCC" because it seems so when we analyse the graph without taking boot files into account. Indeed, we must return a single ResolvedCycle element in the BuildPlan for this as described in Note [Upsweep]. However, since after resolving this is not a true SCC anymore, `findCycle` fails to find a cycle and we have a sub-optimal error message as a result. To handle this, I extended `findCycle` to not assume its input is an SCC, and to try harder to find cycles in its input. Fixes #24275 - - - - - b35dd613 by Zubin Duggal at 2024-02-06T10:13:17-05:00 GHCi: Lookup breakpoint CCs in the correct module We need to look up breakpoint CCs in the module that the breakpoint points to, and not the current module. Fixes #24327 - - - - - b09e6958 by Zubin Duggal at 2024-02-06T10:13:17-05:00 testsuite: Add test for #24327 - - - - - 569b4c10 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add compile_artifact, ignore_extension flag In b521354216f2821e00d75f088d74081d8b236810 the testsuite gained the capability to collect generic metrics. But this assumed that the test was not linking and producing artifacts and we only wanted to track object files, interface files, or build artifacts from the compiler build. However, some backends, such as the JS backend, produce artifacts when compiling, such as the jsexe directory which we want to track. This patch: - tweaks the testsuite to collect generic metrics on any build artifact in the test directory. - expands the exe_extension function to consider windows and adds the ignore_extension flag. - Modifies certain tests to add the ignore_extension flag. Tests such as heaprof002 expect a .ps file, but on windows without ignore_extensions the testsuite will look for foo.exe.ps. Hence the flag. - adds the size_hello_artifact test - - - - - 75a31379 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add wasm_arch, heapprof002 wasm extension - - - - - c9731d6d by Rodrigo Mesquita at 2024-02-07T03:07:03-05:00 Synchronize bindist configure for #24324 In cdddeb0f1280b40cc194028bbaef36e127175c4c, we set up a workaround for #24324 in the in-tree configure script, but forgot to update the bindist configure script accordingly. This updates it. - - - - - d309f4e7 by Matthew Pickering at 2024-02-07T03:07:38-05:00 distrib/configure: Fix typo in CONF_GCC_LINKER_OPTS_STAGE2 variable Instead we were setting CONF_GCC_LINK_OPTS_STAGE2 which meant that we were missing passing `--target` when invoking the linker. Fixes #24414 - - - - - 77db84ab by Ben Gamari at 2024-02-08T00:35:22-05:00 llvmGen: Adapt to allow use of new pass manager. We now must use `-passes` in place of `-O<n>` due to #21936. Closes #21936. - - - - - 3c9ddf97 by Matthew Pickering at 2024-02-08T00:35:59-05:00 testsuite: Mark length001 as fragile on javascript Modifying the timeout multiplier is not a robust way to get this test to reliably fail. Therefore we mark it as fragile until/if javascript ever supports the stack limit. - - - - - 20b702b5 by Matthew Pickering at 2024-02-08T00:35:59-05:00 Javascript: Don't filter out rtsDeps list This logic appears to be incorrect as it would drop any dependency which was not in a direct dependency of the package being linked. In the ghc-internals split this started to cause errors because `ghc-internal` is not a direct dependency of most packages, and hence important symbols to keep which are hard coded into the js runtime were getting dropped. - - - - - 2df96366 by Ben Gamari at 2024-02-08T00:35:59-05:00 base: Cleanup whitespace in cbits - - - - - 44f6557a by Ben Gamari at 2024-02-08T00:35:59-05:00 Move `base` to `ghc-internal` Here we move a good deal of the implementation of `base` into a new package, `ghc-internal` such that it can be evolved independently from the user-visible interfaces of `base`. While we want to isolate implementation from interfaces, naturally, we would like to avoid turning `base` into a mere set of module re-exports. However, this is a non-trivial undertaking for a variety of reasons: * `base` contains numerous known-key and wired-in things, requiring corresponding changes in the compiler * `base` contains a significant amount of C code and corresponding autoconf logic, which is very fragile and difficult to break apart * `base` has numerous import cycles, which are currently dealt with via carefully balanced `hs-boot` files * We must not break existing users To accomplish this migration, I tried the following approaches: * [Split-GHC.Base]: Break apart the GHC.Base knot to allow incremental migration of modules into ghc-internal: this knot is simply too intertwined to be easily pulled apart, especially given the rather tricky import cycles that it contains) * [Move-Core]: Moving the "core" connected component of base (roughly 150 modules) into ghc-internal. While the Haskell side of this seems tractable, the C dependencies are very subtle to break apart. * [Move-Incrementally]: 1. Move all of base into ghc-internal 2. Examine the module structure and begin moving obvious modules (e.g. leaves of the import graph) back into base 3. Examine the modules remaining in ghc-internal, refactor as necessary to facilitate further moves 4. Go to (2) iterate until the cost/benefit of further moves is insufficient to justify continuing 5. Rename the modules moved into ghc-internal to ensure that they don't overlap with those in base 6. For each module moved into ghc-internal, add a shim module to base with the declarations which should be exposed and any requisite Haddocks (thus guaranteeing that base will be insulated from changes in the export lists of modules in ghc-internal Here I am using the [Move-Incrementally] approach, which is empirically the least painful of the unpleasant options above Bumps haddock submodule. Metric Decrease: haddock.Cabal haddock.base Metric Increase: MultiComponentModulesRecomp T16875 size_hello_artifact - - - - - e8fb2451 by Vladislav Zavialov at 2024-02-08T00:36:36-05:00 Haddock comments on infix constructors (#24221) Rewrite the `HasHaddock` instance for `ConDecl GhcPs` to account for infix constructors. This change fixes a Haddock regression (introduced in 19e80b9af252) that affected leading comments on infix data constructor declarations: -- | Docs for infix constructor | Int :* Bool The comment should be associated with the data constructor (:*), not with its left-hand side Int. - - - - - 9060d55b by Ben Gamari at 2024-02-08T00:37:13-05:00 Add os-string as a boot package Introduces `os-string` submodule. This will be necessary for `filepath-1.5`. - - - - - 9d65235a by Ben Gamari at 2024-02-08T00:37:13-05:00 gitignore: Ignore .hadrian_ghci_multi/ - - - - - d7ee12ea by Ben Gamari at 2024-02-08T00:37:13-05:00 hadrian: Set -this-package-name When constructing the GHC flags for a package Hadrian must take care to set `-this-package-name` in addition to `-this-unit-id`. This hasn't broken until now as we have not had any uses of qualified package imports. However, this will change with `filepath-1.5` and the corresponding `unix` bump, breaking `hadrian/multi-ghci`. - - - - - f2dffd2e by Ben Gamari at 2024-02-08T00:37:13-05:00 Bump filepath to 1.5.0.0 Required bumps of the following submodules: * `directory` * `filepath` * `haskeline` * `process` * `unix` * `hsc2hs` * `Win32` * `semaphore-compat` and the addition of `os-string` as a boot package. - - - - - ab533e71 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Use specific clang assembler when compiling with -fllvm There are situations where LLVM will produce assembly which older gcc toolchains can't handle. For example on Deb10, it seems that LLVM >= 13 produces assembly which the default gcc doesn't support. A more robust solution in the long term is to require a specific LLVM compatible assembler when using -fllvm. Fixes #16354 - - - - - c32b6426 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update CI images with LLVM 15, ghc-9.6.4 and cabal-install-3.10.2.0 - - - - - 5fcd58be by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update bootstrap plans for 9.4.8 and 9.6.4 - - - - - 707a32f5 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Add alpine 3_18 release job This is mainly experimental and future proofing to enable a smooth transition to newer alpine releases once 3_12 is too old. - - - - - c37931b3 by John Ericson at 2024-02-08T06:39:05-05:00 Generate LLVM min/max bound policy via Hadrian Per #23966, I want the top-level configure to only generate configuration data for Hadrian, not do any "real" tasks on its own. This is part of that effort --- one less file generated by it. (It is still done with a `.in` file, so in a future world non-Hadrian also can easily create this file.) Split modules: - GHC.CmmToLlvm.Config - GHC.CmmToLlvm.Version - GHC.CmmToLlvm.Version.Bounds - GHC.CmmToLlvm.Version.Type This also means we can get rid of the silly `unused.h` introduced in !6803 / 7dfcab2f4bcb7206174ea48857df1883d05e97a2 as temporary kludge. Part of #23966 - - - - - 9f987235 by Apoorv Ingle at 2024-02-08T06:39:42-05:00 Enable mdo statements to use HsExpansions Fixes: #24411 Added test T24411 for regression - - - - - 762b2120 by Jade at 2024-02-08T15:17:15+00:00 Improve Monad, Functor & Applicative docs This patch aims to improve the documentation of Functor, Applicative, Monad and related symbols. The main goal is to make it more consistent and make accessible. See also: !10979 (closed) and !10985 (closed) Ticket #17929 Updates haddock submodule - - - - - 151770ca by Josh Meredith at 2024-02-10T14:28:15-05:00 JavaScript codegen: Use GHC's tag inference where JS backend-specific evaluation inference was previously used (#24309) - - - - - 2e880635 by Zubin Duggal at 2024-02-10T14:28:51-05:00 ci: Allow release-hackage-lint to fail Otherwise it blocks the ghcup metadata pipeline from running. - - - - - b0293f78 by Matthew Pickering at 2024-02-10T14:29:28-05:00 rts: eras profiling mode The eras profiling mode is useful for tracking the life-time of closures. When a closure is written, the current era is recorded in the profiling header. This records the era in which the closure was created. * Enable with -he * User mode: Use functions ghc-experimental module GHC.Profiling.Eras to modify the era * Automatically: --automatic-era-increment, increases the user era on major collections * The first era is era 1 * -he<era> can be used with other profiling modes to select a specific era If you just want to record the era but not to perform heap profiling you can use `-he --no-automatic-heap-samples`. https://well-typed.com/blog/2024/01/ghc-eras-profiling/ Fixes #24332 - - - - - be674a2c by Jade at 2024-02-10T14:30:04-05:00 Adjust error message for trailing whitespace in as-pattern. Fixes #22524 - - - - - 53ef83f9 by doyougnu at 2024-02-10T14:30:47-05:00 gitlab: js: add codeowners Fixes: - #24409 Follow on from: - #21078 and MR !9133 - When we added the JS backend this was forgotten. This patch adds the rightful codeowners. - - - - - 8bbe12f2 by Matthew Pickering at 2024-02-10T14:31:23-05:00 Bump CI images so that alpine3_18 image includes clang15 The only changes here are that clang15 is now installed on the alpine-3_18 image. - - - - - df9fd9f7 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: handle stored null StablePtr Some Haskell codes unsafely cast StablePtr into ptr to compare against NULL. E.g. in direct-sqlite: if castStablePtrToPtr aggStPtr /= nullPtr then where `aggStPtr` is read (`peek`) from zeroed memory initially. We fix this by giving these StablePtr the same representation as other null pointers. It's safe because StablePtr at offset 0 is unused (for this exact reason). - - - - - 55346ede by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: disable MergeObjsMode test This isn't implemented for JS backend objects. - - - - - aef587f6 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: add support for linking C sources Support linking C sources with JS output of the JavaScript backend. See the added documentation in the users guide. The implementation simply extends the JS linker to use the objects (.o) that were already produced by the emcc compiler and which were filtered out previously. I've also added some options to control the link with C functions (see the documentation about pragmas). With this change I've successfully compiled the direct-sqlite package which embeds the sqlite.c database code. Some wrappers are still required (see the documentation about wrappers) but everything generic enough to be reused for other libraries have been integrated into rts/js/mem.js. - - - - - b71b392f by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: avoid EMCC logging spurious failure emcc would sometime output messages like: cache:INFO: generating system asset: symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json" for subsequent builds) cache:INFO: - ok Cf https://github.com/emscripten-core/emscripten/issues/18607 This breaks our tests matching the stderr output. We avoid this by setting EMCC_LOGGING=0 - - - - - ff2c0cc9 by Simon Peyton Jones at 2024-02-12T12:19:17-05:00 Remove a dead comment Just remove an out of date block of commented-out code, and tidy up the relevant Notes. See #8317. - - - - - bedb4f0d by Teo Camarasu at 2024-02-12T18:50:33-05:00 nonmoving: Add support for heap profiling Add support for heap profiling while using the nonmoving collector. We greatly simply the implementation by disabling concurrent collection for GCs when heap profiling is enabled. This entails that the marked objects on the nonmoving heap are exactly the live objects. Note that we match the behaviour for live bytes accounting by taking the size of objects on the nonmoving heap to be that of the segment's block rather than the object itself. Resolves #22221 - - - - - d0d5acb5 by Teo Camarasu at 2024-02-12T18:51:09-05:00 doc: Add requires prof annotation to options that require it Resolves #24421 - - - - - 57bb8c92 by Cheng Shao at 2024-02-13T14:07:49-05:00 deriveConstants: add needed constants for wasm backend This commit adds needed constants to deriveConstants. They are used by RTS code in the wasm backend to support the JSFFI logic. - - - - - 615eb855 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms The pure Haskell implementation causes i386 regression in unrelated work that can be fixed by using C-based atomic increment, see added comment for details. - - - - - a9918891 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow JSFFI for wasm32 This commit allows the javascript calling convention to be used when the target platform is wasm32. - - - - - 8771a53b by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow boxed JSVal as a foreign type This commit allows the boxed JSVal type to be used as a foreign argument/result type. - - - - - 053c92b3 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: ensure ctors have the right priority on wasm32 This commit fixes the priorities of ctors generated by GHC codegen on wasm32, see the referred note for details. - - - - - b7942e0a by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JSFFI desugar logic for wasm32 This commit adds JSFFI desugar logic for the wasm backend. - - - - - 2c1dca76 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JavaScriptFFI to supported extension list on wasm32 This commit adds JavaScriptFFI as a supported extension when the target platform is wasm32. - - - - - 9ad0e2b4 by Cheng Shao at 2024-02-13T14:07:49-05:00 rts/ghc-internal: add JSFFI support logic for wasm32 This commit adds rts/ghc-internal logic to support the wasm backend's JSFFI functionality. - - - - - e9ebea66 by Cheng Shao at 2024-02-13T14:07:49-05:00 ghc-internal: fix threadDelay for wasm in browsers This commit fixes broken threadDelay for wasm when it runs in browsers, see added note for detailed explanation. - - - - - f85f3fdb by Cheng Shao at 2024-02-13T14:07:49-05:00 utils: add JSFFI utility code This commit adds JavaScript util code to utils to support the wasm backend's JSFFI functionality: - jsffi/post-link.mjs, a post-linker to process the linked wasm module and emit a small complement JavaScript ESM module to be used with it at runtime - jsffi/prelude.js, a tiny bit of prelude code as the JavaScript side of runtime logic - jsffi/test-runner.mjs, run the jsffi test cases Co-authored-by: amesgen <amesgen at amesgen.de> - - - - - 77e91500 by Cheng Shao at 2024-02-13T14:07:49-05:00 hadrian: distribute jsbits needed for wasm backend's JSFFI support The post-linker.mjs/prelude.js files are now distributed in the bindist libdir, so when using the wasm backend's JSFFI feature, the user wouldn't need to fetch them from a ghc checkout manually. - - - - - c47ba1c3 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add opts.target_wrapper This commit adds opts.target_wrapper which allows overriding the target wrapper on a per test case basis when testing a cross target. This is used when testing the wasm backend's JSFFI functionality; the rest of the cases are tested using wasmtime, though the jsffi cases are tested using the node.js based test runner. - - - - - 8e048675 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: T22774 should work for wasm JSFFI T22774 works since the wasm backend now supports the JSFFI feature. - - - - - 1d07f9a6 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add JSFFI test cases for wasm backend This commit adds a few test cases for the wasm backend's JSFFI functionality, as well as a simple README to instruct future contributors to add new test cases. - - - - - b8997080 by Cheng Shao at 2024-02-13T14:07:49-05:00 docs: add documentation for wasm backend JSFFI This commit adds changelog and user facing documentation for the wasm backend's JSFFI feature. - - - - - ffeb000d by David Binder at 2024-02-13T14:08:30-05:00 Add tests from libraries/process/tests and libraries/Win32/tests to GHC These tests were previously part of the libraries, which themselves are submodules of the GHC repository. This commit moves the tests directly to the GHC repository. - - - - - 5a932cf2 by David Binder at 2024-02-13T14:08:30-05:00 Do not execute win32 tests on non-windows runners - - - - - 500d8cb8 by Jade at 2024-02-13T14:09:07-05:00 prevent GHCi (and runghc) from suggesting other symbols when not finding main Fixes: #23996 - - - - - b19ec331 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: update xxHash to v0.8.2 - - - - - 4a97bdb8 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: use XXH3_64bits hash on all 64-bit platforms This commit enables XXH3_64bits hash to be used on all 64-bit platforms. Previously it was only enabled on x86_64, so platforms like aarch64 silently falls back to using XXH32 which degrades the hashing function quality. - - - - - ee01de7d by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: define XXH_INLINE_ALL This commit cleans up how we include the xxhash.h header and only define XXH_INLINE_ALL, which is sufficient to inline the xxHash functions without symbol collision. - - - - - 0e01e1db by Alan Zimmerman at 2024-02-14T02:13:22-05:00 EPA: Move EpAnn out of extension points Leaving a few that are too tricky, maybe some other time. Also - remove some unneeded helpers from Parser.y - reduce allocations with strictness annotations Updates haddock submodule Metric Decrease: parsing001 - - - - - de589554 by Andreas Klebinger at 2024-02-14T02:13:59-05:00 Fix ffi callbacks with >6 args and non-64bit args. Check for ptr/int arguments rather than 64-bit width arguments when counting integer register arguments. The old approach broke when we stopped using exclusively W64-sized types to represent sub-word sized integers. Fixes #24314 - - - - - 325b7613 by Ben Gamari at 2024-02-14T14:27:45-05:00 rts/EventLog: Place eliminate duplicate strlens Previously many of the `post*` implementations would first compute the length of the event's strings in order to determine the event length. Later we would then end up computing the length yet again in `postString`. Now we instead pass the string length to `postStringLen`, avoiding the repeated work. - - - - - 8aafa51c by Ben Gamari at 2024-02-14T14:27:46-05:00 rts/eventlog: Place upper bound on IPE string field lengths The strings in IPE events may be of unbounded length. Limit the lengths of these fields to 64k characters to ensure that we don't exceed the maximum event length. - - - - - 0e60d52c by Zubin Duggal at 2024-02-14T14:27:46-05:00 rts: drop unused postString function - - - - - d8d1333a by Cheng Shao at 2024-02-14T14:28:23-05:00 compiler/rts: fix wasm unreg regression This commit fixes two wasm unreg regressions caught by a nightly pipeline: - Unknown stg_scheduler_loopzh symbol when compiling scheduler.cmm - Invalid _hs_constructor(101) function name when handling ctor - - - - - 264a4fa9 by Owen Shepherd at 2024-02-15T09:41:06-05:00 feat: Add sortOn to Data.List.NonEmpty Adds `sortOn` to `Data.List.NonEmpty`, and adds comments describing when to use it, compared to `sortWith` or `sortBy . comparing`. The aim is to smooth out the API between `Data.List`, and `Data.List.NonEmpty`. This change has been discussed in the [clc issue](https://github.com/haskell/core-libraries-committee/issues/227). - - - - - b57200de by Fendor at 2024-02-15T09:41:47-05:00 Prefer RdrName over OccName for looking up locations in doc renaming step Looking up by OccName only does not take into account when functions are only imported in a qualified way. Fixes issue #24294 Bump haddock submodule to include regression test - - - - - 8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00 JS: add simple optimizer The simple optimizer reduces the size of the code generated by the JavaScript backend without the complexity and performance penalty of the optimizer in GHCJS. Also see #22736 Metric Decrease: libdir size_hello_artifact - - - - - 20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00 base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and modifies the base API to reflect the new RTS flag. CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243 Fixes #24337 - - - - - 08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00 base: export System.Mem.performBlockingMajorGC The corresponding C function was introduced in ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264. Resolves #24228 The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230 Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00 Fix C output for modern C initiative GCC 14 on aarch64 rejects the C code written by GHC with this kind of error: error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion] 68 | *(ffi_arg*)resp = cret; | ^ Add the correct cast. For more information on this see: https://fedoraproject.org/wiki/Changes/PortingToModernC Tested-by: Richard W.M. Jones <rjones at redhat.com> - - - - - 5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00 Bump bytestring submodule to 0.12.1.0 - - - - - 902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00 Add missing BCO handling in scavenge_one. - - - - - 97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Make cast between words and floats real primops (#24331) First step towards fixing #24331. Replace foreign prim imports with real primops. - - - - - a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: add constant folding for bitcast between float and word (#24331) - - - - - 5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: replace stack checks with assertions in casting primops There are RESERVED_STACK_WORDS free words (currently 21) on the stack, so omit the checks. Suggested by Cheng Shao. - - - - - 401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00 Reexport primops from GHC.Float + add deprecation - - - - - 4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00 rts/Hash: Don't iterate over chunks if we don't need to free data When freeing a `HashTable` there is no reason to walk over the hash list before freeing it if the user has not given us a `dataFreeFun`. Noticed while looking at #24410. - - - - - bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00 compiler: add SEQ_CST fence support In addition to existing Acquire/Release fences, this commit adds SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a fence that enforces total memory ordering. The following logic is added: - The MO_SeqCstFence callish MachOp - The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h - MO_SeqCstFence lowering logic in every single GHC codegen backend - - - - - 2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00 testsuite: fix hs_try_putmvar002 for targets without pthread.h hs_try_putmvar002 includes pthread.h and doesn't work on targets without this header (e.g. wasm32). It doesn't need to include this header at all. This was previously unnoticed by wasm CI, though recent toolchain upgrade brought in upstream changes that completely removes pthread.h in the single-threaded wasm32-wasi sysroot, therefore we need to handle that change. - - - - - 1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00 ci: bump ci-images to use updated wasm image This commit bumps our ci-images revision to use updated wasm image. - - - - - 56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00 Bump submodule text to 2.1.1 T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a. Metric Decrease: T17123 - - - - - a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00 rts: remove redundant rCCCS initialization This commit removes the redundant logic of initializing each Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before initProfiling() is called during RTS startup, each Capability's rCCCS has already been assigned CCS_SYSTEM when they're first initialized. - - - - - 7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00 Parser, renamer, type checker for @a-binders (#17594) GHC Proposal 448 introduces binders for invisible type arguments (@a-binders) in various contexts. This patch implements @-binders in lambda patterns and function equations: {-# LANGUAGE TypeAbstractions #-} id1 :: a -> a id1 @t x = x :: t -- @t-binder on the LHS of a function equation higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16) higherRank f = (f 42, f 42) ex :: (Int8, Int16) ex = higherRank (\ @a x -> maxBound @a - x ) -- @a-binder in a lambda pattern in an argument -- to a higher-order function Syntax ------ To represent those @-binders in the AST, the list of patterns in Match now uses ArgPat instead of Pat: data Match p body = Match { ... - m_pats :: [LPat p], + m_pats :: [LArgPat p], ... } + data ArgPat pass + = VisPat (XVisPat pass) (LPat pass) + | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass)) + | XArgPat !(XXArgPat pass) The VisPat constructor represents patterns for visible arguments, which include ordinary value-level arguments and required type arguments (neither is prefixed with a @), while InvisPat represents invisible type arguments (prefixed with a @). Parser ------ In the grammar (Parser.y), the lambda and lambda-cases productions of aexp non-terminal were updated to accept argpats instead of apats: aexp : ... - | '\\' apats '->' exp + | '\\' argpats '->' exp ... - | '\\' 'lcases' altslist(apats) + | '\\' 'lcases' altslist(argpats) ... + argpat : apat + | PREFIX_AT atype Function left-hand sides did not require any changes to the grammar, as they were already parsed with productions capable of parsing @-binders. Those binders were being rejected in post-processing (isFunLhs), and now we accept them. In Parser.PostProcess, patterns are constructed with the help of PatBuilder, which is used as an intermediate data structure when disambiguating between FunBind and PatBind. In this patch we define ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived data structure produced in isFunLhs and consumed in checkFunBind. Renamer ------- Renaming of @-binders builds upon prior work on type patterns, implemented in 2afbddb0f24, which guarantees proper scoping and shadowing behavior of bound type variables. This patch merely defines rnLArgPatsAndThen to process a mix of visible and invisible patterns: + rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn] + rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where + rnArgPatAndThen (VisPat x p) = ... rnLPatAndThen ... + rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ... Common logic between rnArgPats and rnPats is factored out into the rn_pats_general helper. Type checker ------------ Type-checking of @-binders builds upon prior work on lazy skolemisation, implemented in f5d3e03c56f. This patch extends tcMatchPats to handle @-binders. Now it takes and returns a list of LArgPat rather than LPat: tcMatchPats :: ... - -> [LPat GhcRn] + -> [LArgPat GhcRn] ... - -> TcM ([LPat GhcTc], a) + -> TcM ([LArgPat GhcTc], a) Invisible binders in the Match are matched up with invisible (Specified) foralls in the type. This is done with a new clause in the `loop` worker of tcMatchPats: loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a) loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys) ... -- NEW CLAUSE: | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis = ... In addition to that, tcMatchPats no longer discards type patterns. This is done by filterOutErasedPats in the desugarer instead. x86_64-linux-deb10-validate+debug_info Metric Increase: MultiLayerModulesTH_OneShot - - - - - 486979b0 by Jade at 2024-02-19T07:12:13-05:00 Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246 Fixes: #24346 - - - - - 17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00 Fix reST in users guide It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax. - - - - - 35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00 Fix searching for errors in sphinx build - - - - - 4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00 hadrian: fix wasm backend post linker script permissions The post-link.mjs script was incorrectly copied and installed as a regular data file without executable permission, this commit fixes it. - - - - - a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00 testsuite: mark T23540 as fragile on i386 See #24449 for details. - - - - - 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 8a8ac65a by Matthew Craven at 2024-03-23T00:20:52-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 0c48f2b9 by Apoorv Ingle at 2024-03-23T00:21:28-04:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - b72705e9 by Simon Peyton Jones at 2024-03-23T00:22:04-04:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 8f7cfc7e by Tristan Cacqueray at 2024-03-23T00:22:44-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - 5bd8ed53 by Andreas Klebinger at 2024-03-23T16:18:33-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8d67f247 by Ben Gamari at 2024-03-23T16:19:09-04:00 docs: Drop old release notes, add for 9.12.1 - - - - - 7db8c992 by Cheng Shao at 2024-03-25T13:45:46-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. - - - - - 237194ce by Sylvain Henry at 2024-03-25T13:46:27-04:00 Lexer: fix imports for Alex 3.5.1 (#24583) - - - - - 810660b7 by Cheng Shao at 2024-03-25T22:19:16-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - d2ba41e8 by Alan Zimmerman at 2024-03-25T22:19:51-04:00 EPA: do not duplicate comments in signature RHS - - - - - 32a8103f by Rodrigo Mesquita at 2024-03-26T21:16:12-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. - - - - - bf65a7c3 by Rodrigo Mesquita at 2024-03-26T21:16:48-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 - - - - - cfeb70d3 by Rodrigo Mesquita at 2024-03-26T21:17:24-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 13223f6d by Serge S. Gulin at 2024-03-27T07:28:51-04:00 JS: `h$rts_isProfiled` is removed from `profiling` and left its version at `rts/js/config.js` - - - - - 0acfe391 by Alan Zimmerman at 2024-03-27T07:29:27-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. - - - - - cd0fb82f by Alan Zimmerman at 2024-03-27T19:33:08+00:00 EPA: Fix FamDecl range The span was incorrect if opt_datafam_kind_sig was empty - - - - - f8f384a8 by Ben Gamari at 2024-03-29T01:23:03-04:00 Fix type of _get_osfhandle foreign import Fixes #24601. - - - - - 00d3ecf0 by Alan Zimmerman at 2024-03-29T12:19:10+00:00 EPA: Extend StringLiteral range to include trailing commas This goes slightly against the exact printing philosophy where trailing decorations should be in an annotation, but the practicalities of adding it to the WarningTxt environment, and the problems caused by deviating do not make a more principles approach worthwhile. - - - - - efab3649 by brandon s allbery kf8nh at 2024-03-31T20:04:01-04:00 clarify Note [Preproccesing invocations] - - - - - c8a4c050 by Ben Gamari at 2024-04-02T12:50:35-04:00 rts: Fix TSAN_ENABLED CPP guard This should be `#if defined(TSAN_ENABLED)`, not `#if TSAN_ENABLED`, lest we suffer warnings. - - - - - e91dad93 by Cheng Shao at 2024-04-02T12:50:35-04:00 rts: fix errors when compiling with TSAN This commit fixes rts compilation errors when compiling with TSAN: - xxx_FENCE macros are redefined and trigger CPP warnings. - Use SIZEOF_W. WORD_SIZE_IN_BITS is provided by MachDeps.h which Cmm.h doesn't include by default. - - - - - a9ab9455 by Cheng Shao at 2024-04-02T12:50:35-04:00 rts: fix clang-specific errors when compiling with TSAN This commit fixes clang-specific rts compilation errors when compiling with TSAN: - clang doesn't have -Wtsan flag - Fix prototype of ghc_tsan_* helper functions - __tsan_atomic_* functions aren't clang built-ins and sanitizer/tsan_interface_atomic.h needs to be included - On macOS, TSAN runtime library is libclang_rt.tsan_osx_dynamic.dylib, not libtsan. -fsanitize-thread as a link-time flag will take care of linking the TSAN runtime library anyway so remove tsan as an rts extra library - - - - - 865bd717 by Cheng Shao at 2024-04-02T12:50:35-04:00 compiler: fix github link to __tsan_memory_order in a comment - - - - - 07cb627c by Cheng Shao at 2024-04-02T12:50:35-04:00 ci: improve TSAN CI jobs - Run TSAN jobs with +thread_sanitizer_cmm which enables Cmm instrumentation as well. - Run TSAN jobs in deb12 which ships gcc-12, a reasonably recent gcc that @bgamari confirms he's using in #GHC:matrix.org. Ideally we should be using latest clang release for latest improvements in sanitizers, though that's left as future work. - Mark TSAN jobs as manual+allow_failure in validate pipelines. The purpose is to demonstrate that we have indeed at least fixed building of TSAN mode in CI without blocking the patch to land, and once merged other people can begin playing with TSAN using their own dev setups and feature branches. - - - - - a1c18c7b by Andrei Borzenkov at 2024-04-02T12:51:11-04:00 Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy (#24299, #23639) This patch implements refactoring which is a prerequisite to updating kind checking of type patterns. This is a huge simplification of the main worker that checks kind of HsType. It also fixes the issues caused by previous code duplication, e.g. that we didn't add module finalizers from splices in inference mode. - - - - - 817e8936 by Rodrigo Mesquita at 2024-04-02T20:13:05-04:00 th: Hide the Language.Haskell.TH.Lib.Internal module from haddock Fixes #24562 - - - - - b36ee57b by Sylvain Henry at 2024-04-02T20:13:46-04:00 JS: reenable h$appendToHsString optimization (#24495) The optimization introducing h$appendToHsString wasn't kicking in anymore (while it did in 9.8.1) because of the changes introduced in #23270 (7e0c8b3bab30). This patch reenables the optimization by matching on case-expression, as done in Cmm for unpackCString# standard thunks. The test is also T24495 added in the next commits (two commits for ease of backporting to 9.8). - - - - - 527616e9 by Sylvain Henry at 2024-04-02T20:13:46-04:00 JS: fix h$appendToHsString implementation (#24495) h$appendToHsString needs to wrap its argument in an updatable thunk to behave like unpackAppendCString#. Otherwise if a SingleEntry thunk is passed, it is stored as-is in a CONS cell, making the resulting list impossible to deepseq (forcing the thunk doesn't update the contents of the CONS cell)! The added test checks that the optimization kicks in and that h$appendToHsString works as intended. Fix #24495 - - - - - faa30b41 by Simon Peyton Jones at 2024-04-02T20:14:22-04:00 Deal with duplicate tyvars in type declarations GHC was outright crashing before this fix: #24604 - - - - - e0b0c717 by Simon Peyton Jones at 2024-04-02T20:14:58-04:00 Try using MCoercion in exprIsConApp_maybe This is just a simple refactor that makes exprIsConApp_maybe a little bit more direct, simple, and efficient. Metrics: compile_time/bytes allocated geo. mean -0.1% minimum -2.0% maximum -0.0% Not a big gain, but worthwhile given that the code is, if anything, easier to grok. - - - - - 15f4d867 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Initial ./configure support for selecting I/O managers In this patch we just define new CPP vars, but don't yet use them or replace the existing approach. That will follow. The intention here is that every I/O manager can be enabled/disabled at GHC build time (subject to some constraints). More than one I/O manager can be enabled to be built. At least one I/O manager supporting the non-threaded RTS must be enabled as well as at least one supporting the non-threaded RTS. The I/O managers enabled here will become the choices available at runtime at RTS startup (in later patches). The choice can be made with RTS flags. There are separate sets of choices for the threaded and non-threaded RTS ways, because most I/O managers are specific to these ways. Furthermore we must establish a default I/O manager for the threaded and non-threaded RTS. Most I/O managers are platform-specific so there are checks to ensure each one can be enabled on the platform. Such checks are also where (in future) any system dependencies (e.g. libraries) can be checked. The output is a set of CPP flags (in the mk/config.h file), with one flag per named I/O manager: * IOMGR_BUILD_<name> : which ones should be built (some) * IOMGR_DEFAULT_NON_THREADED_<name> : which one is default (exactly one) * IOMGR_DEFAULT_THREADED_<name> : which one is default (exactly one) and a set of derived flags in IOManager.h * IOMGR_ENABLED_<name> : enabled for the current RTS way Note that IOMGR_BUILD_<name> just says that an I/O manager will be built for _some_ RTS way (i.e. threaded or non-threaded). The derived flags IOMGR_ENABLED_<name> in IOManager.h say if each I/O manager is enabled in the "current" RTS way. These are the ones that can be used for conditional compilation of the I/O manager code. Co-authored-by: Pi Delport <pi at well-typed.com> - - - - - 85b0f87a by Duncan Coutts at 2024-04-03T01:27:17-04:00 Change the handling of the RTS flag --io-manager= Now instead of it being just used on Windows to select between the WinIO vs the MIO or Win32-legacy I/O managers, it is now used on all platforms for selecting the I/O manager to use. Right now it remains the case that there is only an actual choice on Windows, but that will change later. Document the --io-manager flag in the user guide. This change is also reflected in the RTS flags types in the base library. Deprecate the export of IoSubSystem from GHC.RTS.Flags with a message to import it from GHC.IO.Subsystem. The way the 'IoSubSystem' is detected also changes. Instead of looking at the RTS flag, there is now a C bool global var in the RTS which gets set on startup when the I/O manager is selected. This bool var says whether the selected I/O manager classifies as "native" on Windows, which in practice means the WinIO I/O manager has been selected. Similarly, the is_io_mng_native_p RTS helper function is re-implemented in terms of the selected I/O manager, rather than based on the RTS flags. We do however remove the ./configure --native-io-manager flag because we're bringing the WinIO/MIO/Win32-legacy choice under the new general scheme for selecting I/O managers, and that new scheme involves no ./configure time user choices, just runtime RTS flag choices. - - - - - 1a8f020f by Duncan Coutts at 2024-04-03T01:27:17-04:00 Convert {init,stop,exit}IOManager to switch style Rather than ad-hoc cpp conitionals on THREADED_RTS and mingw32_HOST_OS, we use a style where we switch on the I/O manager impl, with cases for each I/O manager impl. - - - - - a5bad3d2 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Split up the CapIOManager content by I/O manager Using the new IOMGR_ENABLED_<name> CPP defines. - - - - - 1d36e609 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Convert initIOManagerAfterFork and wakeupIOManager to switch style - - - - - c2f26f36 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move most of waitRead#/Write# from cmm to C Moves it into the IOManager.c where we can follow the new pattern of switching on the selected I/O manager. - - - - - 457705a8 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move most of the delay# impl from cmm to C Moves it into the IOManager.c where we can follow the new pattern of switching on the selected I/O manager. Uses a new IOManager API: syncDelay, following the naming convention of sync* for thread-synchronous I/O & timer/delay operations. As part of porting from cmm to C, we maintain the rule that the why_blocked gets accessed using load acquire and store release atomic memory operations. There was one exception to this rule: in the delay# primop cmm code on posix (not win32), the why_blocked was being updated using a store relaxed, not a store release. I've no idea why. In this convesion I'm playing it safe here and using store release consistently. - - - - - e93058e0 by Duncan Coutts at 2024-04-03T01:27:18-04:00 insertIntoSleepingQueue is no longer public No longer defined in IOManager.h, just a private function in IOManager.c. Since it is no longer called from cmm code, just from syncDelay. It ought to get moved further into the select() I/O manager impl, rather than living in IOManager.c. On the other hand appendToIOBlockedQueue is still called from cmm code in the win32-legacy I/O manager primops async{Read,Write}#, and it is also used by the select() I/O manager. Update the CPP and comments to reflect this. - - - - - 60ce9910 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move anyPendingTimeoutsOrIO impl from .h to .c The implementation is eventually going to need to use more private things, which will drag in unwanted includes into IOManager.h, so it's better to move the impl out of the header file and into the .c file, at the slight cost of it no longer being inline. At the same time, change to the "switch (iomgr_type)" style. - - - - - f70b8108 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Take a simpler approach to gcc warnings in IOManager.c We have lots of functions with conditional implementations for different I/O managers. Some functions, for some I/O managers, naturally have implementations that do nothing or barf. When only one such I/O manager is enabled then the whole function implementation will have an implementation that does nothing or barfs. This then results in warnings from gcc that parameters are unused, or that the function should be marked with attribute noreturn (since barf does not return). The USED_IF_THREADS trick for fine-grained warning supression is fine for just two cases, but an equivalent here would need USED_IF_THE_ONLY_ENABLED_IOMGR_IS_X_OR_Y which would have combinitorial blowup. So we take a coarse grained approach and simply disable these two warnings for the whole file. So we use a GCC pragma, with its handy push/pop support: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsuggest-attribute=noreturn" #pragma GCC diagnostic ignored "-Wunused-parameter" ... #pragma GCC diagnostic pop - - - - - b48805b9 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add a new trace class for the iomanager It makes sense now for it to be separate from the scheduler class of tracers. Enabled with +RTS -Do. Document the -Do debug flag in the user guide. - - - - - f0c1f862 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Have the throwTo impl go via (new) IOManager APIs rather than directly operating on the IO manager's data structures. Specifically, when thowing an async exception to a thread that is blocked waiting for I/O or waiting for a timer, then we want to cancel that I/O waiting or cancel the timer. Currently this is done directly in removeFromQueues() in RaiseAsync.c. We want it to go via proper APIs both for modularity but also to let us support multiple I/O managers. So add sync{IO,Delay}Cancel, which is the cancellation for the corresponding sync{IO,Delay}. The implementations of these use the usual "switch (iomgr_type)" style. - - - - - 4f9e9c4e by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move awaitEvent into a proper IOManager API and have the scheduler use it. Previously the scheduler calls awaitEvent directly, and awaitEvent is implemented directly in the RTS I/O managers (select, win32). This relies on the old scheme where there's a single active I/O manager for each platform and RTS way. We want to move that to go via an API in IOManager.{h,c} which can then call out to the active I/O manager. Also take the opportunity to split awaitEvent into two. The existing awaitEvent has a bool wait parameter, to say if the call should be blocking or non-blocking. We split this into two separate functions: pollCompletedTimeoutsOrIO and awaitCompletedTimeoutsOrIO. We split them for a few reasons: they have different post-conditions (specifically the await version is supposed to guarantee that there are threads runnable when it completes). Secondly, it is also anticipated that in future I/O managers the implementations of the two cases will be simpler if they are separated. - - - - - 5ad4b30f by Duncan Coutts at 2024-04-03T01:27:18-04:00 Rename awaitEvent in select and win32 I/O managers These are now just called from IOManager.c and are the per-I/O manager backend impls (whereas previously awaitEvent was the entry point). Follow the new naming convention in the IOManager.{h,c} of awaitCompletedTimeoutsOrIO, with the I/O manager's name as a suffix: so awaitCompletedTimeoutsOrIO{Select,Win32}. - - - - - d30c6bc6 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Tidy up a couple things in Select.{h,c} Use the standard #include {Begin,End}Private.h style rather than RTS_PRIVATE on individual decls. And conditionally build the code for the select I/O manager based on the new CPP IOMGR_ENABLED_SELECT rather than on THREADED_RTS. - - - - - 4161f516 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add an IOManager API for scavenging TSO blocked_info When the GC scavenges a TSO it needs to scavenge the tso->blocked_info but the blocked_info is a big union and what lives there depends on the two->why_blocked, which for I/O-related reasons is something that in principle is the responsibility of the I/O manager and not the GC. So the right thing to do is for the GC to ask the I/O manager to sscavenge the blocked_info if it encounters any I/O-related why_blocked reasons. So we add scavengeTSOIOManager in IOManager.{h,c} with the usual style. Now as it happens, right now, there is no special scavenging to do, so the implementation of scavengeTSOIOManager is a fancy no-op. That's because the select I/O manager uses only the fd and target members, which are not GC pointers, and the win32-legacy I/O manager _ought_ to be using GC-managed heap objects for the StgAsyncIOResult but it is actually usingthe C heap, so again no GC pointers. If the win32-legacy were doing this more sensibly, then scavengeTSOIOManager would be the right place to do the GC magic. Future I/O managers will need GC heap objects in the tso->blocked_info and will make use of this functionality. - - - - - 94a87d21 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add I/O manager API notifyIOManagerCapabilitiesChanged Used in setNumCapabilities. It only does anything for MIO on Posix. Previously it always invoked Haskell code, but that code only did anything on non-Windows (and non-JS), and only threaded. That currently effectively means the MIO I/O manager on Posix. So now it only invokes it for the MIO Posix case. - - - - - 3be6d591 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Select an I/O manager early in RTS startup We need to select the I/O manager to use during startup before the per-cap I/O manager initialisation. - - - - - aaa294d0 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Make struct CapIOManager be fully opaque Provide an opaque (forward) definition in Capability.h (since the cap contains a *CapIOManager) and then only provide a full definition in a new file IOManagerInternals.h. This new file is only supposed to be included by the IOManager implementation, not by its users. So that means IOManager.c and individual I/O manager implementations. The posix/Signals.c still needs direct access, but that should be eliminated. Anything that needs direct access either needs to be clearly part of an I/O manager (e.g. the sleect() one) or go via a proper API. - - - - - 877a2a80 by Duncan Coutts at 2024-04-03T01:27:18-04:00 The select() I/O manager does have some global initialisation It's just to make sure an exception CAF is a GC root. - - - - - 9c51473b by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add tracing for the main I/O manager actions Using the new tracer class. Note: The unconditional definition of showIOManager should be compatible with the debugTrace change in 7c7d1f6. Co-authored-by: Pi Delport <pi at well-typed.com> - - - - - c7d3e3a3 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Include the default I/O manager in the +RTS --info output Document the extra +RTS --info output in the user guide - - - - - 8023bad4 by Duncan Coutts at 2024-04-03T01:27:18-04:00 waitRead# / waitWrite# do not work for win32-legacy I/O manager Previously it was unclear that they did not work because the code path was shared with other I/O managers (in particular select()). Following the code carefully shows that what actually happens is that the calling thread would block forever: the thread will be put into the blocked queue, but no other action is scheduled that will ever result in it getting unblocked. It's better to just fail loudly in case anyone accidentally calls it, also it's less confusing code. - - - - - 83a74d20 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Conditionally ignore some GCC warnings Some GCC versions don't know about some warnings, and they complain that we're ignoring unknown warnings. So we try to ignore the warning based on the GCC version. - - - - - 1adc6fa4 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Accept changes to base-exports All the changes are in fact not changes at all. Previously, the IoSubSystem data type was defined in GHC.RTS.Flags and exported from both GHC.RTS.Flags and GHC.IO.SubSystem. Now, the data type is defined in GHC.IO.SubSystem and still exported from both modules. Therefore, the same exports and same instances are still available from both modules. But the base-exports records only the defining module, and so it looks like a change when it is fully compatible. Related: we do add a deprecation to the export of the type via GHC.RTS.Flags, telling people to use the export from GHC.IO.SubSystem. Also the sort order for some unrelated Show instances changed. No idea why. The same changes apply in the other versions, with a few more changes due to sort order weirdness. - - - - - 8d950968 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Accept metric decrease in T12227 I can't think of any good reason that anything in this MR should have changed the number of allocations, up or down. (Yes this is an empty commit.) Metric Decrease: T12227 - - - - - e869605e by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Several improvements to the handling of coercions * Make `mkSymCo` and `mkInstCo` smarter Fixes #23642 * Fix return role of `SelCo` in the coercion optimiser. Fixes #23617 * Make the coercion optimiser `opt_trans_rule` work better for newtypes Fixes #23619 - - - - - 1efd0714 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 FloatOut: improve floating for join point See the new Note [Floating join point bindings]. * Completely get rid of the complicated join_ceiling nonsense, which I have never understood. * Do not float join points at all, except perhaps to top level. * Some refactoring around wantToFloat, to treat Rec and NonRec more uniformly - - - - - 9c00154d by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Improve eta-expansion through call stacks See Note [Eta expanding through CallStacks] in GHC.Core.Opt.Arity This is a one-line change, that fixes an inconsistency - || isCallStackPredTy ty + || isCallStackPredTy ty || isCallStackTy ty - - - - - 95a9a172 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Spelling, layout, pretty-printing only - - - - - bdf1660f by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Improve exprIsConApp_maybe a little Eliminate a redundant case at birth. This sometimes reduces Simplifier iterations. See Note [Case elim in exprIsConApp_maybe]. - - - - - 609cd32c by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Inline GHC.HsToCore.Pmc.Solver.Types.trvVarInfo When exploring compile-time regressions after meddling with the Simplifier, I discovered that GHC.HsToCore.Pmc.Solver.Types.trvVarInfo was very delicately balanced. It's a small, heavily used, overloaded function and it's important that it inlines. By a fluke it was before, but at various times in my journey it stopped doing so. So I just added an INLINE pragma to it; no sense in depending on a delicately-balanced fluke. - - - - - ae24c9bc by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Slight improvement in WorkWrap Ensure that WorkWrap preserves lambda binders, in case of join points. Sadly I have forgotten why I made this change (it was while I was doing a lot of meddling in the Simplifier, but * it does no harm, * it is slightly more efficient, and * presumably it made something better! Anyway I have kept it in a separate commit. - - - - - e9297181 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Use named record fields for the CastIt { ... } data constructor This is a pure refactor - - - - - b4581e23 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Remove a long-commented-out line Pure refactoring - - - - - e026bdf2 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The main changes are below. There are also many new or rewritten Notes. Avoiding simplifying repeatedly ~~~~~~~~~~~~~~~ See Note [Avoiding simplifying repeatedly] * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env. Currently used only for the next point: avoiding repeatedly simplifying coercions. * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] * Improve the case-merge transformation: - Move the main code to `GHC.Core.Utils.mergeCaseAlts`, to join `filterAlts` and friends. See Note [Merge Nested Cases] in GHC.Core.Utils. - Add a new case for `tagToEnum#`; see wrinkle (MC3). - Add a new case to look through join points: see wrinkle (MC4) postInlineUnconditionally ~~~~~~~~~~~~~~~~~~~~~~~~~ * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. * Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. * Improve occurrence analyis for bottoming function calls, to help postInlineUnconditionally. See Note [Bottoming function calls] in GHC.Core.Opt.OccurAnal Inlining generally ~~~~~~~~~~~~~~~~~~ * In GHC.Core.Opt.Simplify.Utils.interestingCallContext, use RhsCtxt NonRecursive (not BoringCtxt) for a plain-seq case. See Note [Seq is boring] Also, wrinkle (SB1), inline in that `seq` context only for INLINE functions (UnfWhen guidance). * In GHC.Core.Opt.Simplify.Utils.interestingArg, - return ValueArg for OtherCon [c1,c2, ...], but - return NonTrivArg for OtherCon [] This makes a function a little less likely to inline if all we know is that the argument is evaluated, but nothing else. * isConLikeUnfolding is no longer true for OtherCon {}. This propagates to exprIsConLike. Con-like-ness has /positive/ information. Join points ~~~~~~~~~~~ * Be very careful about inlining join points. See these two long Notes Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline * When making join points, don't do so if the join point is so small it will immediately be inlined; check uncondInlineJoin. * In GHC.Core.Opt.Simplify.Inline.tryUnfolding, improve the inlining heuristics for join points. In general we /do not/ want to inline join points /even if they are small/. See Note [Duplicating join points] GHC.Core.Opt.Simplify.Iteration. But sometimes we do: see Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline; and the new `isBetterUnfoldingThan` function. * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * In GHC.Core.Unfold.sizeExpr, make jumps small, so that we don't penalise having a non-inlined join point. Performance changes ~~~~~~~~~~~~~~~~~~~ * Binary sizes fall by around 2.6%, according to nofib. * Compile times improve slightly. Here are the figures over 1%. I investiate the biggest differnce in T18304. It's a very small module, just a few hundred nodes. The large percentage difffence is due to a single function that didn't quite inline before, and does now, making code size a bit bigger. I decided gains outweighed the losses. Metrics: compile_time/bytes allocated (changes over +/- 1%) ------------------------------------------------ CoOpt_Singletons(normal) -9.2% GOOD LargeRecord(normal) -23.5% GOOD MultiComponentModulesRecomp(normal) +1.2% MultiLayerModulesTH_OneShot(normal) +4.1% BAD PmSeriesS(normal) -3.8% PmSeriesV(normal) -1.5% T11195(normal) -1.3% T12227(normal) -20.4% GOOD T12545(normal) -3.2% T12707(normal) -2.1% GOOD T13253(normal) -1.2% T13253-spj(normal) +8.1% BAD T13386(normal) -3.1% GOOD T14766(normal) -2.6% GOOD T15164(normal) -1.4% T15304(normal) +1.2% T15630(normal) -8.2% T15630a(normal) NEW T15703(normal) -14.7% GOOD T16577(normal) -2.3% GOOD T17516(normal) -39.7% GOOD T18140(normal) +1.2% T18223(normal) -17.1% GOOD T18282(normal) -5.0% GOOD T18304(normal) +10.8% BAD T18923(normal) -2.9% GOOD T1969(normal) +1.0% T19695(normal) -1.5% T20049(normal) -12.7% GOOD T21839c(normal) -4.1% GOOD T3064(normal) -1.5% T3294(normal) +1.2% BAD T4801(normal) +1.2% T5030(normal) -15.2% GOOD T5321Fun(normal) -2.2% GOOD T6048(optasm) -16.8% GOOD T783(normal) -1.2% T8095(normal) -6.0% GOOD T9630(normal) -4.7% GOOD T9961(normal) +1.9% BAD WWRec(normal) -1.4% info_table_map_perf(normal) -1.3% parsing001(normal) +1.5% geo. mean -2.0% minimum -39.7% maximum +10.8% * Runtimes generally improve. In the testsuite perf/should_run gives: Metrics: runtime/bytes allocated ------------------------------------------ Conversions(normal) -0.3% T13536a(optasm) -41.7% GOOD T4830(normal) -0.1% haddock.Cabal(normal) -0.1% haddock.base(normal) -0.1% haddock.compiler(normal) -0.1% geo. mean -0.8% minimum -41.7% maximum +0.0% * For runtime, nofib is a better test. The news is mostly good. Here are the number more than +/- 0.1%: # bytes allocated ==========================++========== imaginary/digits-of-e1 || -14.40% imaginary/digits-of-e2 || -4.41% imaginary/paraffins || -0.17% imaginary/rfib || -0.15% imaginary/wheel-sieve2 || -0.10% real/compress || -0.47% real/fluid || -0.10% real/fulsom || +0.14% real/gamteb || -1.47% real/gg || -0.20% real/infer || +0.24% real/pic || -0.23% real/prolog || -0.36% real/scs || -0.46% real/smallpt || +4.03% shootout/k-nucleotide || -20.23% shootout/n-body || -0.42% shootout/spectral-norm || -0.13% spectral/boyer2 || -3.80% spectral/constraints || -0.27% spectral/hartel/ida || -0.82% spectral/mate || -20.34% spectral/para || +0.46% spectral/rewrite || +1.30% spectral/sphere || -0.14% ==========================++========== geom mean || -0.59% real/smallpt has a huge nest of local definitions, and I could not pin down a reason for a regression. But there are three big wins! Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12707 T13386 T13536a T14766 T15703 T16577 T17516 T18223 T18282 T18923 T21839c T20049 T5321Fun T5030 T6048 T8095 T9630 T783 Metric Increase: MultiLayerModulesTH_OneShot T13253-spj T18304 T18698a T9961 T3294 - - - - - 27db3c5e by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Testsuite message changes from simplifier improvements - - - - - 271a7812 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Account for bottoming functions in OccurAnal This fixes #24582, a small but long-standing bug - - - - - 0fde229f by Ben Gamari at 2024-04-04T07:04:58-04:00 testsuite: Introduce template-haskell-exports test - - - - - 0c4a9686 by Luite Stegeman at 2024-04-04T07:05:39-04:00 Update correct counter in bumpTickyAllocd - - - - - 5f085d3a by Fendor at 2024-04-04T14:47:33-04:00 Replace `SizedSeq` with `FlatBag` for flattened structure LinkedLists are notoriously memory ineffiecient when all we do is traversing a structure. As 'UnlinkedBCO' has been identified as a data structure that impacts the overall memory usage of GHCi sessions, we avoid linked lists and prefer flattened structure for storing. We introduce a new memory efficient representation of sequential elements that has special support for the cases: * Empty * Singleton * Tuple Elements This improves sharing in the 'Empty' case and avoids the overhead of 'Array' until its constant overhead is justified. - - - - - 82cfe10c by Fendor at 2024-04-04T14:47:33-04:00 Compact FlatBag array representation `Array` contains three additional `Word`'s we do not need in `FlatBag`. Move `FlatBag` to `SmallArray`. Expand the API of SmallArray by `sizeofSmallArray` and add common traversal functions, such as `mapSmallArray` and `foldMapSmallArray`. Additionally, allow users to force the elements of a `SmallArray` via `rnfSmallArray`. - - - - - 36a75b80 by Andrei Borzenkov at 2024-04-04T14:48:10-04:00 Change how invisible patterns represented in haskell syntax and TH AST (#24557) Before this patch: data ArgPat p = InvisPat (LHsType p) | VisPat (LPat p) With this patch: data Pat p = ... | InvisPat (LHsType p) ... And the same transformation in the TH land. The rest of the changes is just updating code to handle new AST and writing tests to check if it is possible to create invalid states using TH. Metric Increase: MultiLayerModulesTH_OneShot - - - - - 28009fbc by Matthew Pickering at 2024-04-04T14:48:46-04:00 Fix off by one error in seekBinNoExpand and seekBin - - - - - 9b9e031b by Ben Gamari at 2024-04-04T21:30:08-04:00 compiler: Allow more types in GHCForeignImportPrim For many, many years `GHCForeignImportPrim` has suffered from the rather restrictive limitation of not allowing any non-trivial types in arguments or results. This limitation was justified by the code generator allegely barfing in the presence of such types. However, this restriction appears to originate well before the NCG rewrite and the new NCG does not appear to have any trouble with such types (see the added `T24598` test). Lift this restriction. Fixes #24598. - - - - - 1324b862 by Alan Zimmerman at 2024-04-04T21:30:44-04:00 EPA: Use EpaLocation not SrcSpan in ForeignDecls This allows us to update them for makeDeltaAst in ghc-exactprint - - - - - 19883a23 by Alan Zimmerman at 2024-04-05T16:58:17-04:00 EPA: Use EpaLocation for RecFieldsDotDot So we can update it to a delta position in makeDeltaAst if needed. - - - - - e8724327 by Matthew Pickering at 2024-04-05T16:58:53-04:00 Remove accidentally committed test.hs - - - - - 88cb3e10 by Fendor at 2024-04-08T09:03:34-04:00 Avoid UArray when indexing is not required `UnlinkedBCO`'s can occur many times in the heap. Each `UnlinkedBCO` references two `UArray`'s but never indexes them. They are only needed to encode the elements into a `ByteArray#`. The three words for the lower bound, upper bound and number of elements are essentially unused, thus we replace `UArray` with a wrapper around `ByteArray#`. This saves us up to three words for each `UnlinkedBCO`. Further, to avoid re-allocating these words for `ResolvedBCO`, we repeat the procedure for `ResolvedBCO` and add custom `Binary` and `Show` instances. For example, agda's repl session has around 360_000 UnlinkedBCO's, so avoiding these three words is already saving us around 8MB residency. - - - - - f2cc1107 by Fendor at 2024-04-08T09:04:11-04:00 Never UNPACK `FastMutInt` for counting z-encoded `FastString`s In `FastStringTable`, we count the number of z-encoded FastStrings that exist in a GHC session. We used to UNPACK the counters to not waste memory, but live retainer analysis showed that we allocate a lot of `FastMutInt`s, retained by `mkFastZString`. We lazily compute the `FastZString`, only incrementing the counter when the `FastZString` is forced. The function `mkFastStringWith` calls `mkZFastString` and boxes the `FastMutInt`, leading to the following core: mkFastStringWith = \ mk_fs _ -> = case stringTable of { FastStringTable _ n_zencs segments# _ -> ... case ((mk_fs (I# ...) (FastMutInt n_zencs)) `cast` <Co:2> :: ...) ... Marking this field as `NOUNPACK` avoids this reboxing, eliminating the allocation of a fresh `FastMutInt` on every `FastString` allocation. - - - - - c6def949 by Matthew Pickering at 2024-04-08T16:06:51-04:00 Force in_multi to avoid retaining entire hsc_env - - - - - fbb91a63 by Fendor at 2024-04-08T16:06:51-04:00 Eliminate name thunk in declaration fingerprinting Thunk analysis showed that we have about 100_000 thunks (in agda and `-fwrite-simplified-core`) pointing to the name of the name decl. Forcing this thunk fixes this issue. The thunk created here is retained by the thunk created by forkM, it is better to eagerly force this because the result (a `Name`) is already retained indirectly via the `IfaceDecl`. - - - - - 3b7b0c1c by Alan Zimmerman at 2024-04-08T16:07:27-04:00 EPA: Use EpaLocation in WarningTxt This allows us to use an EpDelta if needed when using makeDeltaAst. - - - - - 12b997df by Alan Zimmerman at 2024-04-08T16:07:27-04:00 EPA: Move DeltaPos and EpaLocation' into GHC.Types.SrcLoc This allows us to use a NoCommentsLocation for the possibly trailing comma location in a StringLiteral. This in turn allows us to correctly roundtrip via makeDeltaAst. - - - - - 868c8a78 by Fendor at 2024-04-09T08:51:50-04:00 Prefer packed representation for CompiledByteCode As there are many 'CompiledByteCode' objects alive during a GHCi session, representing its element in a more packed manner improves space behaviour at a minimal cost. When running GHCi on the agda codebase, we find around 380 live 'CompiledByteCode' objects. Packing their respective 'UnlinkedByteCode' can save quite some pointers. - - - - - be3bddde by Alan Zimmerman at 2024-04-09T08:52:26-04:00 EPA: Capture all comments in a ClassDecl Hopefully the final fix needed for #24533 - - - - - 3d0806fc by Jade at 2024-04-10T05:39:53-04:00 Validate -main-is flag using parseIdentifier Fixes #24368 - - - - - dd530bb7 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: free error message before returning Fixes a memory leak in rts/linker/PEi386.c - - - - - e008a19a by Alexis King at 2024-04-10T05:40:29-04:00 linker: Avoid linear search when looking up Haskell symbols via dlsym See the primary Note [Looking up symbols in the relevant objects] for a more in-depth explanation. When dynamically loading a Haskell symbol (typical when running a splice or GHCi expression), before this commit we would search for the symbol in all dynamic libraries that were loaded. However, this could be very inefficient when too many packages are loaded (which can happen if there are many package dependencies) because the time to lookup the would be linear in the number of packages loaded. This commit drastically improves symbol loading performance by introducing a mapping from units to the handles of corresponding loaded dlls. These handles are returned by dlopen when we load a dll, and can then be used to look up in a specific dynamic library. Looking up a given Name is now much more precise because we can get lookup its unit in the mapping and lookup the symbol solely in the handles of the dynamic libraries loaded for that unit. In one measurement, the wait time before the expression was executed went from +-38 seconds down to +-2s. This commit also includes Note [Symbols may not be found in pkgs_loaded], explaining the fallback to the old behaviour in case no dll can be found in the unit mapping for a given Name. Fixes #23415 Co-authored-by: Rodrigo Mesquita (@alt-romes) - - - - - dcfaa190 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: Make addDLL a wrapper around loadNativeObj Rewrite the implementation of `addDLL` as a wrapper around the more principled `loadNativeObj` rts linker function. The latter should be preferred while the former is preserved for backwards compatibility. `loadNativeObj` was previously only available on ELF platforms, so this commit further refactors the rts linker to transform loadNativeObj_ELF into loadNativeObj_POSIX, which is available in ELF and MachO platforms. The refactor made it possible to remove the `dl_mutex` mutex in favour of always using `linker_mutex` (rather than a combination of both). Lastly, we implement `loadNativeObj` for Windows too. - - - - - 12931698 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 Use symbol cache in internal interpreter too This commit makes the symbol cache that was used by the external interpreter available for the internal interpreter too. This follows from the analysis in #23415 that suggests the internal interpreter could benefit from this cache too, and that there is no good reason not to have the cache for it too. It also makes it a bit more uniform to have the symbol cache range over both the internal and external interpreter. This commit also refactors the cache into a function which is used by both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the caching logic to `lookupSymbolInDLL` too. - - - - - dccd3ea1 by Ben Gamari at 2024-04-10T05:40:29-04:00 testsuite: Add test for lookupSymbolInNativeObj - - - - - 1b1a92bd by Alan Zimmerman at 2024-04-10T05:41:05-04:00 EPA: Remove unnecessary XRec in CompleteMatchSig The XRec for [LIdP pass] is not needed for exact printing, remove it. - - - - - 6e18ce2b by Ben Gamari at 2024-04-12T08:16:09-04:00 users-guide: Clarify language extension documentation Over the years the users guide's language extension documentation has gone through quite a few refactorings. In the process some of the descriptions have been rendered non-sensical. For instance, the description of `NoImplicitPrelude` actually describes the semantics of `ImplicitPrelude`. To fix this we: * ensure that all extensions are named in their "positive" sense (e.g. `ImplicitPrelude` rather than `NoImplicitPrelude`). * rework the documentation to avoid flag-oriented wording like "enable" and "disable" * ensure that the polarity of the documentation is consistent with reality. Fixes #23895. - - - - - a933aff3 by Zubin Duggal at 2024-04-12T08:16:45-04:00 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - 23c3e624 by Andreas Klebinger at 2024-04-12T08:17:21-04:00 RTS: Emit warning when -M < -H Fixes #24487 - - - - - d23afb8c by Ben Gamari at 2024-04-12T08:17:56-04:00 testsuite: Add broken test for CApiFFI with -fprefer-bytecode See #24634. - - - - - a4bb3a51 by Ben Gamari at 2024-04-12T08:18:32-04:00 base: Deprecate GHC.Pack As proposed in #21461. Closes #21540. - - - - - 55eb8c98 by Ben Gamari at 2024-04-12T08:19:08-04:00 ghc-internal: Fix mentions of ghc-internal in deprecation warnings Closes #24609. - - - - - b0fbd181 by Ben Gamari at 2024-04-12T08:19:44-04:00 rts: Implement set_initial_registers for AArch64 Fixes #23680. - - - - - 14c9ec62 by Ben Gamari at 2024-04-12T08:20:20-04:00 ghcup-metadata: Use Debian 9 binaries on Ubuntu 16, 17 Closes #24646. - - - - - 35a1621e by Ben Gamari at 2024-04-12T08:20:55-04:00 Bump unix submodule to 2.8.5.1 Closes #24640. - - - - - a1c24df0 by Finley McIlwaine at 2024-04-12T08:21:31-04:00 Correct default -funfolding-use-threshold in docs - - - - - 0255d03c by Oleg Grenrus at 2024-04-12T08:22:07-04:00 FastString is a __Modified__ UTF-8 - - - - - c3489547 by Matthew Pickering at 2024-04-12T13:13:44-04:00 rts: Improve tracing message when nursery is resized It is sometimes more useful to know how much bigger or smaller the nursery got when it is resized. In particular I am trying to investigate situations where we end up with fragmentation due to the nursery (#24577) - - - - - 5e4f4ba8 by Simon Peyton Jones at 2024-04-12T13:14:20-04:00 Don't generate wrappers for `type data` constructors with StrictData Previously, the logic for checking if a data constructor needs a wrapper or not would take into account whether the constructor's fields have explicit strictness (e.g., `data T = MkT !Int`), but the logic would _not_ take into account whether `StrictData` was enabled. This meant that something like `type data T = MkT Int` would incorrectly generate a wrapper for `MkT` if `StrictData` was enabled, leading to the horrible errors seen in #24620. To fix this, we disable generating wrappers for `type data` constructors altogether. Fixes #24620. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - dbdf1995 by Alex Mason at 2024-04-15T15:28:26+10:00 Implements MO_S_Mul2 and MO_U_Mul2 using the UMULH, UMULL and SMULH instructions for AArch64 Also adds a test for MO_S_Mul2 - - - - - 42bd0407 by Teo Camarasu at 2024-04-16T20:06:39-04:00 Make template-haskell a stage1 package Promoting template-haskell from a stage0 to a stage1 package means that we can much more easily refactor template-haskell. We implement this by duplicating the in-tree `template-haskell`. A new `template-haskell-next` library is autogenerated to mirror `template-haskell` `stage1:ghc` to depend on the new interface of the library including the `Binary` instances without adding an explicit dependency on `template-haskell`. This is controlled by the `bootstrap-th` cabal flag When building `template-haskell` modules as part of this vendoring we do not have access to quote syntax, so we cannot use variable quote notation (`'Just`). So we either replace these with hand-written `Name`s or hide the code behind CPP. We can remove the `th_hack` from hadrian, which was required when building stage0 packages using the in-tree `template-haskell` library. For more details see Note [Bootstrapping Template Haskell]. Resolves #23536 Co-Authored-By: Sebastian Graf <sgraf1337 at gmail.com> Co-Authored-By: Matthew Craven <5086-clyring at users.noreply.gitlab.haskell.org> - - - - - 3d973e47 by Ben Gamari at 2024-04-16T20:07:15-04:00 Bump parsec submodule to 3.1.17.0 - - - - - 9d38bfa0 by Simon Peyton Jones at 2024-04-16T20:07:51-04:00 Clone CoVars in CorePrep This MR addresses #24463. It's all explained in the new Note [Cloning CoVars and TyVars] - - - - - 0fe2b410 by Andreas Klebinger at 2024-04-16T20:08:27-04:00 NCG: Fix a bug where we errounously removed a required jump instruction. Add a new method to the Instruction class to check if we can eliminate a jump in favour of fallthrough control flow. Fixes #24507 - - - - - 9f99126a by Teo Camarasu at 2024-04-16T20:09:04-04:00 Fix documentation preview from doc-tarball job - Include all the .html files and assets in the job artefacts - Include all the .pdf files in the job artefacts - Mark the artefact as an "exposed" artefact meaning it turns up in the UI. Resolves #24651 - - - - - 3a0642ea by Ben Gamari at 2024-04-16T20:09:39-04:00 rts: Ignore EINTR while polling in timerfd itimer implementation While the RTS does attempt to mask signals, it may be that a foreign library unmasks them. This previously caused benign warnings which we now ignore. See #24610. - - - - - 9a53cd3f by Alan Zimmerman at 2024-04-16T20:10:15-04:00 EPA: Add additional comments field to AnnsModule This is used in exact printing to store comments coming after the `where` keyword but before any comments allocated to imports or decls. It is used in ghc-exactprint, see https://github.com/alanz/ghc-exactprint/commit/44bbed311fd8f0d053053fef195bf47c17d34fa7 - - - - - e5c43259 by Bryan Richter at 2024-04-16T20:10:51-04:00 Remove unrunnable FreeBSD CI jobs FreeBSD runner supply is inelastic. Currently there is only one, and it's unavailable because of a hardware issue. - - - - - 914eb49a by Ben Gamari at 2024-04-16T20:11:27-04:00 rel-eng: Fix mktemp usage in recompress-all We need a temporary directory, not a file. - - - - - f30e4984 by Teo Camarasu at 2024-04-16T20:12:03-04:00 Fix ghc API link in docs/index.html This was missing part of the unit ID meaning it would 404. Resolves #24674 - - - - - d7a3d6b5 by Ben Gamari at 2024-04-16T20:12:39-04:00 template-haskell: Declare TH.Lib.Internal as not-home Rather than `hide`. Closes #24659. - - - - - 5eaa46e7 by Matthew Pickering at 2024-04-19T02:14:55-04:00 testsuite: Rename isCross() predicate to needsTargetWrapper() isCross() was a misnamed because it assumed that all cross targets would provide a target wrapper, but the two most common cross targets (javascript, wasm) don't need a target wrapper. Therefore we rename this predicate to `needsTargetWrapper()` so situations in the testsuite where we can check whether running executables requires a target wrapper or not. - - - - - 55a9d699 by Simon Peyton Jones at 2024-04-19T02:15:32-04:00 Do not float HNFs out of lambdas This MR adjusts SetLevels so that it is less eager to float a HNF (lambda or constructor application) out of a lambda, unless it gets to top level. Data suggests that this change is a small net win: * nofib bytes-allocated falls by -0.09% (but a couple go up) * perf/should_compile bytes-allocated falls by -0.5% * perf/should_run bytes-allocated falls by -0.1% See !12410 for more detail. When fiddling elsewhere, I also found that this patch had a huge positive effect on the (very delicate) test perf/should_run/T21839r But that improvement doesn't show up in this MR by itself. Metric Decrease: MultiLayerModulesRecomp T15703 parsing001 - - - - - f0701585 by Alan Zimmerman at 2024-04-19T02:16:08-04:00 EPA: Fix comments in mkListSyntaxTy0 Also extend the test to confirm. Addresses #24669, 1 of 4 - - - - - b01c01d4 by Serge S. Gulin at 2024-04-19T02:16:51-04:00 JS: set image `x86_64-linux-deb11-emsdk-closure` for build - - - - - c90c6039 by Alan Zimmerman at 2024-04-19T02:17:27-04:00 EPA: Provide correct span for PatBind And remove unused parameter in checkPatBind Contributes to #24669 - - - - - 26036f96 by Alan Zimmerman at 2024-04-19T13:11:08-04:00 EPA: Fix span for PatBuilderAppType Include the location of the prefix @ in the span for InVisPat. Also removes unnecessary annotations from HsTP. Contributes to #24669 - - - - - dba03aab by Matthew Craven at 2024-04-19T13:11:44-04:00 testsuite: Give the pre_cmd for mhu-perf more time - - - - - d31fbf6c by Krzysztof Gogolewski at 2024-04-19T21:04:09-04:00 Fix quantification order for a `op` b and a %m -> b Fixes #23764 Implements https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0640-tyop-quantification-order.rst Updates haddock submodule. - - - - - 385cd1c4 by Sebastian Graf at 2024-04-19T21:04:45-04:00 Make `seq#` a magic Id and inline it in CorePrep (#24124) We can save much code and explanation in Tag Inference and StgToCmm by making `seq#` a known-key Magic Id in `GHC.Internal.IO` and inline this definition in CorePrep. See the updated `Note [seq# magic]`. I also implemented a new `Note [Flatten case-bind]` to get better code for otherwise nested case scrutinees. I renamed the contructors of `ArgInfo` to use an `AI` prefix in order to resolve the clash between `type CpeApp = CoreExpr` and the data constructor of `ArgInfo`, as well as fixed typos in `Note [CorePrep invariants]`. Fixes #24252 and #24124. - - - - - 275e41a9 by Jade at 2024-04-20T11:10:40-04:00 Put the newline after errors instead of before them This mainly has consequences for GHCi but also slightly alters how the output of GHC on the commandline looks. Fixes: #22499 - - - - - dd339c7a by Teo Camarasu at 2024-04-20T11:11:16-04:00 Remove unecessary stage0 packages Historically quite a few packages had to be stage0 as they depended on `template-haskell` and that was stage0. In #23536 we made it so that was no longer the case. This allows us to remove a bunch of packages from this list. A few still remain. A new version of `Win32` is required by `semaphore-compat`. Including `Win32` in the stage0 set requires also including `filepath` because otherwise Hadrian's dependency logic gets confused. Once our boot compiler has a newer version of `Win32` all of these will be able to be dropped. Resolves #24652 - - - - - 2f8e3a25 by Alan Zimmerman at 2024-04-20T11:11:52-04:00 EPA: Avoid duplicated comments in splice decls Contributes to #24669 - - - - - c70b9ddb by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fix typos and namings (fixes #24602) You may noted that I've also changed term of ``` , global "h$vt_double" ||= toJExpr IntV ``` See "IntV" and ``` WaitReadOp -> \[] [fd] -> pure $ PRPrimCall $ returnS (app "h$waidRead" [fd]) ``` See "h$waidRead" - - - - - 3db54f9b by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: trivial checks for variable presence (fixes #24602) - - - - - 777f108f by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fs module imported twice (by emscripten and by ghc-internal). ghc-internal import wrapped in a closure to prevent conflict with emscripten (fixes #24602) Better solution is to use some JavaScript module system like AMD, CommonJS or even UMD. It will be investigated at other issues. At first glance we should try UMD (See https://github.com/umdjs/umd) - - - - - a45a5712 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: thread.js requires h$fds and h$fdReady to be declared for static code analysis, minimal code copied from GHCJS (fixes #24602) I've just copied some old pieces of GHCJS from publicly available sources (See https://github.com/Taneb/shims/blob/a6dd0202dcdb86ad63201495b8b5d9763483eb35/src/io.js#L607). Also I didn't put details to h$fds. I took minimal and left only its object initialization: `var h$fds = {};` - - - - - ad90bf12 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: heap and stack overflows reporting defined as js hard failure (fixes #24602) These errors were treated as a hard failure for browser application. The fix is trivial: just throw error. - - - - - 5962fa52 by Serge S. Gulin at 2024-04-21T16:33:44+03:00 JS: Stubs for code without actual implementation detected by Google Closure Compiler (fixes #24602) These errors were fixed just by introducing stubbed functions with throw for further implementation. - - - - - a0694298 by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add externs to linker (fixes #24602) After enabling jsdoc and built-in google closure compiler types I was needed to deal with the following: 1. Define NodeJS-environment types. I've just copied minimal set of externs from semi-official repo (see https://github.com/externs/nodejs/blob/6c6882c73efcdceecf42e7ba11f1e3e5c9c041f0/v8/nodejs.js#L8). 2. Define Emscripten-environment types: `HEAP8`. Emscripten already provides some externs in our code but it supposed to be run in some module system. And its definitions do not work well in plain bundle. 3. We have some functions which purpose is to add to functions some contextual information via function properties. These functions should be marked as `modifies` to let google closure compiler remove calls if these functions are not used actually by call graph. Such functions are: `h$o`, `h$sti`, `h$init_closure`, `h$setObjInfo`. 4. STG primitives such as registries and stuff from `GHC.StgToJS`. `dXX` properties were already present at externs generator function but they are started from `7`, not from `1`. This message is related: `// fixme does closure compiler bite us here?` - - - - - e58bb29f by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: added both tests: for size and for correctness (fixes #24602) By some reason MacOS builds add to stderr messages like: Ignoring unexpected archive entry: __.SYMDEF ... However I left stderr to `/dev/null` for compatibility with linux CI builds. - - - - - 909f3a9c by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Disable js linker warning for empty symbol table to make js tests running consistent across environments - - - - - 83eb10da by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add special preprocessor for js files due of needing to keep jsdoc comments (fixes #24602) Our js files have defined google closure compiler types at jsdoc entries but these jsdoc entries are removed by cpp preprocessor. I considered that reusing them in javascript-backend would be a nice thing. Right now haskell processor uses `-traditional` option to deal with comments and `//` operators. But now there are following compiler options: `-C` and `-CC`. You can read about them at GCC (see https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#index-CC) and CLang (see https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-CC). It seems that `-CC` works better for javascript jsdoc than `-traditional`. At least it leaves `/* ... */` comments w/o changes. - - - - - e1cf8dc2 by brandon s allbery kf8nh at 2024-04-22T03:48:26-04:00 fix link in CODEOWNERS It seems that our local Gitlab no longer has documentation for the `CODEOWNERS` file, but the master documentation still does. Use that instead. - - - - - 593f4e04 by Fendor at 2024-04-23T10:19:14-04:00 Add performance regression test for '-fwrite-simplified-core' - - - - - 1ba39b05 by Fendor at 2024-04-23T10:19:14-04:00 Typecheck corebindings lazily during bytecode generation This delays typechecking the corebindings until the bytecode generation happens. We also avoid allocating a thunk that is retained by `unsafeInterleaveIO`. In general, we shouldn't retain values of the hydrated `Type`, as not evaluating the bytecode object keeps it alive. It is better if we retain the unhydrated `IfaceType`. See Note [Hydrating Modules] - - - - - e916fc92 by Alan Zimmerman at 2024-04-23T10:19:50-04:00 EPA: Keep comments in a CaseAlt match The comments now live in the surrounding location, not inside the Match. Make sure we keep them. Closes #24707 - - - - - d2b17f32 by Cheng Shao at 2024-04-23T15:01:22-04:00 driver: force merge objects when building dynamic objects This patch forces the driver to always merge objects when building dynamic objects even when ar -L is supported. It is an oversight of !8887: original rationale of that patch is favoring the relatively cheap ar -L operation over object merging when ar -L is supported, which makes sense but only if we are building static objects! Omitting check for whether we are building dynamic objects will result in broken .so files with undefined reference errors at executable link time when building GHC with llvm-ar. Fixes #22210. - - - - - 209d09f5 by Julian Ospald at 2024-04-23T15:02:03-04:00 Allow non-absolute values for bootstrap GHC variable Fixes #24682 - - - - - 3fff0977 by Matthew Pickering at 2024-04-23T15:02:38-04:00 Don't depend on registerPackage function in Cabal More recent versions of Cabal modify the behaviour of libAbiHash which breaks our usage of registerPackage. It is simpler to inline the part of registerPackage that we need and avoid any additional dependency and complication using the higher-level function introduces. - - - - - c62dc317 by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: remove obsolete ln script This commit removes an obsolete ln script in ghc-bignum/gmp. See 060251c24ad160264ae8553efecbb8bed2f06360 for its original intention, but it's been obsolete for a long time, especially since the removal of the make build system. Hence the house cleaning. - - - - - 6399d52b by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: update gmp to 6.3.0 This patch bumps the gmp-tarballs submodule and updates gmp to 6.3.0. The tarball format is now xz, and gmpsrc.patch has been patched into the tarball so hadrian no longer needs to deal with patching logic when building in-tree GMP. - - - - - 65b4b92f by Cheng Shao at 2024-04-25T01:32:02-04:00 hadrian: remove obsolete Patch logic This commit removes obsolete Patch logic from hadrian, given we no longer need to patch the gmp tarball when building in-tree GMP. - - - - - 71f28958 by Cheng Shao at 2024-04-25T01:32:02-04:00 autoconf: remove obsolete patch detection This commit removes obsolete deletection logic of the patch command from autoconf scripts, given we no longer need to patch anything in the GHC build process. - - - - - daeda834 by Sylvain Henry at 2024-04-25T01:32:43-04:00 JS: correctly handle RUBBISH literals (#24664) - - - - - 8a06ddf6 by Matthew Pickering at 2024-04-25T11:16:16-04:00 Linearise ghc-internal and base build This is achieved by requesting the final package database for ghc-internal, which mandates it is fully built as a dependency of configuring the `base` package. This is at the expense of cross-package parrallelism between ghc-internal and the base package. Fixes #24436 - - - - - 94da9365 by Andrei Borzenkov at 2024-04-25T11:16:54-04:00 Fix tuple puns renaming (24702) Move tuple renaming short cutter from `isBuiltInOcc_maybe` to `isPunOcc_maybe`, so we consider incoming module. I also fixed some hidden bugs that raised after the change was done. - - - - - fa03b1fb by Fendor at 2024-04-26T18:03:13-04:00 Refactor the Binary serialisation interface The goal is simplifiy adding deduplication tables to `ModIface` interface serialisation. We identify two main points of interest that make this difficult: 1. UserData hardcodes what `Binary` instances can have deduplication tables. Moreover, it heavily uses partial functions. 2. GHC.Iface.Binary hardcodes the deduplication tables for 'Name' and 'FastString', making it difficult to add more deduplication. Instead of having a single `UserData` record with fields for all the types that can have deduplication tables, we allow to provide custom serialisers for any `Typeable`. These are wrapped in existentials and stored in a `Map` indexed by their respective `TypeRep`. The `Binary` instance of the type to deduplicate still needs to explicitly look up the decoder via `findUserDataReader` and `findUserDataWriter`, which is no worse than the status-quo. `Map` was chosen as microbenchmarks indicate it is the fastest for a small number of keys (< 10). To generalise the deduplication table serialisation mechanism, we introduce the types `ReaderTable` and `WriterTable` which provide a simple interface that is sufficient to implement a general purpose deduplication mechanism for `writeBinIface` and `readBinIface`. This allows us to provide a list of deduplication tables for serialisation that can be extended more easily, for example for `IfaceTyCon`, see the issue https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for more motivation. In addition to this refactoring, we split `UserData` into `ReaderUserData` and `WriterUserData`, to avoid partial functions and reduce overall memory usage, as we need fewer mutable variables. Bump haddock submodule to accomodate for `UserData` split. ------------------------- Metric Increase: MultiLayerModulesTH_Make MultiLayerModulesRecomp T21839c ------------------------- - - - - - bac57298 by Fendor at 2024-04-26T18:03:13-04:00 Split `BinHandle` into `ReadBinHandle` and `WriteBinHandle` A `BinHandle` contains too much information for reading data. For example, it needs to keep a `FastMutInt` and a `IORef BinData`, when the non-mutable variants would suffice. Additionally, this change has the benefit that anyone can immediately tell whether the `BinHandle` is used for reading or writing. Bump haddock submodule BinHandle split. - - - - - 4d6394dd by Simon Peyton Jones at 2024-04-26T18:03:49-04:00 Fix missing escaping-kind check in tcPatSynSig Note [Escaping kind in type signatures] explains how we deal with escaping kinds in type signatures, e.g. f :: forall r (a :: TYPE r). a where the kind of the body is (TYPE r), but `r` is not in scope outside the forall-type. I had missed this subtlety in tcPatSynSig, leading to #24686. This MR fixes it; and a similar bug in tc_top_lhs_type. (The latter is tested by T24686a.) - - - - - 981c2c2c by Alan Zimmerman at 2024-04-26T18:04:25-04:00 EPA: check-exact: check that the roundtrip reproduces the source Closes #24670 - - - - - a8616747 by Andrew Lelechenko at 2024-04-26T18:05:01-04:00 Document that setEnv is not thread-safe - - - - - 1e41de83 by Bryan Richter at 2024-04-26T18:05:37-04:00 CI: Work around frequent Signal 9 errors - - - - - a6d5f9da by Naïm Favier at 2024-04-27T17:52:40-04:00 ghc-internal: add MonadFix instance for (,) Closes https://gitlab.haskell.org/ghc/ghc/-/issues/24288, implements CLC proposal https://github.com/haskell/core-libraries-committee/issues/238. Adds a MonadFix instance for tuples, permitting value recursion in the "native" writer monad and bringing consistency with the existing instance for transformers's WriterT (and, to a lesser extent, for Solo). - - - - - 64feadcd by Rodrigo Mesquita at 2024-04-27T17:53:16-04:00 bindist: Fix xattr cleaning The original fix (725343aa) was incorrect because it used the shell bracket syntax which is the quoting syntax in autoconf, making the test for existence be incorrect and therefore `xattr` was never run. Fixes #24554 - - - - - e2094df3 by damhiya at 2024-04-28T23:52:00+09:00 Make read accepts binary integer formats CLC proposal : https://github.com/haskell/core-libraries-committee/issues/177 - - - - - 1c2fd963 by Alan Zimmerman at 2024-04-29T23:17:00-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 - - - - - 4189d17e by Sylvain Henry at 2024-04-29T23:17:42-04:00 LLVM: better unreachable default destination in Switch (#24717) See added note. Co-authored-by: Siddharth Bhat <siddu.druid at gmail.com> - - - - - a3725c88 by Cheng Shao at 2024-04-29T23:18:20-04:00 ci: enable wasm jobs for MRs with wasm label This patch enables wasm jobs for MRs with wasm label. Previously the wasm label didn't actually have any effect on the CI pipeline, and full-ci needed to be applied to run wasm jobs which was a waste of runners when working on the wasm backend, hence the fix here. - - - - - 702f7964 by Matthew Pickering at 2024-04-29T23:18:56-04:00 Make interface files and object files depend on inplace .conf file A potential fix for #24737 - - - - - 728af21e by Cheng Shao at 2024-04-30T05:30:23-04:00 utils: remove obsolete vagrant scripts Vagrantfile has long been removed in !5288. This commit further removes the obsolete vagrant scripts in the tree. - - - - - 36f2c342 by Cheng Shao at 2024-04-30T05:31:00-04:00 Update autoconf scripts Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 - - - - - ecbf22a6 by Ben Gamari at 2024-04-30T05:31:36-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - de3d09b9 by Rodrigo Mesquita at 2024-05-02T20:50:51+01:00 Add e-graphs submodule (hegg) - - - - - 5c03df3b by Rodrigo Mesquita at 2024-05-02T20:50:52+01:00 Create Core.Equality module This module defines CoreExprF -- the base functor of CoreExpr, and equality and ordering operations on the debruijnized CoreExprF. Furthermore, it provides a function to represent a CoreExpr in an e-graph. This is a requirement to represent, reason about equality, and manipulate CoreExprs in e-graphs. E-graphs are going to be used in the pattern match checker (#19272), and potentially for type family rewriting (#TODO) -- amongst other oportunities that are unlocked by having them available. - - - - - 63f32673 by Rodrigo Mesquita at 2024-05-02T20:50:52+01:00 Drop GHC.Types.Unique.SDFM in favour of e-graphs - - - - - 68f24bf0 by Rodrigo Mesquita at 2024-05-02T20:52:32+01:00 The rest of the owl Drawing of multiple owls Keep drawing WIP MORE WIP ALMOST WIP... WIP.; whitsepac Ww Better Outputable instance mergeNotConCt can't use implications only now...? Sometimes we can omit implied nalts Fixes + debugging STAGE 1 BUILDS WITHOUT FAILURES. depstest submodule update - - - - - 20 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/merge_request_templates/Default.md - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - .gitmodules - CODEOWNERS - + TODO - compiler/GHC.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/af60b03e6638d951282f59eab14b92da5046192a...68f24bf04e3338076e9144b99157bff45f1d2718 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/af60b03e6638d951282f59eab14b92da5046192a...68f24bf04e3338076e9144b99157bff45f1d2718 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 20:05:33 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Thu, 02 May 2024 16:05:33 -0400 Subject: [Git][ghc/ghc][wip/romes/egraphs-pmc-2] The rest of the owl Message-ID: <6633f20d7be52_1a3d2444d0414158796@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/egraphs-pmc-2 at Glasgow Haskell Compiler / GHC Commits: 87c04a41 by Rodrigo Mesquita at 2024-05-02T21:05:07+01:00 The rest of the owl Drawing of multiple owls Keep drawing WIP MORE WIP ALMOST WIP... WIP.; whitsepac Ww Better Outputable instance mergeNotConCt can't use implications only now...? Sometimes we can omit implied nalts Fixes + debugging STAGE 1 BUILDS WITHOUT FAILURES. depstest submodule update - - - - - 7 changed files: - + TODO - compiler/GHC/Core.hs - compiler/GHC/Core/Equality.hs - compiler/GHC/HsToCore/Pmc/Solver.hs - compiler/GHC/HsToCore/Pmc/Solver/Types.hs - libraries/hegg - testsuite/tests/count-deps/CountDepsParser.stdout Changes: ===================================== TODO ===================================== @@ -0,0 +1,9 @@ +The current failures might be because congruence isn't being maintained properly downwards, I think...? +Instead, we might do this manually for merging positive constructor info in the e-graphs analysis modify function? + +If this works, the major todos are +* Propagating strictness annotations to underlying newtypes (likely modify analysis) +* Clean up equality + * How to do Ord Type? +* Clean up solver + * Merge args of data cons when merging by congruence (likely modify analysis as well) ===================================== compiler/GHC/Core.hs ===================================== @@ -294,6 +294,7 @@ data AltCon -- The instance adheres to the order described in Note [Case expression invariants] instance Ord AltCon where compare (DataAlt con1) (DataAlt con2) = + -- ROMES:TODO: Couldn't simply do this right by comparing the dataConName of the cons? assert (dataConTyCon con1 == dataConTyCon con2) $ compare (dataConTag con1) (dataConTag con2) compare (DataAlt _) _ = GT ===================================== compiler/GHC/Core/Equality.hs ===================================== @@ -17,7 +17,6 @@ import GHC.Core.TyCo.Rep import GHC.Core.Map.Type import GHC.Types.Var import GHC.Types.Literal -import GHC.Types.Tickish import Data.Equality.Graph as EG import Data.Equality.Analysis.Monadic @@ -91,7 +90,7 @@ instance Ord AltCon' where -- we might as well make it a better suited representation for the e-graph... -- keeping the on-fly debruijn is harder representCoreExprEgr :: forall a m - . Analysis m a CoreExprF + . AnalysisM m a CoreExprF => CoreExpr -> EGraph a CoreExprF -> m (ClassId, EGraph a CoreExprF) @@ -134,7 +133,7 @@ representCoreExprEgr expr egr = EGM.runEGraphMT egr (runReaderT (go expr) emptyC e' <- local (`extendCMEs` bs) $ go e return (AltF (AC' c) (map (const ()) bs) e') - addE :: Analysis m a CoreExprF => CoreExprF ClassId -> ReaderT CmEnv (EGM.EGraphMT a CoreExprF m) ClassId + addE :: AnalysisM m a CoreExprF => CoreExprF ClassId -> ReaderT CmEnv (EGM.EGraphMT a CoreExprF m) ClassId addE e = lift $ EGM.addM $ Node e {-# INLINEABLE representCoreExprEgr #-} @@ -142,6 +141,9 @@ type CoreExprF = ExprF type CoreAltF = AltF type CoreBindF = BindF +instance Outputable (EG.ENode CoreExprF) where + ppr (EG.Node n) = text (show n) + -- cmpDeBruijnTickish :: DeBruijn CoreTickish -> DeBruijn CoreTickish -> Ordering -- cmpDeBruijnTickish (D env1 t1) (D env2 t2) = go t1 t2 where -- go (Breakpoint lext lid lids _) (Breakpoint rext rid rids _) ===================================== compiler/GHC/HsToCore/Pmc/Solver.hs ===================================== @@ -1,6 +1,13 @@ -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE TupleSections #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE MultiWayIf #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE RankNTypes, GADTs #-} +{-# OPTIONS_GHC -Wno-orphans #-} -- Analysis........ {- Authors: George Karachalias @@ -48,22 +55,22 @@ import GHC.Data.Bag import GHC.Types.CompleteMatch import GHC.Types.Unique.Set import GHC.Types.Unique.DSet -import GHC.Types.Unique.SDFM import GHC.Types.Id import GHC.Types.Name import GHC.Types.Var (EvVar) import GHC.Types.Var.Env -import GHC.Types.Var.Set import GHC.Types.Unique.Supply import GHC.Core +import GHC.Core.Equality import GHC.Core.FVs (exprFreeVars) import GHC.Core.TyCo.Compare( eqType ) -import GHC.Core.Map.Expr +import GHC.Core.Map.Type (deBruijnize) import GHC.Core.Predicate (typeDeterminesValue) import GHC.Core.SimpleOpt (simpleOptExpr, exprIsConApp_maybe) import GHC.Core.Utils (exprType) -import GHC.Core.Make (mkListExpr, mkCharExpr, mkImpossibleExpr) +import GHC.Core.Make (mkListExpr, mkCharExpr, mkImpossibleExpr, mkCoreApp) +import GHC.Types.Id.Make (unboxedUnitExpr) import GHC.Data.FastString import GHC.Types.SrcLoc @@ -97,6 +104,14 @@ import Data.List (sortBy, find) import qualified Data.List.NonEmpty as NE import Data.Ord (comparing) +import Data.Equality.Analysis.Monadic +import Data.Equality.Graph (ClassId) +import Data.Equality.Graph.Lens +import qualified Data.Equality.Graph as EG +import qualified Data.Equality.Graph.Monad as EGM +import Data.Function ((&)) +import qualified Data.IntSet as IS + -- -- * Main exports -- @@ -602,8 +617,10 @@ addPhiCts :: Nabla -> PhiCts -> DsM (Maybe Nabla) -- See Note [TmState invariants]. addPhiCts nabla cts = runMaybeT $ do let (ty_cts, tm_cts) = partitionPhiCts cts - nabla' <- addTyCts nabla (listToBag ty_cts) + nabla' <- addTyCts nabla (listToBag ty_cts) nabla'' <- foldlM addPhiTmCt nabla' (listToBag tm_cts) + lift $ tracePm "addPhiCts, doing inhabitationTest" (ppr nabla'') + -- ROMES:TODO: Should the ty_st be nabla' or nabla'' !? inhabitationTest initFuel (nabla_ty_st nabla) nabla'' partitionPhiCts :: PhiCts -> ([PredType], [PhiCt]) @@ -666,7 +683,7 @@ addPhiTmCt nabla (PhiConCt x con tvs dicts args) = do -- PhiConCt correspond to the higher-level φ constraints from the paper with -- bindings semantics. It disperses into lower-level δ constraints that the -- 'add*Ct' functions correspond to. - nabla' <- addTyCts nabla (listToBag dicts) + nabla' <- addTyCts nabla (listToBag dicts) nabla'' <- addConCt nabla' x con tvs args foldlM addNotBotCt nabla'' (filterUnliftedFields con args) addPhiTmCt nabla (PhiNotConCt x con) = addNotConCt nabla x con @@ -682,33 +699,68 @@ filterUnliftedFields con args = -- surely diverges. Quite similar to 'addConCt', only that it only cares about -- ⊥. addBotCt :: Nabla -> Id -> MaybeT DsM Nabla -addBotCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ ts_facts=env } } x = do - let (y, vi at VI { vi_bot = bot }) = lookupVarInfoNT (nabla_tm_st nabla) x - case bot of - IsNotBot -> mzero -- There was x ≁ ⊥. Contradiction! - IsBot -> pure nabla -- There already is x ~ ⊥. Nothing left to do - MaybeBot -- We add x ~ ⊥ - | definitelyUnliftedType (idType x) - -- Case (3) in Note [Strict fields and variables of unlifted type] - -> mzero -- unlifted vars can never be ⊥ - | otherwise - -> do - let vi' = vi{ vi_bot = IsBot } - pure nabla{ nabla_tm_st = ts{ts_facts = addToUSDFM env y vi' } } +addBotCt nabla0 at MkNabla{nabla_tm_st = ts0} x = do + let (y, vi at VI { vi_bot = bot0 }) = lookupVarInfoNT ts0 x + -- NOTE FOR REVIEWER: + -- we were previously using the idType of |x|, but I think it should rather + -- be |y|, since, if y /= x, then x is a newtype and newtypes cannot be + -- unlifted + bot1 <- mergeBots (idType y) IsBot bot0 + let vi' = vi{ vi_bot = bot1 } + + (yid, nabla1) <- representId y nabla0 + + pure (nabla1 & nabla_egr._class yid._data .~ Just vi') -- | Adds the constraint @x ~/ ⊥@ to 'Nabla'. Quite similar to 'addNotConCt', -- but only cares for the ⊥ "constructor". addNotBotCt :: Nabla -> Id -> MaybeT DsM Nabla -addNotBotCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ts_facts=env} } x = do - let (y, vi at VI { vi_bot = bot }) = lookupVarInfoNT (nabla_tm_st nabla) x - case bot of - IsBot -> mzero -- There was x ~ ⊥. Contradiction! - IsNotBot -> pure nabla -- There already is x ≁ ⊥. Nothing left to do - MaybeBot -> do -- We add x ≁ ⊥ and test if x is still inhabited - -- Mark dirty for a delayed inhabitation test - let vi' = vi{ vi_bot = IsNotBot} - pure $ markDirty y - $ nabla{ nabla_tm_st = ts{ ts_facts = addToUSDFM env y vi' } } +addNotBotCt nabla0 at MkNabla{ nabla_tm_st = ts0 } x = do + let (y, vi at VI { vi_bot = bot0 }) = lookupVarInfoNT ts0 x + bot1 <- mergeBots (idType y) IsNotBot bot0 + let vi' = vi{ vi_bot = bot1 } + + (yid, nabla1) <- representId y nabla0 + let + marked + = case bot0 of + -- Mark dirty for a delayed inhabitation test (see comment in 'mergeBots' as well) + MaybeBot -> markDirty y + _ -> id + return $ + marked + (nabla1 & nabla_egr._class yid._data .~ Just vi') + +mergeBots :: Type + -- ^ The type of the pattern whose 'BotInfo's are being merged + -> BotInfo + -> BotInfo + -> MaybeT DsM BotInfo +-- There already is x ~ ⊥. Nothing left to do +mergeBots _ IsBot IsBot = pure IsBot +-- There was x ≁ ⊥. Contradiction! +mergeBots _ IsBot IsNotBot = mzero +-- We add x ~ ⊥ +mergeBots t IsBot MaybeBot + | definitelyUnliftedType t + -- Case (3) in Note [Strict fields and variables of unlifted type] + -- (unlifted vars can never be ⊥) + = mzero + | otherwise + = pure IsBot +-- There was x ~ ⊥. Contradiction! +mergeBots _ IsNotBot IsBot = mzero +-- There already is x ≁ ⊥. Nothing left to do +mergeBots _ IsNotBot IsNotBot = pure IsNotBot +-- We add x ≁ ⊥ and will need to test if x is still inhabited (see addNotBotCt) +-- romes:todo: We don't have the dirty set in the e-graph, so +-- congruence-fueled merging won't mark anything as dirty... hmm... +mergeBots _ IsNotBot MaybeBot = pure IsNotBot +-- Commutativity of 'mergeBots', +-- and trivially merging MaybeBots +mergeBots x MaybeBot IsBot = mergeBots x IsBot MaybeBot +mergeBots x MaybeBot IsNotBot = mergeBots x IsNotBot MaybeBot +mergeBots _ MaybeBot MaybeBot = pure MaybeBot -- | Record a @x ~/ K@ constraint, e.g. that a particular 'Id' @x@ can't -- take the shape of a 'PmAltCon' @K@ in the 'Nabla' and return @Nothing@ if @@ -717,41 +769,44 @@ addNotBotCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ts_facts=env} } x = do addNotConCt :: Nabla -> Id -> PmAltCon -> MaybeT DsM Nabla addNotConCt _ _ (PmAltConLike (RealDataCon dc)) | isNewDataCon dc = mzero -- (3) in Note [Coverage checking Newtype matches] -addNotConCt nabla x nalt = do - (mb_mark_dirty, nabla') <- trvVarInfo go nabla x +addNotConCt nabla0 x nalt = do + (xid, nabla1) <- representId x nabla0 + (mb_mark_dirty, nabla2) <- trvVarInfo (`mergeNotConCt` nalt) nabla1 (xid, x) pure $ case mb_mark_dirty of - Just x -> markDirty x nabla' - Nothing -> nabla' - where - -- Update `x`'s 'VarInfo' entry. Fail ('MaybeT') if contradiction, - -- otherwise return updated entry and `Just x'` if `x` should be marked dirty, - -- where `x'` is the representative of `x`. - go :: VarInfo -> MaybeT DsM (Maybe Id, VarInfo) - go vi@(VI x' pos neg _ rcm) = do - -- 1. Bail out quickly when nalt contradicts a solution - let contradicts nalt sol = eqPmAltCon (paca_con sol) nalt == Equal - guard (not (any (contradicts nalt) pos)) - -- 2. Only record the new fact when it's not already implied by one of the - -- solutions - let implies nalt sol = eqPmAltCon (paca_con sol) nalt == Disjoint - let neg' - | any (implies nalt) pos = neg - -- See Note [Completeness checking with required Thetas] - | hasRequiredTheta nalt = neg - | otherwise = extendPmAltConSet neg nalt - massert (isPmAltConMatchStrict nalt) - let vi' = vi{ vi_neg = neg', vi_bot = IsNotBot } - -- 3. Make sure there's at least one other possible constructor - mb_rcm' <- lift (markMatched nalt rcm) - pure $ case mb_rcm' of - -- If nalt could be removed from a COMPLETE set, we'll get back Just and - -- have to mark x dirty, by returning Just x'. - Just rcm' -> (Just x', vi'{ vi_rcm = rcm' }) - -- Otherwise, nalt didn't occur in any residual COMPLETE set and we - -- don't have to mark it dirty. So we return Nothing, which in the case - -- above would have compromised precision. - -- See Note [Shortcutting the inhabitation test], grep for T17836. - Nothing -> (Nothing, vi') + Just x -> markDirty x nabla2 + Nothing -> nabla2 + +-- Update `x`'s 'VarInfo' entry. Fail ('MaybeT') if contradiction, +-- otherwise return updated entry and `Just x'` if `x` should be marked dirty, +-- where `x'` is the representative of `x`. +mergeNotConCt :: VarInfo -> PmAltCon -> MaybeT DsM (Maybe Id, VarInfo) +mergeNotConCt vi@(VI x' pos neg _ rcm) nalt = do + lift $ tracePm "mergeNotConCt vi nalt" (ppr vi <+> ppr nalt) + -- 1. Bail out quickly when nalt contradicts a solution + let contradicts nalt sol = eqPmAltCon (paca_con sol) nalt == Equal + guard (not (any (contradicts nalt) pos)) + -- 2. Only record the new fact when it's not already implied by one of the + -- solutions + let implies nalt sol = eqPmAltCon (paca_con sol) nalt == Disjoint + let neg' + | any (implies nalt) pos = neg + -- See Note [Completeness checking with required Thetas] + | hasRequiredTheta nalt = neg + | otherwise = extendPmAltConSet neg nalt + massert (isPmAltConMatchStrict nalt) + let vi' = vi{ vi_neg = neg', vi_bot = IsNotBot } + -- 3. Make sure there's at least one other possible constructor + mb_rcm' <- lift (markMatched nalt rcm) + lift $ tracePm "mergeNotConCt vi' (no upd. rcm)" (ppr vi') + pure $ case mb_rcm' of + -- If nalt could be removed from a COMPLETE set, we'll get back Just and + -- have to mark x dirty, by returning Just x'. + Just rcm' -> (Just x', vi'{ vi_rcm = rcm' }) + -- Otherwise, nalt didn't occur in any residual COMPLETE set and we + -- don't have to mark it dirty. So we return Nothing, which in the case + -- above would have compromised precision. + -- See Note [Shortcutting the inhabitation test], grep for T17836. + Nothing -> (Nothing, vi') hasRequiredTheta :: PmAltCon -> Bool hasRequiredTheta (PmAltConLike cl) = notNull req_theta @@ -759,6 +814,10 @@ hasRequiredTheta (PmAltConLike cl) = notNull req_theta (_,_,_,_,req_theta,_,_) = conLikeFullSig cl hasRequiredTheta _ = False +-- | Worth making a lens from Nabla to EGraph, to make changing data operations much easier +nabla_egr :: Functor f => (TmEGraph -> f TmEGraph) -> (Nabla -> f Nabla) +nabla_egr f (MkNabla tyst ts at TmSt{ts_facts=egr}) = (\egr' -> MkNabla tyst ts{ts_facts=egr'}) <$> f egr + -- | Add a @x ~ K tvs args ts@ constraint. -- @addConCt x K tvs args ts@ extends the substitution with a solution -- @x :-> (K, tvs, args)@ if compatible with the negative and positive info we @@ -766,8 +825,42 @@ hasRequiredTheta _ = False -- -- See Note [TmState invariants]. addConCt :: Nabla -> Id -> PmAltCon -> [TyVar] -> [Id] -> MaybeT DsM Nabla -addConCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ ts_facts=env } } x alt tvs args = do - let vi@(VI _ pos neg bot _) = lookupVarInfo ts x +addConCt nabla0 x alt tvs args = do + (xid, nabla1) <- representId x nabla0 + let vi_x = lookupVarInfo (nabla_tm_st nabla1) x + (kid, nabla2) <- fromMaybe (xid, nabla1) <$> representPattern vi_x alt tvs args nabla1 -- VarInfo contains K data in pos info + let k_vi = (emptyVarInfo x){vi_pos=[PACA alt tvs args]} + + nabla3 <- case (alt, args) of + (PmAltConLike (RealDataCon dc), [y]) | isNewDataCon dc -> do + (_yid, nabla3) <- representId y nabla2 + + -- A newtype con and the underlying var are in the same e-class + -- nabla4 <- mergeVarIds xid yid nabla3 + + -- Return the nabla3 and set the k_vi unchanged + pure (nabla3 & nabla_egr._class kid._data .~ Just k_vi) + + -- If the merging y and N y thing works, we won't need this. + -- (UPDT: It didn't work (looped, i Think. Try uncommenting that line above). + -- That means we're not currently moving the strictness information from the NT pattern to the underlying variable. + -- We need to.) + -- Also, if we do that manually here, that means we won't add strictness + -- annotations to underlying NT representatives if merging is done by + -- congruence instead of by manually calling 'addConCt' + -- case bot of + -- MaybeBot -> pure (nabla_with MaybeBot) + -- IsBot -> addBotCt (nabla_with IsBot) y + -- IsNotBot -> addNotBotCt (nabla_with IsNotBot) y + + _ -> assert (isPmAltConMatchStrict alt) + -- Return the nabla2 and set the k_vi with additional IsNotBot info + pure (nabla2 & nabla_egr._class kid._data .~ Just k_vi{vi_bot=IsNotBot}) -- strict match ==> not ⊥ + + mergeVarIds xid kid nabla3 + +mergeConCt :: VarInfo -> PmAltConApp -> StateT TyState (MaybeT DsM) VarInfo +mergeConCt vi@(VI _ pos neg _bot _) paca@(PACA alt tvs _args) = StateT $ \tyst -> do -- First try to refute with a negative fact guard (not (elemPmAltConSet alt neg)) -- Then see if any of the other solutions (remember: each of them is an @@ -777,25 +870,19 @@ addConCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ ts_facts=env } } x alt tvs args = -- Now we should be good! Add (alt, tvs, args) as a possible solution, or -- refine an existing one case find ((== Equal) . eqPmAltCon alt . paca_con) pos of - Just (PACA _con other_tvs other_args) -> do + Just (PACA _con other_tvs _other_args) -> do -- We must unify existentially bound ty vars and arguments! + -- + -- The arguments are handled automatically by representing K in + -- the e-class...! all equivalent things will be merged. + -- + -- So we treat the ty vars: let ty_cts = equateTys (map mkTyVarTy tvs) (map mkTyVarTy other_tvs) - nabla' <- MaybeT $ addPhiCts nabla (listToBag ty_cts) - let add_var_ct nabla (a, b) = addVarCt nabla a b - foldlM add_var_ct nabla' $ zipEqual "addConCt" args other_args + tyst' <- MaybeT (tyOracle tyst (listToBag $ map (\case (PhiTyCt pred) -> pred; _ -> error "impossible") ty_cts)) + return (vi, tyst') -- All good, and we get no new term information. Nothing -> do - let pos' = PACA alt tvs args : pos - let nabla_with bot' = - nabla{ nabla_tm_st = ts{ts_facts = addToUSDFM env x (vi{vi_pos = pos', vi_bot = bot'})} } - -- Do (2) in Note [Coverage checking Newtype matches] - case (alt, args) of - (PmAltConLike (RealDataCon dc), [y]) | isNewDataCon dc -> - case bot of - MaybeBot -> pure (nabla_with MaybeBot) - IsBot -> addBotCt (nabla_with MaybeBot) y - IsNotBot -> addNotBotCt (nabla_with MaybeBot) y - _ -> assert (isPmAltConMatchStrict alt ) - pure (nabla_with IsNotBot) -- strict match ==> not ⊥ + -- Add new con info + return (vi{vi_pos = paca:pos}, tyst) equateTys :: [Type] -> [Type] -> [PhiCt] equateTys ts us = @@ -815,18 +902,22 @@ equateTys ts us = -- -- See Note [TmState invariants]. addVarCt :: Nabla -> Id -> Id -> MaybeT DsM Nabla -addVarCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ ts_facts = env } } x y = - case equateUSDFM env x y of - (Nothing, env') -> pure (nabla{ nabla_tm_st = ts{ ts_facts = env' } }) - -- Add the constraints we had for x to y - (Just vi_x, env') -> do - let nabla_equated = nabla{ nabla_tm_st = ts{ts_facts = env'} } - -- and then gradually merge every positive fact we have on x into y - let add_pos nabla (PACA cl tvs args) = addConCt nabla y cl tvs args - nabla_pos <- foldlM add_pos nabla_equated (vi_pos vi_x) - -- Do the same for negative info - let add_neg nabla nalt = addNotConCt nabla y nalt - foldlM add_neg nabla_pos (pmAltConSetElems (vi_neg vi_x)) +addVarCt nabla0 x y = do + + -- We'd really rather ([xid, yid], nabla1) <- representIds [x,y] nabla0, but that's not exhaustive... + ((xid, yid), nabla1) + <- runStateT ((,) <$> StateT (representId x) <*> StateT (representId y)) nabla0 + + mergeVarIds xid yid nabla1 + +mergeVarIds :: ClassId -> ClassId -> Nabla -> MaybeT DsM Nabla +mergeVarIds xid yid (MkNabla tyst0 (TmSt egr0 is)) = do + + -- @merge env x y@ makes @x@ and @y@ point to the same entry, + -- thereby merging @x@'s class with @y@'s. + (egr1, tyst1) <- runStateT (EG.mergeM xid yid egr0 >>= EG.rebuildM . snd) tyst0 + + return (MkNabla tyst1 (TmSt egr1 is)) -- | Inspects a 'PmCoreCt' @let x = e@ by recording constraints for @x@ based -- on the shape of the 'CoreExpr' @e at . Examples: @@ -894,9 +985,11 @@ addCoreCt nabla x e = do -- @x ~ y at . equate_with_similar_expr :: Id -> CoreExpr -> StateT Nabla (MaybeT DsM) () equate_with_similar_expr x e = do - rep <- StateT $ \nabla -> lift (representCoreExpr nabla e) + rep <- StateT $ \nabla -> representCoreExpr nabla e -- Note that @rep == x@ if we encountered @e@ for the first time. - modifyT (\nabla -> addVarCt nabla x rep) + modifyT (\nabla0 -> do + (xid, nabla1) <- representId x nabla0 + mergeVarIds xid rep nabla1) bind_expr :: CoreExpr -> StateT Nabla (MaybeT DsM) Id bind_expr e = do @@ -951,14 +1044,13 @@ modifyT f = StateT $ fmap ((,) ()) . f -- Which is the @x@ of a @let x = e'@ constraint (with @e@ semantically -- equivalent to @e'@) we encountered earlier, or a fresh identifier if -- there weren't any such constraints. -representCoreExpr :: Nabla -> CoreExpr -> DsM (Id, Nabla) -representCoreExpr nabla at MkNabla{ nabla_tm_st = ts at TmSt{ ts_reps = reps } } e - | Just rep <- lookupCoreMap reps key = pure (rep, nabla) - | otherwise = do - rep <- mkPmId (exprType e) - let reps' = extendCoreMap reps key rep - let nabla' = nabla{ nabla_tm_st = ts{ ts_reps = reps' } } - pure (rep, nabla') +representCoreExpr :: Nabla -> CoreExpr -> MaybeT DsM (ClassId, Nabla) +representCoreExpr (MkNabla tyst ts at TmSt{ ts_facts = egraph }) e = do + ((xid, egr''), tysty') <- (`runStateT` tyst) $ do + (xid, egr') <- representCoreExprEgr key egraph + egr'' <- EG.rebuildM egr' + return (xid, egr'') + return (xid, MkNabla tysty' ts{ts_facts = egr''}) where key = makeDictsCoherent e -- Use a key in which dictionaries for the same type become equal. @@ -969,6 +1061,8 @@ representCoreExpr nabla at MkNabla{ nabla_tm_st = ts at TmSt{ ts_reps = reps } } e -- are considered equal when building a 'CoreMap'. -- -- See Note [Unique dictionaries in the TmOracle CoreMap] +-- ROMES:TODO: I suppose this should be taken into account by the Eq instance of DeBruijnF CoreExprF +-- if we do that there then we're sure that EG.represent takes that into account. makeDictsCoherent :: CoreExpr -> CoreExpr makeDictsCoherent var@(Var v) | let ty = idType v @@ -1271,21 +1365,30 @@ tyStateRefined a b = ty_st_n a /= ty_st_n b markDirty :: Id -> Nabla -> Nabla markDirty x nabla at MkNabla{nabla_tm_st = ts at TmSt{ts_dirty = dirty} } = - nabla{ nabla_tm_st = ts{ ts_dirty = extendDVarSet dirty x } } + case lookupId ts x of + Nothing -> error "Marking as dirty an Id that is not represented in the Nabla" + Just xid -> + nabla{ nabla_tm_st = ts{ ts_dirty = IS.insert xid dirty } } traverseDirty :: Monad m => (VarInfo -> m VarInfo) -> TmState -> m TmState traverseDirty f ts at TmSt{ts_facts = env, ts_dirty = dirty} = - go (uniqDSetToList dirty) env + go (IS.elems dirty) env where go [] env = pure ts{ts_facts=env} - go (x:xs) !env = do - vi' <- f (lookupVarInfo ts x) - go xs (addToUSDFM env x vi') + go (xid:xs) !env = do + vi' <- f' (env ^._class xid._data) + go xs (env & _class xid._data .~ vi') + + f' Nothing = pure Nothing + f' (Just x) = Just <$> f x traverseAll :: Monad m => (VarInfo -> m VarInfo) -> TmState -> m TmState traverseAll f ts at TmSt{ts_facts = env} = do - env' <- traverseUSDFM f env + env' <- (_classes._data) f' env pure ts{ts_facts = env'} + where + f' Nothing = pure Nothing + f' (Just x) = Just <$> f x -- | Makes sure the given 'Nabla' is still inhabited, by trying to instantiate -- all dirty variables (or all variables when the 'TyState' changed) to concrete @@ -1296,48 +1399,50 @@ traverseAll f ts at TmSt{ts_facts = env} = do inhabitationTest :: Int -> TyState -> Nabla -> MaybeT DsM Nabla inhabitationTest 0 _ nabla = pure nabla inhabitationTest fuel old_ty_st nabla at MkNabla{ nabla_tm_st = ts } = {-# SCC "inhabitationTest" #-} do - -- lift $ tracePm "inhabitation test" $ vcat - -- [ ppr fuel - -- , ppr old_ty_st - -- , ppr nabla - -- , text "tyStateRefined:" <+> ppr (tyStateRefined old_ty_st (nabla_ty_st nabla)) - -- ] + lift $ tracePm "inhabitation test" $ vcat + [ ppr fuel + , ppr old_ty_st + , ppr nabla + , text "tyStateRefined:" <+> ppr (tyStateRefined old_ty_st (nabla_ty_st nabla)) + ] -- When type state didn't change, we only need to traverse dirty VarInfos ts' <- if tyStateRefined old_ty_st (nabla_ty_st nabla) then traverseAll test_one ts else traverseDirty test_one ts - pure nabla{ nabla_tm_st = ts'{ts_dirty=emptyDVarSet}} + pure nabla{ nabla_tm_st = ts'{ts_dirty=IS.empty}} where - nabla_not_dirty = nabla{ nabla_tm_st = ts{ts_dirty=emptyDVarSet} } + nabla_not_dirty = nabla{ nabla_tm_st = ts{ts_dirty=IS.empty} } test_one :: VarInfo -> MaybeT DsM VarInfo - test_one vi = + test_one vi = do lift (varNeedsTesting old_ty_st nabla vi) >>= \case True -> do - -- lift $ tracePm "test_one" (ppr vi) + lift $ tracePm "test_one" (ppr vi) -- No solution yet and needs testing -- We have to test with a Nabla where all dirty bits are cleared instantiate (fuel-1) nabla_not_dirty vi - _ -> pure vi + _ -> do + lift $ tracePm "test_one needs no testing" (ppr vi) + pure vi -- | Checks whether the given 'VarInfo' needs to be tested for inhabitants. -- Returns `False` when we can skip the inhabitation test, presuming it would -- say "yes" anyway. See Note [Shortcutting the inhabitation test]. varNeedsTesting :: TyState -> Nabla -> VarInfo -> DsM Bool -varNeedsTesting _ MkNabla{nabla_tm_st=tm_st} vi - | elemDVarSet (vi_id vi) (ts_dirty tm_st) = pure True -varNeedsTesting _ _ vi - | notNull (vi_pos vi) = pure False -varNeedsTesting old_ty_st MkNabla{nabla_ty_st=new_ty_st} _ - -- Same type state => still inhabited - | not (tyStateRefined old_ty_st new_ty_st) = pure False -varNeedsTesting old_ty_st MkNabla{nabla_ty_st=new_ty_st} vi = do - -- These normalisations are relatively expensive, but still better than having - -- to perform a full inhabitation test - (_, _, old_norm_ty) <- tntrGuts <$> pmTopNormaliseType old_ty_st (idType $ vi_id vi) - (_, _, new_norm_ty) <- tntrGuts <$> pmTopNormaliseType new_ty_st (idType $ vi_id vi) - if old_norm_ty `eqType` new_norm_ty - then pure False - else pure True +varNeedsTesting old_ty_st n at MkNabla{nabla_ty_st=new_ty_st,nabla_tm_st=tm_st} vi + = do + Just (xid, _) <- runMaybeT $ representId (vi_id vi) n + if | IS.member xid (IS.map (`EG.find` ts_facts tm_st) $ ts_dirty tm_st) -> pure True + | notNull (vi_pos vi) -> pure False + -- Same type state => still inhabited + | not (tyStateRefined old_ty_st new_ty_st) -> pure False + -- These normalisations are relatively expensive, but still better than having + -- to perform a full inhabitation test + | otherwise -> do + (_, _, old_norm_ty) <- tntrGuts <$> pmTopNormaliseType old_ty_st (idType $ vi_id vi) + (_, _, new_norm_ty) <- tntrGuts <$> pmTopNormaliseType new_ty_st (idType $ vi_id vi) + if old_norm_ty `eqType` new_norm_ty + then pure False + else pure True -- | Returns (Just vi) if at least one member of each ConLike in the COMPLETE -- set satisfies the oracle @@ -1358,8 +1463,10 @@ instBot _fuel nabla vi = {-# SCC "instBot" #-} do pure vi addNormalisedTypeMatches :: Nabla -> Id -> DsM (ResidualCompleteMatches, Nabla) -addNormalisedTypeMatches nabla at MkNabla{ nabla_ty_st = ty_st } x - = trvVarInfo add_matches nabla x +addNormalisedTypeMatches nabla at MkNabla{ nabla_ty_st = ty_st, nabla_tm_st = ts } x + = case lookupId ts x of + Just xid -> trvVarInfo add_matches nabla (xid, x) + Nothing -> error "An Id with a VarInfo (see call site) is not represented in the e-graph..." where add_matches vi at VI{ vi_rcm = rcm } -- important common case, shaving down allocations of PmSeriesG by -5% @@ -2080,3 +2187,135 @@ Note that for -XEmptyCase, we don't want to emit a minimal cover. We arrange that by passing 'CaseSplitTopLevel' to 'generateInhabitingPatterns'. We detect the -XEmptyCase case in 'reportWarnings' by looking for 'ReportEmptyCase'. -} + +------------------------------------------------ +-- * E-graphs for pattern match checking + +representPattern :: VarInfo + -- ^ Var info of e-class in which this pattern is going to be represented... + -- The things we are doing with this should rather be done as + -- an e-graph analysis modify to "downwards" merge in the e-graph the sub-nodes + -- A bit weird that the e-graph doesn't do this, but it seems like it doesn't... (see egraphs zulip discussion) + -> PmAltCon -> [TyVar] -> [Id] -> Nabla -> MaybeT DsM (Maybe (ClassId, Nabla)) +-- We don't need to do anything in the case of PmAltLit. +-- The Constructor information is recorded in the positive info e-class +-- it is represented in, so when we merge we take care of handling this +-- equality right. +-- If we did this even more ideally, we'd just represent PmAltLit in the e-graph and it would fail on merge without having to edit the e-class. +-- Wait, is it even safe to edit the e-class? Won't that *NOT* trigger the merging?? +-- Here I suppose we're creating the e-class. So we can add information at will. When we eventually merge this class with another one, we can do things. +-- But we could definitely check whether the information we're adding isn't colliding with the existing one. +representPattern _ (PmAltLit _) _ _ _ = return Nothing + -- We might need represent patterns alongside expressions -- then we can use the "real" equality instances for the patterns (e.g. eqPmLit) +representPattern (VI _ pos _ _ _) alt@(PmAltConLike conLike) tvs args nab00 = do + (args', nab01) <- representIds args nab00 + + -- rOMES: It is very akward that this is being done here... perhaps it would be best as a modify method in the analysis + -- it certainly won't work for things we learn by congruence... + MkNabla tyst0 ts at TmSt{ts_facts=egr0} <- + case find ((== Equal) . eqPmAltCon alt . paca_con) pos of + Just (PACA _con _other_tvs other_args) -> do + let add_var_ct nabla (a, b) = addVarCt nabla a b + foldlM add_var_ct nab01 $ zipEqual "addConCt" args other_args + Nothing -> pure nab01 + + ((cid, egr1), tyst1) <- (`runStateT` tyst0) $ EGM.runEGraphMT egr0 $ do + -- We must represent the constructor application in the e-graph to make + -- sure the children are recursively merged against other children of + -- other constructors represneted in the same e-class. + -- We need to represent the constructor correctly to ensure existing + -- constructors match or not the new one + -- dsHsConLike basically implements the logic we want. + -- ROMES:TODO: Nevermind, the dsHsConLike won't work because we want to + -- talk about pattern synonyms in their "matching" form, and converting + -- them with dsHsConLike assumes they are used as a constructor, + -- meaning we will fail for unidirectional patterns + desugaredCon <- lift . lift . lift $ ds_hs_con_like_pat conLike -- DsM action to desugar the conlike into the expression we'll represent for this constructor + conLikeId <- StateT $ representCoreExprEgr desugaredCon + tvs' <- mapM (EGM.addM . EG.Node . TypeF . DBT . deBruijnize . TyVarTy) tvs -- ugh... + foldlM (\acc i -> EGM.addM (EG.Node $ AppF acc i)) conLikeId (tvs' ++ args') + return (Just (cid, MkNabla tyst1 ts{ts_facts=egr1})) + where + -- TODO: do something cleaner than the following inlined thing... + + -- We inlined dsHsConLike but use patSynMatcher instead of patSynBuilder + ds_hs_con_like_pat :: ConLike -> DsM CoreExpr + ds_hs_con_like_pat (RealDataCon dc) + = return (varToCoreExpr (dataConWrapId dc)) + ds_hs_con_like_pat (PatSynCon ps) + | (builder_name, _, add_void) <- patSynMatcher ps + = do { builder_id <- dsLookupGlobalId builder_name + ; return (if add_void + then mkCoreApp (text "dsConLike" <+> ppr ps) + (Var builder_id) unboxedUnitExpr + else Var builder_id) } + +representId :: Id -> Nabla -> MaybeT DsM (ClassId, Nabla) +representId x (MkNabla tyst tmst at TmSt{ts_facts=eg0}) + = do + ((xid, tmst'),tyst') <- (`runStateT` tyst) $ do + (xid, eg1) <- EG.addM (EG.Node (FreeVarF x)) eg0 + eg2 <- EG.rebuildM eg1 -- why do this here? I guess a good place as any, and should be cheap anyway (workload is not something like eqsat) + return (xid, tmst{ts_facts=eg2}) + return (xid, MkNabla tyst' tmst') + +representIds :: [Id] -> Nabla -> MaybeT DsM ([ClassId], Nabla) +representIds xs = runStateT (mapM (StateT . representId) xs) + +-- There are too many cycles for this to be in Solver.Types... +-- We need the TyState to check insoluble constraints while merging VarInfos +instance AnalysisM (StateT TyState (MaybeT DsM)) (Maybe VarInfo) ExprF where + {-# INLINE makeA #-} + + -- When an e-class is created for a variable, we create an VarInfo from it. + -- It doesn't matter if this variable is bound or free, since it's the first + -- variable in this e-class (and all others would have to be equivalent to + -- it) + -- + -- Also, the Eq instance for DeBruijn Vars will ensure that two free + -- variables with the same Id are equal and so they will be represented in + -- the same e-class + -- + -- It would be good if we didn't do this always... It might be a bit expensive + makeA (FreeVarF x) = pure $ Just $ emptyVarInfo x + makeA _ = pure $ Nothing + + joinA Nothing Nothing = pure $ Nothing + joinA Nothing (Just b) = pure $ Just b + joinA (Just a) Nothing = pure $ Just a + + -- Merge the 'VarInfo's from @x@ and @y@ + joinA (Just vi_x at VI{ vi_id=_id_x + , vi_pos=pos_x + , vi_neg=neg_x + , vi_bot=bot_x + , vi_rcm=_rcm_x + }) + (Just vi_y) = do + lift . lift $ tracePm "merging vi_x and vi_y" (ppr vi_x <+> ppr vi_y) + -- If we can merge x ~ N y with y too, then we no longer need to worry + -- about propagating the bottomness information, since it will always be + -- right... though I'm not sure if that would be correct + + -- Gradually merge every positive fact we have on x into y + -- The args are merged by congruence, since we represent the + -- constructor in the e-graph in addConCt. + vi_res1 <- foldlM mergeConCt vi_y pos_x + + -- Do the same for negative info + let add_neg vi nalt = lift $ snd <$> mergeNotConCt vi nalt + vi_res2 <- foldlM add_neg vi_res1 (pmAltConSetElems neg_x) + + -- We previously were not merging the bottom information, but now we do. + -- TODO: We don't need to do it yet if we are only trying to be as good as before, but not better + -- Although it might not be so simple if we consider one of the classes is a newtype? + -- (No, I think that situation can occur) + bot_res <- lift $ + mergeBots (idType (vi_id vi_res2)) + bot_x (vi_bot vi_y) + let vi_res3 = vi_res2{vi_bot = bot_res} + + lift . lift $ tracePm "result of merging vi_x and vi_y" (ppr vi_res3) + return (Just vi_res3) + + ===================================== compiler/GHC/HsToCore/Pmc/Solver/Types.hs ===================================== @@ -1,7 +1,11 @@ {-# LANGUAGE ApplicativeDo #-} +{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE MultiWayIf #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeApplications #-} -- | Domain types used in "GHC.HsToCore.Pmc.Solver". -- The ultimate goal is to define 'Nabla', which models normalised refinement @@ -10,13 +14,16 @@ module GHC.HsToCore.Pmc.Solver.Types ( -- * Normalised refinement types - BotInfo(..), PmAltConApp(..), VarInfo(..), TmState(..), TyState(..), - Nabla(..), Nablas(..), initNablas, + BotInfo(..), PmAltConApp(..), VarInfo(..), TmState(..), TyState(..), TmEGraph, + Nabla(..), Nablas(..), initNablas, emptyVarInfo, lookupRefuts, lookupSolution, -- ** Looking up 'VarInfo' lookupVarInfo, lookupVarInfoNT, trvVarInfo, + -- *** Looking up 'ClassId' + lookupId, + -- ** Caching residual COMPLETE sets CompleteMatch, ResidualCompleteMatches(..), getRcm, isRcmInitialised, @@ -42,9 +49,7 @@ import GHC.Prelude import GHC.Data.Bag import GHC.Data.FastString import GHC.Types.Id -import GHC.Types.Var.Set import GHC.Types.Unique.DSet -import GHC.Types.Unique.SDFM import GHC.Types.Name import GHC.Core.DataCon import GHC.Core.ConLike @@ -58,7 +63,6 @@ import GHC.Core.TyCon import GHC.Types.Literal import GHC.Core import GHC.Core.TyCo.Compare( eqType ) -import GHC.Core.Map.Expr import GHC.Core.Utils (exprType) import GHC.Builtin.Names import GHC.Builtin.Types @@ -75,6 +79,18 @@ import Data.Ratio import GHC.Real (Ratio(..)) import qualified Data.Semigroup as Semi +import GHC.Core.Equality +import Data.Functor.Const +import Data.Functor.Compose +import Data.Equality.Graph (EGraph, ClassId) +import Data.Equality.Graph.Lens +import qualified Data.Equality.Graph.Nodes as EGN +import qualified Data.Equality.Graph as EG +import qualified Data.Equality.Graph.Internal as EGI +import Data.IntSet (IntSet) +import qualified Data.IntSet as IS (empty, toList) +import Data.Bifunctor (second) + -- import GHC.Driver.Ppr -- @@ -138,14 +154,12 @@ initTyState = TySt 0 emptyInert -- See Note [TmState invariants] in "GHC.HsToCore.Pmc.Solver". data TmState = TmSt - { ts_facts :: !(UniqSDFM Id VarInfo) - -- ^ Facts about term variables. Deterministic env, so that we generate - -- deterministic error messages. - , ts_reps :: !(CoreMap Id) - -- ^ An environment for looking up whether we already encountered semantically - -- equivalent expressions that we want to represent by the same 'Id' - -- representative. - , ts_dirty :: !DIdSet + { ts_facts :: !TmEGraph + -- ^ Facts about term variables. + + -- ROMES:TODO: ts_dirty looks a bit to me like the bookkeeping done by the + -- analysis rebuilding mechanism, so perhaps we can get rid of it too + , ts_dirty :: !IntSet -- ^ Which 'VarInfo' needs to be checked for inhabitants because of new -- negative constraints (e.g. @x ≁ ⊥@ or @x ≁ K@). } @@ -161,6 +175,7 @@ data VarInfo { vi_id :: !Id -- ^ The 'Id' in question. Important for adding new constraints relative to -- this 'VarInfo' when we don't easily have the 'Id' available. + -- ROMES:TODO: Do we still need this? , vi_pos :: ![PmAltConApp] -- ^ Positive info: 'PmAltCon' apps it is (i.e. @x ~ [Just y, PatSyn z]@), all @@ -168,7 +183,7 @@ data VarInfo -- pattern matches involving pattern synonym -- case x of { Just y -> case x of PatSyn z -> ... } -- However, no more than one RealDataCon in the list, otherwise contradiction - -- because of generativity. + -- because of generativity (which would violate Invariant 1 from the paper). , vi_neg :: !PmAltConSet -- ^ Negative info: A list of 'PmAltCon's that it cannot match. @@ -227,7 +242,13 @@ instance Outputable BotInfo where -- | Not user-facing. instance Outputable TmState where - ppr (TmSt state reps dirty) = ppr state $$ ppr reps $$ ppr dirty + ppr (TmSt state dirty) = + (vcat $ getConst $ _iclasses (\(i,cl) -> Const [ppr i <> text ":" <+> ppr cl]) state) + $$ ppr (IS.toList dirty) + + +instance Outputable (EG.EClass (Maybe VarInfo) CoreExprF) where + ppr cl = ppr (cl^._nodes) $$ ppr (cl^._data) -- | Not user-facing. instance Outputable VarInfo where @@ -248,7 +269,7 @@ instance Outputable VarInfo where -- | Initial state of the term oracle. initTmState :: TmState -initTmState = TmSt emptyUSDFM emptyCoreMap emptyDVarSet +initTmState = TmSt EG.emptyEGraph IS.empty -- | A data type that caches for the 'VarInfo' of @x@ the results of querying -- 'dsGetCompleteMatches' and then striking out all occurrences of @K@ for @@ -302,7 +323,9 @@ emptyVarInfo x lookupVarInfo :: TmState -> Id -> VarInfo -- (lookupVarInfo tms x) tells what we know about 'x' -lookupVarInfo (TmSt env _ _) x = fromMaybe (emptyVarInfo x) (lookupUSDFM env x) +lookupVarInfo ts@(TmSt env _) x = fromMaybe (emptyVarInfo x) $ do + xid <- lookupId ts x + env ^. _class xid . _data -- | Like @lookupVarInfo ts x@, but @lookupVarInfo ts x = (y, vi)@ also looks -- through newtype constructors. We have @x ~ N1 (... (Nk y))@ such that the @@ -324,17 +347,32 @@ lookupVarInfoNT ts x = case lookupVarInfo ts x of | isNewDataCon dc = Just y go _ = Nothing -trvVarInfo :: Functor f => (VarInfo -> f (a, VarInfo)) -> Nabla -> Id -> f (a, Nabla) +trvVarInfo :: forall f a. Functor f => (VarInfo -> f (a, VarInfo)) -> Nabla + -> (ClassId,Id) + -- ^ The ClassId of the VarInfo to traverse, and the Id represented + -- to get it, to determine the empty var info in case it isn't available. + -- ... Feels a bit weird, but let's see if it works at all + -> f (a, Nabla) {-# INLINE trvVarInfo #-} -- This function is called a lot and we want to specilise it, not only -- for the type class, but also for its 'f' function argument. -- Before the INLINE pragma it sometimes inlined and sometimes didn't, -- depending delicately on GHC's optimisations. Better to use a pragma. -trvVarInfo f nabla at MkNabla{ nabla_tm_st = ts at TmSt{ts_facts = env} } x - = set_vi <$> f (lookupVarInfo ts x) +trvVarInfo f nabla at MkNabla{ nabla_tm_st = ts at TmSt{ts_facts = env} } (xid,x) + = second (\g -> nabla{nabla_tm_st = ts{ts_facts=g}}) <$> + updateAccum (_class xid._data.defaultEmpty) f env where - set_vi (a, vi') = - (a, nabla{ nabla_tm_st = ts{ ts_facts = addToUSDFM env (vi_id vi') vi' } }) + updateAccum :: forall f a s c. Functor f => Lens' s a -> (a -> f (c,a)) -> s -> f (c,s) + updateAccum lens g = getCompose . lens @(Compose f ((,) c)) (Compose . g) + + defaultEmpty :: Lens' (Maybe VarInfo) VarInfo + defaultEmpty f s = Just <$> (f (fromMaybe (emptyVarInfo x) s)) + +------------------------------------------ +-- * Utility for looking up Ids in 'Nabla' + +lookupId :: TmState -> Id -> Maybe ClassId +lookupId TmSt{ts_facts = eg0} x = EGN.lookupNM (EG.Node (FreeVarF x)) (EGI.memo eg0) ------------------------------------------------ -- * Exported utility functions querying 'Nabla' @@ -802,3 +840,19 @@ instance Outputable PmAltCon where instance Outputable PmEquality where ppr = text . show + +----------------------------------------------------- +-- * E-graphs to represent normalised refinment types + +type TmEGraph = EGraph (Maybe VarInfo) CoreExprF + +-- TODO delete orphans for showing TmEGraph for debugging reasons +instance Show VarInfo where + show = showPprUnsafe . ppr + +-- | This instance is seriously wrong for general purpose, it's just required for instancing Analysis. +-- There ought to be a better way. +-- ROMES:TODO: +instance Eq VarInfo where + (==) a b = vi_id a == vi_id b -- ROMES:TODO: The rest of the equality comparisons + ===================================== libraries/hegg ===================================== @@ -1 +1 @@ -Subproject commit 68e6b218aade16451ce94d15a485c04d626f3218 +Subproject commit e124cb2a999c0058b6cca283142ac18b289416f2 ===================================== testsuite/tests/count-deps/CountDepsParser.stdout ===================================== @@ -20,11 +20,11 @@ GHC.Core.Coercion.Axiom GHC.Core.Coercion.Opt GHC.Core.ConLike GHC.Core.DataCon +GHC.Core.Equality GHC.Core.FVs GHC.Core.FamInstEnv GHC.Core.InstEnv GHC.Core.Make -GHC.Core.Map.Expr GHC.Core.Map.Type GHC.Core.Multiplicity GHC.Core.Opt.Arity @@ -195,7 +195,6 @@ GHC.Types.Unique.DFM GHC.Types.Unique.DSet GHC.Types.Unique.FM GHC.Types.Unique.Map -GHC.Types.Unique.SDFM GHC.Types.Unique.Set GHC.Types.Unique.Supply GHC.Types.Var View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/87c04a41c3cc75a546784abff9aafefd54df7725 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/87c04a41c3cc75a546784abff9aafefd54df7725 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 20:43:07 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 02 May 2024 16:43:07 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: testsuite: expand size testing infrastructure Message-ID: <6633fadb3f7d9_1a3d244adb90816724a@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 79dc9a09 by Mikolaj Konarski at 2024-05-02T16:42:52-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - c254299d by Ben Gamari at 2024-05-02T16:42:52-04:00 Bump time submodule to 1.14 As requested in #24528. - - - - - 679a5293 by Ben Gamari at 2024-05-02T16:42:53-04:00 Bump terminfo submodule to current master - - - - - 3ea00c12 by Cheng Shao at 2024-05-02T16:42:55-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Eval/Types.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/Tc/TyCl/Utils.hs - compiler/GHC/Tc/Utils/TcMType.hs - − compiler/GHC/Types/BreakInfo.hs - + compiler/GHC/Types/Breakpoint.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/RepType.hs - compiler/GHC/Types/TyThing/Ppr.hs - compiler/GHC/Types/Unique/DSet.hs - compiler/GHC/Types/Var/Set.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/62eebf298d19726821f1a7b9edf3964dce0eab6b...3ea00c12e33215cceefa8db0841c9411e358e151 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/62eebf298d19726821f1a7b9edf3964dce0eab6b...3ea00c12e33215cceefa8db0841c9411e358e151 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 21:01:00 2024 From: gitlab at gitlab.haskell.org (Oleg Grenrus (@phadej)) Date: Thu, 02 May 2024 17:01:00 -0400 Subject: [Git][ghc/ghc][wip/T23478] 586 commits: Take care when simplifying unfoldings Message-ID: <6633ff0ca6ee9_1a3d244e082841744d8@gitlab.mail> Oleg Grenrus pushed to branch wip/T23478 at Glasgow Haskell Compiler / GHC Commits: d8baa1bd by Simon Peyton Jones at 2023-12-08T15:40:37+00:00 Take care when simplifying unfoldings This MR fixes a very subtle bug exposed by #24242. See Note [Environment for simplLetUnfolding]. I also updated a bunch of Notes on shadowing - - - - - 03ca551d by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Comments only in FloatIn Relevant to #3458 - - - - - 50c78779 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Comments only in SpecConstr - - - - - 9431e195 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Add test for #22238 - - - - - d9e4c597 by Vladislav Zavialov at 2023-12-11T04:19:34-05:00 Make forall a keyword (#23719) Before this change, GHC used to accept `forall` as a term-level identifier: -- from constraints-0.13 forall :: forall p. (forall a. Dict (p a)) -> Dict (Forall p) forall d = ... Now it is a parse error. The -Wforall-identifier warning has served its purpose and is now a deprecated no-op. - - - - - 58d56644 by Zubin Duggal at 2023-12-11T04:20:10-05:00 driver: Ensure we actually clear the interactive context before reloading Previously we called discardIC, but immediately after set the session back to an old HscEnv that still contained the IC Partially addresses #24107 Fixes #23405 - - - - - 8e5745a0 by Zubin Duggal at 2023-12-11T04:20:10-05:00 driver: Ensure we force the lookup of old build artifacts before returning the build plan This prevents us from retaining all previous build artifacts in memory until a recompile finishes, instead only retaining the exact artifacts we need. Fixes #24118 - - - - - 105c370c by Zubin Duggal at 2023-12-11T04:20:10-05:00 testsuite: add test for #24118 and #24107 MultiLayerModulesDefsGhci was not able to catch the leak because it uses :l which discards the previous environment. Using :r catches both of these leaks - - - - - e822ff88 by Zubin Duggal at 2023-12-11T04:20:10-05:00 compiler: Add some strictness annotations to ImportSpec and related constructors This prevents us from retaining entire HscEnvs. Force these ImportSpecs when forcing the GlobalRdrEltX Adds an NFData instance for Bag Fixes #24107 - - - - - 522c12a4 by Zubin Duggal at 2023-12-11T04:20:10-05:00 compiler: Force IfGlobalRdrEnv in NFData instance. - - - - - 188b280d by Arnaud Spiwack at 2023-12-11T15:33:31+01:00 LinearTypes => MonoLocalBinds - - - - - 8e0446df by Arnaud Spiwack at 2023-12-11T15:44:28+01:00 Linear let and where bindings For expediency, the initial implementation of linear types in GHC made it so that let and where binders would always be considered unrestricted. This was rather unpleasant, and probably a big obstacle to adoption. At any rate, this was not how the proposal was designed. This patch fixes this infelicity. It was surprisingly difficult to build, which explains, in part, why it took so long to materialise. As of this patch, let or where bindings marked with %1 will be linear (respectively %p for an arbitrary multiplicity p). Unmarked let will infer their multiplicity. Here is a prototypical example of program that used to be rejected and is accepted with this patch: ```haskell f :: A %1 -> B g :: B %1 -> C h :: A %1 -> C h x = g y where y = f x ``` Exceptions: - Recursive let are unrestricted, as there isn't a clear semantics of what a linear recursive binding would be. - Destructive lets with lazy bindings are unrestricted, as their desugaring isn't linear (see also #23461). - (Strict) destructive lets with inferred polymorphic type are unrestricted. Because the desugaring isn't linear (See #18461 down-thread). Closes #18461 and #18739 Co-authored-by: @jackohughes - - - - - effa7e2d by Matthew Craven at 2023-12-12T04:37:20-05:00 Introduce `dataToTagSmall#` primop (closes #21710) ...and use it to generate slightly better code when dataToTag# is used at a "small data type" where there is no need to mess with "is_too_big_tag" or potentially look at an info table. Metric Decrease: T18304 - - - - - 35c7aef6 by Matthew Craven at 2023-12-12T04:37:20-05:00 Fix formatting of Note [alg-alt heap check] - - - - - 7397c784 by Oleg Grenrus at 2023-12-12T04:37:56-05:00 Allow untyped brackets in typed splices and vice versa. Resolves #24190 Apparently the check was essentially always (as far as I can trace back: d0d47ba76f8f0501cf3c4966bc83966ab38cac27), and while it does catch some mismatches, the type-checker will catch them too. OTOH, it prevents writing completely reasonable programs. - - - - - a3ee3b99 by Moritz Angermann at 2023-12-12T19:50:58-05:00 Drop hard Xcode dependency XCODE_VERSION calls out to `xcodebuild`, which is only available when having `Xcode` installed. The CommandLineTools are not sufficient. To install Xcode, you must have an apple id to download the Xcode.xip from apple. We do not use xcodebuild anywhere in our build explicilty. At best it appears to be a proxy for checking the linker or the compiler. These should rather be done with ``` xcrun ld -version ``` or similar, and not by proxy through Xcode. The CLR should be sufficient for building software on macOS. - - - - - 1c9496e0 by Vladislav Zavialov at 2023-12-12T19:51:34-05:00 docs: update information on RequiredTypeArguments Update the User's Guide and Release Notes to account for the recent progress in the implementation of RequiredTypeArguments. - - - - - d0b17576 by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Fix off-by-one in assertion Previously we failed to account for the NULL terminator `postString` asserted that there is enough room in the buffer for the string. - - - - - a10f9b9b by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Honor result of ensureRoomForVariableEvent is Previously we would keep plugging along, even if isn't enough room for the event. - - - - - 0e0f41c0 by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Avoid truncating event sizes Previously ensureRoomForVariableEvent would truncate the desired size to 16-bits, resulting in #24197. Fixes #24197. - - - - - 64e724c8 by Artin Ghasivand at 2023-12-13T06:34:20-05:00 Remove the "Derived Constraint" argument of TcPluginSolver, docs - - - - - fe6d97dd by Vladislav Zavialov at 2023-12-13T06:34:56-05:00 EPA: Move tokens into GhcPs extension fields (#23447) Summary of changes * Remove Language.Haskell.Syntax.Concrete * Move all tokens into GhcPs extension fields (LHsToken -> EpToken) * Create new TTG extension fields as needed * Drop the MultAnn wrapper Updates the haddock submodule. Co-authored-by: Alan Zimmerman <alan.zimm at gmail.com> - - - - - 8106e695 by Zubin Duggal at 2023-12-13T06:35:34-05:00 testsuite: use copy_files in T23405 This prevents the tree from being dirtied when the file is modified. - - - - - ed0e4099 by Bryan Richter at 2023-12-14T04:30:53-05:00 Document ghc package's PVP-noncompliance This changes nothing, it just makes the status quo explicit. - - - - - 8bef8d9f by Luite Stegeman at 2023-12-14T04:31:33-05:00 JS: Mark spurious CI failures js_fragile(24259) This marks the spurious test failures on the JS platform as js_fragile(24259), so we don't hold up merge requests while fixing the underlying issues. See #24259 - - - - - 1c79526a by Finley McIlwaine at 2023-12-15T12:24:40-08:00 Late plugins - - - - - 000c3302 by Finley McIlwaine at 2023-12-15T12:24:40-08:00 withTiming on LateCCs and late plugins - - - - - be4551ac by Finley McIlwaine at 2023-12-15T12:24:40-08:00 add test for late plugins - - - - - 7c29da9f by Finley McIlwaine at 2023-12-15T12:24:40-08:00 Document late plugins - - - - - 9a52ae46 by Ben Gamari at 2023-12-20T07:07:26-05:00 Fix thunk update ordering Previously we attempted to ensure soundness of concurrent thunk update by synchronizing on the access of the thunk's info table pointer field. This was believed to be sufficient since the indirectee (which may expose a closure allocated by another core) would not be examined until the info table pointer update is complete. However, it turns out that this can result in data races in the presence of multiple threads racing a update a single thunk. For instance, consider this interleaving under the old scheme: Thread A Thread B --------- --------- t=0 Enter t 1 Push update frame 2 Begin evaluation 4 Pause thread 5 t.indirectee=tso 6 Release t.info=BLACKHOLE 7 ... (e.g. GC) 8 Resume thread 9 Finish evaluation 10 Relaxed t.indirectee=x 11 Load t.info 12 Acquire fence 13 Inspect t.indirectee 14 Release t.info=BLACKHOLE Here Thread A enters thunk `t` but is soon paused, resulting in `t` being lazily blackholed at t=6. Then, at t=10 Thread A finishes evaluation and updates `t.indirectee` with a relaxed store. Meanwhile, Thread B enters the blackhole. Under the old scheme this would introduce an acquire-fence but this would only synchronize with Thread A at t=6. Consequently, the result of the evaluation, `x`, is not visible to Thread B, introducing a data race. We fix this by treating the `indirectee` field as we do all other mutable fields. This means we must always access this field with acquire-loads and release-stores. See #23185. - - - - - f4b53538 by Vladislav Zavialov at 2023-12-20T07:08:02-05:00 docs: Fix link to 051-ghc-base-libraries.rst The proposal is no longer available at the previous URL. - - - - - f7e21fab by Matthew Pickering at 2023-12-21T14:57:40+00:00 hadrian: Build all executables in bin/ folder In the end the bindist creation logic copies them all into the bin folder. There is no benefit to building a specific few binaries in the lib/bin folder anymore. This also removes the ad-hoc logic to copy the touchy and unlit executables from stage0 into stage1. It takes <1s to build so we might as well just build it. - - - - - 0038d052 by Zubin Duggal at 2023-12-22T23:28:00-05:00 testsuite: mark jspace as fragile on i386. This test has been flaky for some time and has been failing consistently on i386-linux since 8e0446df landed. See #24261 - - - - - dfd670a0 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 609e6225 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 865513b2 by Ömer Sinan Ağacan at 2023-12-24T10:11:13-05:00 Fix BNF in user manual 6.6.8.2: formal syntax for instance declarations - - - - - c247b6be by Zubin Duggal at 2023-12-25T16:01:23-05:00 docs: document permissibility of -XOverloadedLabels (#24249) Document the permissibility introduced by https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - e5b7eb59 by Ömer Sinan Ağacan at 2023-12-25T16:02:03-05:00 Fix a code block syntax in user manual sec. 6.8.8.6 - - - - - 2db11c08 by Ben Gamari at 2023-12-29T15:35:48-05:00 genSym: Reimplement via CAS on 32-bit platforms Previously the remaining use of the C implementation on 32-bit platforms resulted in a subtle bug, #24261. This was due to the C object (which used the RTS's `atomic_inc64` macro) being compiled without `-threaded` yet later being used in a threaded compiler. Side-step this issue by using the pure Haskell `genSym` implementation on all platforms. This required implementing `fetchAddWord64Addr#` in terms of CAS on 64-bit platforms. - - - - - 19328a8c by Xiaoyan Ren at 2023-12-29T15:36:30-05:00 Do not color the diagnostic code in error messages (#24172) - - - - - 685b467c by Krzysztof Gogolewski at 2023-12-29T15:37:06-05:00 Enforce that bindings of implicit parameters are lifted Fixes #24298 - - - - - bc4d67b7 by Matthew Craven at 2023-12-31T06:15:42-05:00 StgToCmm: Detect some no-op case-continuations ...and generate no code for them. Fixes #24264. - - - - - 5b603139 by Krzysztof Gogolewski at 2023-12-31T06:16:18-05:00 Revert "testsuite: mark jspace as fragile on i386." This reverts commit 0038d052c8c80b4b430bb2aa1c66d5280be1aa95. The atomicity bug should be fixed by !11802. - - - - - d55216ad by Krzysztof Gogolewski at 2024-01-01T12:05:49-05:00 Refactor: store [[PrimRep]] rather than [Type] in STG StgConApp stored a list of types. This list was used exclusively during unarisation of unboxed sums (mkUbxSum). However, this is at a wrong level of abstraction: STG shouldn't be concerned with Haskell types, only PrimReps. Update the code to store a [[PrimRep]]. Also, there's no point in storing this list when we're not dealing with an unboxed sum. - - - - - 8b340bc7 by Ömer Sinan Ağacan at 2024-01-01T12:06:29-05:00 Kind signatures docs: mention that they're allowed in newtypes - - - - - 989bf8e5 by Zubin Duggal at 2024-01-03T20:08:47-05:00 ci: Ensure we use the correct bindist name for the test artifact when generating release ghcup metadata Fixes #24268 - - - - - 89299a89 by Krzysztof Gogolewski at 2024-01-03T20:09:23-05:00 Refactor: remove calls to typePrimRepArgs The function typePrimRepArgs is just a thin wrapper around typePrimRep, adding a VoidRep if the list is empty. However, in StgToByteCode, we were discarding that VoidRep anyway, so there's no point in calling it. - - - - - c7be0c68 by mmzk1526 at 2024-01-03T20:10:07-05:00 Use "-V" for alex version check for better backward compatibility Fixes #24302. In recent versions of alex, "-v" is used for "--verbose" instead of "-version". - - - - - 67dbcc0a by Krzysztof Gogolewski at 2024-01-05T02:07:18-05:00 Fix VoidRep handling in ghci debugger 'go' inside extractSubTerms was giving a bad result given a VoidRep, attempting to round towards the next multiple of 0. I don't understand much about the debugger but the code should be better than it was. Fixes #24306 - - - - - 90ea574e by Krzysztof Gogolewski at 2024-01-05T02:07:54-05:00 VoidRep-related refactor * In GHC.StgToByteCode, replace bcIdPrimId with idPrimRep, bcIdArgRep with idArgRep, atomPrimRep with stgArgRep1. All of them were duplicates. * In GHC.Stg.Unarise, we were converting a PrimRep to a Type and back to PrimRep. Remove the calls to primRepToType and typePrimRep1 which cancel out. * In GHC.STG.Lint, GHC.StgToCmm, GHC.Types.RepType we were filtering out VoidRep from the result of typePrimRep. But typePrimRep never returns VoidRep - remove the filtering. - - - - - eaf72479 by brian at 2024-01-06T23:03:09-05:00 Add unaligned Addr# primops Implements CLC proposal #154: https://github.com/haskell/core-libraries-committee/issues/154 * add unaligned addr primops * add tests * accept tests * add documentation * fix js primops * uncomment in access ops * use Word64 in tests * apply suggestions * remove extra file * move docs * remove random options * use setByteArray# primop * better naming * update base-exports test * add base-exports for other architectures - - - - - d471d445 by Krzysztof Gogolewski at 2024-01-06T23:03:47-05:00 Remove VoidRep from PrimRep, introduce PrimOrVoidRep This introduces data PrimOrVoidRep = VoidRep | NVRep PrimRep changes typePrimRep1 to return PrimOrVoidRep, and adds a new function typePrimRepU to be used when the argument is definitely non-void. Details in Note [VoidRep] in GHC.Types.RepType. Fixes #19520 - - - - - 48720a07 by Matthew Craven at 2024-01-08T18:57:36-05:00 Apply Note [Sensitivity to unique increment] to LargeRecord - - - - - 9e2e180f by Sebastian Graf at 2024-01-08T18:58:13-05:00 Debugging: Add diffUFM for convenient diffing between UniqFMs - - - - - 948f3e35 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Rename Opt_D_dump_stranal to Opt_D_dump_dmdanal ... and Opt_D_dump_str_signatures to Opt_D_dump_dmd_signatures - - - - - 4e217e3e by Sebastian Graf at 2024-01-08T18:58:13-05:00 Deprecate -ddump-stranal and -ddump-str-signatures ... and suggest -ddump-dmdanal and -ddump-dmd-signatures instead - - - - - 6c613c90 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Move testsuite/tests/stranal to testsuite/tests/dmdanal A separate commit so that the rename is obvious to Git(Lab) - - - - - c929f02b by Sebastian Graf at 2024-01-08T18:58:13-05:00 CoreSubst: Stricten `substBndr` and `cloneBndr` Doing so reduced allocations of `cloneBndr` by about 25%. ``` T9233(normal) ghc/alloc 672,488,656 663,083,216 -1.4% GOOD T9675(optasm) ghc/alloc 423,029,256 415,812,200 -1.7% geo. mean -0.1% minimum -1.7% maximum +0.1% ``` Metric Decrease: T9233 - - - - - e3ca78f3 by Krzysztof Gogolewski at 2024-01-10T17:35:59-05:00 Deprecate -Wsemigroup This warning was used to prepare for Semigroup becoming a superclass of Monoid, and for (<>) being exported from Prelude. This happened in GHC 8.4 in 8ae263ceb3566 and feac0a3bc69fd3. The leftover logic for (<>) has been removed in GHC 9.8, 4d29ecdfcc79. Now the warning does nothing at all and can be deprecated. - - - - - 08d14925 by amesgen at 2024-01-10T17:36:42-05:00 WASM metadata: use correct GHC version - - - - - 7a808419 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Allow SCC declarations in TH (#24081) - - - - - 28827c51 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Fix prettyprinting of SCC pragmas - - - - - ae9cc1a8 by Matthew Craven at 2024-01-10T17:38:01-05:00 Fix loopification in the presence of void arguments This also removes Note [Void arguments in self-recursive tail calls], which was just misleading. It's important to count void args both in the function's arity and at the call site. Fixes #24295. - - - - - b718b145 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: Teach testsuite driver about c++ sources - - - - - 09cb57ad by Zubin Duggal at 2024-01-10T17:38:36-05:00 driver: Set -DPROFILING when compiling C++ sources with profiling Earlier, we used to pass all preprocessor flags to the c++ compiler. This meant that -DPROFILING was passed to the c++ compiler because it was a part of C++ flags However, this was incorrect and the behaviour was changed in 8ff3134ed4aa323b0199ad683f72165e51a59ab6. See #21291. But that commit exposed this bug where -DPROFILING was no longer being passed when compiling c++ sources. The fix is to explicitly include -DPROFILING in `opt_cxx` when profiling is enabled to ensure we pass the correct options for the way to both C and C++ compilers Fixes #24286 - - - - - 2cf9dd96 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: rename objcpp -> objcxx To avoid confusion with C Pre Processsor - - - - - af6932d6 by Simon Peyton Jones at 2024-01-10T17:39:12-05:00 Make TYPE and CONSTRAINT not-apart Issue #24279 showed up a bug in the logic in GHC.Core.Unify.unify_ty which is supposed to make TYPE and CONSTRAINT be not-apart. Easily fixed. - - - - - 4a39b5ff by Zubin Duggal at 2024-01-10T17:39:48-05:00 ci: Fix typo in mk_ghcup_metadata.py There was a missing colon in the fix to #24268 in 989bf8e53c08eb22de716901b914b3607bc8dd08 - - - - - 13503451 by Zubin Duggal at 2024-01-10T17:40:24-05:00 release-ci: remove release-x86_64-linux-deb11-release+boot_nonmoving_gc job There is no reason to have this release build or distribute this variation. This configuration is for testing purposes only. - - - - - afca46a4 by Sebastian Graf at 2024-01-10T17:41:00-05:00 Parser: Add a Note detailing why we need happy's `error` to implement layout - - - - - eaf8a06d by Krzysztof Gogolewski at 2024-01-11T00:43:17+01:00 Turn -Wtype-equality-out-of-scope on by default Also remove -Wnoncanonical-{monoid,monad}-instances from -Wcompat, since they are enabled by default. Refresh wcompat-warnings/ test with new -Wcompat warnings. Part of #24267 Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 42bee5aa by Sebastian Graf at 2024-01-12T21:16:21-05:00 Arity: Require called *exactly once* for eta exp with -fpedantic-bottoms (#24296) In #24296, we had a program in which we eta expanded away an error despite the presence of `-fpedantic-bottoms`. This was caused by turning called *at least once* lambdas into one-shot lambdas, while with `-fpedantic-bottoms` it is only sound to eta expand over lambdas that are called *exactly* once. An example can be found in `Note [Combining arity type with demand info]`. Fixes #24296. - - - - - 7e95f738 by Andreas Klebinger at 2024-01-12T21:16:57-05:00 Aarch64: Enable -mfma by default. Fixes #24311 - - - - - e43788d0 by Jason Shipman at 2024-01-14T12:47:38-05:00 Add more instances for Compose: Fractional, RealFrac, Floating, RealFloat CLC proposal #226 https://github.com/haskell/core-libraries-committee/issues/226 - - - - - ae6d8cd2 by Sebastian Graf at 2024-01-14T12:48:15-05:00 Pmc: COMPLETE pragmas associated with Family TyCons should apply to representation TyCons as well (#24326) Fixes #24326. - - - - - c5fc7304 by sheaf at 2024-01-15T14:15:29-05:00 Use lookupOccRn_maybe in TH.lookupName When looking up a value, we want to be able to find both variables and record fields. So we should not use the lookupSameOccRn_maybe function, as we can't know ahead of time which record field namespace a record field with the given textual name will belong to. Fixes #24293 - - - - - da908790 by Krzysztof Gogolewski at 2024-01-15T14:16:05-05:00 Make the build more strict on documentation errors * Detect undefined labels. This can be tested by adding :ref:`nonexistent` to a documentation rst file; attempting to build docs will fail. Fixed the undefined label in `9.8.1-notes.rst`. * Detect errors. While we have plenty of warnings, we can at least enforce that Sphinx does not report errors. Fixed the error in `required_type_arguments.rst`. Unrelated change: I have documented that the `-dlint` enables `-fcatch-nonexhaustive-cases`, as can be verified by checking `enableDLint`. - - - - - 5077416e by Javier Sagredo at 2024-01-16T15:40:06-05:00 Profiling: Adds an option to not start time profiling at startup Using the functionality provided by d89deeba47ce04a5198a71fa4cbc203fe2c90794, this patch creates a new rts flag `--no-automatic-time-samples` which disables the time profiling when starting a program. It is then expected that the user starts it whenever it is needed. Fixes #24337 - - - - - 5776008c by Matthew Pickering at 2024-01-16T15:40:42-05:00 eventlog: Fix off-by-one error in postIPE We were missing the extra_comma from the calculation of the size of the payload of postIPE. This was causing assertion failures when the event would overflow the buffer by one byte, as ensureRoomForVariable event would report there was enough space for `n` bytes but then we would write `n + 1` bytes into the buffer. Fixes #24287 - - - - - 66dc09b1 by Simon Peyton Jones at 2024-01-16T15:41:18-05:00 Improve SpecConstr (esp nofib/spectral/ansi) This MR makes three improvements to SpecConstr: see #24282 * It fixes an outright (and recently-introduced) bug in `betterPat`, which was wrongly forgetting to compare the lengths of the argument lists. * It enhances ConVal to inclue a boolean for work-free-ness, so that the envt can contain non-work-free constructor applications, so that we can do more: see Note [ConVal work-free-ness] * It rejigs `subsumePats` so that it doesn't reverse the list. This can make a difference because, when patterns overlap, we arbitrarily pick the first. There is no "right" way, but this retains the old pre-subsumePats behaviour, thereby "fixing" the regression in #24282. Nofib results +======================================== | spectral/ansi -21.14% | spectral/hartel/comp_lab_zift -0.12% | spectral/hartel/parstof +0.09% | spectral/last-piece -2.32% | spectral/multiplier +6.03% | spectral/para +0.60% | spectral/simple -0.26% +======================================== | geom mean -0.18% +---------------------------------------- The regression in `multiplier` is sad, but it simply replicates GHC's previous behaviour (e.g. GHC 9.6). - - - - - 65da79b3 by Matthew Pickering at 2024-01-16T15:41:54-05:00 hadrian: Reduce Cabal verbosity The comment claims that `simpleUserHooks` decrease verbosity, and it does, but only for the `postConf` phase. The other phases are too verbose with `-V`. At the moment > 5000 lines of the build log are devoted to output from `cabal copy`. So I take the simple approach and just decrease the verbosity level again. If the output of `postConf` is essential then it would be better to implement our own `UserHooks` which doesn't decrease the verbosity for `postConf`. Fixes #24338 - - - - - 16414d7d by Matthew Pickering at 2024-01-17T10:54:59-05:00 Stop retaining old ModGuts throughout subsequent simplifier phases Each phase of the simplifier typically rewrites the majority of ModGuts, so we want to be able to release the old ModGuts as soon as possible. `name_ppr_ctxt` lives throught the whole optimiser phase and it was retaining a reference to `ModGuts`, so we were failing to release the old `ModGuts` until the end of the phase (potentially doubling peak memory usage for that particular phase). This was discovered using eras profiling (#24332) Fixes #24328 - - - - - 7f0879e1 by Matthew Pickering at 2024-01-17T10:55:35-05:00 Update nofib submodule - - - - - 320454d3 by Cheng Shao at 2024-01-17T23:02:40+00:00 ci: bump ci-images for updated wasm image - - - - - 2eca52b4 by Cheng Shao at 2024-01-17T23:06:44+00:00 base: treat all FDs as "nonblocking" on wasm On posix platforms, when performing read/write on FDs, we check the nonblocking flag first. For FDs without this flag (e.g. stdout), we call fdReady() first, which in turn calls poll() to wait for I/O to be available on that FD. This is problematic for wasm32-wasi: although select()/poll() is supported via the poll_oneoff() wasi syscall, that syscall is rather heavyweight and runtime behavior differs in different wasi implementations. The issue is even worse when targeting browsers, given there's no satisfactory way to implement async I/O as a synchronous syscall, so existing JS polyfills for wasi often give up and simply return ENOSYS. Before we have a proper I/O manager that avoids poll_oneoff() for async I/O on wasm, this patch improves the status quo a lot by merely pretending all FDs are "nonblocking". Read/write on FDs will directly invoke read()/write(), which are much more reliably handled in existing wasi implementations, especially those in browsers. Fixes #23275 and the following test cases: T7773 isEOF001 openFile009 T4808 cgrun025 Approved by CLC proposal #234: https://github.com/haskell/core-libraries-committee/issues/234 - - - - - 83c6c710 by Andrew Lelechenko at 2024-01-18T05:21:49-05:00 base: clarify how to disable warnings about partiality of Data.List.{head,tail} - - - - - c4078f2f by Simon Peyton Jones at 2024-01-18T05:22:25-05:00 Fix four bug in handling of (forall cv. body_ty) These bugs are all described in #24335 It's not easy to provoke the bug, hence no test case. - - - - - 119586ea by Alexis King at 2024-01-19T00:08:00-05:00 Always refresh profiling CCSes after running pending initializers Fixes #24171. - - - - - 9718d970 by Oleg Grenrus at 2024-01-19T00:08:36-05:00 Set default-language: GHC2021 in ghc library Go through compiler/ sources, and remove all BangPatterns (and other GHC2021 enabled extensions in these files). - - - - - 3ef71669 by Matthew Pickering at 2024-01-19T21:55:16-05:00 testsuite: Remove unused have_library function Also remove the hence unused testsuite option `--test-package-db`. Fixes #24342 - - - - - 5b7fa20c by Jade at 2024-01-19T21:55:53-05:00 Fix Spelling in the compiler Tracking: #16591 - - - - - 09875f48 by Matthew Pickering at 2024-01-20T12:20:44-05:00 testsuite: Implement `isInTreeCompiler` in a more robust way Just a small refactoring to avoid redundantly specifying the same strings in two different places. - - - - - 0d12b987 by Jade at 2024-01-20T12:21:20-05:00 Change maintainer email from cvs-ghc at haskell.org to ghc-devs at haskell.org. Fixes #22142 - - - - - 1fa1c00c by Jade at 2024-01-23T19:17:03-05:00 Enhance Documentation of functions exported by Data.Function This patch aims to improve the documentation of functions exported in Data.Function Tracking: #17929 Fixes: #10065 - - - - - ab47a43d by Jade at 2024-01-23T19:17:39-05:00 Improve documentation of hGetLine. - Add explanation for whether a newline is returned - Add examples Fixes #14804 - - - - - dd4af0e5 by Cheng Shao at 2024-01-23T19:18:17-05:00 Fix genapply for cross-compilation by nuking fragile CPP logic This commit fixes incorrectly built genapply when cross compiling (#24347) by nuking all fragile CPP logic in it from the orbit. All target-specific info are now read from DerivedConstants.h at runtime, see added note for details. Also removes a legacy Makefile and adds haskell language server support for genapply. - - - - - 0cda2b8b by Cheng Shao at 2024-01-23T19:18:17-05:00 rts: enable wasm32 register mapping The wasm backend didn't properly make use of all Cmm global registers due to #24347. Now that it is fixed, this patch re-enables full register mapping for wasm32, and we can now generate smaller & faster wasm modules that doesn't always spill arguments onto the stack. Fixes #22460 #24152. - - - - - 0325a6e5 by Greg Steuck at 2024-01-24T01:29:44-05:00 Avoid utf8 in primops.txt.pp comments They don't make it through readFile' without explicitly setting the encoding. See https://gitlab.haskell.org/ghc/ghc/-/issues/17755 - - - - - 1aaf0bd8 by David Binder at 2024-01-24T01:30:20-05:00 Bump hpc and hpc-bin submodule Bump hpc to 0.7.0.1 Bump hpc-bin to commit d1780eb2 - - - - - e693a4e8 by Ben Gamari at 2024-01-24T01:30:56-05:00 testsuite: Ignore stderr in T8089 Otherwise spurious "Killed: 9" messages to stderr may cause the test to fail. Fixes #24361. - - - - - a40f4ab2 by sheaf at 2024-01-24T14:04:33-05:00 Fix FMA instruction on LLVM We were emitting the wrong instructions for fused multiply-add operations on LLVM: - the instruction name is "llvm.fma.f32" or "llvm.fma.f64", not "fmadd" - LLVM does not support other instructions such as "fmsub"; instead we implement these by flipping signs of some arguments - the instruction is an LLVM intrinsic, which requires handling it like a normal function call instead of a machine instruction Fixes #24223 - - - - - 69abc786 by Andrei Borzenkov at 2024-01-24T14:05:09-05:00 Add changelog entry for renaming tuples from (,,...,,) to Tuple<n> (24291) - - - - - 0ac8f385 by Cheng Shao at 2024-01-25T00:27:48-05:00 compiler: remove unused GHC.Linker module The GHC.Linker module is empty and unused, other than as a hack for the make build system. We can remove it now that make is long gone; the note is moved to GHC.Linker.Loader instead. - - - - - 699da01b by Hécate Moonlight at 2024-01-25T00:28:27-05:00 Clarification for newtype constructors when using `coerce` - - - - - b2d8cd85 by Matt Walker at 2024-01-26T09:50:08-05:00 Fix #24308 Add tests for semicolon separated where clauses - - - - - 0da490a1 by Ben Gamari at 2024-01-26T17:34:41-05:00 hsc2hs: Bump submodule - - - - - 3f442fd2 by Ben Gamari at 2024-01-26T17:34:41-05:00 Bump containers submodule to 0.7 - - - - - 82a1c656 by Sebastian Nagel at 2024-01-29T02:32:40-05:00 base: with{Binary}File{Blocking} only annotates own exceptions Fixes #20886 This ensures that inner, unrelated exceptions are not misleadingly annotated with the opened file. - - - - - 9294a086 by Andreas Klebinger at 2024-01-29T02:33:15-05:00 Fix fma warning when using llvm on aarch64. On aarch64 fma is always on so the +fma flag doesn't exist for that target. Hence no need to try and pass +fma to llvm. Fixes #24379 - - - - - ced2e731 by sheaf at 2024-01-29T17:27:12-05:00 No shadowing warnings for NoFieldSelector fields This commit ensures we don't emit shadowing warnings when a user shadows a field defined with NoFieldSelectors. Fixes #24381 - - - - - 8eeadfad by Patrick at 2024-01-29T17:27:51-05:00 Fix bug wrong span of nested_doc_comment #24378 close #24378 1. Update the start position of span in `nested_doc_comment` correctly. and hence the spans of identifiers of haddoc can be computed correctly. 2. add test `HaddockSpanIssueT24378`. - - - - - a557580f by Alexey Radkov at 2024-01-30T19:41:52-05:00 Fix irrelevant dodgy-foreign-imports warning on import f-pointers by value A test *сс018* is attached (not sure about the naming convention though). Note that without the fix, the test fails with the *dodgy-foreign-imports* warning passed to stderr. The warning disappears after the fix. GHC shouldn't warn on imports of natural function pointers from C by value (which is feasible with CApiFFI), such as ```haskell foreign import capi "cc018.h value f" f :: FunPtr (Int -> IO ()) ``` where ```c void (*f)(int); ``` See a related real-world use-case [here](https://gitlab.com/daniel-casanueva/pcre-light/-/merge_requests/17). There, GHC warns on import of C function pointer `pcre_free`. - - - - - ca99efaf by Alexey Radkov at 2024-01-30T19:41:53-05:00 Rename test cc018 -> T24034 - - - - - 88c38dd5 by Ben Gamari at 2024-01-30T19:42:28-05:00 rts/TraverseHeap.c: Ensure that PosixSource.h is included first - - - - - ca2e919e by Simon Peyton Jones at 2024-01-31T09:29:45+00:00 Make decomposeRuleLhs a bit more clever This fixes #24370 by making decomposeRuleLhs undertand dictionary /functions/ as well as plain /dictionaries/ - - - - - 94ce031d by Teo Camarasu at 2024-02-01T05:49:49-05:00 doc: Add -Dn flag to user guide Resolves #24394 - - - - - 31553b11 by Ben Gamari at 2024-02-01T12:21:29-05:00 cmm: Introduce MO_RelaxedRead In hand-written Cmm it can sometimes be necessary to atomically load from memory deep within an expression (e.g. see the `CHECK_GC` macro). This MachOp provides a convenient way to do so without breaking the expression into multiple statements. - - - - - 0785cf81 by Ben Gamari at 2024-02-01T12:21:29-05:00 codeGen: Use relaxed accesses in ticky bumping - - - - - be423dda by Ben Gamari at 2024-02-01T12:21:29-05:00 base: use atomic write when updating timer manager - - - - - 8a310e35 by Ben Gamari at 2024-02-01T12:21:29-05:00 Use relaxed atomics to manipulate TSO status fields - - - - - d6809ee4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Add necessary barriers when manipulating TSO owner - - - - - 39e3ac5d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Use `switch` to branch on why_blocked This is a semantics-preserving refactoring. - - - - - 515eb33d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix synchronization on thread blocking state We now use a release barrier whenever we update a thread's blocking state. This required widening StgTSO.why_blocked as AArch64 does not support atomic writes on 16-bit values. - - - - - eb38812e by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadPaused This only affects an assertion in the debug RTS and only needs relaxed ordering. - - - - - 26c48dd6 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadStatus# - - - - - 6af43ab4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in Interpreter's preemption check - - - - - 9502ad3c by Ben Gamari at 2024-02-01T12:21:29-05:00 rts/Messages: Fix data race - - - - - 60802db5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts/Prof: Fix data race - - - - - ef8ccef5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use relaxed ordering on dirty/clean info tables updates When changing the dirty/clean state of a mutable object we needn't have any particular ordering. - - - - - 76fe2b75 by Ben Gamari at 2024-02-01T12:21:30-05:00 codeGen: Use relaxed-read in closureInfoPtr - - - - - a6316eb4 by Ben Gamari at 2024-02-01T12:21:30-05:00 STM: Use acquire loads when possible Full sequential consistency is not needed here. - - - - - 6bddfd3d by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use fence rather than redundant load Previously we would use an atomic load to ensure acquire ordering. However, we now have `ACQUIRE_FENCE_ON`, which allows us to express this more directly. - - - - - 55c65dbc by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Fix data races in profiling timer - - - - - 856b5e75 by Ben Gamari at 2024-02-01T12:21:30-05:00 Add Note [C11 memory model] - - - - - 6534da24 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: move generic cmm optimization logic in NCG to a standalone module This commit moves GHC.CmmToAsm.cmmToCmm to a standalone module, GHC.Cmm.GenericOpt. The main motivation is enabling this logic to be run in the wasm backend NCG code, which is defined in other modules that's imported by GHC.CmmToAsm, causing a cyclic dependency issue. - - - - - 87e34888 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: explicitly disable PIC in wasm32 NCG This commit explicitly disables the ncgPIC flag for the wasm32 target. The wasm backend doesn't support PIC for the time being. - - - - - c6ce242e by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: enable generic cmm optimizations in wasm backend NCG This commit enables the generic cmm optimizations in other NCGs to be run in the wasm backend as well, followed by a late cmm control-flow optimization pass. The added optimizations do catch some corner cases not handled by the pre-NCG cmm pipeline and are useful in generating smaller CFGs. - - - - - 151dda4e by Andrei Borzenkov at 2024-02-01T12:22:43-05:00 Namespacing for WARNING/DEPRECATED pragmas (#24396) New syntax for WARNING and DEPRECATED pragmas was added, namely namespace specifierss: namespace_spec ::= 'type' | 'data' | {- empty -} warning ::= warning_category namespace_spec namelist strings deprecation ::= namespace_spec namelist strings A new data type was introduced to represent these namespace specifiers: data NamespaceSpecifier = NoSpecifier | TypeNamespaceSpecifier (EpToken "type") | DataNamespaceSpecifier (EpToken "data") Extension field XWarning now contains this NamespaceSpecifier. lookupBindGroupOcc function was changed: it now takes NamespaceSpecifier and checks that the namespace of the found names matches the passed flag. With this change {-# WARNING data D "..." #-} pragma will only affect value namespace and {-# WARNING type D "..." #-} will only affect type namespace. The same logic is applicable to DEPRECATED pragmas. Finding duplicated warnings inside rnSrcWarnDecls now takes into consideration NamespaceSpecifier flag to allow warnings with the same names that refer to different namespaces. - - - - - 38c3afb6 by Bryan Richter at 2024-02-01T12:23:19-05:00 CI: Disable the test-cabal-reinstall job Fixes #24363 - - - - - 27020458 by Matthew Craven at 2024-02-03T01:53:26-05:00 Bump bytestring submodule to something closer to 0.12.1 ...mostly so that 16d6b7e835ffdcf9b894e79f933dd52348dedd0c (which reworks unaligned writes in Builder) and the stuff in https://github.com/haskell/bytestring/pull/631 can see wider testing. The less-terrible code for unaligned writes used in Builder on hosts not known to be ulaigned-friendly also takes less effort for GHC to compile, resulting in a metric decrease for T21839c on some platforms. The metric increase on T21839r is caused by the unrelated commit 750dac33465e7b59100698a330b44de7049a345c. It perhaps warrants further analysis and discussion (see #23822) but is not critical. Metric Decrease: T21839c Metric Increase: T21839r - - - - - cdddeb0f by Rodrigo Mesquita at 2024-02-03T01:54:02-05:00 Work around autotools setting C11 standard in CC/CXX In autoconf >=2.70, C11 is set by default for $CC and $CXX via the -std=...11 flag. In this patch, we split the "-std" flag out of the $CC and $CXX variables, which we traditionally assume to be just the executable name/path, and move it to $CFLAGS/$CXXFLAGS instead. Fixes #24324 - - - - - 5ff7cc26 by Apoorv Ingle at 2024-02-03T13:14:46-06:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - The change is detailed in - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` - Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - Adds new datatypes: - `GHC.Hs.Expr.XXExprGhcRn`: new datatype makes this expansion work easier 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - Ensures warnings such as 1. Pattern match checks 2. Failable patterns 3. non-() return in body statements are preserved - Kill `HsMatchCtxt` in favor of `TcMatchAltChecker` - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) Also repoint haddock to the right submodule so that the test (haddockHypsrcTest) pass Metric Increase 'compile_time/bytes allocated': T9020 The testcase is a pathalogical example of a `do`-block with many statements that do nothing. Given that we are expanding the statements into function binds, we will have to bear a (small) 2% cost upfront in the compiler to unroll the statements. - - - - - 0df8ce27 by Vladislav Zavialov at 2024-02-04T03:55:14-05:00 Reduce parser allocations in allocateCommentsP In the most common case, the comment queue is empty, so we can skip the work of processing it. This reduces allocations by about 10% in the parsing001 test. Metric Decrease: MultiLayerModulesRecomp parsing001 - - - - - cfd68290 by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Stop dropping a case whose binder is demanded This MR fixes #24251. See Note [Case-to-let for strictly-used binders] in GHC.Core.Opt.Simplify.Iteration, plus #24251, for lots of discussion. Final Nofib changes over 0.1%: +----------------------------------------- | imaginary/digits-of-e2 -2.16% | imaginary/rfib -0.15% | real/fluid -0.10% | real/gamteb -1.47% | real/gg -0.20% | real/maillist +0.19% | real/pic -0.23% | real/scs -0.43% | shootout/n-body -0.41% | shootout/spectral-norm -0.12% +======================================== | geom mean -0.05% Pleasingly, overall executable size is down by just over 1%. Compile times (in perf/compiler) wobble around a bit +/- 0.5%, but the geometric mean is -0.1% which seems good. - - - - - e4d137bb by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Add Note [Bangs in Integer functions] ...to document the bangs in the functions in GHC.Num.Integer - - - - - ce90f12f by Andrei Borzenkov at 2024-02-05T17:59:09-05:00 Hide WARNING/DEPRECATED namespacing under -XExplicitNamespaces (#24396) - - - - - e2ea933f by Simon Peyton Jones at 2024-02-06T10:12:04-05:00 Refactoring in preparation for lazy skolemisation * Make HsMatchContext and HsStmtContext be parameterised over the function name itself, rather than over the pass. See [mc_fun field of FunRhs] in Language.Haskell.Syntax.Expr - Replace types HsMatchContext GhcPs --> HsMatchContextPs HsMatchContext GhcRn --> HsMatchContextRn HsMatchContext GhcTc --> HsMatchContextRn (sic! not Tc) HsStmtContext GhcRn --> HsStmtContextRn - Kill off convertHsMatchCtxt * Split GHC.Tc.Type.BasicTypes.TcSigInfo so that TcCompleteSig (describing a complete user-supplied signature) is its own data type. - Split TcIdSigInfo(CompleteSig, PartialSig) into TcCompleteSig(CSig) TcPartialSig(PSig) - Use TcCompleteSig in tcPolyCheck, CheckGen - Rename types and data constructors: TcIdSigInfo --> TcIdSig TcPatSynInfo(TPSI) --> TcPatSynSig(PatSig) - Shuffle around helper functions: tcSigInfoName (moved to GHC.Tc.Types.BasicTypes) completeSigPolyId_maybe (moved to GHC.Tc.Types.BasicTypes) tcIdSigName (inlined and removed) tcIdSigLoc (introduced) - Rearrange the pattern match in chooseInferredQuantifiers * Rename functions and types: tcMatchesCase --> tcCaseMatches tcMatchesFun --> tcFunBindMatches tcMatchLambda --> tcLambdaMatches tcPats --> tcMatchPats matchActualFunTysRho --> matchActualFunTys matchActualFunTySigma --> matchActualFunTy * Add HasDebugCallStack constraints to: mkBigCoreVarTupTy, mkBigCoreTupTy, boxTy, mkPiTy, mkPiTys, splitAppTys, splitTyConAppNoView_maybe * Use `penv` from the outer context in the inner loop of GHC.Tc.Gen.Pat.tcMultiple * Move tcMkVisFunTy, tcMkInvisFunTy, tcMkScaledFunTys down the file, factor out and export tcMkScaledFunTy. * Move isPatSigCtxt down the file. * Formatting and comments Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - f5d3e03c by Andrei Borzenkov at 2024-02-06T10:12:04-05:00 Lazy skolemisation for @a-binders (#17594) This patch is a preparation for @a-binders implementation. The main changes are: * Skolemisation is now prepared to deal with @binders. See Note [Skolemisation overview] in GHC.Tc.Utils.Unify. Most of the action is in - Utils.Unify.matchExpectedFunTys - Gen.Pat.tcMatchPats - Gen.Expr.tcPolyExprCheck - Gen.Binds.tcPolyCheck Some accompanying refactoring: * I found that funTyConAppTy_maybe was doing a lot of allocation, and rejigged userTypeError_maybe to avoid calling it. - - - - - 532993c8 by Zubin Duggal at 2024-02-06T10:12:41-05:00 driver: Really don't lose track of nodes when we fail to resolve cycles This fixes a bug in 8db8d2fd1c881032b1b360c032b6d9d072c11723, where we could lose track of acyclic components at the start of an unresolved cycle. We now ensure we never loose track of any of these components. As T24275 demonstrates, a "cyclic" SCC might not really be a true SCC: When viewed without boot files, we have a single SCC ``` [REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A [main:T24275A {-# SOURCE #-}]] ``` But with boot files this turns into ``` [NONREC main:T24275B {-# SOURCE #-} [], REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A {-# SOURCE #-} [main:T24275B], NONREC main:T24275A [main:T24275A {-# SOURCE #-}]] ``` Note that this is truly not an SCC, as no nodes are reachable from T24275B.hs-boot. However, we treat this entire group as a single "SCC" because it seems so when we analyse the graph without taking boot files into account. Indeed, we must return a single ResolvedCycle element in the BuildPlan for this as described in Note [Upsweep]. However, since after resolving this is not a true SCC anymore, `findCycle` fails to find a cycle and we have a sub-optimal error message as a result. To handle this, I extended `findCycle` to not assume its input is an SCC, and to try harder to find cycles in its input. Fixes #24275 - - - - - b35dd613 by Zubin Duggal at 2024-02-06T10:13:17-05:00 GHCi: Lookup breakpoint CCs in the correct module We need to look up breakpoint CCs in the module that the breakpoint points to, and not the current module. Fixes #24327 - - - - - b09e6958 by Zubin Duggal at 2024-02-06T10:13:17-05:00 testsuite: Add test for #24327 - - - - - 569b4c10 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add compile_artifact, ignore_extension flag In b521354216f2821e00d75f088d74081d8b236810 the testsuite gained the capability to collect generic metrics. But this assumed that the test was not linking and producing artifacts and we only wanted to track object files, interface files, or build artifacts from the compiler build. However, some backends, such as the JS backend, produce artifacts when compiling, such as the jsexe directory which we want to track. This patch: - tweaks the testsuite to collect generic metrics on any build artifact in the test directory. - expands the exe_extension function to consider windows and adds the ignore_extension flag. - Modifies certain tests to add the ignore_extension flag. Tests such as heaprof002 expect a .ps file, but on windows without ignore_extensions the testsuite will look for foo.exe.ps. Hence the flag. - adds the size_hello_artifact test - - - - - 75a31379 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add wasm_arch, heapprof002 wasm extension - - - - - c9731d6d by Rodrigo Mesquita at 2024-02-07T03:07:03-05:00 Synchronize bindist configure for #24324 In cdddeb0f1280b40cc194028bbaef36e127175c4c, we set up a workaround for #24324 in the in-tree configure script, but forgot to update the bindist configure script accordingly. This updates it. - - - - - d309f4e7 by Matthew Pickering at 2024-02-07T03:07:38-05:00 distrib/configure: Fix typo in CONF_GCC_LINKER_OPTS_STAGE2 variable Instead we were setting CONF_GCC_LINK_OPTS_STAGE2 which meant that we were missing passing `--target` when invoking the linker. Fixes #24414 - - - - - 77db84ab by Ben Gamari at 2024-02-08T00:35:22-05:00 llvmGen: Adapt to allow use of new pass manager. We now must use `-passes` in place of `-O<n>` due to #21936. Closes #21936. - - - - - 3c9ddf97 by Matthew Pickering at 2024-02-08T00:35:59-05:00 testsuite: Mark length001 as fragile on javascript Modifying the timeout multiplier is not a robust way to get this test to reliably fail. Therefore we mark it as fragile until/if javascript ever supports the stack limit. - - - - - 20b702b5 by Matthew Pickering at 2024-02-08T00:35:59-05:00 Javascript: Don't filter out rtsDeps list This logic appears to be incorrect as it would drop any dependency which was not in a direct dependency of the package being linked. In the ghc-internals split this started to cause errors because `ghc-internal` is not a direct dependency of most packages, and hence important symbols to keep which are hard coded into the js runtime were getting dropped. - - - - - 2df96366 by Ben Gamari at 2024-02-08T00:35:59-05:00 base: Cleanup whitespace in cbits - - - - - 44f6557a by Ben Gamari at 2024-02-08T00:35:59-05:00 Move `base` to `ghc-internal` Here we move a good deal of the implementation of `base` into a new package, `ghc-internal` such that it can be evolved independently from the user-visible interfaces of `base`. While we want to isolate implementation from interfaces, naturally, we would like to avoid turning `base` into a mere set of module re-exports. However, this is a non-trivial undertaking for a variety of reasons: * `base` contains numerous known-key and wired-in things, requiring corresponding changes in the compiler * `base` contains a significant amount of C code and corresponding autoconf logic, which is very fragile and difficult to break apart * `base` has numerous import cycles, which are currently dealt with via carefully balanced `hs-boot` files * We must not break existing users To accomplish this migration, I tried the following approaches: * [Split-GHC.Base]: Break apart the GHC.Base knot to allow incremental migration of modules into ghc-internal: this knot is simply too intertwined to be easily pulled apart, especially given the rather tricky import cycles that it contains) * [Move-Core]: Moving the "core" connected component of base (roughly 150 modules) into ghc-internal. While the Haskell side of this seems tractable, the C dependencies are very subtle to break apart. * [Move-Incrementally]: 1. Move all of base into ghc-internal 2. Examine the module structure and begin moving obvious modules (e.g. leaves of the import graph) back into base 3. Examine the modules remaining in ghc-internal, refactor as necessary to facilitate further moves 4. Go to (2) iterate until the cost/benefit of further moves is insufficient to justify continuing 5. Rename the modules moved into ghc-internal to ensure that they don't overlap with those in base 6. For each module moved into ghc-internal, add a shim module to base with the declarations which should be exposed and any requisite Haddocks (thus guaranteeing that base will be insulated from changes in the export lists of modules in ghc-internal Here I am using the [Move-Incrementally] approach, which is empirically the least painful of the unpleasant options above Bumps haddock submodule. Metric Decrease: haddock.Cabal haddock.base Metric Increase: MultiComponentModulesRecomp T16875 size_hello_artifact - - - - - e8fb2451 by Vladislav Zavialov at 2024-02-08T00:36:36-05:00 Haddock comments on infix constructors (#24221) Rewrite the `HasHaddock` instance for `ConDecl GhcPs` to account for infix constructors. This change fixes a Haddock regression (introduced in 19e80b9af252) that affected leading comments on infix data constructor declarations: -- | Docs for infix constructor | Int :* Bool The comment should be associated with the data constructor (:*), not with its left-hand side Int. - - - - - 9060d55b by Ben Gamari at 2024-02-08T00:37:13-05:00 Add os-string as a boot package Introduces `os-string` submodule. This will be necessary for `filepath-1.5`. - - - - - 9d65235a by Ben Gamari at 2024-02-08T00:37:13-05:00 gitignore: Ignore .hadrian_ghci_multi/ - - - - - d7ee12ea by Ben Gamari at 2024-02-08T00:37:13-05:00 hadrian: Set -this-package-name When constructing the GHC flags for a package Hadrian must take care to set `-this-package-name` in addition to `-this-unit-id`. This hasn't broken until now as we have not had any uses of qualified package imports. However, this will change with `filepath-1.5` and the corresponding `unix` bump, breaking `hadrian/multi-ghci`. - - - - - f2dffd2e by Ben Gamari at 2024-02-08T00:37:13-05:00 Bump filepath to 1.5.0.0 Required bumps of the following submodules: * `directory` * `filepath` * `haskeline` * `process` * `unix` * `hsc2hs` * `Win32` * `semaphore-compat` and the addition of `os-string` as a boot package. - - - - - ab533e71 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Use specific clang assembler when compiling with -fllvm There are situations where LLVM will produce assembly which older gcc toolchains can't handle. For example on Deb10, it seems that LLVM >= 13 produces assembly which the default gcc doesn't support. A more robust solution in the long term is to require a specific LLVM compatible assembler when using -fllvm. Fixes #16354 - - - - - c32b6426 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update CI images with LLVM 15, ghc-9.6.4 and cabal-install-3.10.2.0 - - - - - 5fcd58be by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update bootstrap plans for 9.4.8 and 9.6.4 - - - - - 707a32f5 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Add alpine 3_18 release job This is mainly experimental and future proofing to enable a smooth transition to newer alpine releases once 3_12 is too old. - - - - - c37931b3 by John Ericson at 2024-02-08T06:39:05-05:00 Generate LLVM min/max bound policy via Hadrian Per #23966, I want the top-level configure to only generate configuration data for Hadrian, not do any "real" tasks on its own. This is part of that effort --- one less file generated by it. (It is still done with a `.in` file, so in a future world non-Hadrian also can easily create this file.) Split modules: - GHC.CmmToLlvm.Config - GHC.CmmToLlvm.Version - GHC.CmmToLlvm.Version.Bounds - GHC.CmmToLlvm.Version.Type This also means we can get rid of the silly `unused.h` introduced in !6803 / 7dfcab2f4bcb7206174ea48857df1883d05e97a2 as temporary kludge. Part of #23966 - - - - - 9f987235 by Apoorv Ingle at 2024-02-08T06:39:42-05:00 Enable mdo statements to use HsExpansions Fixes: #24411 Added test T24411 for regression - - - - - 762b2120 by Jade at 2024-02-08T15:17:15+00:00 Improve Monad, Functor & Applicative docs This patch aims to improve the documentation of Functor, Applicative, Monad and related symbols. The main goal is to make it more consistent and make accessible. See also: !10979 (closed) and !10985 (closed) Ticket #17929 Updates haddock submodule - - - - - 151770ca by Josh Meredith at 2024-02-10T14:28:15-05:00 JavaScript codegen: Use GHC's tag inference where JS backend-specific evaluation inference was previously used (#24309) - - - - - 2e880635 by Zubin Duggal at 2024-02-10T14:28:51-05:00 ci: Allow release-hackage-lint to fail Otherwise it blocks the ghcup metadata pipeline from running. - - - - - b0293f78 by Matthew Pickering at 2024-02-10T14:29:28-05:00 rts: eras profiling mode The eras profiling mode is useful for tracking the life-time of closures. When a closure is written, the current era is recorded in the profiling header. This records the era in which the closure was created. * Enable with -he * User mode: Use functions ghc-experimental module GHC.Profiling.Eras to modify the era * Automatically: --automatic-era-increment, increases the user era on major collections * The first era is era 1 * -he<era> can be used with other profiling modes to select a specific era If you just want to record the era but not to perform heap profiling you can use `-he --no-automatic-heap-samples`. https://well-typed.com/blog/2024/01/ghc-eras-profiling/ Fixes #24332 - - - - - be674a2c by Jade at 2024-02-10T14:30:04-05:00 Adjust error message for trailing whitespace in as-pattern. Fixes #22524 - - - - - 53ef83f9 by doyougnu at 2024-02-10T14:30:47-05:00 gitlab: js: add codeowners Fixes: - #24409 Follow on from: - #21078 and MR !9133 - When we added the JS backend this was forgotten. This patch adds the rightful codeowners. - - - - - 8bbe12f2 by Matthew Pickering at 2024-02-10T14:31:23-05:00 Bump CI images so that alpine3_18 image includes clang15 The only changes here are that clang15 is now installed on the alpine-3_18 image. - - - - - df9fd9f7 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: handle stored null StablePtr Some Haskell codes unsafely cast StablePtr into ptr to compare against NULL. E.g. in direct-sqlite: if castStablePtrToPtr aggStPtr /= nullPtr then where `aggStPtr` is read (`peek`) from zeroed memory initially. We fix this by giving these StablePtr the same representation as other null pointers. It's safe because StablePtr at offset 0 is unused (for this exact reason). - - - - - 55346ede by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: disable MergeObjsMode test This isn't implemented for JS backend objects. - - - - - aef587f6 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: add support for linking C sources Support linking C sources with JS output of the JavaScript backend. See the added documentation in the users guide. The implementation simply extends the JS linker to use the objects (.o) that were already produced by the emcc compiler and which were filtered out previously. I've also added some options to control the link with C functions (see the documentation about pragmas). With this change I've successfully compiled the direct-sqlite package which embeds the sqlite.c database code. Some wrappers are still required (see the documentation about wrappers) but everything generic enough to be reused for other libraries have been integrated into rts/js/mem.js. - - - - - b71b392f by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: avoid EMCC logging spurious failure emcc would sometime output messages like: cache:INFO: generating system asset: symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json" for subsequent builds) cache:INFO: - ok Cf https://github.com/emscripten-core/emscripten/issues/18607 This breaks our tests matching the stderr output. We avoid this by setting EMCC_LOGGING=0 - - - - - ff2c0cc9 by Simon Peyton Jones at 2024-02-12T12:19:17-05:00 Remove a dead comment Just remove an out of date block of commented-out code, and tidy up the relevant Notes. See #8317. - - - - - bedb4f0d by Teo Camarasu at 2024-02-12T18:50:33-05:00 nonmoving: Add support for heap profiling Add support for heap profiling while using the nonmoving collector. We greatly simply the implementation by disabling concurrent collection for GCs when heap profiling is enabled. This entails that the marked objects on the nonmoving heap are exactly the live objects. Note that we match the behaviour for live bytes accounting by taking the size of objects on the nonmoving heap to be that of the segment's block rather than the object itself. Resolves #22221 - - - - - d0d5acb5 by Teo Camarasu at 2024-02-12T18:51:09-05:00 doc: Add requires prof annotation to options that require it Resolves #24421 - - - - - 57bb8c92 by Cheng Shao at 2024-02-13T14:07:49-05:00 deriveConstants: add needed constants for wasm backend This commit adds needed constants to deriveConstants. They are used by RTS code in the wasm backend to support the JSFFI logic. - - - - - 615eb855 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms The pure Haskell implementation causes i386 regression in unrelated work that can be fixed by using C-based atomic increment, see added comment for details. - - - - - a9918891 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow JSFFI for wasm32 This commit allows the javascript calling convention to be used when the target platform is wasm32. - - - - - 8771a53b by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow boxed JSVal as a foreign type This commit allows the boxed JSVal type to be used as a foreign argument/result type. - - - - - 053c92b3 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: ensure ctors have the right priority on wasm32 This commit fixes the priorities of ctors generated by GHC codegen on wasm32, see the referred note for details. - - - - - b7942e0a by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JSFFI desugar logic for wasm32 This commit adds JSFFI desugar logic for the wasm backend. - - - - - 2c1dca76 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JavaScriptFFI to supported extension list on wasm32 This commit adds JavaScriptFFI as a supported extension when the target platform is wasm32. - - - - - 9ad0e2b4 by Cheng Shao at 2024-02-13T14:07:49-05:00 rts/ghc-internal: add JSFFI support logic for wasm32 This commit adds rts/ghc-internal logic to support the wasm backend's JSFFI functionality. - - - - - e9ebea66 by Cheng Shao at 2024-02-13T14:07:49-05:00 ghc-internal: fix threadDelay for wasm in browsers This commit fixes broken threadDelay for wasm when it runs in browsers, see added note for detailed explanation. - - - - - f85f3fdb by Cheng Shao at 2024-02-13T14:07:49-05:00 utils: add JSFFI utility code This commit adds JavaScript util code to utils to support the wasm backend's JSFFI functionality: - jsffi/post-link.mjs, a post-linker to process the linked wasm module and emit a small complement JavaScript ESM module to be used with it at runtime - jsffi/prelude.js, a tiny bit of prelude code as the JavaScript side of runtime logic - jsffi/test-runner.mjs, run the jsffi test cases Co-authored-by: amesgen <amesgen at amesgen.de> - - - - - 77e91500 by Cheng Shao at 2024-02-13T14:07:49-05:00 hadrian: distribute jsbits needed for wasm backend's JSFFI support The post-linker.mjs/prelude.js files are now distributed in the bindist libdir, so when using the wasm backend's JSFFI feature, the user wouldn't need to fetch them from a ghc checkout manually. - - - - - c47ba1c3 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add opts.target_wrapper This commit adds opts.target_wrapper which allows overriding the target wrapper on a per test case basis when testing a cross target. This is used when testing the wasm backend's JSFFI functionality; the rest of the cases are tested using wasmtime, though the jsffi cases are tested using the node.js based test runner. - - - - - 8e048675 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: T22774 should work for wasm JSFFI T22774 works since the wasm backend now supports the JSFFI feature. - - - - - 1d07f9a6 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add JSFFI test cases for wasm backend This commit adds a few test cases for the wasm backend's JSFFI functionality, as well as a simple README to instruct future contributors to add new test cases. - - - - - b8997080 by Cheng Shao at 2024-02-13T14:07:49-05:00 docs: add documentation for wasm backend JSFFI This commit adds changelog and user facing documentation for the wasm backend's JSFFI feature. - - - - - ffeb000d by David Binder at 2024-02-13T14:08:30-05:00 Add tests from libraries/process/tests and libraries/Win32/tests to GHC These tests were previously part of the libraries, which themselves are submodules of the GHC repository. This commit moves the tests directly to the GHC repository. - - - - - 5a932cf2 by David Binder at 2024-02-13T14:08:30-05:00 Do not execute win32 tests on non-windows runners - - - - - 500d8cb8 by Jade at 2024-02-13T14:09:07-05:00 prevent GHCi (and runghc) from suggesting other symbols when not finding main Fixes: #23996 - - - - - b19ec331 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: update xxHash to v0.8.2 - - - - - 4a97bdb8 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: use XXH3_64bits hash on all 64-bit platforms This commit enables XXH3_64bits hash to be used on all 64-bit platforms. Previously it was only enabled on x86_64, so platforms like aarch64 silently falls back to using XXH32 which degrades the hashing function quality. - - - - - ee01de7d by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: define XXH_INLINE_ALL This commit cleans up how we include the xxhash.h header and only define XXH_INLINE_ALL, which is sufficient to inline the xxHash functions without symbol collision. - - - - - 0e01e1db by Alan Zimmerman at 2024-02-14T02:13:22-05:00 EPA: Move EpAnn out of extension points Leaving a few that are too tricky, maybe some other time. Also - remove some unneeded helpers from Parser.y - reduce allocations with strictness annotations Updates haddock submodule Metric Decrease: parsing001 - - - - - de589554 by Andreas Klebinger at 2024-02-14T02:13:59-05:00 Fix ffi callbacks with >6 args and non-64bit args. Check for ptr/int arguments rather than 64-bit width arguments when counting integer register arguments. The old approach broke when we stopped using exclusively W64-sized types to represent sub-word sized integers. Fixes #24314 - - - - - 325b7613 by Ben Gamari at 2024-02-14T14:27:45-05:00 rts/EventLog: Place eliminate duplicate strlens Previously many of the `post*` implementations would first compute the length of the event's strings in order to determine the event length. Later we would then end up computing the length yet again in `postString`. Now we instead pass the string length to `postStringLen`, avoiding the repeated work. - - - - - 8aafa51c by Ben Gamari at 2024-02-14T14:27:46-05:00 rts/eventlog: Place upper bound on IPE string field lengths The strings in IPE events may be of unbounded length. Limit the lengths of these fields to 64k characters to ensure that we don't exceed the maximum event length. - - - - - 0e60d52c by Zubin Duggal at 2024-02-14T14:27:46-05:00 rts: drop unused postString function - - - - - d8d1333a by Cheng Shao at 2024-02-14T14:28:23-05:00 compiler/rts: fix wasm unreg regression This commit fixes two wasm unreg regressions caught by a nightly pipeline: - Unknown stg_scheduler_loopzh symbol when compiling scheduler.cmm - Invalid _hs_constructor(101) function name when handling ctor - - - - - 264a4fa9 by Owen Shepherd at 2024-02-15T09:41:06-05:00 feat: Add sortOn to Data.List.NonEmpty Adds `sortOn` to `Data.List.NonEmpty`, and adds comments describing when to use it, compared to `sortWith` or `sortBy . comparing`. The aim is to smooth out the API between `Data.List`, and `Data.List.NonEmpty`. This change has been discussed in the [clc issue](https://github.com/haskell/core-libraries-committee/issues/227). - - - - - b57200de by Fendor at 2024-02-15T09:41:47-05:00 Prefer RdrName over OccName for looking up locations in doc renaming step Looking up by OccName only does not take into account when functions are only imported in a qualified way. Fixes issue #24294 Bump haddock submodule to include regression test - - - - - 8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00 JS: add simple optimizer The simple optimizer reduces the size of the code generated by the JavaScript backend without the complexity and performance penalty of the optimizer in GHCJS. Also see #22736 Metric Decrease: libdir size_hello_artifact - - - - - 20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00 base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and modifies the base API to reflect the new RTS flag. CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243 Fixes #24337 - - - - - 08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00 base: export System.Mem.performBlockingMajorGC The corresponding C function was introduced in ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264. Resolves #24228 The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230 Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00 Fix C output for modern C initiative GCC 14 on aarch64 rejects the C code written by GHC with this kind of error: error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion] 68 | *(ffi_arg*)resp = cret; | ^ Add the correct cast. For more information on this see: https://fedoraproject.org/wiki/Changes/PortingToModernC Tested-by: Richard W.M. Jones <rjones at redhat.com> - - - - - 5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00 Bump bytestring submodule to 0.12.1.0 - - - - - 902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00 Add missing BCO handling in scavenge_one. - - - - - 97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Make cast between words and floats real primops (#24331) First step towards fixing #24331. Replace foreign prim imports with real primops. - - - - - a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: add constant folding for bitcast between float and word (#24331) - - - - - 5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: replace stack checks with assertions in casting primops There are RESERVED_STACK_WORDS free words (currently 21) on the stack, so omit the checks. Suggested by Cheng Shao. - - - - - 401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00 Reexport primops from GHC.Float + add deprecation - - - - - 4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00 rts/Hash: Don't iterate over chunks if we don't need to free data When freeing a `HashTable` there is no reason to walk over the hash list before freeing it if the user has not given us a `dataFreeFun`. Noticed while looking at #24410. - - - - - bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00 compiler: add SEQ_CST fence support In addition to existing Acquire/Release fences, this commit adds SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a fence that enforces total memory ordering. The following logic is added: - The MO_SeqCstFence callish MachOp - The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h - MO_SeqCstFence lowering logic in every single GHC codegen backend - - - - - 2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00 testsuite: fix hs_try_putmvar002 for targets without pthread.h hs_try_putmvar002 includes pthread.h and doesn't work on targets without this header (e.g. wasm32). It doesn't need to include this header at all. This was previously unnoticed by wasm CI, though recent toolchain upgrade brought in upstream changes that completely removes pthread.h in the single-threaded wasm32-wasi sysroot, therefore we need to handle that change. - - - - - 1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00 ci: bump ci-images to use updated wasm image This commit bumps our ci-images revision to use updated wasm image. - - - - - 56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00 Bump submodule text to 2.1.1 T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a. Metric Decrease: T17123 - - - - - a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00 rts: remove redundant rCCCS initialization This commit removes the redundant logic of initializing each Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before initProfiling() is called during RTS startup, each Capability's rCCCS has already been assigned CCS_SYSTEM when they're first initialized. - - - - - 7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00 Parser, renamer, type checker for @a-binders (#17594) GHC Proposal 448 introduces binders for invisible type arguments (@a-binders) in various contexts. This patch implements @-binders in lambda patterns and function equations: {-# LANGUAGE TypeAbstractions #-} id1 :: a -> a id1 @t x = x :: t -- @t-binder on the LHS of a function equation higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16) higherRank f = (f 42, f 42) ex :: (Int8, Int16) ex = higherRank (\ @a x -> maxBound @a - x ) -- @a-binder in a lambda pattern in an argument -- to a higher-order function Syntax ------ To represent those @-binders in the AST, the list of patterns in Match now uses ArgPat instead of Pat: data Match p body = Match { ... - m_pats :: [LPat p], + m_pats :: [LArgPat p], ... } + data ArgPat pass + = VisPat (XVisPat pass) (LPat pass) + | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass)) + | XArgPat !(XXArgPat pass) The VisPat constructor represents patterns for visible arguments, which include ordinary value-level arguments and required type arguments (neither is prefixed with a @), while InvisPat represents invisible type arguments (prefixed with a @). Parser ------ In the grammar (Parser.y), the lambda and lambda-cases productions of aexp non-terminal were updated to accept argpats instead of apats: aexp : ... - | '\\' apats '->' exp + | '\\' argpats '->' exp ... - | '\\' 'lcases' altslist(apats) + | '\\' 'lcases' altslist(argpats) ... + argpat : apat + | PREFIX_AT atype Function left-hand sides did not require any changes to the grammar, as they were already parsed with productions capable of parsing @-binders. Those binders were being rejected in post-processing (isFunLhs), and now we accept them. In Parser.PostProcess, patterns are constructed with the help of PatBuilder, which is used as an intermediate data structure when disambiguating between FunBind and PatBind. In this patch we define ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived data structure produced in isFunLhs and consumed in checkFunBind. Renamer ------- Renaming of @-binders builds upon prior work on type patterns, implemented in 2afbddb0f24, which guarantees proper scoping and shadowing behavior of bound type variables. This patch merely defines rnLArgPatsAndThen to process a mix of visible and invisible patterns: + rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn] + rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where + rnArgPatAndThen (VisPat x p) = ... rnLPatAndThen ... + rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ... Common logic between rnArgPats and rnPats is factored out into the rn_pats_general helper. Type checker ------------ Type-checking of @-binders builds upon prior work on lazy skolemisation, implemented in f5d3e03c56f. This patch extends tcMatchPats to handle @-binders. Now it takes and returns a list of LArgPat rather than LPat: tcMatchPats :: ... - -> [LPat GhcRn] + -> [LArgPat GhcRn] ... - -> TcM ([LPat GhcTc], a) + -> TcM ([LArgPat GhcTc], a) Invisible binders in the Match are matched up with invisible (Specified) foralls in the type. This is done with a new clause in the `loop` worker of tcMatchPats: loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a) loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys) ... -- NEW CLAUSE: | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis = ... In addition to that, tcMatchPats no longer discards type patterns. This is done by filterOutErasedPats in the desugarer instead. x86_64-linux-deb10-validate+debug_info Metric Increase: MultiLayerModulesTH_OneShot - - - - - 486979b0 by Jade at 2024-02-19T07:12:13-05:00 Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246 Fixes: #24346 - - - - - 17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00 Fix reST in users guide It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax. - - - - - 35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00 Fix searching for errors in sphinx build - - - - - 4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00 hadrian: fix wasm backend post linker script permissions The post-link.mjs script was incorrectly copied and installed as a regular data file without executable permission, this commit fixes it. - - - - - a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00 testsuite: mark T23540 as fragile on i386 See #24449 for details. - - - - - 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 8a8ac65a by Matthew Craven at 2024-03-23T00:20:52-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 0c48f2b9 by Apoorv Ingle at 2024-03-23T00:21:28-04:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - b72705e9 by Simon Peyton Jones at 2024-03-23T00:22:04-04:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 8f7cfc7e by Tristan Cacqueray at 2024-03-23T00:22:44-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - 5bd8ed53 by Andreas Klebinger at 2024-03-23T16:18:33-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8d67f247 by Ben Gamari at 2024-03-23T16:19:09-04:00 docs: Drop old release notes, add for 9.12.1 - - - - - 7db8c992 by Cheng Shao at 2024-03-25T13:45:46-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. - - - - - 237194ce by Sylvain Henry at 2024-03-25T13:46:27-04:00 Lexer: fix imports for Alex 3.5.1 (#24583) - - - - - 810660b7 by Cheng Shao at 2024-03-25T22:19:16-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - d2ba41e8 by Alan Zimmerman at 2024-03-25T22:19:51-04:00 EPA: do not duplicate comments in signature RHS - - - - - 32a8103f by Rodrigo Mesquita at 2024-03-26T21:16:12-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. - - - - - bf65a7c3 by Rodrigo Mesquita at 2024-03-26T21:16:48-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 - - - - - cfeb70d3 by Rodrigo Mesquita at 2024-03-26T21:17:24-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 13223f6d by Serge S. Gulin at 2024-03-27T07:28:51-04:00 JS: `h$rts_isProfiled` is removed from `profiling` and left its version at `rts/js/config.js` - - - - - 0acfe391 by Alan Zimmerman at 2024-03-27T07:29:27-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. - - - - - cd0fb82f by Alan Zimmerman at 2024-03-27T19:33:08+00:00 EPA: Fix FamDecl range The span was incorrect if opt_datafam_kind_sig was empty - - - - - f8f384a8 by Ben Gamari at 2024-03-29T01:23:03-04:00 Fix type of _get_osfhandle foreign import Fixes #24601. - - - - - 00d3ecf0 by Alan Zimmerman at 2024-03-29T12:19:10+00:00 EPA: Extend StringLiteral range to include trailing commas This goes slightly against the exact printing philosophy where trailing decorations should be in an annotation, but the practicalities of adding it to the WarningTxt environment, and the problems caused by deviating do not make a more principles approach worthwhile. - - - - - efab3649 by brandon s allbery kf8nh at 2024-03-31T20:04:01-04:00 clarify Note [Preproccesing invocations] - - - - - c8a4c050 by Ben Gamari at 2024-04-02T12:50:35-04:00 rts: Fix TSAN_ENABLED CPP guard This should be `#if defined(TSAN_ENABLED)`, not `#if TSAN_ENABLED`, lest we suffer warnings. - - - - - e91dad93 by Cheng Shao at 2024-04-02T12:50:35-04:00 rts: fix errors when compiling with TSAN This commit fixes rts compilation errors when compiling with TSAN: - xxx_FENCE macros are redefined and trigger CPP warnings. - Use SIZEOF_W. WORD_SIZE_IN_BITS is provided by MachDeps.h which Cmm.h doesn't include by default. - - - - - a9ab9455 by Cheng Shao at 2024-04-02T12:50:35-04:00 rts: fix clang-specific errors when compiling with TSAN This commit fixes clang-specific rts compilation errors when compiling with TSAN: - clang doesn't have -Wtsan flag - Fix prototype of ghc_tsan_* helper functions - __tsan_atomic_* functions aren't clang built-ins and sanitizer/tsan_interface_atomic.h needs to be included - On macOS, TSAN runtime library is libclang_rt.tsan_osx_dynamic.dylib, not libtsan. -fsanitize-thread as a link-time flag will take care of linking the TSAN runtime library anyway so remove tsan as an rts extra library - - - - - 865bd717 by Cheng Shao at 2024-04-02T12:50:35-04:00 compiler: fix github link to __tsan_memory_order in a comment - - - - - 07cb627c by Cheng Shao at 2024-04-02T12:50:35-04:00 ci: improve TSAN CI jobs - Run TSAN jobs with +thread_sanitizer_cmm which enables Cmm instrumentation as well. - Run TSAN jobs in deb12 which ships gcc-12, a reasonably recent gcc that @bgamari confirms he's using in #GHC:matrix.org. Ideally we should be using latest clang release for latest improvements in sanitizers, though that's left as future work. - Mark TSAN jobs as manual+allow_failure in validate pipelines. The purpose is to demonstrate that we have indeed at least fixed building of TSAN mode in CI without blocking the patch to land, and once merged other people can begin playing with TSAN using their own dev setups and feature branches. - - - - - a1c18c7b by Andrei Borzenkov at 2024-04-02T12:51:11-04:00 Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy (#24299, #23639) This patch implements refactoring which is a prerequisite to updating kind checking of type patterns. This is a huge simplification of the main worker that checks kind of HsType. It also fixes the issues caused by previous code duplication, e.g. that we didn't add module finalizers from splices in inference mode. - - - - - 817e8936 by Rodrigo Mesquita at 2024-04-02T20:13:05-04:00 th: Hide the Language.Haskell.TH.Lib.Internal module from haddock Fixes #24562 - - - - - b36ee57b by Sylvain Henry at 2024-04-02T20:13:46-04:00 JS: reenable h$appendToHsString optimization (#24495) The optimization introducing h$appendToHsString wasn't kicking in anymore (while it did in 9.8.1) because of the changes introduced in #23270 (7e0c8b3bab30). This patch reenables the optimization by matching on case-expression, as done in Cmm for unpackCString# standard thunks. The test is also T24495 added in the next commits (two commits for ease of backporting to 9.8). - - - - - 527616e9 by Sylvain Henry at 2024-04-02T20:13:46-04:00 JS: fix h$appendToHsString implementation (#24495) h$appendToHsString needs to wrap its argument in an updatable thunk to behave like unpackAppendCString#. Otherwise if a SingleEntry thunk is passed, it is stored as-is in a CONS cell, making the resulting list impossible to deepseq (forcing the thunk doesn't update the contents of the CONS cell)! The added test checks that the optimization kicks in and that h$appendToHsString works as intended. Fix #24495 - - - - - faa30b41 by Simon Peyton Jones at 2024-04-02T20:14:22-04:00 Deal with duplicate tyvars in type declarations GHC was outright crashing before this fix: #24604 - - - - - e0b0c717 by Simon Peyton Jones at 2024-04-02T20:14:58-04:00 Try using MCoercion in exprIsConApp_maybe This is just a simple refactor that makes exprIsConApp_maybe a little bit more direct, simple, and efficient. Metrics: compile_time/bytes allocated geo. mean -0.1% minimum -2.0% maximum -0.0% Not a big gain, but worthwhile given that the code is, if anything, easier to grok. - - - - - 15f4d867 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Initial ./configure support for selecting I/O managers In this patch we just define new CPP vars, but don't yet use them or replace the existing approach. That will follow. The intention here is that every I/O manager can be enabled/disabled at GHC build time (subject to some constraints). More than one I/O manager can be enabled to be built. At least one I/O manager supporting the non-threaded RTS must be enabled as well as at least one supporting the non-threaded RTS. The I/O managers enabled here will become the choices available at runtime at RTS startup (in later patches). The choice can be made with RTS flags. There are separate sets of choices for the threaded and non-threaded RTS ways, because most I/O managers are specific to these ways. Furthermore we must establish a default I/O manager for the threaded and non-threaded RTS. Most I/O managers are platform-specific so there are checks to ensure each one can be enabled on the platform. Such checks are also where (in future) any system dependencies (e.g. libraries) can be checked. The output is a set of CPP flags (in the mk/config.h file), with one flag per named I/O manager: * IOMGR_BUILD_<name> : which ones should be built (some) * IOMGR_DEFAULT_NON_THREADED_<name> : which one is default (exactly one) * IOMGR_DEFAULT_THREADED_<name> : which one is default (exactly one) and a set of derived flags in IOManager.h * IOMGR_ENABLED_<name> : enabled for the current RTS way Note that IOMGR_BUILD_<name> just says that an I/O manager will be built for _some_ RTS way (i.e. threaded or non-threaded). The derived flags IOMGR_ENABLED_<name> in IOManager.h say if each I/O manager is enabled in the "current" RTS way. These are the ones that can be used for conditional compilation of the I/O manager code. Co-authored-by: Pi Delport <pi at well-typed.com> - - - - - 85b0f87a by Duncan Coutts at 2024-04-03T01:27:17-04:00 Change the handling of the RTS flag --io-manager= Now instead of it being just used on Windows to select between the WinIO vs the MIO or Win32-legacy I/O managers, it is now used on all platforms for selecting the I/O manager to use. Right now it remains the case that there is only an actual choice on Windows, but that will change later. Document the --io-manager flag in the user guide. This change is also reflected in the RTS flags types in the base library. Deprecate the export of IoSubSystem from GHC.RTS.Flags with a message to import it from GHC.IO.Subsystem. The way the 'IoSubSystem' is detected also changes. Instead of looking at the RTS flag, there is now a C bool global var in the RTS which gets set on startup when the I/O manager is selected. This bool var says whether the selected I/O manager classifies as "native" on Windows, which in practice means the WinIO I/O manager has been selected. Similarly, the is_io_mng_native_p RTS helper function is re-implemented in terms of the selected I/O manager, rather than based on the RTS flags. We do however remove the ./configure --native-io-manager flag because we're bringing the WinIO/MIO/Win32-legacy choice under the new general scheme for selecting I/O managers, and that new scheme involves no ./configure time user choices, just runtime RTS flag choices. - - - - - 1a8f020f by Duncan Coutts at 2024-04-03T01:27:17-04:00 Convert {init,stop,exit}IOManager to switch style Rather than ad-hoc cpp conitionals on THREADED_RTS and mingw32_HOST_OS, we use a style where we switch on the I/O manager impl, with cases for each I/O manager impl. - - - - - a5bad3d2 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Split up the CapIOManager content by I/O manager Using the new IOMGR_ENABLED_<name> CPP defines. - - - - - 1d36e609 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Convert initIOManagerAfterFork and wakeupIOManager to switch style - - - - - c2f26f36 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move most of waitRead#/Write# from cmm to C Moves it into the IOManager.c where we can follow the new pattern of switching on the selected I/O manager. - - - - - 457705a8 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move most of the delay# impl from cmm to C Moves it into the IOManager.c where we can follow the new pattern of switching on the selected I/O manager. Uses a new IOManager API: syncDelay, following the naming convention of sync* for thread-synchronous I/O & timer/delay operations. As part of porting from cmm to C, we maintain the rule that the why_blocked gets accessed using load acquire and store release atomic memory operations. There was one exception to this rule: in the delay# primop cmm code on posix (not win32), the why_blocked was being updated using a store relaxed, not a store release. I've no idea why. In this convesion I'm playing it safe here and using store release consistently. - - - - - e93058e0 by Duncan Coutts at 2024-04-03T01:27:18-04:00 insertIntoSleepingQueue is no longer public No longer defined in IOManager.h, just a private function in IOManager.c. Since it is no longer called from cmm code, just from syncDelay. It ought to get moved further into the select() I/O manager impl, rather than living in IOManager.c. On the other hand appendToIOBlockedQueue is still called from cmm code in the win32-legacy I/O manager primops async{Read,Write}#, and it is also used by the select() I/O manager. Update the CPP and comments to reflect this. - - - - - 60ce9910 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move anyPendingTimeoutsOrIO impl from .h to .c The implementation is eventually going to need to use more private things, which will drag in unwanted includes into IOManager.h, so it's better to move the impl out of the header file and into the .c file, at the slight cost of it no longer being inline. At the same time, change to the "switch (iomgr_type)" style. - - - - - f70b8108 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Take a simpler approach to gcc warnings in IOManager.c We have lots of functions with conditional implementations for different I/O managers. Some functions, for some I/O managers, naturally have implementations that do nothing or barf. When only one such I/O manager is enabled then the whole function implementation will have an implementation that does nothing or barfs. This then results in warnings from gcc that parameters are unused, or that the function should be marked with attribute noreturn (since barf does not return). The USED_IF_THREADS trick for fine-grained warning supression is fine for just two cases, but an equivalent here would need USED_IF_THE_ONLY_ENABLED_IOMGR_IS_X_OR_Y which would have combinitorial blowup. So we take a coarse grained approach and simply disable these two warnings for the whole file. So we use a GCC pragma, with its handy push/pop support: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsuggest-attribute=noreturn" #pragma GCC diagnostic ignored "-Wunused-parameter" ... #pragma GCC diagnostic pop - - - - - b48805b9 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add a new trace class for the iomanager It makes sense now for it to be separate from the scheduler class of tracers. Enabled with +RTS -Do. Document the -Do debug flag in the user guide. - - - - - f0c1f862 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Have the throwTo impl go via (new) IOManager APIs rather than directly operating on the IO manager's data structures. Specifically, when thowing an async exception to a thread that is blocked waiting for I/O or waiting for a timer, then we want to cancel that I/O waiting or cancel the timer. Currently this is done directly in removeFromQueues() in RaiseAsync.c. We want it to go via proper APIs both for modularity but also to let us support multiple I/O managers. So add sync{IO,Delay}Cancel, which is the cancellation for the corresponding sync{IO,Delay}. The implementations of these use the usual "switch (iomgr_type)" style. - - - - - 4f9e9c4e by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move awaitEvent into a proper IOManager API and have the scheduler use it. Previously the scheduler calls awaitEvent directly, and awaitEvent is implemented directly in the RTS I/O managers (select, win32). This relies on the old scheme where there's a single active I/O manager for each platform and RTS way. We want to move that to go via an API in IOManager.{h,c} which can then call out to the active I/O manager. Also take the opportunity to split awaitEvent into two. The existing awaitEvent has a bool wait parameter, to say if the call should be blocking or non-blocking. We split this into two separate functions: pollCompletedTimeoutsOrIO and awaitCompletedTimeoutsOrIO. We split them for a few reasons: they have different post-conditions (specifically the await version is supposed to guarantee that there are threads runnable when it completes). Secondly, it is also anticipated that in future I/O managers the implementations of the two cases will be simpler if they are separated. - - - - - 5ad4b30f by Duncan Coutts at 2024-04-03T01:27:18-04:00 Rename awaitEvent in select and win32 I/O managers These are now just called from IOManager.c and are the per-I/O manager backend impls (whereas previously awaitEvent was the entry point). Follow the new naming convention in the IOManager.{h,c} of awaitCompletedTimeoutsOrIO, with the I/O manager's name as a suffix: so awaitCompletedTimeoutsOrIO{Select,Win32}. - - - - - d30c6bc6 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Tidy up a couple things in Select.{h,c} Use the standard #include {Begin,End}Private.h style rather than RTS_PRIVATE on individual decls. And conditionally build the code for the select I/O manager based on the new CPP IOMGR_ENABLED_SELECT rather than on THREADED_RTS. - - - - - 4161f516 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add an IOManager API for scavenging TSO blocked_info When the GC scavenges a TSO it needs to scavenge the tso->blocked_info but the blocked_info is a big union and what lives there depends on the two->why_blocked, which for I/O-related reasons is something that in principle is the responsibility of the I/O manager and not the GC. So the right thing to do is for the GC to ask the I/O manager to sscavenge the blocked_info if it encounters any I/O-related why_blocked reasons. So we add scavengeTSOIOManager in IOManager.{h,c} with the usual style. Now as it happens, right now, there is no special scavenging to do, so the implementation of scavengeTSOIOManager is a fancy no-op. That's because the select I/O manager uses only the fd and target members, which are not GC pointers, and the win32-legacy I/O manager _ought_ to be using GC-managed heap objects for the StgAsyncIOResult but it is actually usingthe C heap, so again no GC pointers. If the win32-legacy were doing this more sensibly, then scavengeTSOIOManager would be the right place to do the GC magic. Future I/O managers will need GC heap objects in the tso->blocked_info and will make use of this functionality. - - - - - 94a87d21 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add I/O manager API notifyIOManagerCapabilitiesChanged Used in setNumCapabilities. It only does anything for MIO on Posix. Previously it always invoked Haskell code, but that code only did anything on non-Windows (and non-JS), and only threaded. That currently effectively means the MIO I/O manager on Posix. So now it only invokes it for the MIO Posix case. - - - - - 3be6d591 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Select an I/O manager early in RTS startup We need to select the I/O manager to use during startup before the per-cap I/O manager initialisation. - - - - - aaa294d0 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Make struct CapIOManager be fully opaque Provide an opaque (forward) definition in Capability.h (since the cap contains a *CapIOManager) and then only provide a full definition in a new file IOManagerInternals.h. This new file is only supposed to be included by the IOManager implementation, not by its users. So that means IOManager.c and individual I/O manager implementations. The posix/Signals.c still needs direct access, but that should be eliminated. Anything that needs direct access either needs to be clearly part of an I/O manager (e.g. the sleect() one) or go via a proper API. - - - - - 877a2a80 by Duncan Coutts at 2024-04-03T01:27:18-04:00 The select() I/O manager does have some global initialisation It's just to make sure an exception CAF is a GC root. - - - - - 9c51473b by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add tracing for the main I/O manager actions Using the new tracer class. Note: The unconditional definition of showIOManager should be compatible with the debugTrace change in 7c7d1f6. Co-authored-by: Pi Delport <pi at well-typed.com> - - - - - c7d3e3a3 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Include the default I/O manager in the +RTS --info output Document the extra +RTS --info output in the user guide - - - - - 8023bad4 by Duncan Coutts at 2024-04-03T01:27:18-04:00 waitRead# / waitWrite# do not work for win32-legacy I/O manager Previously it was unclear that they did not work because the code path was shared with other I/O managers (in particular select()). Following the code carefully shows that what actually happens is that the calling thread would block forever: the thread will be put into the blocked queue, but no other action is scheduled that will ever result in it getting unblocked. It's better to just fail loudly in case anyone accidentally calls it, also it's less confusing code. - - - - - 83a74d20 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Conditionally ignore some GCC warnings Some GCC versions don't know about some warnings, and they complain that we're ignoring unknown warnings. So we try to ignore the warning based on the GCC version. - - - - - 1adc6fa4 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Accept changes to base-exports All the changes are in fact not changes at all. Previously, the IoSubSystem data type was defined in GHC.RTS.Flags and exported from both GHC.RTS.Flags and GHC.IO.SubSystem. Now, the data type is defined in GHC.IO.SubSystem and still exported from both modules. Therefore, the same exports and same instances are still available from both modules. But the base-exports records only the defining module, and so it looks like a change when it is fully compatible. Related: we do add a deprecation to the export of the type via GHC.RTS.Flags, telling people to use the export from GHC.IO.SubSystem. Also the sort order for some unrelated Show instances changed. No idea why. The same changes apply in the other versions, with a few more changes due to sort order weirdness. - - - - - 8d950968 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Accept metric decrease in T12227 I can't think of any good reason that anything in this MR should have changed the number of allocations, up or down. (Yes this is an empty commit.) Metric Decrease: T12227 - - - - - e869605e by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Several improvements to the handling of coercions * Make `mkSymCo` and `mkInstCo` smarter Fixes #23642 * Fix return role of `SelCo` in the coercion optimiser. Fixes #23617 * Make the coercion optimiser `opt_trans_rule` work better for newtypes Fixes #23619 - - - - - 1efd0714 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 FloatOut: improve floating for join point See the new Note [Floating join point bindings]. * Completely get rid of the complicated join_ceiling nonsense, which I have never understood. * Do not float join points at all, except perhaps to top level. * Some refactoring around wantToFloat, to treat Rec and NonRec more uniformly - - - - - 9c00154d by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Improve eta-expansion through call stacks See Note [Eta expanding through CallStacks] in GHC.Core.Opt.Arity This is a one-line change, that fixes an inconsistency - || isCallStackPredTy ty + || isCallStackPredTy ty || isCallStackTy ty - - - - - 95a9a172 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Spelling, layout, pretty-printing only - - - - - bdf1660f by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Improve exprIsConApp_maybe a little Eliminate a redundant case at birth. This sometimes reduces Simplifier iterations. See Note [Case elim in exprIsConApp_maybe]. - - - - - 609cd32c by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Inline GHC.HsToCore.Pmc.Solver.Types.trvVarInfo When exploring compile-time regressions after meddling with the Simplifier, I discovered that GHC.HsToCore.Pmc.Solver.Types.trvVarInfo was very delicately balanced. It's a small, heavily used, overloaded function and it's important that it inlines. By a fluke it was before, but at various times in my journey it stopped doing so. So I just added an INLINE pragma to it; no sense in depending on a delicately-balanced fluke. - - - - - ae24c9bc by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Slight improvement in WorkWrap Ensure that WorkWrap preserves lambda binders, in case of join points. Sadly I have forgotten why I made this change (it was while I was doing a lot of meddling in the Simplifier, but * it does no harm, * it is slightly more efficient, and * presumably it made something better! Anyway I have kept it in a separate commit. - - - - - e9297181 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Use named record fields for the CastIt { ... } data constructor This is a pure refactor - - - - - b4581e23 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Remove a long-commented-out line Pure refactoring - - - - - e026bdf2 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The main changes are below. There are also many new or rewritten Notes. Avoiding simplifying repeatedly ~~~~~~~~~~~~~~~ See Note [Avoiding simplifying repeatedly] * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env. Currently used only for the next point: avoiding repeatedly simplifying coercions. * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] * Improve the case-merge transformation: - Move the main code to `GHC.Core.Utils.mergeCaseAlts`, to join `filterAlts` and friends. See Note [Merge Nested Cases] in GHC.Core.Utils. - Add a new case for `tagToEnum#`; see wrinkle (MC3). - Add a new case to look through join points: see wrinkle (MC4) postInlineUnconditionally ~~~~~~~~~~~~~~~~~~~~~~~~~ * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. * Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. * Improve occurrence analyis for bottoming function calls, to help postInlineUnconditionally. See Note [Bottoming function calls] in GHC.Core.Opt.OccurAnal Inlining generally ~~~~~~~~~~~~~~~~~~ * In GHC.Core.Opt.Simplify.Utils.interestingCallContext, use RhsCtxt NonRecursive (not BoringCtxt) for a plain-seq case. See Note [Seq is boring] Also, wrinkle (SB1), inline in that `seq` context only for INLINE functions (UnfWhen guidance). * In GHC.Core.Opt.Simplify.Utils.interestingArg, - return ValueArg for OtherCon [c1,c2, ...], but - return NonTrivArg for OtherCon [] This makes a function a little less likely to inline if all we know is that the argument is evaluated, but nothing else. * isConLikeUnfolding is no longer true for OtherCon {}. This propagates to exprIsConLike. Con-like-ness has /positive/ information. Join points ~~~~~~~~~~~ * Be very careful about inlining join points. See these two long Notes Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline * When making join points, don't do so if the join point is so small it will immediately be inlined; check uncondInlineJoin. * In GHC.Core.Opt.Simplify.Inline.tryUnfolding, improve the inlining heuristics for join points. In general we /do not/ want to inline join points /even if they are small/. See Note [Duplicating join points] GHC.Core.Opt.Simplify.Iteration. But sometimes we do: see Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline; and the new `isBetterUnfoldingThan` function. * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * In GHC.Core.Unfold.sizeExpr, make jumps small, so that we don't penalise having a non-inlined join point. Performance changes ~~~~~~~~~~~~~~~~~~~ * Binary sizes fall by around 2.6%, according to nofib. * Compile times improve slightly. Here are the figures over 1%. I investiate the biggest differnce in T18304. It's a very small module, just a few hundred nodes. The large percentage difffence is due to a single function that didn't quite inline before, and does now, making code size a bit bigger. I decided gains outweighed the losses. Metrics: compile_time/bytes allocated (changes over +/- 1%) ------------------------------------------------ CoOpt_Singletons(normal) -9.2% GOOD LargeRecord(normal) -23.5% GOOD MultiComponentModulesRecomp(normal) +1.2% MultiLayerModulesTH_OneShot(normal) +4.1% BAD PmSeriesS(normal) -3.8% PmSeriesV(normal) -1.5% T11195(normal) -1.3% T12227(normal) -20.4% GOOD T12545(normal) -3.2% T12707(normal) -2.1% GOOD T13253(normal) -1.2% T13253-spj(normal) +8.1% BAD T13386(normal) -3.1% GOOD T14766(normal) -2.6% GOOD T15164(normal) -1.4% T15304(normal) +1.2% T15630(normal) -8.2% T15630a(normal) NEW T15703(normal) -14.7% GOOD T16577(normal) -2.3% GOOD T17516(normal) -39.7% GOOD T18140(normal) +1.2% T18223(normal) -17.1% GOOD T18282(normal) -5.0% GOOD T18304(normal) +10.8% BAD T18923(normal) -2.9% GOOD T1969(normal) +1.0% T19695(normal) -1.5% T20049(normal) -12.7% GOOD T21839c(normal) -4.1% GOOD T3064(normal) -1.5% T3294(normal) +1.2% BAD T4801(normal) +1.2% T5030(normal) -15.2% GOOD T5321Fun(normal) -2.2% GOOD T6048(optasm) -16.8% GOOD T783(normal) -1.2% T8095(normal) -6.0% GOOD T9630(normal) -4.7% GOOD T9961(normal) +1.9% BAD WWRec(normal) -1.4% info_table_map_perf(normal) -1.3% parsing001(normal) +1.5% geo. mean -2.0% minimum -39.7% maximum +10.8% * Runtimes generally improve. In the testsuite perf/should_run gives: Metrics: runtime/bytes allocated ------------------------------------------ Conversions(normal) -0.3% T13536a(optasm) -41.7% GOOD T4830(normal) -0.1% haddock.Cabal(normal) -0.1% haddock.base(normal) -0.1% haddock.compiler(normal) -0.1% geo. mean -0.8% minimum -41.7% maximum +0.0% * For runtime, nofib is a better test. The news is mostly good. Here are the number more than +/- 0.1%: # bytes allocated ==========================++========== imaginary/digits-of-e1 || -14.40% imaginary/digits-of-e2 || -4.41% imaginary/paraffins || -0.17% imaginary/rfib || -0.15% imaginary/wheel-sieve2 || -0.10% real/compress || -0.47% real/fluid || -0.10% real/fulsom || +0.14% real/gamteb || -1.47% real/gg || -0.20% real/infer || +0.24% real/pic || -0.23% real/prolog || -0.36% real/scs || -0.46% real/smallpt || +4.03% shootout/k-nucleotide || -20.23% shootout/n-body || -0.42% shootout/spectral-norm || -0.13% spectral/boyer2 || -3.80% spectral/constraints || -0.27% spectral/hartel/ida || -0.82% spectral/mate || -20.34% spectral/para || +0.46% spectral/rewrite || +1.30% spectral/sphere || -0.14% ==========================++========== geom mean || -0.59% real/smallpt has a huge nest of local definitions, and I could not pin down a reason for a regression. But there are three big wins! Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12707 T13386 T13536a T14766 T15703 T16577 T17516 T18223 T18282 T18923 T21839c T20049 T5321Fun T5030 T6048 T8095 T9630 T783 Metric Increase: MultiLayerModulesTH_OneShot T13253-spj T18304 T18698a T9961 T3294 - - - - - 27db3c5e by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Testsuite message changes from simplifier improvements - - - - - 271a7812 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Account for bottoming functions in OccurAnal This fixes #24582, a small but long-standing bug - - - - - 0fde229f by Ben Gamari at 2024-04-04T07:04:58-04:00 testsuite: Introduce template-haskell-exports test - - - - - 0c4a9686 by Luite Stegeman at 2024-04-04T07:05:39-04:00 Update correct counter in bumpTickyAllocd - - - - - 5f085d3a by Fendor at 2024-04-04T14:47:33-04:00 Replace `SizedSeq` with `FlatBag` for flattened structure LinkedLists are notoriously memory ineffiecient when all we do is traversing a structure. As 'UnlinkedBCO' has been identified as a data structure that impacts the overall memory usage of GHCi sessions, we avoid linked lists and prefer flattened structure for storing. We introduce a new memory efficient representation of sequential elements that has special support for the cases: * Empty * Singleton * Tuple Elements This improves sharing in the 'Empty' case and avoids the overhead of 'Array' until its constant overhead is justified. - - - - - 82cfe10c by Fendor at 2024-04-04T14:47:33-04:00 Compact FlatBag array representation `Array` contains three additional `Word`'s we do not need in `FlatBag`. Move `FlatBag` to `SmallArray`. Expand the API of SmallArray by `sizeofSmallArray` and add common traversal functions, such as `mapSmallArray` and `foldMapSmallArray`. Additionally, allow users to force the elements of a `SmallArray` via `rnfSmallArray`. - - - - - 36a75b80 by Andrei Borzenkov at 2024-04-04T14:48:10-04:00 Change how invisible patterns represented in haskell syntax and TH AST (#24557) Before this patch: data ArgPat p = InvisPat (LHsType p) | VisPat (LPat p) With this patch: data Pat p = ... | InvisPat (LHsType p) ... And the same transformation in the TH land. The rest of the changes is just updating code to handle new AST and writing tests to check if it is possible to create invalid states using TH. Metric Increase: MultiLayerModulesTH_OneShot - - - - - 28009fbc by Matthew Pickering at 2024-04-04T14:48:46-04:00 Fix off by one error in seekBinNoExpand and seekBin - - - - - 9b9e031b by Ben Gamari at 2024-04-04T21:30:08-04:00 compiler: Allow more types in GHCForeignImportPrim For many, many years `GHCForeignImportPrim` has suffered from the rather restrictive limitation of not allowing any non-trivial types in arguments or results. This limitation was justified by the code generator allegely barfing in the presence of such types. However, this restriction appears to originate well before the NCG rewrite and the new NCG does not appear to have any trouble with such types (see the added `T24598` test). Lift this restriction. Fixes #24598. - - - - - 1324b862 by Alan Zimmerman at 2024-04-04T21:30:44-04:00 EPA: Use EpaLocation not SrcSpan in ForeignDecls This allows us to update them for makeDeltaAst in ghc-exactprint - - - - - 19883a23 by Alan Zimmerman at 2024-04-05T16:58:17-04:00 EPA: Use EpaLocation for RecFieldsDotDot So we can update it to a delta position in makeDeltaAst if needed. - - - - - e8724327 by Matthew Pickering at 2024-04-05T16:58:53-04:00 Remove accidentally committed test.hs - - - - - 88cb3e10 by Fendor at 2024-04-08T09:03:34-04:00 Avoid UArray when indexing is not required `UnlinkedBCO`'s can occur many times in the heap. Each `UnlinkedBCO` references two `UArray`'s but never indexes them. They are only needed to encode the elements into a `ByteArray#`. The three words for the lower bound, upper bound and number of elements are essentially unused, thus we replace `UArray` with a wrapper around `ByteArray#`. This saves us up to three words for each `UnlinkedBCO`. Further, to avoid re-allocating these words for `ResolvedBCO`, we repeat the procedure for `ResolvedBCO` and add custom `Binary` and `Show` instances. For example, agda's repl session has around 360_000 UnlinkedBCO's, so avoiding these three words is already saving us around 8MB residency. - - - - - f2cc1107 by Fendor at 2024-04-08T09:04:11-04:00 Never UNPACK `FastMutInt` for counting z-encoded `FastString`s In `FastStringTable`, we count the number of z-encoded FastStrings that exist in a GHC session. We used to UNPACK the counters to not waste memory, but live retainer analysis showed that we allocate a lot of `FastMutInt`s, retained by `mkFastZString`. We lazily compute the `FastZString`, only incrementing the counter when the `FastZString` is forced. The function `mkFastStringWith` calls `mkZFastString` and boxes the `FastMutInt`, leading to the following core: mkFastStringWith = \ mk_fs _ -> = case stringTable of { FastStringTable _ n_zencs segments# _ -> ... case ((mk_fs (I# ...) (FastMutInt n_zencs)) `cast` <Co:2> :: ...) ... Marking this field as `NOUNPACK` avoids this reboxing, eliminating the allocation of a fresh `FastMutInt` on every `FastString` allocation. - - - - - c6def949 by Matthew Pickering at 2024-04-08T16:06:51-04:00 Force in_multi to avoid retaining entire hsc_env - - - - - fbb91a63 by Fendor at 2024-04-08T16:06:51-04:00 Eliminate name thunk in declaration fingerprinting Thunk analysis showed that we have about 100_000 thunks (in agda and `-fwrite-simplified-core`) pointing to the name of the name decl. Forcing this thunk fixes this issue. The thunk created here is retained by the thunk created by forkM, it is better to eagerly force this because the result (a `Name`) is already retained indirectly via the `IfaceDecl`. - - - - - 3b7b0c1c by Alan Zimmerman at 2024-04-08T16:07:27-04:00 EPA: Use EpaLocation in WarningTxt This allows us to use an EpDelta if needed when using makeDeltaAst. - - - - - 12b997df by Alan Zimmerman at 2024-04-08T16:07:27-04:00 EPA: Move DeltaPos and EpaLocation' into GHC.Types.SrcLoc This allows us to use a NoCommentsLocation for the possibly trailing comma location in a StringLiteral. This in turn allows us to correctly roundtrip via makeDeltaAst. - - - - - 868c8a78 by Fendor at 2024-04-09T08:51:50-04:00 Prefer packed representation for CompiledByteCode As there are many 'CompiledByteCode' objects alive during a GHCi session, representing its element in a more packed manner improves space behaviour at a minimal cost. When running GHCi on the agda codebase, we find around 380 live 'CompiledByteCode' objects. Packing their respective 'UnlinkedByteCode' can save quite some pointers. - - - - - be3bddde by Alan Zimmerman at 2024-04-09T08:52:26-04:00 EPA: Capture all comments in a ClassDecl Hopefully the final fix needed for #24533 - - - - - 3d0806fc by Jade at 2024-04-10T05:39:53-04:00 Validate -main-is flag using parseIdentifier Fixes #24368 - - - - - dd530bb7 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: free error message before returning Fixes a memory leak in rts/linker/PEi386.c - - - - - e008a19a by Alexis King at 2024-04-10T05:40:29-04:00 linker: Avoid linear search when looking up Haskell symbols via dlsym See the primary Note [Looking up symbols in the relevant objects] for a more in-depth explanation. When dynamically loading a Haskell symbol (typical when running a splice or GHCi expression), before this commit we would search for the symbol in all dynamic libraries that were loaded. However, this could be very inefficient when too many packages are loaded (which can happen if there are many package dependencies) because the time to lookup the would be linear in the number of packages loaded. This commit drastically improves symbol loading performance by introducing a mapping from units to the handles of corresponding loaded dlls. These handles are returned by dlopen when we load a dll, and can then be used to look up in a specific dynamic library. Looking up a given Name is now much more precise because we can get lookup its unit in the mapping and lookup the symbol solely in the handles of the dynamic libraries loaded for that unit. In one measurement, the wait time before the expression was executed went from +-38 seconds down to +-2s. This commit also includes Note [Symbols may not be found in pkgs_loaded], explaining the fallback to the old behaviour in case no dll can be found in the unit mapping for a given Name. Fixes #23415 Co-authored-by: Rodrigo Mesquita (@alt-romes) - - - - - dcfaa190 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: Make addDLL a wrapper around loadNativeObj Rewrite the implementation of `addDLL` as a wrapper around the more principled `loadNativeObj` rts linker function. The latter should be preferred while the former is preserved for backwards compatibility. `loadNativeObj` was previously only available on ELF platforms, so this commit further refactors the rts linker to transform loadNativeObj_ELF into loadNativeObj_POSIX, which is available in ELF and MachO platforms. The refactor made it possible to remove the `dl_mutex` mutex in favour of always using `linker_mutex` (rather than a combination of both). Lastly, we implement `loadNativeObj` for Windows too. - - - - - 12931698 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 Use symbol cache in internal interpreter too This commit makes the symbol cache that was used by the external interpreter available for the internal interpreter too. This follows from the analysis in #23415 that suggests the internal interpreter could benefit from this cache too, and that there is no good reason not to have the cache for it too. It also makes it a bit more uniform to have the symbol cache range over both the internal and external interpreter. This commit also refactors the cache into a function which is used by both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the caching logic to `lookupSymbolInDLL` too. - - - - - dccd3ea1 by Ben Gamari at 2024-04-10T05:40:29-04:00 testsuite: Add test for lookupSymbolInNativeObj - - - - - 1b1a92bd by Alan Zimmerman at 2024-04-10T05:41:05-04:00 EPA: Remove unnecessary XRec in CompleteMatchSig The XRec for [LIdP pass] is not needed for exact printing, remove it. - - - - - 6e18ce2b by Ben Gamari at 2024-04-12T08:16:09-04:00 users-guide: Clarify language extension documentation Over the years the users guide's language extension documentation has gone through quite a few refactorings. In the process some of the descriptions have been rendered non-sensical. For instance, the description of `NoImplicitPrelude` actually describes the semantics of `ImplicitPrelude`. To fix this we: * ensure that all extensions are named in their "positive" sense (e.g. `ImplicitPrelude` rather than `NoImplicitPrelude`). * rework the documentation to avoid flag-oriented wording like "enable" and "disable" * ensure that the polarity of the documentation is consistent with reality. Fixes #23895. - - - - - a933aff3 by Zubin Duggal at 2024-04-12T08:16:45-04:00 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - 23c3e624 by Andreas Klebinger at 2024-04-12T08:17:21-04:00 RTS: Emit warning when -M < -H Fixes #24487 - - - - - d23afb8c by Ben Gamari at 2024-04-12T08:17:56-04:00 testsuite: Add broken test for CApiFFI with -fprefer-bytecode See #24634. - - - - - a4bb3a51 by Ben Gamari at 2024-04-12T08:18:32-04:00 base: Deprecate GHC.Pack As proposed in #21461. Closes #21540. - - - - - 55eb8c98 by Ben Gamari at 2024-04-12T08:19:08-04:00 ghc-internal: Fix mentions of ghc-internal in deprecation warnings Closes #24609. - - - - - b0fbd181 by Ben Gamari at 2024-04-12T08:19:44-04:00 rts: Implement set_initial_registers for AArch64 Fixes #23680. - - - - - 14c9ec62 by Ben Gamari at 2024-04-12T08:20:20-04:00 ghcup-metadata: Use Debian 9 binaries on Ubuntu 16, 17 Closes #24646. - - - - - 35a1621e by Ben Gamari at 2024-04-12T08:20:55-04:00 Bump unix submodule to 2.8.5.1 Closes #24640. - - - - - a1c24df0 by Finley McIlwaine at 2024-04-12T08:21:31-04:00 Correct default -funfolding-use-threshold in docs - - - - - 0255d03c by Oleg Grenrus at 2024-04-12T08:22:07-04:00 FastString is a __Modified__ UTF-8 - - - - - c3489547 by Matthew Pickering at 2024-04-12T13:13:44-04:00 rts: Improve tracing message when nursery is resized It is sometimes more useful to know how much bigger or smaller the nursery got when it is resized. In particular I am trying to investigate situations where we end up with fragmentation due to the nursery (#24577) - - - - - 5e4f4ba8 by Simon Peyton Jones at 2024-04-12T13:14:20-04:00 Don't generate wrappers for `type data` constructors with StrictData Previously, the logic for checking if a data constructor needs a wrapper or not would take into account whether the constructor's fields have explicit strictness (e.g., `data T = MkT !Int`), but the logic would _not_ take into account whether `StrictData` was enabled. This meant that something like `type data T = MkT Int` would incorrectly generate a wrapper for `MkT` if `StrictData` was enabled, leading to the horrible errors seen in #24620. To fix this, we disable generating wrappers for `type data` constructors altogether. Fixes #24620. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - dbdf1995 by Alex Mason at 2024-04-15T15:28:26+10:00 Implements MO_S_Mul2 and MO_U_Mul2 using the UMULH, UMULL and SMULH instructions for AArch64 Also adds a test for MO_S_Mul2 - - - - - 42bd0407 by Teo Camarasu at 2024-04-16T20:06:39-04:00 Make template-haskell a stage1 package Promoting template-haskell from a stage0 to a stage1 package means that we can much more easily refactor template-haskell. We implement this by duplicating the in-tree `template-haskell`. A new `template-haskell-next` library is autogenerated to mirror `template-haskell` `stage1:ghc` to depend on the new interface of the library including the `Binary` instances without adding an explicit dependency on `template-haskell`. This is controlled by the `bootstrap-th` cabal flag When building `template-haskell` modules as part of this vendoring we do not have access to quote syntax, so we cannot use variable quote notation (`'Just`). So we either replace these with hand-written `Name`s or hide the code behind CPP. We can remove the `th_hack` from hadrian, which was required when building stage0 packages using the in-tree `template-haskell` library. For more details see Note [Bootstrapping Template Haskell]. Resolves #23536 Co-Authored-By: Sebastian Graf <sgraf1337 at gmail.com> Co-Authored-By: Matthew Craven <5086-clyring at users.noreply.gitlab.haskell.org> - - - - - 3d973e47 by Ben Gamari at 2024-04-16T20:07:15-04:00 Bump parsec submodule to 3.1.17.0 - - - - - 9d38bfa0 by Simon Peyton Jones at 2024-04-16T20:07:51-04:00 Clone CoVars in CorePrep This MR addresses #24463. It's all explained in the new Note [Cloning CoVars and TyVars] - - - - - 0fe2b410 by Andreas Klebinger at 2024-04-16T20:08:27-04:00 NCG: Fix a bug where we errounously removed a required jump instruction. Add a new method to the Instruction class to check if we can eliminate a jump in favour of fallthrough control flow. Fixes #24507 - - - - - 9f99126a by Teo Camarasu at 2024-04-16T20:09:04-04:00 Fix documentation preview from doc-tarball job - Include all the .html files and assets in the job artefacts - Include all the .pdf files in the job artefacts - Mark the artefact as an "exposed" artefact meaning it turns up in the UI. Resolves #24651 - - - - - 3a0642ea by Ben Gamari at 2024-04-16T20:09:39-04:00 rts: Ignore EINTR while polling in timerfd itimer implementation While the RTS does attempt to mask signals, it may be that a foreign library unmasks them. This previously caused benign warnings which we now ignore. See #24610. - - - - - 9a53cd3f by Alan Zimmerman at 2024-04-16T20:10:15-04:00 EPA: Add additional comments field to AnnsModule This is used in exact printing to store comments coming after the `where` keyword but before any comments allocated to imports or decls. It is used in ghc-exactprint, see https://github.com/alanz/ghc-exactprint/commit/44bbed311fd8f0d053053fef195bf47c17d34fa7 - - - - - e5c43259 by Bryan Richter at 2024-04-16T20:10:51-04:00 Remove unrunnable FreeBSD CI jobs FreeBSD runner supply is inelastic. Currently there is only one, and it's unavailable because of a hardware issue. - - - - - 914eb49a by Ben Gamari at 2024-04-16T20:11:27-04:00 rel-eng: Fix mktemp usage in recompress-all We need a temporary directory, not a file. - - - - - f30e4984 by Teo Camarasu at 2024-04-16T20:12:03-04:00 Fix ghc API link in docs/index.html This was missing part of the unit ID meaning it would 404. Resolves #24674 - - - - - d7a3d6b5 by Ben Gamari at 2024-04-16T20:12:39-04:00 template-haskell: Declare TH.Lib.Internal as not-home Rather than `hide`. Closes #24659. - - - - - 5eaa46e7 by Matthew Pickering at 2024-04-19T02:14:55-04:00 testsuite: Rename isCross() predicate to needsTargetWrapper() isCross() was a misnamed because it assumed that all cross targets would provide a target wrapper, but the two most common cross targets (javascript, wasm) don't need a target wrapper. Therefore we rename this predicate to `needsTargetWrapper()` so situations in the testsuite where we can check whether running executables requires a target wrapper or not. - - - - - 55a9d699 by Simon Peyton Jones at 2024-04-19T02:15:32-04:00 Do not float HNFs out of lambdas This MR adjusts SetLevels so that it is less eager to float a HNF (lambda or constructor application) out of a lambda, unless it gets to top level. Data suggests that this change is a small net win: * nofib bytes-allocated falls by -0.09% (but a couple go up) * perf/should_compile bytes-allocated falls by -0.5% * perf/should_run bytes-allocated falls by -0.1% See !12410 for more detail. When fiddling elsewhere, I also found that this patch had a huge positive effect on the (very delicate) test perf/should_run/T21839r But that improvement doesn't show up in this MR by itself. Metric Decrease: MultiLayerModulesRecomp T15703 parsing001 - - - - - f0701585 by Alan Zimmerman at 2024-04-19T02:16:08-04:00 EPA: Fix comments in mkListSyntaxTy0 Also extend the test to confirm. Addresses #24669, 1 of 4 - - - - - b01c01d4 by Serge S. Gulin at 2024-04-19T02:16:51-04:00 JS: set image `x86_64-linux-deb11-emsdk-closure` for build - - - - - c90c6039 by Alan Zimmerman at 2024-04-19T02:17:27-04:00 EPA: Provide correct span for PatBind And remove unused parameter in checkPatBind Contributes to #24669 - - - - - 26036f96 by Alan Zimmerman at 2024-04-19T13:11:08-04:00 EPA: Fix span for PatBuilderAppType Include the location of the prefix @ in the span for InVisPat. Also removes unnecessary annotations from HsTP. Contributes to #24669 - - - - - dba03aab by Matthew Craven at 2024-04-19T13:11:44-04:00 testsuite: Give the pre_cmd for mhu-perf more time - - - - - d31fbf6c by Krzysztof Gogolewski at 2024-04-19T21:04:09-04:00 Fix quantification order for a `op` b and a %m -> b Fixes #23764 Implements https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0640-tyop-quantification-order.rst Updates haddock submodule. - - - - - 385cd1c4 by Sebastian Graf at 2024-04-19T21:04:45-04:00 Make `seq#` a magic Id and inline it in CorePrep (#24124) We can save much code and explanation in Tag Inference and StgToCmm by making `seq#` a known-key Magic Id in `GHC.Internal.IO` and inline this definition in CorePrep. See the updated `Note [seq# magic]`. I also implemented a new `Note [Flatten case-bind]` to get better code for otherwise nested case scrutinees. I renamed the contructors of `ArgInfo` to use an `AI` prefix in order to resolve the clash between `type CpeApp = CoreExpr` and the data constructor of `ArgInfo`, as well as fixed typos in `Note [CorePrep invariants]`. Fixes #24252 and #24124. - - - - - 275e41a9 by Jade at 2024-04-20T11:10:40-04:00 Put the newline after errors instead of before them This mainly has consequences for GHCi but also slightly alters how the output of GHC on the commandline looks. Fixes: #22499 - - - - - dd339c7a by Teo Camarasu at 2024-04-20T11:11:16-04:00 Remove unecessary stage0 packages Historically quite a few packages had to be stage0 as they depended on `template-haskell` and that was stage0. In #23536 we made it so that was no longer the case. This allows us to remove a bunch of packages from this list. A few still remain. A new version of `Win32` is required by `semaphore-compat`. Including `Win32` in the stage0 set requires also including `filepath` because otherwise Hadrian's dependency logic gets confused. Once our boot compiler has a newer version of `Win32` all of these will be able to be dropped. Resolves #24652 - - - - - 2f8e3a25 by Alan Zimmerman at 2024-04-20T11:11:52-04:00 EPA: Avoid duplicated comments in splice decls Contributes to #24669 - - - - - c70b9ddb by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fix typos and namings (fixes #24602) You may noted that I've also changed term of ``` , global "h$vt_double" ||= toJExpr IntV ``` See "IntV" and ``` WaitReadOp -> \[] [fd] -> pure $ PRPrimCall $ returnS (app "h$waidRead" [fd]) ``` See "h$waidRead" - - - - - 3db54f9b by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: trivial checks for variable presence (fixes #24602) - - - - - 777f108f by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fs module imported twice (by emscripten and by ghc-internal). ghc-internal import wrapped in a closure to prevent conflict with emscripten (fixes #24602) Better solution is to use some JavaScript module system like AMD, CommonJS or even UMD. It will be investigated at other issues. At first glance we should try UMD (See https://github.com/umdjs/umd) - - - - - a45a5712 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: thread.js requires h$fds and h$fdReady to be declared for static code analysis, minimal code copied from GHCJS (fixes #24602) I've just copied some old pieces of GHCJS from publicly available sources (See https://github.com/Taneb/shims/blob/a6dd0202dcdb86ad63201495b8b5d9763483eb35/src/io.js#L607). Also I didn't put details to h$fds. I took minimal and left only its object initialization: `var h$fds = {};` - - - - - ad90bf12 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: heap and stack overflows reporting defined as js hard failure (fixes #24602) These errors were treated as a hard failure for browser application. The fix is trivial: just throw error. - - - - - 5962fa52 by Serge S. Gulin at 2024-04-21T16:33:44+03:00 JS: Stubs for code without actual implementation detected by Google Closure Compiler (fixes #24602) These errors were fixed just by introducing stubbed functions with throw for further implementation. - - - - - a0694298 by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add externs to linker (fixes #24602) After enabling jsdoc and built-in google closure compiler types I was needed to deal with the following: 1. Define NodeJS-environment types. I've just copied minimal set of externs from semi-official repo (see https://github.com/externs/nodejs/blob/6c6882c73efcdceecf42e7ba11f1e3e5c9c041f0/v8/nodejs.js#L8). 2. Define Emscripten-environment types: `HEAP8`. Emscripten already provides some externs in our code but it supposed to be run in some module system. And its definitions do not work well in plain bundle. 3. We have some functions which purpose is to add to functions some contextual information via function properties. These functions should be marked as `modifies` to let google closure compiler remove calls if these functions are not used actually by call graph. Such functions are: `h$o`, `h$sti`, `h$init_closure`, `h$setObjInfo`. 4. STG primitives such as registries and stuff from `GHC.StgToJS`. `dXX` properties were already present at externs generator function but they are started from `7`, not from `1`. This message is related: `// fixme does closure compiler bite us here?` - - - - - e58bb29f by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: added both tests: for size and for correctness (fixes #24602) By some reason MacOS builds add to stderr messages like: Ignoring unexpected archive entry: __.SYMDEF ... However I left stderr to `/dev/null` for compatibility with linux CI builds. - - - - - 909f3a9c by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Disable js linker warning for empty symbol table to make js tests running consistent across environments - - - - - 83eb10da by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add special preprocessor for js files due of needing to keep jsdoc comments (fixes #24602) Our js files have defined google closure compiler types at jsdoc entries but these jsdoc entries are removed by cpp preprocessor. I considered that reusing them in javascript-backend would be a nice thing. Right now haskell processor uses `-traditional` option to deal with comments and `//` operators. But now there are following compiler options: `-C` and `-CC`. You can read about them at GCC (see https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#index-CC) and CLang (see https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-CC). It seems that `-CC` works better for javascript jsdoc than `-traditional`. At least it leaves `/* ... */` comments w/o changes. - - - - - e1cf8dc2 by brandon s allbery kf8nh at 2024-04-22T03:48:26-04:00 fix link in CODEOWNERS It seems that our local Gitlab no longer has documentation for the `CODEOWNERS` file, but the master documentation still does. Use that instead. - - - - - 593f4e04 by Fendor at 2024-04-23T10:19:14-04:00 Add performance regression test for '-fwrite-simplified-core' - - - - - 1ba39b05 by Fendor at 2024-04-23T10:19:14-04:00 Typecheck corebindings lazily during bytecode generation This delays typechecking the corebindings until the bytecode generation happens. We also avoid allocating a thunk that is retained by `unsafeInterleaveIO`. In general, we shouldn't retain values of the hydrated `Type`, as not evaluating the bytecode object keeps it alive. It is better if we retain the unhydrated `IfaceType`. See Note [Hydrating Modules] - - - - - e916fc92 by Alan Zimmerman at 2024-04-23T10:19:50-04:00 EPA: Keep comments in a CaseAlt match The comments now live in the surrounding location, not inside the Match. Make sure we keep them. Closes #24707 - - - - - d2b17f32 by Cheng Shao at 2024-04-23T15:01:22-04:00 driver: force merge objects when building dynamic objects This patch forces the driver to always merge objects when building dynamic objects even when ar -L is supported. It is an oversight of !8887: original rationale of that patch is favoring the relatively cheap ar -L operation over object merging when ar -L is supported, which makes sense but only if we are building static objects! Omitting check for whether we are building dynamic objects will result in broken .so files with undefined reference errors at executable link time when building GHC with llvm-ar. Fixes #22210. - - - - - 209d09f5 by Julian Ospald at 2024-04-23T15:02:03-04:00 Allow non-absolute values for bootstrap GHC variable Fixes #24682 - - - - - 3fff0977 by Matthew Pickering at 2024-04-23T15:02:38-04:00 Don't depend on registerPackage function in Cabal More recent versions of Cabal modify the behaviour of libAbiHash which breaks our usage of registerPackage. It is simpler to inline the part of registerPackage that we need and avoid any additional dependency and complication using the higher-level function introduces. - - - - - c62dc317 by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: remove obsolete ln script This commit removes an obsolete ln script in ghc-bignum/gmp. See 060251c24ad160264ae8553efecbb8bed2f06360 for its original intention, but it's been obsolete for a long time, especially since the removal of the make build system. Hence the house cleaning. - - - - - 6399d52b by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: update gmp to 6.3.0 This patch bumps the gmp-tarballs submodule and updates gmp to 6.3.0. The tarball format is now xz, and gmpsrc.patch has been patched into the tarball so hadrian no longer needs to deal with patching logic when building in-tree GMP. - - - - - 65b4b92f by Cheng Shao at 2024-04-25T01:32:02-04:00 hadrian: remove obsolete Patch logic This commit removes obsolete Patch logic from hadrian, given we no longer need to patch the gmp tarball when building in-tree GMP. - - - - - 71f28958 by Cheng Shao at 2024-04-25T01:32:02-04:00 autoconf: remove obsolete patch detection This commit removes obsolete deletection logic of the patch command from autoconf scripts, given we no longer need to patch anything in the GHC build process. - - - - - daeda834 by Sylvain Henry at 2024-04-25T01:32:43-04:00 JS: correctly handle RUBBISH literals (#24664) - - - - - 8a06ddf6 by Matthew Pickering at 2024-04-25T11:16:16-04:00 Linearise ghc-internal and base build This is achieved by requesting the final package database for ghc-internal, which mandates it is fully built as a dependency of configuring the `base` package. This is at the expense of cross-package parrallelism between ghc-internal and the base package. Fixes #24436 - - - - - 94da9365 by Andrei Borzenkov at 2024-04-25T11:16:54-04:00 Fix tuple puns renaming (24702) Move tuple renaming short cutter from `isBuiltInOcc_maybe` to `isPunOcc_maybe`, so we consider incoming module. I also fixed some hidden bugs that raised after the change was done. - - - - - fa03b1fb by Fendor at 2024-04-26T18:03:13-04:00 Refactor the Binary serialisation interface The goal is simplifiy adding deduplication tables to `ModIface` interface serialisation. We identify two main points of interest that make this difficult: 1. UserData hardcodes what `Binary` instances can have deduplication tables. Moreover, it heavily uses partial functions. 2. GHC.Iface.Binary hardcodes the deduplication tables for 'Name' and 'FastString', making it difficult to add more deduplication. Instead of having a single `UserData` record with fields for all the types that can have deduplication tables, we allow to provide custom serialisers for any `Typeable`. These are wrapped in existentials and stored in a `Map` indexed by their respective `TypeRep`. The `Binary` instance of the type to deduplicate still needs to explicitly look up the decoder via `findUserDataReader` and `findUserDataWriter`, which is no worse than the status-quo. `Map` was chosen as microbenchmarks indicate it is the fastest for a small number of keys (< 10). To generalise the deduplication table serialisation mechanism, we introduce the types `ReaderTable` and `WriterTable` which provide a simple interface that is sufficient to implement a general purpose deduplication mechanism for `writeBinIface` and `readBinIface`. This allows us to provide a list of deduplication tables for serialisation that can be extended more easily, for example for `IfaceTyCon`, see the issue https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for more motivation. In addition to this refactoring, we split `UserData` into `ReaderUserData` and `WriterUserData`, to avoid partial functions and reduce overall memory usage, as we need fewer mutable variables. Bump haddock submodule to accomodate for `UserData` split. ------------------------- Metric Increase: MultiLayerModulesTH_Make MultiLayerModulesRecomp T21839c ------------------------- - - - - - bac57298 by Fendor at 2024-04-26T18:03:13-04:00 Split `BinHandle` into `ReadBinHandle` and `WriteBinHandle` A `BinHandle` contains too much information for reading data. For example, it needs to keep a `FastMutInt` and a `IORef BinData`, when the non-mutable variants would suffice. Additionally, this change has the benefit that anyone can immediately tell whether the `BinHandle` is used for reading or writing. Bump haddock submodule BinHandle split. - - - - - 4d6394dd by Simon Peyton Jones at 2024-04-26T18:03:49-04:00 Fix missing escaping-kind check in tcPatSynSig Note [Escaping kind in type signatures] explains how we deal with escaping kinds in type signatures, e.g. f :: forall r (a :: TYPE r). a where the kind of the body is (TYPE r), but `r` is not in scope outside the forall-type. I had missed this subtlety in tcPatSynSig, leading to #24686. This MR fixes it; and a similar bug in tc_top_lhs_type. (The latter is tested by T24686a.) - - - - - 981c2c2c by Alan Zimmerman at 2024-04-26T18:04:25-04:00 EPA: check-exact: check that the roundtrip reproduces the source Closes #24670 - - - - - a8616747 by Andrew Lelechenko at 2024-04-26T18:05:01-04:00 Document that setEnv is not thread-safe - - - - - 1e41de83 by Bryan Richter at 2024-04-26T18:05:37-04:00 CI: Work around frequent Signal 9 errors - - - - - a6d5f9da by Naïm Favier at 2024-04-27T17:52:40-04:00 ghc-internal: add MonadFix instance for (,) Closes https://gitlab.haskell.org/ghc/ghc/-/issues/24288, implements CLC proposal https://github.com/haskell/core-libraries-committee/issues/238. Adds a MonadFix instance for tuples, permitting value recursion in the "native" writer monad and bringing consistency with the existing instance for transformers's WriterT (and, to a lesser extent, for Solo). - - - - - 64feadcd by Rodrigo Mesquita at 2024-04-27T17:53:16-04:00 bindist: Fix xattr cleaning The original fix (725343aa) was incorrect because it used the shell bracket syntax which is the quoting syntax in autoconf, making the test for existence be incorrect and therefore `xattr` was never run. Fixes #24554 - - - - - e2094df3 by damhiya at 2024-04-28T23:52:00+09:00 Make read accepts binary integer formats CLC proposal : https://github.com/haskell/core-libraries-committee/issues/177 - - - - - 1c2fd963 by Alan Zimmerman at 2024-04-29T23:17:00-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 - - - - - 4189d17e by Sylvain Henry at 2024-04-29T23:17:42-04:00 LLVM: better unreachable default destination in Switch (#24717) See added note. Co-authored-by: Siddharth Bhat <siddu.druid at gmail.com> - - - - - a3725c88 by Cheng Shao at 2024-04-29T23:18:20-04:00 ci: enable wasm jobs for MRs with wasm label This patch enables wasm jobs for MRs with wasm label. Previously the wasm label didn't actually have any effect on the CI pipeline, and full-ci needed to be applied to run wasm jobs which was a waste of runners when working on the wasm backend, hence the fix here. - - - - - 702f7964 by Matthew Pickering at 2024-04-29T23:18:56-04:00 Make interface files and object files depend on inplace .conf file A potential fix for #24737 - - - - - 728af21e by Cheng Shao at 2024-04-30T05:30:23-04:00 utils: remove obsolete vagrant scripts Vagrantfile has long been removed in !5288. This commit further removes the obsolete vagrant scripts in the tree. - - - - - 36f2c342 by Cheng Shao at 2024-04-30T05:31:00-04:00 Update autoconf scripts Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 - - - - - ecbf22a6 by Ben Gamari at 2024-04-30T05:31:36-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 64a51487 by Oleg Grenrus at 2024-05-03T00:00:38+03:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - 18 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - .gitmodules - CODEOWNERS - compiler/GHC.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/413e4e47c445d4fa3d72b3ccad23fc1b4ae83626...64a51487c811652270c7efe704ecc44cd141cb52 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/413e4e47c445d4fa3d72b3ccad23fc1b4ae83626...64a51487c811652270c7efe704ecc44cd141cb52 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 21:04:04 2024 From: gitlab at gitlab.haskell.org (Oleg Grenrus (@phadej)) Date: Thu, 02 May 2024 17:04:04 -0400 Subject: [Git][ghc/ghc][wip/T24245] 603 commits: Only exit ghci in -e mode when :add command fails Message-ID: <6633ffc4c41e7_1a3d244ed9c441750a0@gitlab.mail> Oleg Grenrus pushed to branch wip/T24245 at Glasgow Haskell Compiler / GHC Commits: d5610737 by Claudio Bley at 2023-12-06T16:13:33-05:00 Only exit ghci in -e mode when :add command fails Previously, when running `ghci -e ':add Sample.hs'` the process would exit with exit code 1 if the file exists and could be loaded. Fixes #24115 - - - - - 0f0c53a5 by Vladislav Zavialov at 2023-12-06T16:14:09-05:00 T2T in Patterns (#23739) This patch implements the T2T (term-to-type) transformation in patterns. Patterns that are checked against a visible forall can now be written without the `type` keyword: \(type t) (x :: t) -> ... -- old \t (x :: t) -> ... -- new The `t` binder is parsed and renamed as a term pattern (Pat), but then undergoes a conversion to a type pattern (HsTyPat). See the new function pat_to_type_pat in compiler/GHC/Tc/Gen/Pat.hs - - - - - 10a1a6c6 by Sebastian Graf at 2023-12-06T16:14:45-05:00 Pmc: Fix SrcLoc and warning for incomplete irrefutable pats (#24234) Before, the source location would point at the surrounding function definition, causing the confusion in #24234. I also took the opportunity to introduce a new `LazyPatCtx :: HsMatchContext _` to make the warning message say "irrefutable pattern" instead of "pattern binding". - - - - - 36b9a38c by Matthew Pickering at 2023-12-06T16:15:21-05:00 libraries: Bump filepath to 1.4.200.1 and unix to 2.8.4.0 Updates filepath submodule Updates unix submodule Fixes #24240 - - - - - 91ff0971 by Matthew Pickering at 2023-12-06T16:15:21-05:00 Submodule linter: Allow references to tags We modify the submodule linter so that if the bumped commit is a specific tag then the commit is accepted. Fixes #24241 - - - - - 86f652dc by Zubin Duggal at 2023-12-06T16:15:21-05:00 hadrian: set -Wno-deprecations for directory and Win32 The filepath bump to 1.4.200.1 introduces a deprecation warning. See https://gitlab.haskell.org/ghc/ghc/-/issues/24240 https://github.com/haskell/filepath/pull/206 - - - - - 7ac6006e by Sylvain Henry at 2023-12-06T16:16:02-05:00 Zap OccInfo on case binders during StgCse #14895 #24233 StgCse can revive dead binders: case foo of dead { Foo x y -> Foo x y; ... } ===> case foo of dead { Foo x y -> dead; ... } -- dead is no longer dead So we must zap occurrence information on case binders. Fix #14895 and #24233 - - - - - 57c391c4 by Sebastian Graf at 2023-12-06T16:16:37-05:00 Cpr: Turn an assertion into a check to deal with some dead code (#23862) See the new `Note [Dead code may contain type confusions]`. Fixes #23862. - - - - - c1c8abf8 by Zubin Duggal at 2023-12-08T02:25:07-05:00 testsuite: add test for #23944 - - - - - 6329d308 by Zubin Duggal at 2023-12-08T02:25:07-05:00 driver: Only run a dynamic-too pipeline if object files are going to be generated Otherwise we run into a panic in hscMaybeWriteIface: "Unexpected DT_Dyn state when writing simple interface" when dynamic-too is enabled We could remove the panic and just write the interface even if the state is `DT_Dyn`, but it seems pointless to run the pipeline twice when `hscMaybeWriteIface` is already designed to write both `hi` and `dyn_hi` files if dynamic-too is enabled. Fixes #23944. - - - - - 28811f88 by Simon Peyton Jones at 2023-12-08T05:47:18-05:00 Improve duplicate elimination in SpecConstr This partially fixes #24229. See the new Note [Pattern duplicate elimination] in SpecConstr - - - - - fec7894f by Simon Peyton Jones at 2023-12-08T05:47:18-05:00 Make SpecConstr deal with casts better This patch does two things, to fix #23209: * It improves SpecConstr so that it no longer quantifies over coercion variables. See Note [SpecConstr and casts] * It improves the rule matcher to deal nicely with the case where the rule does not quantify over coercion variables, but the the template has a cast in it. See Note [Casts in the template] - - - - - 8db8d2fd by Zubin Duggal at 2023-12-08T05:47:54-05:00 driver: Don't lose track of nodes when we fail to resolve cycles The nodes that take part in a cycle should include both hs-boot and hs files, but when we fail to resolve a cycle, we were only counting the nodes from the graph without boot files. Fixes #24196 - - - - - c5b4efd3 by Zubin Duggal at 2023-12-08T05:48:30-05:00 testsuite: Skip MultiLayerModulesTH_OneShot on darwin See #24177 - - - - - fae472a9 by Wendao Lee at 2023-12-08T05:49:12-05:00 docs(Data.Char):Add more detailed descriptions for some functions Related changed function's docs: -GHC.Unicode.isAlpha -GHC.Unicode.isPrint -GHC.Unicode.isAlphaNum Add more details for what the function will return. Co-authored-by: Bodigrim <andrew.lelechenko at gmail.com> - - - - - ca7510e4 by Malik Ammar Faisal at 2023-12-08T05:49:55-05:00 Fix float parsing in GHC Cmm Lexer Add test case for bug #24224 - - - - - d8baa1bd by Simon Peyton Jones at 2023-12-08T15:40:37+00:00 Take care when simplifying unfoldings This MR fixes a very subtle bug exposed by #24242. See Note [Environment for simplLetUnfolding]. I also updated a bunch of Notes on shadowing - - - - - 03ca551d by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Comments only in FloatIn Relevant to #3458 - - - - - 50c78779 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Comments only in SpecConstr - - - - - 9431e195 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Add test for #22238 - - - - - d9e4c597 by Vladislav Zavialov at 2023-12-11T04:19:34-05:00 Make forall a keyword (#23719) Before this change, GHC used to accept `forall` as a term-level identifier: -- from constraints-0.13 forall :: forall p. (forall a. Dict (p a)) -> Dict (Forall p) forall d = ... Now it is a parse error. The -Wforall-identifier warning has served its purpose and is now a deprecated no-op. - - - - - 58d56644 by Zubin Duggal at 2023-12-11T04:20:10-05:00 driver: Ensure we actually clear the interactive context before reloading Previously we called discardIC, but immediately after set the session back to an old HscEnv that still contained the IC Partially addresses #24107 Fixes #23405 - - - - - 8e5745a0 by Zubin Duggal at 2023-12-11T04:20:10-05:00 driver: Ensure we force the lookup of old build artifacts before returning the build plan This prevents us from retaining all previous build artifacts in memory until a recompile finishes, instead only retaining the exact artifacts we need. Fixes #24118 - - - - - 105c370c by Zubin Duggal at 2023-12-11T04:20:10-05:00 testsuite: add test for #24118 and #24107 MultiLayerModulesDefsGhci was not able to catch the leak because it uses :l which discards the previous environment. Using :r catches both of these leaks - - - - - e822ff88 by Zubin Duggal at 2023-12-11T04:20:10-05:00 compiler: Add some strictness annotations to ImportSpec and related constructors This prevents us from retaining entire HscEnvs. Force these ImportSpecs when forcing the GlobalRdrEltX Adds an NFData instance for Bag Fixes #24107 - - - - - 522c12a4 by Zubin Duggal at 2023-12-11T04:20:10-05:00 compiler: Force IfGlobalRdrEnv in NFData instance. - - - - - 188b280d by Arnaud Spiwack at 2023-12-11T15:33:31+01:00 LinearTypes => MonoLocalBinds - - - - - 8e0446df by Arnaud Spiwack at 2023-12-11T15:44:28+01:00 Linear let and where bindings For expediency, the initial implementation of linear types in GHC made it so that let and where binders would always be considered unrestricted. This was rather unpleasant, and probably a big obstacle to adoption. At any rate, this was not how the proposal was designed. This patch fixes this infelicity. It was surprisingly difficult to build, which explains, in part, why it took so long to materialise. As of this patch, let or where bindings marked with %1 will be linear (respectively %p for an arbitrary multiplicity p). Unmarked let will infer their multiplicity. Here is a prototypical example of program that used to be rejected and is accepted with this patch: ```haskell f :: A %1 -> B g :: B %1 -> C h :: A %1 -> C h x = g y where y = f x ``` Exceptions: - Recursive let are unrestricted, as there isn't a clear semantics of what a linear recursive binding would be. - Destructive lets with lazy bindings are unrestricted, as their desugaring isn't linear (see also #23461). - (Strict) destructive lets with inferred polymorphic type are unrestricted. Because the desugaring isn't linear (See #18461 down-thread). Closes #18461 and #18739 Co-authored-by: @jackohughes - - - - - effa7e2d by Matthew Craven at 2023-12-12T04:37:20-05:00 Introduce `dataToTagSmall#` primop (closes #21710) ...and use it to generate slightly better code when dataToTag# is used at a "small data type" where there is no need to mess with "is_too_big_tag" or potentially look at an info table. Metric Decrease: T18304 - - - - - 35c7aef6 by Matthew Craven at 2023-12-12T04:37:20-05:00 Fix formatting of Note [alg-alt heap check] - - - - - 7397c784 by Oleg Grenrus at 2023-12-12T04:37:56-05:00 Allow untyped brackets in typed splices and vice versa. Resolves #24190 Apparently the check was essentially always (as far as I can trace back: d0d47ba76f8f0501cf3c4966bc83966ab38cac27), and while it does catch some mismatches, the type-checker will catch them too. OTOH, it prevents writing completely reasonable programs. - - - - - a3ee3b99 by Moritz Angermann at 2023-12-12T19:50:58-05:00 Drop hard Xcode dependency XCODE_VERSION calls out to `xcodebuild`, which is only available when having `Xcode` installed. The CommandLineTools are not sufficient. To install Xcode, you must have an apple id to download the Xcode.xip from apple. We do not use xcodebuild anywhere in our build explicilty. At best it appears to be a proxy for checking the linker or the compiler. These should rather be done with ``` xcrun ld -version ``` or similar, and not by proxy through Xcode. The CLR should be sufficient for building software on macOS. - - - - - 1c9496e0 by Vladislav Zavialov at 2023-12-12T19:51:34-05:00 docs: update information on RequiredTypeArguments Update the User's Guide and Release Notes to account for the recent progress in the implementation of RequiredTypeArguments. - - - - - d0b17576 by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Fix off-by-one in assertion Previously we failed to account for the NULL terminator `postString` asserted that there is enough room in the buffer for the string. - - - - - a10f9b9b by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Honor result of ensureRoomForVariableEvent is Previously we would keep plugging along, even if isn't enough room for the event. - - - - - 0e0f41c0 by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Avoid truncating event sizes Previously ensureRoomForVariableEvent would truncate the desired size to 16-bits, resulting in #24197. Fixes #24197. - - - - - 64e724c8 by Artin Ghasivand at 2023-12-13T06:34:20-05:00 Remove the "Derived Constraint" argument of TcPluginSolver, docs - - - - - fe6d97dd by Vladislav Zavialov at 2023-12-13T06:34:56-05:00 EPA: Move tokens into GhcPs extension fields (#23447) Summary of changes * Remove Language.Haskell.Syntax.Concrete * Move all tokens into GhcPs extension fields (LHsToken -> EpToken) * Create new TTG extension fields as needed * Drop the MultAnn wrapper Updates the haddock submodule. Co-authored-by: Alan Zimmerman <alan.zimm at gmail.com> - - - - - 8106e695 by Zubin Duggal at 2023-12-13T06:35:34-05:00 testsuite: use copy_files in T23405 This prevents the tree from being dirtied when the file is modified. - - - - - ed0e4099 by Bryan Richter at 2023-12-14T04:30:53-05:00 Document ghc package's PVP-noncompliance This changes nothing, it just makes the status quo explicit. - - - - - 8bef8d9f by Luite Stegeman at 2023-12-14T04:31:33-05:00 JS: Mark spurious CI failures js_fragile(24259) This marks the spurious test failures on the JS platform as js_fragile(24259), so we don't hold up merge requests while fixing the underlying issues. See #24259 - - - - - 1c79526a by Finley McIlwaine at 2023-12-15T12:24:40-08:00 Late plugins - - - - - 000c3302 by Finley McIlwaine at 2023-12-15T12:24:40-08:00 withTiming on LateCCs and late plugins - - - - - be4551ac by Finley McIlwaine at 2023-12-15T12:24:40-08:00 add test for late plugins - - - - - 7c29da9f by Finley McIlwaine at 2023-12-15T12:24:40-08:00 Document late plugins - - - - - 9a52ae46 by Ben Gamari at 2023-12-20T07:07:26-05:00 Fix thunk update ordering Previously we attempted to ensure soundness of concurrent thunk update by synchronizing on the access of the thunk's info table pointer field. This was believed to be sufficient since the indirectee (which may expose a closure allocated by another core) would not be examined until the info table pointer update is complete. However, it turns out that this can result in data races in the presence of multiple threads racing a update a single thunk. For instance, consider this interleaving under the old scheme: Thread A Thread B --------- --------- t=0 Enter t 1 Push update frame 2 Begin evaluation 4 Pause thread 5 t.indirectee=tso 6 Release t.info=BLACKHOLE 7 ... (e.g. GC) 8 Resume thread 9 Finish evaluation 10 Relaxed t.indirectee=x 11 Load t.info 12 Acquire fence 13 Inspect t.indirectee 14 Release t.info=BLACKHOLE Here Thread A enters thunk `t` but is soon paused, resulting in `t` being lazily blackholed at t=6. Then, at t=10 Thread A finishes evaluation and updates `t.indirectee` with a relaxed store. Meanwhile, Thread B enters the blackhole. Under the old scheme this would introduce an acquire-fence but this would only synchronize with Thread A at t=6. Consequently, the result of the evaluation, `x`, is not visible to Thread B, introducing a data race. We fix this by treating the `indirectee` field as we do all other mutable fields. This means we must always access this field with acquire-loads and release-stores. See #23185. - - - - - f4b53538 by Vladislav Zavialov at 2023-12-20T07:08:02-05:00 docs: Fix link to 051-ghc-base-libraries.rst The proposal is no longer available at the previous URL. - - - - - f7e21fab by Matthew Pickering at 2023-12-21T14:57:40+00:00 hadrian: Build all executables in bin/ folder In the end the bindist creation logic copies them all into the bin folder. There is no benefit to building a specific few binaries in the lib/bin folder anymore. This also removes the ad-hoc logic to copy the touchy and unlit executables from stage0 into stage1. It takes <1s to build so we might as well just build it. - - - - - 0038d052 by Zubin Duggal at 2023-12-22T23:28:00-05:00 testsuite: mark jspace as fragile on i386. This test has been flaky for some time and has been failing consistently on i386-linux since 8e0446df landed. See #24261 - - - - - dfd670a0 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 609e6225 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 865513b2 by Ömer Sinan Ağacan at 2023-12-24T10:11:13-05:00 Fix BNF in user manual 6.6.8.2: formal syntax for instance declarations - - - - - c247b6be by Zubin Duggal at 2023-12-25T16:01:23-05:00 docs: document permissibility of -XOverloadedLabels (#24249) Document the permissibility introduced by https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - e5b7eb59 by Ömer Sinan Ağacan at 2023-12-25T16:02:03-05:00 Fix a code block syntax in user manual sec. 6.8.8.6 - - - - - 2db11c08 by Ben Gamari at 2023-12-29T15:35:48-05:00 genSym: Reimplement via CAS on 32-bit platforms Previously the remaining use of the C implementation on 32-bit platforms resulted in a subtle bug, #24261. This was due to the C object (which used the RTS's `atomic_inc64` macro) being compiled without `-threaded` yet later being used in a threaded compiler. Side-step this issue by using the pure Haskell `genSym` implementation on all platforms. This required implementing `fetchAddWord64Addr#` in terms of CAS on 64-bit platforms. - - - - - 19328a8c by Xiaoyan Ren at 2023-12-29T15:36:30-05:00 Do not color the diagnostic code in error messages (#24172) - - - - - 685b467c by Krzysztof Gogolewski at 2023-12-29T15:37:06-05:00 Enforce that bindings of implicit parameters are lifted Fixes #24298 - - - - - bc4d67b7 by Matthew Craven at 2023-12-31T06:15:42-05:00 StgToCmm: Detect some no-op case-continuations ...and generate no code for them. Fixes #24264. - - - - - 5b603139 by Krzysztof Gogolewski at 2023-12-31T06:16:18-05:00 Revert "testsuite: mark jspace as fragile on i386." This reverts commit 0038d052c8c80b4b430bb2aa1c66d5280be1aa95. The atomicity bug should be fixed by !11802. - - - - - d55216ad by Krzysztof Gogolewski at 2024-01-01T12:05:49-05:00 Refactor: store [[PrimRep]] rather than [Type] in STG StgConApp stored a list of types. This list was used exclusively during unarisation of unboxed sums (mkUbxSum). However, this is at a wrong level of abstraction: STG shouldn't be concerned with Haskell types, only PrimReps. Update the code to store a [[PrimRep]]. Also, there's no point in storing this list when we're not dealing with an unboxed sum. - - - - - 8b340bc7 by Ömer Sinan Ağacan at 2024-01-01T12:06:29-05:00 Kind signatures docs: mention that they're allowed in newtypes - - - - - 989bf8e5 by Zubin Duggal at 2024-01-03T20:08:47-05:00 ci: Ensure we use the correct bindist name for the test artifact when generating release ghcup metadata Fixes #24268 - - - - - 89299a89 by Krzysztof Gogolewski at 2024-01-03T20:09:23-05:00 Refactor: remove calls to typePrimRepArgs The function typePrimRepArgs is just a thin wrapper around typePrimRep, adding a VoidRep if the list is empty. However, in StgToByteCode, we were discarding that VoidRep anyway, so there's no point in calling it. - - - - - c7be0c68 by mmzk1526 at 2024-01-03T20:10:07-05:00 Use "-V" for alex version check for better backward compatibility Fixes #24302. In recent versions of alex, "-v" is used for "--verbose" instead of "-version". - - - - - 67dbcc0a by Krzysztof Gogolewski at 2024-01-05T02:07:18-05:00 Fix VoidRep handling in ghci debugger 'go' inside extractSubTerms was giving a bad result given a VoidRep, attempting to round towards the next multiple of 0. I don't understand much about the debugger but the code should be better than it was. Fixes #24306 - - - - - 90ea574e by Krzysztof Gogolewski at 2024-01-05T02:07:54-05:00 VoidRep-related refactor * In GHC.StgToByteCode, replace bcIdPrimId with idPrimRep, bcIdArgRep with idArgRep, atomPrimRep with stgArgRep1. All of them were duplicates. * In GHC.Stg.Unarise, we were converting a PrimRep to a Type and back to PrimRep. Remove the calls to primRepToType and typePrimRep1 which cancel out. * In GHC.STG.Lint, GHC.StgToCmm, GHC.Types.RepType we were filtering out VoidRep from the result of typePrimRep. But typePrimRep never returns VoidRep - remove the filtering. - - - - - eaf72479 by brian at 2024-01-06T23:03:09-05:00 Add unaligned Addr# primops Implements CLC proposal #154: https://github.com/haskell/core-libraries-committee/issues/154 * add unaligned addr primops * add tests * accept tests * add documentation * fix js primops * uncomment in access ops * use Word64 in tests * apply suggestions * remove extra file * move docs * remove random options * use setByteArray# primop * better naming * update base-exports test * add base-exports for other architectures - - - - - d471d445 by Krzysztof Gogolewski at 2024-01-06T23:03:47-05:00 Remove VoidRep from PrimRep, introduce PrimOrVoidRep This introduces data PrimOrVoidRep = VoidRep | NVRep PrimRep changes typePrimRep1 to return PrimOrVoidRep, and adds a new function typePrimRepU to be used when the argument is definitely non-void. Details in Note [VoidRep] in GHC.Types.RepType. Fixes #19520 - - - - - 48720a07 by Matthew Craven at 2024-01-08T18:57:36-05:00 Apply Note [Sensitivity to unique increment] to LargeRecord - - - - - 9e2e180f by Sebastian Graf at 2024-01-08T18:58:13-05:00 Debugging: Add diffUFM for convenient diffing between UniqFMs - - - - - 948f3e35 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Rename Opt_D_dump_stranal to Opt_D_dump_dmdanal ... and Opt_D_dump_str_signatures to Opt_D_dump_dmd_signatures - - - - - 4e217e3e by Sebastian Graf at 2024-01-08T18:58:13-05:00 Deprecate -ddump-stranal and -ddump-str-signatures ... and suggest -ddump-dmdanal and -ddump-dmd-signatures instead - - - - - 6c613c90 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Move testsuite/tests/stranal to testsuite/tests/dmdanal A separate commit so that the rename is obvious to Git(Lab) - - - - - c929f02b by Sebastian Graf at 2024-01-08T18:58:13-05:00 CoreSubst: Stricten `substBndr` and `cloneBndr` Doing so reduced allocations of `cloneBndr` by about 25%. ``` T9233(normal) ghc/alloc 672,488,656 663,083,216 -1.4% GOOD T9675(optasm) ghc/alloc 423,029,256 415,812,200 -1.7% geo. mean -0.1% minimum -1.7% maximum +0.1% ``` Metric Decrease: T9233 - - - - - e3ca78f3 by Krzysztof Gogolewski at 2024-01-10T17:35:59-05:00 Deprecate -Wsemigroup This warning was used to prepare for Semigroup becoming a superclass of Monoid, and for (<>) being exported from Prelude. This happened in GHC 8.4 in 8ae263ceb3566 and feac0a3bc69fd3. The leftover logic for (<>) has been removed in GHC 9.8, 4d29ecdfcc79. Now the warning does nothing at all and can be deprecated. - - - - - 08d14925 by amesgen at 2024-01-10T17:36:42-05:00 WASM metadata: use correct GHC version - - - - - 7a808419 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Allow SCC declarations in TH (#24081) - - - - - 28827c51 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Fix prettyprinting of SCC pragmas - - - - - ae9cc1a8 by Matthew Craven at 2024-01-10T17:38:01-05:00 Fix loopification in the presence of void arguments This also removes Note [Void arguments in self-recursive tail calls], which was just misleading. It's important to count void args both in the function's arity and at the call site. Fixes #24295. - - - - - b718b145 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: Teach testsuite driver about c++ sources - - - - - 09cb57ad by Zubin Duggal at 2024-01-10T17:38:36-05:00 driver: Set -DPROFILING when compiling C++ sources with profiling Earlier, we used to pass all preprocessor flags to the c++ compiler. This meant that -DPROFILING was passed to the c++ compiler because it was a part of C++ flags However, this was incorrect and the behaviour was changed in 8ff3134ed4aa323b0199ad683f72165e51a59ab6. See #21291. But that commit exposed this bug where -DPROFILING was no longer being passed when compiling c++ sources. The fix is to explicitly include -DPROFILING in `opt_cxx` when profiling is enabled to ensure we pass the correct options for the way to both C and C++ compilers Fixes #24286 - - - - - 2cf9dd96 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: rename objcpp -> objcxx To avoid confusion with C Pre Processsor - - - - - af6932d6 by Simon Peyton Jones at 2024-01-10T17:39:12-05:00 Make TYPE and CONSTRAINT not-apart Issue #24279 showed up a bug in the logic in GHC.Core.Unify.unify_ty which is supposed to make TYPE and CONSTRAINT be not-apart. Easily fixed. - - - - - 4a39b5ff by Zubin Duggal at 2024-01-10T17:39:48-05:00 ci: Fix typo in mk_ghcup_metadata.py There was a missing colon in the fix to #24268 in 989bf8e53c08eb22de716901b914b3607bc8dd08 - - - - - 13503451 by Zubin Duggal at 2024-01-10T17:40:24-05:00 release-ci: remove release-x86_64-linux-deb11-release+boot_nonmoving_gc job There is no reason to have this release build or distribute this variation. This configuration is for testing purposes only. - - - - - afca46a4 by Sebastian Graf at 2024-01-10T17:41:00-05:00 Parser: Add a Note detailing why we need happy's `error` to implement layout - - - - - eaf8a06d by Krzysztof Gogolewski at 2024-01-11T00:43:17+01:00 Turn -Wtype-equality-out-of-scope on by default Also remove -Wnoncanonical-{monoid,monad}-instances from -Wcompat, since they are enabled by default. Refresh wcompat-warnings/ test with new -Wcompat warnings. Part of #24267 Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 42bee5aa by Sebastian Graf at 2024-01-12T21:16:21-05:00 Arity: Require called *exactly once* for eta exp with -fpedantic-bottoms (#24296) In #24296, we had a program in which we eta expanded away an error despite the presence of `-fpedantic-bottoms`. This was caused by turning called *at least once* lambdas into one-shot lambdas, while with `-fpedantic-bottoms` it is only sound to eta expand over lambdas that are called *exactly* once. An example can be found in `Note [Combining arity type with demand info]`. Fixes #24296. - - - - - 7e95f738 by Andreas Klebinger at 2024-01-12T21:16:57-05:00 Aarch64: Enable -mfma by default. Fixes #24311 - - - - - e43788d0 by Jason Shipman at 2024-01-14T12:47:38-05:00 Add more instances for Compose: Fractional, RealFrac, Floating, RealFloat CLC proposal #226 https://github.com/haskell/core-libraries-committee/issues/226 - - - - - ae6d8cd2 by Sebastian Graf at 2024-01-14T12:48:15-05:00 Pmc: COMPLETE pragmas associated with Family TyCons should apply to representation TyCons as well (#24326) Fixes #24326. - - - - - c5fc7304 by sheaf at 2024-01-15T14:15:29-05:00 Use lookupOccRn_maybe in TH.lookupName When looking up a value, we want to be able to find both variables and record fields. So we should not use the lookupSameOccRn_maybe function, as we can't know ahead of time which record field namespace a record field with the given textual name will belong to. Fixes #24293 - - - - - da908790 by Krzysztof Gogolewski at 2024-01-15T14:16:05-05:00 Make the build more strict on documentation errors * Detect undefined labels. This can be tested by adding :ref:`nonexistent` to a documentation rst file; attempting to build docs will fail. Fixed the undefined label in `9.8.1-notes.rst`. * Detect errors. While we have plenty of warnings, we can at least enforce that Sphinx does not report errors. Fixed the error in `required_type_arguments.rst`. Unrelated change: I have documented that the `-dlint` enables `-fcatch-nonexhaustive-cases`, as can be verified by checking `enableDLint`. - - - - - 5077416e by Javier Sagredo at 2024-01-16T15:40:06-05:00 Profiling: Adds an option to not start time profiling at startup Using the functionality provided by d89deeba47ce04a5198a71fa4cbc203fe2c90794, this patch creates a new rts flag `--no-automatic-time-samples` which disables the time profiling when starting a program. It is then expected that the user starts it whenever it is needed. Fixes #24337 - - - - - 5776008c by Matthew Pickering at 2024-01-16T15:40:42-05:00 eventlog: Fix off-by-one error in postIPE We were missing the extra_comma from the calculation of the size of the payload of postIPE. This was causing assertion failures when the event would overflow the buffer by one byte, as ensureRoomForVariable event would report there was enough space for `n` bytes but then we would write `n + 1` bytes into the buffer. Fixes #24287 - - - - - 66dc09b1 by Simon Peyton Jones at 2024-01-16T15:41:18-05:00 Improve SpecConstr (esp nofib/spectral/ansi) This MR makes three improvements to SpecConstr: see #24282 * It fixes an outright (and recently-introduced) bug in `betterPat`, which was wrongly forgetting to compare the lengths of the argument lists. * It enhances ConVal to inclue a boolean for work-free-ness, so that the envt can contain non-work-free constructor applications, so that we can do more: see Note [ConVal work-free-ness] * It rejigs `subsumePats` so that it doesn't reverse the list. This can make a difference because, when patterns overlap, we arbitrarily pick the first. There is no "right" way, but this retains the old pre-subsumePats behaviour, thereby "fixing" the regression in #24282. Nofib results +======================================== | spectral/ansi -21.14% | spectral/hartel/comp_lab_zift -0.12% | spectral/hartel/parstof +0.09% | spectral/last-piece -2.32% | spectral/multiplier +6.03% | spectral/para +0.60% | spectral/simple -0.26% +======================================== | geom mean -0.18% +---------------------------------------- The regression in `multiplier` is sad, but it simply replicates GHC's previous behaviour (e.g. GHC 9.6). - - - - - 65da79b3 by Matthew Pickering at 2024-01-16T15:41:54-05:00 hadrian: Reduce Cabal verbosity The comment claims that `simpleUserHooks` decrease verbosity, and it does, but only for the `postConf` phase. The other phases are too verbose with `-V`. At the moment > 5000 lines of the build log are devoted to output from `cabal copy`. So I take the simple approach and just decrease the verbosity level again. If the output of `postConf` is essential then it would be better to implement our own `UserHooks` which doesn't decrease the verbosity for `postConf`. Fixes #24338 - - - - - 16414d7d by Matthew Pickering at 2024-01-17T10:54:59-05:00 Stop retaining old ModGuts throughout subsequent simplifier phases Each phase of the simplifier typically rewrites the majority of ModGuts, so we want to be able to release the old ModGuts as soon as possible. `name_ppr_ctxt` lives throught the whole optimiser phase and it was retaining a reference to `ModGuts`, so we were failing to release the old `ModGuts` until the end of the phase (potentially doubling peak memory usage for that particular phase). This was discovered using eras profiling (#24332) Fixes #24328 - - - - - 7f0879e1 by Matthew Pickering at 2024-01-17T10:55:35-05:00 Update nofib submodule - - - - - 320454d3 by Cheng Shao at 2024-01-17T23:02:40+00:00 ci: bump ci-images for updated wasm image - - - - - 2eca52b4 by Cheng Shao at 2024-01-17T23:06:44+00:00 base: treat all FDs as "nonblocking" on wasm On posix platforms, when performing read/write on FDs, we check the nonblocking flag first. For FDs without this flag (e.g. stdout), we call fdReady() first, which in turn calls poll() to wait for I/O to be available on that FD. This is problematic for wasm32-wasi: although select()/poll() is supported via the poll_oneoff() wasi syscall, that syscall is rather heavyweight and runtime behavior differs in different wasi implementations. The issue is even worse when targeting browsers, given there's no satisfactory way to implement async I/O as a synchronous syscall, so existing JS polyfills for wasi often give up and simply return ENOSYS. Before we have a proper I/O manager that avoids poll_oneoff() for async I/O on wasm, this patch improves the status quo a lot by merely pretending all FDs are "nonblocking". Read/write on FDs will directly invoke read()/write(), which are much more reliably handled in existing wasi implementations, especially those in browsers. Fixes #23275 and the following test cases: T7773 isEOF001 openFile009 T4808 cgrun025 Approved by CLC proposal #234: https://github.com/haskell/core-libraries-committee/issues/234 - - - - - 83c6c710 by Andrew Lelechenko at 2024-01-18T05:21:49-05:00 base: clarify how to disable warnings about partiality of Data.List.{head,tail} - - - - - c4078f2f by Simon Peyton Jones at 2024-01-18T05:22:25-05:00 Fix four bug in handling of (forall cv. body_ty) These bugs are all described in #24335 It's not easy to provoke the bug, hence no test case. - - - - - 119586ea by Alexis King at 2024-01-19T00:08:00-05:00 Always refresh profiling CCSes after running pending initializers Fixes #24171. - - - - - 9718d970 by Oleg Grenrus at 2024-01-19T00:08:36-05:00 Set default-language: GHC2021 in ghc library Go through compiler/ sources, and remove all BangPatterns (and other GHC2021 enabled extensions in these files). - - - - - 3ef71669 by Matthew Pickering at 2024-01-19T21:55:16-05:00 testsuite: Remove unused have_library function Also remove the hence unused testsuite option `--test-package-db`. Fixes #24342 - - - - - 5b7fa20c by Jade at 2024-01-19T21:55:53-05:00 Fix Spelling in the compiler Tracking: #16591 - - - - - 09875f48 by Matthew Pickering at 2024-01-20T12:20:44-05:00 testsuite: Implement `isInTreeCompiler` in a more robust way Just a small refactoring to avoid redundantly specifying the same strings in two different places. - - - - - 0d12b987 by Jade at 2024-01-20T12:21:20-05:00 Change maintainer email from cvs-ghc at haskell.org to ghc-devs at haskell.org. Fixes #22142 - - - - - 1fa1c00c by Jade at 2024-01-23T19:17:03-05:00 Enhance Documentation of functions exported by Data.Function This patch aims to improve the documentation of functions exported in Data.Function Tracking: #17929 Fixes: #10065 - - - - - ab47a43d by Jade at 2024-01-23T19:17:39-05:00 Improve documentation of hGetLine. - Add explanation for whether a newline is returned - Add examples Fixes #14804 - - - - - dd4af0e5 by Cheng Shao at 2024-01-23T19:18:17-05:00 Fix genapply for cross-compilation by nuking fragile CPP logic This commit fixes incorrectly built genapply when cross compiling (#24347) by nuking all fragile CPP logic in it from the orbit. All target-specific info are now read from DerivedConstants.h at runtime, see added note for details. Also removes a legacy Makefile and adds haskell language server support for genapply. - - - - - 0cda2b8b by Cheng Shao at 2024-01-23T19:18:17-05:00 rts: enable wasm32 register mapping The wasm backend didn't properly make use of all Cmm global registers due to #24347. Now that it is fixed, this patch re-enables full register mapping for wasm32, and we can now generate smaller & faster wasm modules that doesn't always spill arguments onto the stack. Fixes #22460 #24152. - - - - - 0325a6e5 by Greg Steuck at 2024-01-24T01:29:44-05:00 Avoid utf8 in primops.txt.pp comments They don't make it through readFile' without explicitly setting the encoding. See https://gitlab.haskell.org/ghc/ghc/-/issues/17755 - - - - - 1aaf0bd8 by David Binder at 2024-01-24T01:30:20-05:00 Bump hpc and hpc-bin submodule Bump hpc to 0.7.0.1 Bump hpc-bin to commit d1780eb2 - - - - - e693a4e8 by Ben Gamari at 2024-01-24T01:30:56-05:00 testsuite: Ignore stderr in T8089 Otherwise spurious "Killed: 9" messages to stderr may cause the test to fail. Fixes #24361. - - - - - a40f4ab2 by sheaf at 2024-01-24T14:04:33-05:00 Fix FMA instruction on LLVM We were emitting the wrong instructions for fused multiply-add operations on LLVM: - the instruction name is "llvm.fma.f32" or "llvm.fma.f64", not "fmadd" - LLVM does not support other instructions such as "fmsub"; instead we implement these by flipping signs of some arguments - the instruction is an LLVM intrinsic, which requires handling it like a normal function call instead of a machine instruction Fixes #24223 - - - - - 69abc786 by Andrei Borzenkov at 2024-01-24T14:05:09-05:00 Add changelog entry for renaming tuples from (,,...,,) to Tuple<n> (24291) - - - - - 0ac8f385 by Cheng Shao at 2024-01-25T00:27:48-05:00 compiler: remove unused GHC.Linker module The GHC.Linker module is empty and unused, other than as a hack for the make build system. We can remove it now that make is long gone; the note is moved to GHC.Linker.Loader instead. - - - - - 699da01b by Hécate Moonlight at 2024-01-25T00:28:27-05:00 Clarification for newtype constructors when using `coerce` - - - - - b2d8cd85 by Matt Walker at 2024-01-26T09:50:08-05:00 Fix #24308 Add tests for semicolon separated where clauses - - - - - 0da490a1 by Ben Gamari at 2024-01-26T17:34:41-05:00 hsc2hs: Bump submodule - - - - - 3f442fd2 by Ben Gamari at 2024-01-26T17:34:41-05:00 Bump containers submodule to 0.7 - - - - - 82a1c656 by Sebastian Nagel at 2024-01-29T02:32:40-05:00 base: with{Binary}File{Blocking} only annotates own exceptions Fixes #20886 This ensures that inner, unrelated exceptions are not misleadingly annotated with the opened file. - - - - - 9294a086 by Andreas Klebinger at 2024-01-29T02:33:15-05:00 Fix fma warning when using llvm on aarch64. On aarch64 fma is always on so the +fma flag doesn't exist for that target. Hence no need to try and pass +fma to llvm. Fixes #24379 - - - - - ced2e731 by sheaf at 2024-01-29T17:27:12-05:00 No shadowing warnings for NoFieldSelector fields This commit ensures we don't emit shadowing warnings when a user shadows a field defined with NoFieldSelectors. Fixes #24381 - - - - - 8eeadfad by Patrick at 2024-01-29T17:27:51-05:00 Fix bug wrong span of nested_doc_comment #24378 close #24378 1. Update the start position of span in `nested_doc_comment` correctly. and hence the spans of identifiers of haddoc can be computed correctly. 2. add test `HaddockSpanIssueT24378`. - - - - - a557580f by Alexey Radkov at 2024-01-30T19:41:52-05:00 Fix irrelevant dodgy-foreign-imports warning on import f-pointers by value A test *сс018* is attached (not sure about the naming convention though). Note that without the fix, the test fails with the *dodgy-foreign-imports* warning passed to stderr. The warning disappears after the fix. GHC shouldn't warn on imports of natural function pointers from C by value (which is feasible with CApiFFI), such as ```haskell foreign import capi "cc018.h value f" f :: FunPtr (Int -> IO ()) ``` where ```c void (*f)(int); ``` See a related real-world use-case [here](https://gitlab.com/daniel-casanueva/pcre-light/-/merge_requests/17). There, GHC warns on import of C function pointer `pcre_free`. - - - - - ca99efaf by Alexey Radkov at 2024-01-30T19:41:53-05:00 Rename test cc018 -> T24034 - - - - - 88c38dd5 by Ben Gamari at 2024-01-30T19:42:28-05:00 rts/TraverseHeap.c: Ensure that PosixSource.h is included first - - - - - ca2e919e by Simon Peyton Jones at 2024-01-31T09:29:45+00:00 Make decomposeRuleLhs a bit more clever This fixes #24370 by making decomposeRuleLhs undertand dictionary /functions/ as well as plain /dictionaries/ - - - - - 94ce031d by Teo Camarasu at 2024-02-01T05:49:49-05:00 doc: Add -Dn flag to user guide Resolves #24394 - - - - - 31553b11 by Ben Gamari at 2024-02-01T12:21:29-05:00 cmm: Introduce MO_RelaxedRead In hand-written Cmm it can sometimes be necessary to atomically load from memory deep within an expression (e.g. see the `CHECK_GC` macro). This MachOp provides a convenient way to do so without breaking the expression into multiple statements. - - - - - 0785cf81 by Ben Gamari at 2024-02-01T12:21:29-05:00 codeGen: Use relaxed accesses in ticky bumping - - - - - be423dda by Ben Gamari at 2024-02-01T12:21:29-05:00 base: use atomic write when updating timer manager - - - - - 8a310e35 by Ben Gamari at 2024-02-01T12:21:29-05:00 Use relaxed atomics to manipulate TSO status fields - - - - - d6809ee4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Add necessary barriers when manipulating TSO owner - - - - - 39e3ac5d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Use `switch` to branch on why_blocked This is a semantics-preserving refactoring. - - - - - 515eb33d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix synchronization on thread blocking state We now use a release barrier whenever we update a thread's blocking state. This required widening StgTSO.why_blocked as AArch64 does not support atomic writes on 16-bit values. - - - - - eb38812e by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadPaused This only affects an assertion in the debug RTS and only needs relaxed ordering. - - - - - 26c48dd6 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadStatus# - - - - - 6af43ab4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in Interpreter's preemption check - - - - - 9502ad3c by Ben Gamari at 2024-02-01T12:21:29-05:00 rts/Messages: Fix data race - - - - - 60802db5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts/Prof: Fix data race - - - - - ef8ccef5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use relaxed ordering on dirty/clean info tables updates When changing the dirty/clean state of a mutable object we needn't have any particular ordering. - - - - - 76fe2b75 by Ben Gamari at 2024-02-01T12:21:30-05:00 codeGen: Use relaxed-read in closureInfoPtr - - - - - a6316eb4 by Ben Gamari at 2024-02-01T12:21:30-05:00 STM: Use acquire loads when possible Full sequential consistency is not needed here. - - - - - 6bddfd3d by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use fence rather than redundant load Previously we would use an atomic load to ensure acquire ordering. However, we now have `ACQUIRE_FENCE_ON`, which allows us to express this more directly. - - - - - 55c65dbc by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Fix data races in profiling timer - - - - - 856b5e75 by Ben Gamari at 2024-02-01T12:21:30-05:00 Add Note [C11 memory model] - - - - - 6534da24 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: move generic cmm optimization logic in NCG to a standalone module This commit moves GHC.CmmToAsm.cmmToCmm to a standalone module, GHC.Cmm.GenericOpt. The main motivation is enabling this logic to be run in the wasm backend NCG code, which is defined in other modules that's imported by GHC.CmmToAsm, causing a cyclic dependency issue. - - - - - 87e34888 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: explicitly disable PIC in wasm32 NCG This commit explicitly disables the ncgPIC flag for the wasm32 target. The wasm backend doesn't support PIC for the time being. - - - - - c6ce242e by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: enable generic cmm optimizations in wasm backend NCG This commit enables the generic cmm optimizations in other NCGs to be run in the wasm backend as well, followed by a late cmm control-flow optimization pass. The added optimizations do catch some corner cases not handled by the pre-NCG cmm pipeline and are useful in generating smaller CFGs. - - - - - 151dda4e by Andrei Borzenkov at 2024-02-01T12:22:43-05:00 Namespacing for WARNING/DEPRECATED pragmas (#24396) New syntax for WARNING and DEPRECATED pragmas was added, namely namespace specifierss: namespace_spec ::= 'type' | 'data' | {- empty -} warning ::= warning_category namespace_spec namelist strings deprecation ::= namespace_spec namelist strings A new data type was introduced to represent these namespace specifiers: data NamespaceSpecifier = NoSpecifier | TypeNamespaceSpecifier (EpToken "type") | DataNamespaceSpecifier (EpToken "data") Extension field XWarning now contains this NamespaceSpecifier. lookupBindGroupOcc function was changed: it now takes NamespaceSpecifier and checks that the namespace of the found names matches the passed flag. With this change {-# WARNING data D "..." #-} pragma will only affect value namespace and {-# WARNING type D "..." #-} will only affect type namespace. The same logic is applicable to DEPRECATED pragmas. Finding duplicated warnings inside rnSrcWarnDecls now takes into consideration NamespaceSpecifier flag to allow warnings with the same names that refer to different namespaces. - - - - - 38c3afb6 by Bryan Richter at 2024-02-01T12:23:19-05:00 CI: Disable the test-cabal-reinstall job Fixes #24363 - - - - - 27020458 by Matthew Craven at 2024-02-03T01:53:26-05:00 Bump bytestring submodule to something closer to 0.12.1 ...mostly so that 16d6b7e835ffdcf9b894e79f933dd52348dedd0c (which reworks unaligned writes in Builder) and the stuff in https://github.com/haskell/bytestring/pull/631 can see wider testing. The less-terrible code for unaligned writes used in Builder on hosts not known to be ulaigned-friendly also takes less effort for GHC to compile, resulting in a metric decrease for T21839c on some platforms. The metric increase on T21839r is caused by the unrelated commit 750dac33465e7b59100698a330b44de7049a345c. It perhaps warrants further analysis and discussion (see #23822) but is not critical. Metric Decrease: T21839c Metric Increase: T21839r - - - - - cdddeb0f by Rodrigo Mesquita at 2024-02-03T01:54:02-05:00 Work around autotools setting C11 standard in CC/CXX In autoconf >=2.70, C11 is set by default for $CC and $CXX via the -std=...11 flag. In this patch, we split the "-std" flag out of the $CC and $CXX variables, which we traditionally assume to be just the executable name/path, and move it to $CFLAGS/$CXXFLAGS instead. Fixes #24324 - - - - - 5ff7cc26 by Apoorv Ingle at 2024-02-03T13:14:46-06:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - The change is detailed in - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` - Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - Adds new datatypes: - `GHC.Hs.Expr.XXExprGhcRn`: new datatype makes this expansion work easier 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - Ensures warnings such as 1. Pattern match checks 2. Failable patterns 3. non-() return in body statements are preserved - Kill `HsMatchCtxt` in favor of `TcMatchAltChecker` - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) Also repoint haddock to the right submodule so that the test (haddockHypsrcTest) pass Metric Increase 'compile_time/bytes allocated': T9020 The testcase is a pathalogical example of a `do`-block with many statements that do nothing. Given that we are expanding the statements into function binds, we will have to bear a (small) 2% cost upfront in the compiler to unroll the statements. - - - - - 0df8ce27 by Vladislav Zavialov at 2024-02-04T03:55:14-05:00 Reduce parser allocations in allocateCommentsP In the most common case, the comment queue is empty, so we can skip the work of processing it. This reduces allocations by about 10% in the parsing001 test. Metric Decrease: MultiLayerModulesRecomp parsing001 - - - - - cfd68290 by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Stop dropping a case whose binder is demanded This MR fixes #24251. See Note [Case-to-let for strictly-used binders] in GHC.Core.Opt.Simplify.Iteration, plus #24251, for lots of discussion. Final Nofib changes over 0.1%: +----------------------------------------- | imaginary/digits-of-e2 -2.16% | imaginary/rfib -0.15% | real/fluid -0.10% | real/gamteb -1.47% | real/gg -0.20% | real/maillist +0.19% | real/pic -0.23% | real/scs -0.43% | shootout/n-body -0.41% | shootout/spectral-norm -0.12% +======================================== | geom mean -0.05% Pleasingly, overall executable size is down by just over 1%. Compile times (in perf/compiler) wobble around a bit +/- 0.5%, but the geometric mean is -0.1% which seems good. - - - - - e4d137bb by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Add Note [Bangs in Integer functions] ...to document the bangs in the functions in GHC.Num.Integer - - - - - ce90f12f by Andrei Borzenkov at 2024-02-05T17:59:09-05:00 Hide WARNING/DEPRECATED namespacing under -XExplicitNamespaces (#24396) - - - - - e2ea933f by Simon Peyton Jones at 2024-02-06T10:12:04-05:00 Refactoring in preparation for lazy skolemisation * Make HsMatchContext and HsStmtContext be parameterised over the function name itself, rather than over the pass. See [mc_fun field of FunRhs] in Language.Haskell.Syntax.Expr - Replace types HsMatchContext GhcPs --> HsMatchContextPs HsMatchContext GhcRn --> HsMatchContextRn HsMatchContext GhcTc --> HsMatchContextRn (sic! not Tc) HsStmtContext GhcRn --> HsStmtContextRn - Kill off convertHsMatchCtxt * Split GHC.Tc.Type.BasicTypes.TcSigInfo so that TcCompleteSig (describing a complete user-supplied signature) is its own data type. - Split TcIdSigInfo(CompleteSig, PartialSig) into TcCompleteSig(CSig) TcPartialSig(PSig) - Use TcCompleteSig in tcPolyCheck, CheckGen - Rename types and data constructors: TcIdSigInfo --> TcIdSig TcPatSynInfo(TPSI) --> TcPatSynSig(PatSig) - Shuffle around helper functions: tcSigInfoName (moved to GHC.Tc.Types.BasicTypes) completeSigPolyId_maybe (moved to GHC.Tc.Types.BasicTypes) tcIdSigName (inlined and removed) tcIdSigLoc (introduced) - Rearrange the pattern match in chooseInferredQuantifiers * Rename functions and types: tcMatchesCase --> tcCaseMatches tcMatchesFun --> tcFunBindMatches tcMatchLambda --> tcLambdaMatches tcPats --> tcMatchPats matchActualFunTysRho --> matchActualFunTys matchActualFunTySigma --> matchActualFunTy * Add HasDebugCallStack constraints to: mkBigCoreVarTupTy, mkBigCoreTupTy, boxTy, mkPiTy, mkPiTys, splitAppTys, splitTyConAppNoView_maybe * Use `penv` from the outer context in the inner loop of GHC.Tc.Gen.Pat.tcMultiple * Move tcMkVisFunTy, tcMkInvisFunTy, tcMkScaledFunTys down the file, factor out and export tcMkScaledFunTy. * Move isPatSigCtxt down the file. * Formatting and comments Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - f5d3e03c by Andrei Borzenkov at 2024-02-06T10:12:04-05:00 Lazy skolemisation for @a-binders (#17594) This patch is a preparation for @a-binders implementation. The main changes are: * Skolemisation is now prepared to deal with @binders. See Note [Skolemisation overview] in GHC.Tc.Utils.Unify. Most of the action is in - Utils.Unify.matchExpectedFunTys - Gen.Pat.tcMatchPats - Gen.Expr.tcPolyExprCheck - Gen.Binds.tcPolyCheck Some accompanying refactoring: * I found that funTyConAppTy_maybe was doing a lot of allocation, and rejigged userTypeError_maybe to avoid calling it. - - - - - 532993c8 by Zubin Duggal at 2024-02-06T10:12:41-05:00 driver: Really don't lose track of nodes when we fail to resolve cycles This fixes a bug in 8db8d2fd1c881032b1b360c032b6d9d072c11723, where we could lose track of acyclic components at the start of an unresolved cycle. We now ensure we never loose track of any of these components. As T24275 demonstrates, a "cyclic" SCC might not really be a true SCC: When viewed without boot files, we have a single SCC ``` [REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A [main:T24275A {-# SOURCE #-}]] ``` But with boot files this turns into ``` [NONREC main:T24275B {-# SOURCE #-} [], REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A {-# SOURCE #-} [main:T24275B], NONREC main:T24275A [main:T24275A {-# SOURCE #-}]] ``` Note that this is truly not an SCC, as no nodes are reachable from T24275B.hs-boot. However, we treat this entire group as a single "SCC" because it seems so when we analyse the graph without taking boot files into account. Indeed, we must return a single ResolvedCycle element in the BuildPlan for this as described in Note [Upsweep]. However, since after resolving this is not a true SCC anymore, `findCycle` fails to find a cycle and we have a sub-optimal error message as a result. To handle this, I extended `findCycle` to not assume its input is an SCC, and to try harder to find cycles in its input. Fixes #24275 - - - - - b35dd613 by Zubin Duggal at 2024-02-06T10:13:17-05:00 GHCi: Lookup breakpoint CCs in the correct module We need to look up breakpoint CCs in the module that the breakpoint points to, and not the current module. Fixes #24327 - - - - - b09e6958 by Zubin Duggal at 2024-02-06T10:13:17-05:00 testsuite: Add test for #24327 - - - - - 569b4c10 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add compile_artifact, ignore_extension flag In b521354216f2821e00d75f088d74081d8b236810 the testsuite gained the capability to collect generic metrics. But this assumed that the test was not linking and producing artifacts and we only wanted to track object files, interface files, or build artifacts from the compiler build. However, some backends, such as the JS backend, produce artifacts when compiling, such as the jsexe directory which we want to track. This patch: - tweaks the testsuite to collect generic metrics on any build artifact in the test directory. - expands the exe_extension function to consider windows and adds the ignore_extension flag. - Modifies certain tests to add the ignore_extension flag. Tests such as heaprof002 expect a .ps file, but on windows without ignore_extensions the testsuite will look for foo.exe.ps. Hence the flag. - adds the size_hello_artifact test - - - - - 75a31379 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add wasm_arch, heapprof002 wasm extension - - - - - c9731d6d by Rodrigo Mesquita at 2024-02-07T03:07:03-05:00 Synchronize bindist configure for #24324 In cdddeb0f1280b40cc194028bbaef36e127175c4c, we set up a workaround for #24324 in the in-tree configure script, but forgot to update the bindist configure script accordingly. This updates it. - - - - - d309f4e7 by Matthew Pickering at 2024-02-07T03:07:38-05:00 distrib/configure: Fix typo in CONF_GCC_LINKER_OPTS_STAGE2 variable Instead we were setting CONF_GCC_LINK_OPTS_STAGE2 which meant that we were missing passing `--target` when invoking the linker. Fixes #24414 - - - - - 77db84ab by Ben Gamari at 2024-02-08T00:35:22-05:00 llvmGen: Adapt to allow use of new pass manager. We now must use `-passes` in place of `-O<n>` due to #21936. Closes #21936. - - - - - 3c9ddf97 by Matthew Pickering at 2024-02-08T00:35:59-05:00 testsuite: Mark length001 as fragile on javascript Modifying the timeout multiplier is not a robust way to get this test to reliably fail. Therefore we mark it as fragile until/if javascript ever supports the stack limit. - - - - - 20b702b5 by Matthew Pickering at 2024-02-08T00:35:59-05:00 Javascript: Don't filter out rtsDeps list This logic appears to be incorrect as it would drop any dependency which was not in a direct dependency of the package being linked. In the ghc-internals split this started to cause errors because `ghc-internal` is not a direct dependency of most packages, and hence important symbols to keep which are hard coded into the js runtime were getting dropped. - - - - - 2df96366 by Ben Gamari at 2024-02-08T00:35:59-05:00 base: Cleanup whitespace in cbits - - - - - 44f6557a by Ben Gamari at 2024-02-08T00:35:59-05:00 Move `base` to `ghc-internal` Here we move a good deal of the implementation of `base` into a new package, `ghc-internal` such that it can be evolved independently from the user-visible interfaces of `base`. While we want to isolate implementation from interfaces, naturally, we would like to avoid turning `base` into a mere set of module re-exports. However, this is a non-trivial undertaking for a variety of reasons: * `base` contains numerous known-key and wired-in things, requiring corresponding changes in the compiler * `base` contains a significant amount of C code and corresponding autoconf logic, which is very fragile and difficult to break apart * `base` has numerous import cycles, which are currently dealt with via carefully balanced `hs-boot` files * We must not break existing users To accomplish this migration, I tried the following approaches: * [Split-GHC.Base]: Break apart the GHC.Base knot to allow incremental migration of modules into ghc-internal: this knot is simply too intertwined to be easily pulled apart, especially given the rather tricky import cycles that it contains) * [Move-Core]: Moving the "core" connected component of base (roughly 150 modules) into ghc-internal. While the Haskell side of this seems tractable, the C dependencies are very subtle to break apart. * [Move-Incrementally]: 1. Move all of base into ghc-internal 2. Examine the module structure and begin moving obvious modules (e.g. leaves of the import graph) back into base 3. Examine the modules remaining in ghc-internal, refactor as necessary to facilitate further moves 4. Go to (2) iterate until the cost/benefit of further moves is insufficient to justify continuing 5. Rename the modules moved into ghc-internal to ensure that they don't overlap with those in base 6. For each module moved into ghc-internal, add a shim module to base with the declarations which should be exposed and any requisite Haddocks (thus guaranteeing that base will be insulated from changes in the export lists of modules in ghc-internal Here I am using the [Move-Incrementally] approach, which is empirically the least painful of the unpleasant options above Bumps haddock submodule. Metric Decrease: haddock.Cabal haddock.base Metric Increase: MultiComponentModulesRecomp T16875 size_hello_artifact - - - - - e8fb2451 by Vladislav Zavialov at 2024-02-08T00:36:36-05:00 Haddock comments on infix constructors (#24221) Rewrite the `HasHaddock` instance for `ConDecl GhcPs` to account for infix constructors. This change fixes a Haddock regression (introduced in 19e80b9af252) that affected leading comments on infix data constructor declarations: -- | Docs for infix constructor | Int :* Bool The comment should be associated with the data constructor (:*), not with its left-hand side Int. - - - - - 9060d55b by Ben Gamari at 2024-02-08T00:37:13-05:00 Add os-string as a boot package Introduces `os-string` submodule. This will be necessary for `filepath-1.5`. - - - - - 9d65235a by Ben Gamari at 2024-02-08T00:37:13-05:00 gitignore: Ignore .hadrian_ghci_multi/ - - - - - d7ee12ea by Ben Gamari at 2024-02-08T00:37:13-05:00 hadrian: Set -this-package-name When constructing the GHC flags for a package Hadrian must take care to set `-this-package-name` in addition to `-this-unit-id`. This hasn't broken until now as we have not had any uses of qualified package imports. However, this will change with `filepath-1.5` and the corresponding `unix` bump, breaking `hadrian/multi-ghci`. - - - - - f2dffd2e by Ben Gamari at 2024-02-08T00:37:13-05:00 Bump filepath to 1.5.0.0 Required bumps of the following submodules: * `directory` * `filepath` * `haskeline` * `process` * `unix` * `hsc2hs` * `Win32` * `semaphore-compat` and the addition of `os-string` as a boot package. - - - - - ab533e71 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Use specific clang assembler when compiling with -fllvm There are situations where LLVM will produce assembly which older gcc toolchains can't handle. For example on Deb10, it seems that LLVM >= 13 produces assembly which the default gcc doesn't support. A more robust solution in the long term is to require a specific LLVM compatible assembler when using -fllvm. Fixes #16354 - - - - - c32b6426 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update CI images with LLVM 15, ghc-9.6.4 and cabal-install-3.10.2.0 - - - - - 5fcd58be by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update bootstrap plans for 9.4.8 and 9.6.4 - - - - - 707a32f5 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Add alpine 3_18 release job This is mainly experimental and future proofing to enable a smooth transition to newer alpine releases once 3_12 is too old. - - - - - c37931b3 by John Ericson at 2024-02-08T06:39:05-05:00 Generate LLVM min/max bound policy via Hadrian Per #23966, I want the top-level configure to only generate configuration data for Hadrian, not do any "real" tasks on its own. This is part of that effort --- one less file generated by it. (It is still done with a `.in` file, so in a future world non-Hadrian also can easily create this file.) Split modules: - GHC.CmmToLlvm.Config - GHC.CmmToLlvm.Version - GHC.CmmToLlvm.Version.Bounds - GHC.CmmToLlvm.Version.Type This also means we can get rid of the silly `unused.h` introduced in !6803 / 7dfcab2f4bcb7206174ea48857df1883d05e97a2 as temporary kludge. Part of #23966 - - - - - 9f987235 by Apoorv Ingle at 2024-02-08T06:39:42-05:00 Enable mdo statements to use HsExpansions Fixes: #24411 Added test T24411 for regression - - - - - 762b2120 by Jade at 2024-02-08T15:17:15+00:00 Improve Monad, Functor & Applicative docs This patch aims to improve the documentation of Functor, Applicative, Monad and related symbols. The main goal is to make it more consistent and make accessible. See also: !10979 (closed) and !10985 (closed) Ticket #17929 Updates haddock submodule - - - - - 151770ca by Josh Meredith at 2024-02-10T14:28:15-05:00 JavaScript codegen: Use GHC's tag inference where JS backend-specific evaluation inference was previously used (#24309) - - - - - 2e880635 by Zubin Duggal at 2024-02-10T14:28:51-05:00 ci: Allow release-hackage-lint to fail Otherwise it blocks the ghcup metadata pipeline from running. - - - - - b0293f78 by Matthew Pickering at 2024-02-10T14:29:28-05:00 rts: eras profiling mode The eras profiling mode is useful for tracking the life-time of closures. When a closure is written, the current era is recorded in the profiling header. This records the era in which the closure was created. * Enable with -he * User mode: Use functions ghc-experimental module GHC.Profiling.Eras to modify the era * Automatically: --automatic-era-increment, increases the user era on major collections * The first era is era 1 * -he<era> can be used with other profiling modes to select a specific era If you just want to record the era but not to perform heap profiling you can use `-he --no-automatic-heap-samples`. https://well-typed.com/blog/2024/01/ghc-eras-profiling/ Fixes #24332 - - - - - be674a2c by Jade at 2024-02-10T14:30:04-05:00 Adjust error message for trailing whitespace in as-pattern. Fixes #22524 - - - - - 53ef83f9 by doyougnu at 2024-02-10T14:30:47-05:00 gitlab: js: add codeowners Fixes: - #24409 Follow on from: - #21078 and MR !9133 - When we added the JS backend this was forgotten. This patch adds the rightful codeowners. - - - - - 8bbe12f2 by Matthew Pickering at 2024-02-10T14:31:23-05:00 Bump CI images so that alpine3_18 image includes clang15 The only changes here are that clang15 is now installed on the alpine-3_18 image. - - - - - df9fd9f7 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: handle stored null StablePtr Some Haskell codes unsafely cast StablePtr into ptr to compare against NULL. E.g. in direct-sqlite: if castStablePtrToPtr aggStPtr /= nullPtr then where `aggStPtr` is read (`peek`) from zeroed memory initially. We fix this by giving these StablePtr the same representation as other null pointers. It's safe because StablePtr at offset 0 is unused (for this exact reason). - - - - - 55346ede by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: disable MergeObjsMode test This isn't implemented for JS backend objects. - - - - - aef587f6 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: add support for linking C sources Support linking C sources with JS output of the JavaScript backend. See the added documentation in the users guide. The implementation simply extends the JS linker to use the objects (.o) that were already produced by the emcc compiler and which were filtered out previously. I've also added some options to control the link with C functions (see the documentation about pragmas). With this change I've successfully compiled the direct-sqlite package which embeds the sqlite.c database code. Some wrappers are still required (see the documentation about wrappers) but everything generic enough to be reused for other libraries have been integrated into rts/js/mem.js. - - - - - b71b392f by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: avoid EMCC logging spurious failure emcc would sometime output messages like: cache:INFO: generating system asset: symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json" for subsequent builds) cache:INFO: - ok Cf https://github.com/emscripten-core/emscripten/issues/18607 This breaks our tests matching the stderr output. We avoid this by setting EMCC_LOGGING=0 - - - - - ff2c0cc9 by Simon Peyton Jones at 2024-02-12T12:19:17-05:00 Remove a dead comment Just remove an out of date block of commented-out code, and tidy up the relevant Notes. See #8317. - - - - - bedb4f0d by Teo Camarasu at 2024-02-12T18:50:33-05:00 nonmoving: Add support for heap profiling Add support for heap profiling while using the nonmoving collector. We greatly simply the implementation by disabling concurrent collection for GCs when heap profiling is enabled. This entails that the marked objects on the nonmoving heap are exactly the live objects. Note that we match the behaviour for live bytes accounting by taking the size of objects on the nonmoving heap to be that of the segment's block rather than the object itself. Resolves #22221 - - - - - d0d5acb5 by Teo Camarasu at 2024-02-12T18:51:09-05:00 doc: Add requires prof annotation to options that require it Resolves #24421 - - - - - 57bb8c92 by Cheng Shao at 2024-02-13T14:07:49-05:00 deriveConstants: add needed constants for wasm backend This commit adds needed constants to deriveConstants. They are used by RTS code in the wasm backend to support the JSFFI logic. - - - - - 615eb855 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms The pure Haskell implementation causes i386 regression in unrelated work that can be fixed by using C-based atomic increment, see added comment for details. - - - - - a9918891 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow JSFFI for wasm32 This commit allows the javascript calling convention to be used when the target platform is wasm32. - - - - - 8771a53b by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow boxed JSVal as a foreign type This commit allows the boxed JSVal type to be used as a foreign argument/result type. - - - - - 053c92b3 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: ensure ctors have the right priority on wasm32 This commit fixes the priorities of ctors generated by GHC codegen on wasm32, see the referred note for details. - - - - - b7942e0a by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JSFFI desugar logic for wasm32 This commit adds JSFFI desugar logic for the wasm backend. - - - - - 2c1dca76 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JavaScriptFFI to supported extension list on wasm32 This commit adds JavaScriptFFI as a supported extension when the target platform is wasm32. - - - - - 9ad0e2b4 by Cheng Shao at 2024-02-13T14:07:49-05:00 rts/ghc-internal: add JSFFI support logic for wasm32 This commit adds rts/ghc-internal logic to support the wasm backend's JSFFI functionality. - - - - - e9ebea66 by Cheng Shao at 2024-02-13T14:07:49-05:00 ghc-internal: fix threadDelay for wasm in browsers This commit fixes broken threadDelay for wasm when it runs in browsers, see added note for detailed explanation. - - - - - f85f3fdb by Cheng Shao at 2024-02-13T14:07:49-05:00 utils: add JSFFI utility code This commit adds JavaScript util code to utils to support the wasm backend's JSFFI functionality: - jsffi/post-link.mjs, a post-linker to process the linked wasm module and emit a small complement JavaScript ESM module to be used with it at runtime - jsffi/prelude.js, a tiny bit of prelude code as the JavaScript side of runtime logic - jsffi/test-runner.mjs, run the jsffi test cases Co-authored-by: amesgen <amesgen at amesgen.de> - - - - - 77e91500 by Cheng Shao at 2024-02-13T14:07:49-05:00 hadrian: distribute jsbits needed for wasm backend's JSFFI support The post-linker.mjs/prelude.js files are now distributed in the bindist libdir, so when using the wasm backend's JSFFI feature, the user wouldn't need to fetch them from a ghc checkout manually. - - - - - c47ba1c3 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add opts.target_wrapper This commit adds opts.target_wrapper which allows overriding the target wrapper on a per test case basis when testing a cross target. This is used when testing the wasm backend's JSFFI functionality; the rest of the cases are tested using wasmtime, though the jsffi cases are tested using the node.js based test runner. - - - - - 8e048675 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: T22774 should work for wasm JSFFI T22774 works since the wasm backend now supports the JSFFI feature. - - - - - 1d07f9a6 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add JSFFI test cases for wasm backend This commit adds a few test cases for the wasm backend's JSFFI functionality, as well as a simple README to instruct future contributors to add new test cases. - - - - - b8997080 by Cheng Shao at 2024-02-13T14:07:49-05:00 docs: add documentation for wasm backend JSFFI This commit adds changelog and user facing documentation for the wasm backend's JSFFI feature. - - - - - ffeb000d by David Binder at 2024-02-13T14:08:30-05:00 Add tests from libraries/process/tests and libraries/Win32/tests to GHC These tests were previously part of the libraries, which themselves are submodules of the GHC repository. This commit moves the tests directly to the GHC repository. - - - - - 5a932cf2 by David Binder at 2024-02-13T14:08:30-05:00 Do not execute win32 tests on non-windows runners - - - - - 500d8cb8 by Jade at 2024-02-13T14:09:07-05:00 prevent GHCi (and runghc) from suggesting other symbols when not finding main Fixes: #23996 - - - - - b19ec331 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: update xxHash to v0.8.2 - - - - - 4a97bdb8 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: use XXH3_64bits hash on all 64-bit platforms This commit enables XXH3_64bits hash to be used on all 64-bit platforms. Previously it was only enabled on x86_64, so platforms like aarch64 silently falls back to using XXH32 which degrades the hashing function quality. - - - - - ee01de7d by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: define XXH_INLINE_ALL This commit cleans up how we include the xxhash.h header and only define XXH_INLINE_ALL, which is sufficient to inline the xxHash functions without symbol collision. - - - - - 0e01e1db by Alan Zimmerman at 2024-02-14T02:13:22-05:00 EPA: Move EpAnn out of extension points Leaving a few that are too tricky, maybe some other time. Also - remove some unneeded helpers from Parser.y - reduce allocations with strictness annotations Updates haddock submodule Metric Decrease: parsing001 - - - - - de589554 by Andreas Klebinger at 2024-02-14T02:13:59-05:00 Fix ffi callbacks with >6 args and non-64bit args. Check for ptr/int arguments rather than 64-bit width arguments when counting integer register arguments. The old approach broke when we stopped using exclusively W64-sized types to represent sub-word sized integers. Fixes #24314 - - - - - 325b7613 by Ben Gamari at 2024-02-14T14:27:45-05:00 rts/EventLog: Place eliminate duplicate strlens Previously many of the `post*` implementations would first compute the length of the event's strings in order to determine the event length. Later we would then end up computing the length yet again in `postString`. Now we instead pass the string length to `postStringLen`, avoiding the repeated work. - - - - - 8aafa51c by Ben Gamari at 2024-02-14T14:27:46-05:00 rts/eventlog: Place upper bound on IPE string field lengths The strings in IPE events may be of unbounded length. Limit the lengths of these fields to 64k characters to ensure that we don't exceed the maximum event length. - - - - - 0e60d52c by Zubin Duggal at 2024-02-14T14:27:46-05:00 rts: drop unused postString function - - - - - d8d1333a by Cheng Shao at 2024-02-14T14:28:23-05:00 compiler/rts: fix wasm unreg regression This commit fixes two wasm unreg regressions caught by a nightly pipeline: - Unknown stg_scheduler_loopzh symbol when compiling scheduler.cmm - Invalid _hs_constructor(101) function name when handling ctor - - - - - 264a4fa9 by Owen Shepherd at 2024-02-15T09:41:06-05:00 feat: Add sortOn to Data.List.NonEmpty Adds `sortOn` to `Data.List.NonEmpty`, and adds comments describing when to use it, compared to `sortWith` or `sortBy . comparing`. The aim is to smooth out the API between `Data.List`, and `Data.List.NonEmpty`. This change has been discussed in the [clc issue](https://github.com/haskell/core-libraries-committee/issues/227). - - - - - b57200de by Fendor at 2024-02-15T09:41:47-05:00 Prefer RdrName over OccName for looking up locations in doc renaming step Looking up by OccName only does not take into account when functions are only imported in a qualified way. Fixes issue #24294 Bump haddock submodule to include regression test - - - - - 8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00 JS: add simple optimizer The simple optimizer reduces the size of the code generated by the JavaScript backend without the complexity and performance penalty of the optimizer in GHCJS. Also see #22736 Metric Decrease: libdir size_hello_artifact - - - - - 20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00 base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and modifies the base API to reflect the new RTS flag. CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243 Fixes #24337 - - - - - 08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00 base: export System.Mem.performBlockingMajorGC The corresponding C function was introduced in ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264. Resolves #24228 The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230 Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00 Fix C output for modern C initiative GCC 14 on aarch64 rejects the C code written by GHC with this kind of error: error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion] 68 | *(ffi_arg*)resp = cret; | ^ Add the correct cast. For more information on this see: https://fedoraproject.org/wiki/Changes/PortingToModernC Tested-by: Richard W.M. Jones <rjones at redhat.com> - - - - - 5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00 Bump bytestring submodule to 0.12.1.0 - - - - - 902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00 Add missing BCO handling in scavenge_one. - - - - - 97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Make cast between words and floats real primops (#24331) First step towards fixing #24331. Replace foreign prim imports with real primops. - - - - - a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: add constant folding for bitcast between float and word (#24331) - - - - - 5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: replace stack checks with assertions in casting primops There are RESERVED_STACK_WORDS free words (currently 21) on the stack, so omit the checks. Suggested by Cheng Shao. - - - - - 401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00 Reexport primops from GHC.Float + add deprecation - - - - - 4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00 rts/Hash: Don't iterate over chunks if we don't need to free data When freeing a `HashTable` there is no reason to walk over the hash list before freeing it if the user has not given us a `dataFreeFun`. Noticed while looking at #24410. - - - - - bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00 compiler: add SEQ_CST fence support In addition to existing Acquire/Release fences, this commit adds SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a fence that enforces total memory ordering. The following logic is added: - The MO_SeqCstFence callish MachOp - The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h - MO_SeqCstFence lowering logic in every single GHC codegen backend - - - - - 2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00 testsuite: fix hs_try_putmvar002 for targets without pthread.h hs_try_putmvar002 includes pthread.h and doesn't work on targets without this header (e.g. wasm32). It doesn't need to include this header at all. This was previously unnoticed by wasm CI, though recent toolchain upgrade brought in upstream changes that completely removes pthread.h in the single-threaded wasm32-wasi sysroot, therefore we need to handle that change. - - - - - 1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00 ci: bump ci-images to use updated wasm image This commit bumps our ci-images revision to use updated wasm image. - - - - - 56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00 Bump submodule text to 2.1.1 T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a. Metric Decrease: T17123 - - - - - a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00 rts: remove redundant rCCCS initialization This commit removes the redundant logic of initializing each Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before initProfiling() is called during RTS startup, each Capability's rCCCS has already been assigned CCS_SYSTEM when they're first initialized. - - - - - 7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00 Parser, renamer, type checker for @a-binders (#17594) GHC Proposal 448 introduces binders for invisible type arguments (@a-binders) in various contexts. This patch implements @-binders in lambda patterns and function equations: {-# LANGUAGE TypeAbstractions #-} id1 :: a -> a id1 @t x = x :: t -- @t-binder on the LHS of a function equation higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16) higherRank f = (f 42, f 42) ex :: (Int8, Int16) ex = higherRank (\ @a x -> maxBound @a - x ) -- @a-binder in a lambda pattern in an argument -- to a higher-order function Syntax ------ To represent those @-binders in the AST, the list of patterns in Match now uses ArgPat instead of Pat: data Match p body = Match { ... - m_pats :: [LPat p], + m_pats :: [LArgPat p], ... } + data ArgPat pass + = VisPat (XVisPat pass) (LPat pass) + | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass)) + | XArgPat !(XXArgPat pass) The VisPat constructor represents patterns for visible arguments, which include ordinary value-level arguments and required type arguments (neither is prefixed with a @), while InvisPat represents invisible type arguments (prefixed with a @). Parser ------ In the grammar (Parser.y), the lambda and lambda-cases productions of aexp non-terminal were updated to accept argpats instead of apats: aexp : ... - | '\\' apats '->' exp + | '\\' argpats '->' exp ... - | '\\' 'lcases' altslist(apats) + | '\\' 'lcases' altslist(argpats) ... + argpat : apat + | PREFIX_AT atype Function left-hand sides did not require any changes to the grammar, as they were already parsed with productions capable of parsing @-binders. Those binders were being rejected in post-processing (isFunLhs), and now we accept them. In Parser.PostProcess, patterns are constructed with the help of PatBuilder, which is used as an intermediate data structure when disambiguating between FunBind and PatBind. In this patch we define ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived data structure produced in isFunLhs and consumed in checkFunBind. Renamer ------- Renaming of @-binders builds upon prior work on type patterns, implemented in 2afbddb0f24, which guarantees proper scoping and shadowing behavior of bound type variables. This patch merely defines rnLArgPatsAndThen to process a mix of visible and invisible patterns: + rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn] + rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where + rnArgPatAndThen (VisPat x p) = ... rnLPatAndThen ... + rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ... Common logic between rnArgPats and rnPats is factored out into the rn_pats_general helper. Type checker ------------ Type-checking of @-binders builds upon prior work on lazy skolemisation, implemented in f5d3e03c56f. This patch extends tcMatchPats to handle @-binders. Now it takes and returns a list of LArgPat rather than LPat: tcMatchPats :: ... - -> [LPat GhcRn] + -> [LArgPat GhcRn] ... - -> TcM ([LPat GhcTc], a) + -> TcM ([LArgPat GhcTc], a) Invisible binders in the Match are matched up with invisible (Specified) foralls in the type. This is done with a new clause in the `loop` worker of tcMatchPats: loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a) loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys) ... -- NEW CLAUSE: | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis = ... In addition to that, tcMatchPats no longer discards type patterns. This is done by filterOutErasedPats in the desugarer instead. x86_64-linux-deb10-validate+debug_info Metric Increase: MultiLayerModulesTH_OneShot - - - - - 486979b0 by Jade at 2024-02-19T07:12:13-05:00 Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246 Fixes: #24346 - - - - - 17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00 Fix reST in users guide It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax. - - - - - 35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00 Fix searching for errors in sphinx build - - - - - 4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00 hadrian: fix wasm backend post linker script permissions The post-link.mjs script was incorrectly copied and installed as a regular data file without executable permission, this commit fixes it. - - - - - a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00 testsuite: mark T23540 as fragile on i386 See #24449 for details. - - - - - 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 8a8ac65a by Matthew Craven at 2024-03-23T00:20:52-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 0c48f2b9 by Apoorv Ingle at 2024-03-23T00:21:28-04:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - b72705e9 by Simon Peyton Jones at 2024-03-23T00:22:04-04:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 8f7cfc7e by Tristan Cacqueray at 2024-03-23T00:22:44-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - 5bd8ed53 by Andreas Klebinger at 2024-03-23T16:18:33-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8d67f247 by Ben Gamari at 2024-03-23T16:19:09-04:00 docs: Drop old release notes, add for 9.12.1 - - - - - 7db8c992 by Cheng Shao at 2024-03-25T13:45:46-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. - - - - - 237194ce by Sylvain Henry at 2024-03-25T13:46:27-04:00 Lexer: fix imports for Alex 3.5.1 (#24583) - - - - - 810660b7 by Cheng Shao at 2024-03-25T22:19:16-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - d2ba41e8 by Alan Zimmerman at 2024-03-25T22:19:51-04:00 EPA: do not duplicate comments in signature RHS - - - - - 32a8103f by Rodrigo Mesquita at 2024-03-26T21:16:12-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. - - - - - bf65a7c3 by Rodrigo Mesquita at 2024-03-26T21:16:48-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 - - - - - cfeb70d3 by Rodrigo Mesquita at 2024-03-26T21:17:24-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 13223f6d by Serge S. Gulin at 2024-03-27T07:28:51-04:00 JS: `h$rts_isProfiled` is removed from `profiling` and left its version at `rts/js/config.js` - - - - - 0acfe391 by Alan Zimmerman at 2024-03-27T07:29:27-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. - - - - - cd0fb82f by Alan Zimmerman at 2024-03-27T19:33:08+00:00 EPA: Fix FamDecl range The span was incorrect if opt_datafam_kind_sig was empty - - - - - f8f384a8 by Ben Gamari at 2024-03-29T01:23:03-04:00 Fix type of _get_osfhandle foreign import Fixes #24601. - - - - - 00d3ecf0 by Alan Zimmerman at 2024-03-29T12:19:10+00:00 EPA: Extend StringLiteral range to include trailing commas This goes slightly against the exact printing philosophy where trailing decorations should be in an annotation, but the practicalities of adding it to the WarningTxt environment, and the problems caused by deviating do not make a more principles approach worthwhile. - - - - - efab3649 by brandon s allbery kf8nh at 2024-03-31T20:04:01-04:00 clarify Note [Preproccesing invocations] - - - - - c8a4c050 by Ben Gamari at 2024-04-02T12:50:35-04:00 rts: Fix TSAN_ENABLED CPP guard This should be `#if defined(TSAN_ENABLED)`, not `#if TSAN_ENABLED`, lest we suffer warnings. - - - - - e91dad93 by Cheng Shao at 2024-04-02T12:50:35-04:00 rts: fix errors when compiling with TSAN This commit fixes rts compilation errors when compiling with TSAN: - xxx_FENCE macros are redefined and trigger CPP warnings. - Use SIZEOF_W. WORD_SIZE_IN_BITS is provided by MachDeps.h which Cmm.h doesn't include by default. - - - - - a9ab9455 by Cheng Shao at 2024-04-02T12:50:35-04:00 rts: fix clang-specific errors when compiling with TSAN This commit fixes clang-specific rts compilation errors when compiling with TSAN: - clang doesn't have -Wtsan flag - Fix prototype of ghc_tsan_* helper functions - __tsan_atomic_* functions aren't clang built-ins and sanitizer/tsan_interface_atomic.h needs to be included - On macOS, TSAN runtime library is libclang_rt.tsan_osx_dynamic.dylib, not libtsan. -fsanitize-thread as a link-time flag will take care of linking the TSAN runtime library anyway so remove tsan as an rts extra library - - - - - 865bd717 by Cheng Shao at 2024-04-02T12:50:35-04:00 compiler: fix github link to __tsan_memory_order in a comment - - - - - 07cb627c by Cheng Shao at 2024-04-02T12:50:35-04:00 ci: improve TSAN CI jobs - Run TSAN jobs with +thread_sanitizer_cmm which enables Cmm instrumentation as well. - Run TSAN jobs in deb12 which ships gcc-12, a reasonably recent gcc that @bgamari confirms he's using in #GHC:matrix.org. Ideally we should be using latest clang release for latest improvements in sanitizers, though that's left as future work. - Mark TSAN jobs as manual+allow_failure in validate pipelines. The purpose is to demonstrate that we have indeed at least fixed building of TSAN mode in CI without blocking the patch to land, and once merged other people can begin playing with TSAN using their own dev setups and feature branches. - - - - - a1c18c7b by Andrei Borzenkov at 2024-04-02T12:51:11-04:00 Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy (#24299, #23639) This patch implements refactoring which is a prerequisite to updating kind checking of type patterns. This is a huge simplification of the main worker that checks kind of HsType. It also fixes the issues caused by previous code duplication, e.g. that we didn't add module finalizers from splices in inference mode. - - - - - 817e8936 by Rodrigo Mesquita at 2024-04-02T20:13:05-04:00 th: Hide the Language.Haskell.TH.Lib.Internal module from haddock Fixes #24562 - - - - - b36ee57b by Sylvain Henry at 2024-04-02T20:13:46-04:00 JS: reenable h$appendToHsString optimization (#24495) The optimization introducing h$appendToHsString wasn't kicking in anymore (while it did in 9.8.1) because of the changes introduced in #23270 (7e0c8b3bab30). This patch reenables the optimization by matching on case-expression, as done in Cmm for unpackCString# standard thunks. The test is also T24495 added in the next commits (two commits for ease of backporting to 9.8). - - - - - 527616e9 by Sylvain Henry at 2024-04-02T20:13:46-04:00 JS: fix h$appendToHsString implementation (#24495) h$appendToHsString needs to wrap its argument in an updatable thunk to behave like unpackAppendCString#. Otherwise if a SingleEntry thunk is passed, it is stored as-is in a CONS cell, making the resulting list impossible to deepseq (forcing the thunk doesn't update the contents of the CONS cell)! The added test checks that the optimization kicks in and that h$appendToHsString works as intended. Fix #24495 - - - - - faa30b41 by Simon Peyton Jones at 2024-04-02T20:14:22-04:00 Deal with duplicate tyvars in type declarations GHC was outright crashing before this fix: #24604 - - - - - e0b0c717 by Simon Peyton Jones at 2024-04-02T20:14:58-04:00 Try using MCoercion in exprIsConApp_maybe This is just a simple refactor that makes exprIsConApp_maybe a little bit more direct, simple, and efficient. Metrics: compile_time/bytes allocated geo. mean -0.1% minimum -2.0% maximum -0.0% Not a big gain, but worthwhile given that the code is, if anything, easier to grok. - - - - - 15f4d867 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Initial ./configure support for selecting I/O managers In this patch we just define new CPP vars, but don't yet use them or replace the existing approach. That will follow. The intention here is that every I/O manager can be enabled/disabled at GHC build time (subject to some constraints). More than one I/O manager can be enabled to be built. At least one I/O manager supporting the non-threaded RTS must be enabled as well as at least one supporting the non-threaded RTS. The I/O managers enabled here will become the choices available at runtime at RTS startup (in later patches). The choice can be made with RTS flags. There are separate sets of choices for the threaded and non-threaded RTS ways, because most I/O managers are specific to these ways. Furthermore we must establish a default I/O manager for the threaded and non-threaded RTS. Most I/O managers are platform-specific so there are checks to ensure each one can be enabled on the platform. Such checks are also where (in future) any system dependencies (e.g. libraries) can be checked. The output is a set of CPP flags (in the mk/config.h file), with one flag per named I/O manager: * IOMGR_BUILD_<name> : which ones should be built (some) * IOMGR_DEFAULT_NON_THREADED_<name> : which one is default (exactly one) * IOMGR_DEFAULT_THREADED_<name> : which one is default (exactly one) and a set of derived flags in IOManager.h * IOMGR_ENABLED_<name> : enabled for the current RTS way Note that IOMGR_BUILD_<name> just says that an I/O manager will be built for _some_ RTS way (i.e. threaded or non-threaded). The derived flags IOMGR_ENABLED_<name> in IOManager.h say if each I/O manager is enabled in the "current" RTS way. These are the ones that can be used for conditional compilation of the I/O manager code. Co-authored-by: Pi Delport <pi at well-typed.com> - - - - - 85b0f87a by Duncan Coutts at 2024-04-03T01:27:17-04:00 Change the handling of the RTS flag --io-manager= Now instead of it being just used on Windows to select between the WinIO vs the MIO or Win32-legacy I/O managers, it is now used on all platforms for selecting the I/O manager to use. Right now it remains the case that there is only an actual choice on Windows, but that will change later. Document the --io-manager flag in the user guide. This change is also reflected in the RTS flags types in the base library. Deprecate the export of IoSubSystem from GHC.RTS.Flags with a message to import it from GHC.IO.Subsystem. The way the 'IoSubSystem' is detected also changes. Instead of looking at the RTS flag, there is now a C bool global var in the RTS which gets set on startup when the I/O manager is selected. This bool var says whether the selected I/O manager classifies as "native" on Windows, which in practice means the WinIO I/O manager has been selected. Similarly, the is_io_mng_native_p RTS helper function is re-implemented in terms of the selected I/O manager, rather than based on the RTS flags. We do however remove the ./configure --native-io-manager flag because we're bringing the WinIO/MIO/Win32-legacy choice under the new general scheme for selecting I/O managers, and that new scheme involves no ./configure time user choices, just runtime RTS flag choices. - - - - - 1a8f020f by Duncan Coutts at 2024-04-03T01:27:17-04:00 Convert {init,stop,exit}IOManager to switch style Rather than ad-hoc cpp conitionals on THREADED_RTS and mingw32_HOST_OS, we use a style where we switch on the I/O manager impl, with cases for each I/O manager impl. - - - - - a5bad3d2 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Split up the CapIOManager content by I/O manager Using the new IOMGR_ENABLED_<name> CPP defines. - - - - - 1d36e609 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Convert initIOManagerAfterFork and wakeupIOManager to switch style - - - - - c2f26f36 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move most of waitRead#/Write# from cmm to C Moves it into the IOManager.c where we can follow the new pattern of switching on the selected I/O manager. - - - - - 457705a8 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move most of the delay# impl from cmm to C Moves it into the IOManager.c where we can follow the new pattern of switching on the selected I/O manager. Uses a new IOManager API: syncDelay, following the naming convention of sync* for thread-synchronous I/O & timer/delay operations. As part of porting from cmm to C, we maintain the rule that the why_blocked gets accessed using load acquire and store release atomic memory operations. There was one exception to this rule: in the delay# primop cmm code on posix (not win32), the why_blocked was being updated using a store relaxed, not a store release. I've no idea why. In this convesion I'm playing it safe here and using store release consistently. - - - - - e93058e0 by Duncan Coutts at 2024-04-03T01:27:18-04:00 insertIntoSleepingQueue is no longer public No longer defined in IOManager.h, just a private function in IOManager.c. Since it is no longer called from cmm code, just from syncDelay. It ought to get moved further into the select() I/O manager impl, rather than living in IOManager.c. On the other hand appendToIOBlockedQueue is still called from cmm code in the win32-legacy I/O manager primops async{Read,Write}#, and it is also used by the select() I/O manager. Update the CPP and comments to reflect this. - - - - - 60ce9910 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move anyPendingTimeoutsOrIO impl from .h to .c The implementation is eventually going to need to use more private things, which will drag in unwanted includes into IOManager.h, so it's better to move the impl out of the header file and into the .c file, at the slight cost of it no longer being inline. At the same time, change to the "switch (iomgr_type)" style. - - - - - f70b8108 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Take a simpler approach to gcc warnings in IOManager.c We have lots of functions with conditional implementations for different I/O managers. Some functions, for some I/O managers, naturally have implementations that do nothing or barf. When only one such I/O manager is enabled then the whole function implementation will have an implementation that does nothing or barfs. This then results in warnings from gcc that parameters are unused, or that the function should be marked with attribute noreturn (since barf does not return). The USED_IF_THREADS trick for fine-grained warning supression is fine for just two cases, but an equivalent here would need USED_IF_THE_ONLY_ENABLED_IOMGR_IS_X_OR_Y which would have combinitorial blowup. So we take a coarse grained approach and simply disable these two warnings for the whole file. So we use a GCC pragma, with its handy push/pop support: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsuggest-attribute=noreturn" #pragma GCC diagnostic ignored "-Wunused-parameter" ... #pragma GCC diagnostic pop - - - - - b48805b9 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add a new trace class for the iomanager It makes sense now for it to be separate from the scheduler class of tracers. Enabled with +RTS -Do. Document the -Do debug flag in the user guide. - - - - - f0c1f862 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Have the throwTo impl go via (new) IOManager APIs rather than directly operating on the IO manager's data structures. Specifically, when thowing an async exception to a thread that is blocked waiting for I/O or waiting for a timer, then we want to cancel that I/O waiting or cancel the timer. Currently this is done directly in removeFromQueues() in RaiseAsync.c. We want it to go via proper APIs both for modularity but also to let us support multiple I/O managers. So add sync{IO,Delay}Cancel, which is the cancellation for the corresponding sync{IO,Delay}. The implementations of these use the usual "switch (iomgr_type)" style. - - - - - 4f9e9c4e by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move awaitEvent into a proper IOManager API and have the scheduler use it. Previously the scheduler calls awaitEvent directly, and awaitEvent is implemented directly in the RTS I/O managers (select, win32). This relies on the old scheme where there's a single active I/O manager for each platform and RTS way. We want to move that to go via an API in IOManager.{h,c} which can then call out to the active I/O manager. Also take the opportunity to split awaitEvent into two. The existing awaitEvent has a bool wait parameter, to say if the call should be blocking or non-blocking. We split this into two separate functions: pollCompletedTimeoutsOrIO and awaitCompletedTimeoutsOrIO. We split them for a few reasons: they have different post-conditions (specifically the await version is supposed to guarantee that there are threads runnable when it completes). Secondly, it is also anticipated that in future I/O managers the implementations of the two cases will be simpler if they are separated. - - - - - 5ad4b30f by Duncan Coutts at 2024-04-03T01:27:18-04:00 Rename awaitEvent in select and win32 I/O managers These are now just called from IOManager.c and are the per-I/O manager backend impls (whereas previously awaitEvent was the entry point). Follow the new naming convention in the IOManager.{h,c} of awaitCompletedTimeoutsOrIO, with the I/O manager's name as a suffix: so awaitCompletedTimeoutsOrIO{Select,Win32}. - - - - - d30c6bc6 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Tidy up a couple things in Select.{h,c} Use the standard #include {Begin,End}Private.h style rather than RTS_PRIVATE on individual decls. And conditionally build the code for the select I/O manager based on the new CPP IOMGR_ENABLED_SELECT rather than on THREADED_RTS. - - - - - 4161f516 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add an IOManager API for scavenging TSO blocked_info When the GC scavenges a TSO it needs to scavenge the tso->blocked_info but the blocked_info is a big union and what lives there depends on the two->why_blocked, which for I/O-related reasons is something that in principle is the responsibility of the I/O manager and not the GC. So the right thing to do is for the GC to ask the I/O manager to sscavenge the blocked_info if it encounters any I/O-related why_blocked reasons. So we add scavengeTSOIOManager in IOManager.{h,c} with the usual style. Now as it happens, right now, there is no special scavenging to do, so the implementation of scavengeTSOIOManager is a fancy no-op. That's because the select I/O manager uses only the fd and target members, which are not GC pointers, and the win32-legacy I/O manager _ought_ to be using GC-managed heap objects for the StgAsyncIOResult but it is actually usingthe C heap, so again no GC pointers. If the win32-legacy were doing this more sensibly, then scavengeTSOIOManager would be the right place to do the GC magic. Future I/O managers will need GC heap objects in the tso->blocked_info and will make use of this functionality. - - - - - 94a87d21 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add I/O manager API notifyIOManagerCapabilitiesChanged Used in setNumCapabilities. It only does anything for MIO on Posix. Previously it always invoked Haskell code, but that code only did anything on non-Windows (and non-JS), and only threaded. That currently effectively means the MIO I/O manager on Posix. So now it only invokes it for the MIO Posix case. - - - - - 3be6d591 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Select an I/O manager early in RTS startup We need to select the I/O manager to use during startup before the per-cap I/O manager initialisation. - - - - - aaa294d0 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Make struct CapIOManager be fully opaque Provide an opaque (forward) definition in Capability.h (since the cap contains a *CapIOManager) and then only provide a full definition in a new file IOManagerInternals.h. This new file is only supposed to be included by the IOManager implementation, not by its users. So that means IOManager.c and individual I/O manager implementations. The posix/Signals.c still needs direct access, but that should be eliminated. Anything that needs direct access either needs to be clearly part of an I/O manager (e.g. the sleect() one) or go via a proper API. - - - - - 877a2a80 by Duncan Coutts at 2024-04-03T01:27:18-04:00 The select() I/O manager does have some global initialisation It's just to make sure an exception CAF is a GC root. - - - - - 9c51473b by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add tracing for the main I/O manager actions Using the new tracer class. Note: The unconditional definition of showIOManager should be compatible with the debugTrace change in 7c7d1f6. Co-authored-by: Pi Delport <pi at well-typed.com> - - - - - c7d3e3a3 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Include the default I/O manager in the +RTS --info output Document the extra +RTS --info output in the user guide - - - - - 8023bad4 by Duncan Coutts at 2024-04-03T01:27:18-04:00 waitRead# / waitWrite# do not work for win32-legacy I/O manager Previously it was unclear that they did not work because the code path was shared with other I/O managers (in particular select()). Following the code carefully shows that what actually happens is that the calling thread would block forever: the thread will be put into the blocked queue, but no other action is scheduled that will ever result in it getting unblocked. It's better to just fail loudly in case anyone accidentally calls it, also it's less confusing code. - - - - - 83a74d20 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Conditionally ignore some GCC warnings Some GCC versions don't know about some warnings, and they complain that we're ignoring unknown warnings. So we try to ignore the warning based on the GCC version. - - - - - 1adc6fa4 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Accept changes to base-exports All the changes are in fact not changes at all. Previously, the IoSubSystem data type was defined in GHC.RTS.Flags and exported from both GHC.RTS.Flags and GHC.IO.SubSystem. Now, the data type is defined in GHC.IO.SubSystem and still exported from both modules. Therefore, the same exports and same instances are still available from both modules. But the base-exports records only the defining module, and so it looks like a change when it is fully compatible. Related: we do add a deprecation to the export of the type via GHC.RTS.Flags, telling people to use the export from GHC.IO.SubSystem. Also the sort order for some unrelated Show instances changed. No idea why. The same changes apply in the other versions, with a few more changes due to sort order weirdness. - - - - - 8d950968 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Accept metric decrease in T12227 I can't think of any good reason that anything in this MR should have changed the number of allocations, up or down. (Yes this is an empty commit.) Metric Decrease: T12227 - - - - - e869605e by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Several improvements to the handling of coercions * Make `mkSymCo` and `mkInstCo` smarter Fixes #23642 * Fix return role of `SelCo` in the coercion optimiser. Fixes #23617 * Make the coercion optimiser `opt_trans_rule` work better for newtypes Fixes #23619 - - - - - 1efd0714 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 FloatOut: improve floating for join point See the new Note [Floating join point bindings]. * Completely get rid of the complicated join_ceiling nonsense, which I have never understood. * Do not float join points at all, except perhaps to top level. * Some refactoring around wantToFloat, to treat Rec and NonRec more uniformly - - - - - 9c00154d by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Improve eta-expansion through call stacks See Note [Eta expanding through CallStacks] in GHC.Core.Opt.Arity This is a one-line change, that fixes an inconsistency - || isCallStackPredTy ty + || isCallStackPredTy ty || isCallStackTy ty - - - - - 95a9a172 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Spelling, layout, pretty-printing only - - - - - bdf1660f by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Improve exprIsConApp_maybe a little Eliminate a redundant case at birth. This sometimes reduces Simplifier iterations. See Note [Case elim in exprIsConApp_maybe]. - - - - - 609cd32c by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Inline GHC.HsToCore.Pmc.Solver.Types.trvVarInfo When exploring compile-time regressions after meddling with the Simplifier, I discovered that GHC.HsToCore.Pmc.Solver.Types.trvVarInfo was very delicately balanced. It's a small, heavily used, overloaded function and it's important that it inlines. By a fluke it was before, but at various times in my journey it stopped doing so. So I just added an INLINE pragma to it; no sense in depending on a delicately-balanced fluke. - - - - - ae24c9bc by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Slight improvement in WorkWrap Ensure that WorkWrap preserves lambda binders, in case of join points. Sadly I have forgotten why I made this change (it was while I was doing a lot of meddling in the Simplifier, but * it does no harm, * it is slightly more efficient, and * presumably it made something better! Anyway I have kept it in a separate commit. - - - - - e9297181 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Use named record fields for the CastIt { ... } data constructor This is a pure refactor - - - - - b4581e23 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Remove a long-commented-out line Pure refactoring - - - - - e026bdf2 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The main changes are below. There are also many new or rewritten Notes. Avoiding simplifying repeatedly ~~~~~~~~~~~~~~~ See Note [Avoiding simplifying repeatedly] * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env. Currently used only for the next point: avoiding repeatedly simplifying coercions. * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] * Improve the case-merge transformation: - Move the main code to `GHC.Core.Utils.mergeCaseAlts`, to join `filterAlts` and friends. See Note [Merge Nested Cases] in GHC.Core.Utils. - Add a new case for `tagToEnum#`; see wrinkle (MC3). - Add a new case to look through join points: see wrinkle (MC4) postInlineUnconditionally ~~~~~~~~~~~~~~~~~~~~~~~~~ * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. * Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. * Improve occurrence analyis for bottoming function calls, to help postInlineUnconditionally. See Note [Bottoming function calls] in GHC.Core.Opt.OccurAnal Inlining generally ~~~~~~~~~~~~~~~~~~ * In GHC.Core.Opt.Simplify.Utils.interestingCallContext, use RhsCtxt NonRecursive (not BoringCtxt) for a plain-seq case. See Note [Seq is boring] Also, wrinkle (SB1), inline in that `seq` context only for INLINE functions (UnfWhen guidance). * In GHC.Core.Opt.Simplify.Utils.interestingArg, - return ValueArg for OtherCon [c1,c2, ...], but - return NonTrivArg for OtherCon [] This makes a function a little less likely to inline if all we know is that the argument is evaluated, but nothing else. * isConLikeUnfolding is no longer true for OtherCon {}. This propagates to exprIsConLike. Con-like-ness has /positive/ information. Join points ~~~~~~~~~~~ * Be very careful about inlining join points. See these two long Notes Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline * When making join points, don't do so if the join point is so small it will immediately be inlined; check uncondInlineJoin. * In GHC.Core.Opt.Simplify.Inline.tryUnfolding, improve the inlining heuristics for join points. In general we /do not/ want to inline join points /even if they are small/. See Note [Duplicating join points] GHC.Core.Opt.Simplify.Iteration. But sometimes we do: see Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline; and the new `isBetterUnfoldingThan` function. * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * In GHC.Core.Unfold.sizeExpr, make jumps small, so that we don't penalise having a non-inlined join point. Performance changes ~~~~~~~~~~~~~~~~~~~ * Binary sizes fall by around 2.6%, according to nofib. * Compile times improve slightly. Here are the figures over 1%. I investiate the biggest differnce in T18304. It's a very small module, just a few hundred nodes. The large percentage difffence is due to a single function that didn't quite inline before, and does now, making code size a bit bigger. I decided gains outweighed the losses. Metrics: compile_time/bytes allocated (changes over +/- 1%) ------------------------------------------------ CoOpt_Singletons(normal) -9.2% GOOD LargeRecord(normal) -23.5% GOOD MultiComponentModulesRecomp(normal) +1.2% MultiLayerModulesTH_OneShot(normal) +4.1% BAD PmSeriesS(normal) -3.8% PmSeriesV(normal) -1.5% T11195(normal) -1.3% T12227(normal) -20.4% GOOD T12545(normal) -3.2% T12707(normal) -2.1% GOOD T13253(normal) -1.2% T13253-spj(normal) +8.1% BAD T13386(normal) -3.1% GOOD T14766(normal) -2.6% GOOD T15164(normal) -1.4% T15304(normal) +1.2% T15630(normal) -8.2% T15630a(normal) NEW T15703(normal) -14.7% GOOD T16577(normal) -2.3% GOOD T17516(normal) -39.7% GOOD T18140(normal) +1.2% T18223(normal) -17.1% GOOD T18282(normal) -5.0% GOOD T18304(normal) +10.8% BAD T18923(normal) -2.9% GOOD T1969(normal) +1.0% T19695(normal) -1.5% T20049(normal) -12.7% GOOD T21839c(normal) -4.1% GOOD T3064(normal) -1.5% T3294(normal) +1.2% BAD T4801(normal) +1.2% T5030(normal) -15.2% GOOD T5321Fun(normal) -2.2% GOOD T6048(optasm) -16.8% GOOD T783(normal) -1.2% T8095(normal) -6.0% GOOD T9630(normal) -4.7% GOOD T9961(normal) +1.9% BAD WWRec(normal) -1.4% info_table_map_perf(normal) -1.3% parsing001(normal) +1.5% geo. mean -2.0% minimum -39.7% maximum +10.8% * Runtimes generally improve. In the testsuite perf/should_run gives: Metrics: runtime/bytes allocated ------------------------------------------ Conversions(normal) -0.3% T13536a(optasm) -41.7% GOOD T4830(normal) -0.1% haddock.Cabal(normal) -0.1% haddock.base(normal) -0.1% haddock.compiler(normal) -0.1% geo. mean -0.8% minimum -41.7% maximum +0.0% * For runtime, nofib is a better test. The news is mostly good. Here are the number more than +/- 0.1%: # bytes allocated ==========================++========== imaginary/digits-of-e1 || -14.40% imaginary/digits-of-e2 || -4.41% imaginary/paraffins || -0.17% imaginary/rfib || -0.15% imaginary/wheel-sieve2 || -0.10% real/compress || -0.47% real/fluid || -0.10% real/fulsom || +0.14% real/gamteb || -1.47% real/gg || -0.20% real/infer || +0.24% real/pic || -0.23% real/prolog || -0.36% real/scs || -0.46% real/smallpt || +4.03% shootout/k-nucleotide || -20.23% shootout/n-body || -0.42% shootout/spectral-norm || -0.13% spectral/boyer2 || -3.80% spectral/constraints || -0.27% spectral/hartel/ida || -0.82% spectral/mate || -20.34% spectral/para || +0.46% spectral/rewrite || +1.30% spectral/sphere || -0.14% ==========================++========== geom mean || -0.59% real/smallpt has a huge nest of local definitions, and I could not pin down a reason for a regression. But there are three big wins! Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12707 T13386 T13536a T14766 T15703 T16577 T17516 T18223 T18282 T18923 T21839c T20049 T5321Fun T5030 T6048 T8095 T9630 T783 Metric Increase: MultiLayerModulesTH_OneShot T13253-spj T18304 T18698a T9961 T3294 - - - - - 27db3c5e by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Testsuite message changes from simplifier improvements - - - - - 271a7812 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Account for bottoming functions in OccurAnal This fixes #24582, a small but long-standing bug - - - - - 0fde229f by Ben Gamari at 2024-04-04T07:04:58-04:00 testsuite: Introduce template-haskell-exports test - - - - - 0c4a9686 by Luite Stegeman at 2024-04-04T07:05:39-04:00 Update correct counter in bumpTickyAllocd - - - - - 5f085d3a by Fendor at 2024-04-04T14:47:33-04:00 Replace `SizedSeq` with `FlatBag` for flattened structure LinkedLists are notoriously memory ineffiecient when all we do is traversing a structure. As 'UnlinkedBCO' has been identified as a data structure that impacts the overall memory usage of GHCi sessions, we avoid linked lists and prefer flattened structure for storing. We introduce a new memory efficient representation of sequential elements that has special support for the cases: * Empty * Singleton * Tuple Elements This improves sharing in the 'Empty' case and avoids the overhead of 'Array' until its constant overhead is justified. - - - - - 82cfe10c by Fendor at 2024-04-04T14:47:33-04:00 Compact FlatBag array representation `Array` contains three additional `Word`'s we do not need in `FlatBag`. Move `FlatBag` to `SmallArray`. Expand the API of SmallArray by `sizeofSmallArray` and add common traversal functions, such as `mapSmallArray` and `foldMapSmallArray`. Additionally, allow users to force the elements of a `SmallArray` via `rnfSmallArray`. - - - - - 36a75b80 by Andrei Borzenkov at 2024-04-04T14:48:10-04:00 Change how invisible patterns represented in haskell syntax and TH AST (#24557) Before this patch: data ArgPat p = InvisPat (LHsType p) | VisPat (LPat p) With this patch: data Pat p = ... | InvisPat (LHsType p) ... And the same transformation in the TH land. The rest of the changes is just updating code to handle new AST and writing tests to check if it is possible to create invalid states using TH. Metric Increase: MultiLayerModulesTH_OneShot - - - - - 28009fbc by Matthew Pickering at 2024-04-04T14:48:46-04:00 Fix off by one error in seekBinNoExpand and seekBin - - - - - 9b9e031b by Ben Gamari at 2024-04-04T21:30:08-04:00 compiler: Allow more types in GHCForeignImportPrim For many, many years `GHCForeignImportPrim` has suffered from the rather restrictive limitation of not allowing any non-trivial types in arguments or results. This limitation was justified by the code generator allegely barfing in the presence of such types. However, this restriction appears to originate well before the NCG rewrite and the new NCG does not appear to have any trouble with such types (see the added `T24598` test). Lift this restriction. Fixes #24598. - - - - - 1324b862 by Alan Zimmerman at 2024-04-04T21:30:44-04:00 EPA: Use EpaLocation not SrcSpan in ForeignDecls This allows us to update them for makeDeltaAst in ghc-exactprint - - - - - 19883a23 by Alan Zimmerman at 2024-04-05T16:58:17-04:00 EPA: Use EpaLocation for RecFieldsDotDot So we can update it to a delta position in makeDeltaAst if needed. - - - - - e8724327 by Matthew Pickering at 2024-04-05T16:58:53-04:00 Remove accidentally committed test.hs - - - - - 88cb3e10 by Fendor at 2024-04-08T09:03:34-04:00 Avoid UArray when indexing is not required `UnlinkedBCO`'s can occur many times in the heap. Each `UnlinkedBCO` references two `UArray`'s but never indexes them. They are only needed to encode the elements into a `ByteArray#`. The three words for the lower bound, upper bound and number of elements are essentially unused, thus we replace `UArray` with a wrapper around `ByteArray#`. This saves us up to three words for each `UnlinkedBCO`. Further, to avoid re-allocating these words for `ResolvedBCO`, we repeat the procedure for `ResolvedBCO` and add custom `Binary` and `Show` instances. For example, agda's repl session has around 360_000 UnlinkedBCO's, so avoiding these three words is already saving us around 8MB residency. - - - - - f2cc1107 by Fendor at 2024-04-08T09:04:11-04:00 Never UNPACK `FastMutInt` for counting z-encoded `FastString`s In `FastStringTable`, we count the number of z-encoded FastStrings that exist in a GHC session. We used to UNPACK the counters to not waste memory, but live retainer analysis showed that we allocate a lot of `FastMutInt`s, retained by `mkFastZString`. We lazily compute the `FastZString`, only incrementing the counter when the `FastZString` is forced. The function `mkFastStringWith` calls `mkZFastString` and boxes the `FastMutInt`, leading to the following core: mkFastStringWith = \ mk_fs _ -> = case stringTable of { FastStringTable _ n_zencs segments# _ -> ... case ((mk_fs (I# ...) (FastMutInt n_zencs)) `cast` <Co:2> :: ...) ... Marking this field as `NOUNPACK` avoids this reboxing, eliminating the allocation of a fresh `FastMutInt` on every `FastString` allocation. - - - - - c6def949 by Matthew Pickering at 2024-04-08T16:06:51-04:00 Force in_multi to avoid retaining entire hsc_env - - - - - fbb91a63 by Fendor at 2024-04-08T16:06:51-04:00 Eliminate name thunk in declaration fingerprinting Thunk analysis showed that we have about 100_000 thunks (in agda and `-fwrite-simplified-core`) pointing to the name of the name decl. Forcing this thunk fixes this issue. The thunk created here is retained by the thunk created by forkM, it is better to eagerly force this because the result (a `Name`) is already retained indirectly via the `IfaceDecl`. - - - - - 3b7b0c1c by Alan Zimmerman at 2024-04-08T16:07:27-04:00 EPA: Use EpaLocation in WarningTxt This allows us to use an EpDelta if needed when using makeDeltaAst. - - - - - 12b997df by Alan Zimmerman at 2024-04-08T16:07:27-04:00 EPA: Move DeltaPos and EpaLocation' into GHC.Types.SrcLoc This allows us to use a NoCommentsLocation for the possibly trailing comma location in a StringLiteral. This in turn allows us to correctly roundtrip via makeDeltaAst. - - - - - 868c8a78 by Fendor at 2024-04-09T08:51:50-04:00 Prefer packed representation for CompiledByteCode As there are many 'CompiledByteCode' objects alive during a GHCi session, representing its element in a more packed manner improves space behaviour at a minimal cost. When running GHCi on the agda codebase, we find around 380 live 'CompiledByteCode' objects. Packing their respective 'UnlinkedByteCode' can save quite some pointers. - - - - - be3bddde by Alan Zimmerman at 2024-04-09T08:52:26-04:00 EPA: Capture all comments in a ClassDecl Hopefully the final fix needed for #24533 - - - - - 3d0806fc by Jade at 2024-04-10T05:39:53-04:00 Validate -main-is flag using parseIdentifier Fixes #24368 - - - - - dd530bb7 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: free error message before returning Fixes a memory leak in rts/linker/PEi386.c - - - - - e008a19a by Alexis King at 2024-04-10T05:40:29-04:00 linker: Avoid linear search when looking up Haskell symbols via dlsym See the primary Note [Looking up symbols in the relevant objects] for a more in-depth explanation. When dynamically loading a Haskell symbol (typical when running a splice or GHCi expression), before this commit we would search for the symbol in all dynamic libraries that were loaded. However, this could be very inefficient when too many packages are loaded (which can happen if there are many package dependencies) because the time to lookup the would be linear in the number of packages loaded. This commit drastically improves symbol loading performance by introducing a mapping from units to the handles of corresponding loaded dlls. These handles are returned by dlopen when we load a dll, and can then be used to look up in a specific dynamic library. Looking up a given Name is now much more precise because we can get lookup its unit in the mapping and lookup the symbol solely in the handles of the dynamic libraries loaded for that unit. In one measurement, the wait time before the expression was executed went from +-38 seconds down to +-2s. This commit also includes Note [Symbols may not be found in pkgs_loaded], explaining the fallback to the old behaviour in case no dll can be found in the unit mapping for a given Name. Fixes #23415 Co-authored-by: Rodrigo Mesquita (@alt-romes) - - - - - dcfaa190 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: Make addDLL a wrapper around loadNativeObj Rewrite the implementation of `addDLL` as a wrapper around the more principled `loadNativeObj` rts linker function. The latter should be preferred while the former is preserved for backwards compatibility. `loadNativeObj` was previously only available on ELF platforms, so this commit further refactors the rts linker to transform loadNativeObj_ELF into loadNativeObj_POSIX, which is available in ELF and MachO platforms. The refactor made it possible to remove the `dl_mutex` mutex in favour of always using `linker_mutex` (rather than a combination of both). Lastly, we implement `loadNativeObj` for Windows too. - - - - - 12931698 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 Use symbol cache in internal interpreter too This commit makes the symbol cache that was used by the external interpreter available for the internal interpreter too. This follows from the analysis in #23415 that suggests the internal interpreter could benefit from this cache too, and that there is no good reason not to have the cache for it too. It also makes it a bit more uniform to have the symbol cache range over both the internal and external interpreter. This commit also refactors the cache into a function which is used by both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the caching logic to `lookupSymbolInDLL` too. - - - - - dccd3ea1 by Ben Gamari at 2024-04-10T05:40:29-04:00 testsuite: Add test for lookupSymbolInNativeObj - - - - - 1b1a92bd by Alan Zimmerman at 2024-04-10T05:41:05-04:00 EPA: Remove unnecessary XRec in CompleteMatchSig The XRec for [LIdP pass] is not needed for exact printing, remove it. - - - - - 6e18ce2b by Ben Gamari at 2024-04-12T08:16:09-04:00 users-guide: Clarify language extension documentation Over the years the users guide's language extension documentation has gone through quite a few refactorings. In the process some of the descriptions have been rendered non-sensical. For instance, the description of `NoImplicitPrelude` actually describes the semantics of `ImplicitPrelude`. To fix this we: * ensure that all extensions are named in their "positive" sense (e.g. `ImplicitPrelude` rather than `NoImplicitPrelude`). * rework the documentation to avoid flag-oriented wording like "enable" and "disable" * ensure that the polarity of the documentation is consistent with reality. Fixes #23895. - - - - - a933aff3 by Zubin Duggal at 2024-04-12T08:16:45-04:00 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - 23c3e624 by Andreas Klebinger at 2024-04-12T08:17:21-04:00 RTS: Emit warning when -M < -H Fixes #24487 - - - - - d23afb8c by Ben Gamari at 2024-04-12T08:17:56-04:00 testsuite: Add broken test for CApiFFI with -fprefer-bytecode See #24634. - - - - - a4bb3a51 by Ben Gamari at 2024-04-12T08:18:32-04:00 base: Deprecate GHC.Pack As proposed in #21461. Closes #21540. - - - - - 55eb8c98 by Ben Gamari at 2024-04-12T08:19:08-04:00 ghc-internal: Fix mentions of ghc-internal in deprecation warnings Closes #24609. - - - - - b0fbd181 by Ben Gamari at 2024-04-12T08:19:44-04:00 rts: Implement set_initial_registers for AArch64 Fixes #23680. - - - - - 14c9ec62 by Ben Gamari at 2024-04-12T08:20:20-04:00 ghcup-metadata: Use Debian 9 binaries on Ubuntu 16, 17 Closes #24646. - - - - - 35a1621e by Ben Gamari at 2024-04-12T08:20:55-04:00 Bump unix submodule to 2.8.5.1 Closes #24640. - - - - - a1c24df0 by Finley McIlwaine at 2024-04-12T08:21:31-04:00 Correct default -funfolding-use-threshold in docs - - - - - 0255d03c by Oleg Grenrus at 2024-04-12T08:22:07-04:00 FastString is a __Modified__ UTF-8 - - - - - c3489547 by Matthew Pickering at 2024-04-12T13:13:44-04:00 rts: Improve tracing message when nursery is resized It is sometimes more useful to know how much bigger or smaller the nursery got when it is resized. In particular I am trying to investigate situations where we end up with fragmentation due to the nursery (#24577) - - - - - 5e4f4ba8 by Simon Peyton Jones at 2024-04-12T13:14:20-04:00 Don't generate wrappers for `type data` constructors with StrictData Previously, the logic for checking if a data constructor needs a wrapper or not would take into account whether the constructor's fields have explicit strictness (e.g., `data T = MkT !Int`), but the logic would _not_ take into account whether `StrictData` was enabled. This meant that something like `type data T = MkT Int` would incorrectly generate a wrapper for `MkT` if `StrictData` was enabled, leading to the horrible errors seen in #24620. To fix this, we disable generating wrappers for `type data` constructors altogether. Fixes #24620. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - dbdf1995 by Alex Mason at 2024-04-15T15:28:26+10:00 Implements MO_S_Mul2 and MO_U_Mul2 using the UMULH, UMULL and SMULH instructions for AArch64 Also adds a test for MO_S_Mul2 - - - - - 42bd0407 by Teo Camarasu at 2024-04-16T20:06:39-04:00 Make template-haskell a stage1 package Promoting template-haskell from a stage0 to a stage1 package means that we can much more easily refactor template-haskell. We implement this by duplicating the in-tree `template-haskell`. A new `template-haskell-next` library is autogenerated to mirror `template-haskell` `stage1:ghc` to depend on the new interface of the library including the `Binary` instances without adding an explicit dependency on `template-haskell`. This is controlled by the `bootstrap-th` cabal flag When building `template-haskell` modules as part of this vendoring we do not have access to quote syntax, so we cannot use variable quote notation (`'Just`). So we either replace these with hand-written `Name`s or hide the code behind CPP. We can remove the `th_hack` from hadrian, which was required when building stage0 packages using the in-tree `template-haskell` library. For more details see Note [Bootstrapping Template Haskell]. Resolves #23536 Co-Authored-By: Sebastian Graf <sgraf1337 at gmail.com> Co-Authored-By: Matthew Craven <5086-clyring at users.noreply.gitlab.haskell.org> - - - - - 3d973e47 by Ben Gamari at 2024-04-16T20:07:15-04:00 Bump parsec submodule to 3.1.17.0 - - - - - 9d38bfa0 by Simon Peyton Jones at 2024-04-16T20:07:51-04:00 Clone CoVars in CorePrep This MR addresses #24463. It's all explained in the new Note [Cloning CoVars and TyVars] - - - - - 0fe2b410 by Andreas Klebinger at 2024-04-16T20:08:27-04:00 NCG: Fix a bug where we errounously removed a required jump instruction. Add a new method to the Instruction class to check if we can eliminate a jump in favour of fallthrough control flow. Fixes #24507 - - - - - 9f99126a by Teo Camarasu at 2024-04-16T20:09:04-04:00 Fix documentation preview from doc-tarball job - Include all the .html files and assets in the job artefacts - Include all the .pdf files in the job artefacts - Mark the artefact as an "exposed" artefact meaning it turns up in the UI. Resolves #24651 - - - - - 3a0642ea by Ben Gamari at 2024-04-16T20:09:39-04:00 rts: Ignore EINTR while polling in timerfd itimer implementation While the RTS does attempt to mask signals, it may be that a foreign library unmasks them. This previously caused benign warnings which we now ignore. See #24610. - - - - - 9a53cd3f by Alan Zimmerman at 2024-04-16T20:10:15-04:00 EPA: Add additional comments field to AnnsModule This is used in exact printing to store comments coming after the `where` keyword but before any comments allocated to imports or decls. It is used in ghc-exactprint, see https://github.com/alanz/ghc-exactprint/commit/44bbed311fd8f0d053053fef195bf47c17d34fa7 - - - - - e5c43259 by Bryan Richter at 2024-04-16T20:10:51-04:00 Remove unrunnable FreeBSD CI jobs FreeBSD runner supply is inelastic. Currently there is only one, and it's unavailable because of a hardware issue. - - - - - 914eb49a by Ben Gamari at 2024-04-16T20:11:27-04:00 rel-eng: Fix mktemp usage in recompress-all We need a temporary directory, not a file. - - - - - f30e4984 by Teo Camarasu at 2024-04-16T20:12:03-04:00 Fix ghc API link in docs/index.html This was missing part of the unit ID meaning it would 404. Resolves #24674 - - - - - d7a3d6b5 by Ben Gamari at 2024-04-16T20:12:39-04:00 template-haskell: Declare TH.Lib.Internal as not-home Rather than `hide`. Closes #24659. - - - - - 5eaa46e7 by Matthew Pickering at 2024-04-19T02:14:55-04:00 testsuite: Rename isCross() predicate to needsTargetWrapper() isCross() was a misnamed because it assumed that all cross targets would provide a target wrapper, but the two most common cross targets (javascript, wasm) don't need a target wrapper. Therefore we rename this predicate to `needsTargetWrapper()` so situations in the testsuite where we can check whether running executables requires a target wrapper or not. - - - - - 55a9d699 by Simon Peyton Jones at 2024-04-19T02:15:32-04:00 Do not float HNFs out of lambdas This MR adjusts SetLevels so that it is less eager to float a HNF (lambda or constructor application) out of a lambda, unless it gets to top level. Data suggests that this change is a small net win: * nofib bytes-allocated falls by -0.09% (but a couple go up) * perf/should_compile bytes-allocated falls by -0.5% * perf/should_run bytes-allocated falls by -0.1% See !12410 for more detail. When fiddling elsewhere, I also found that this patch had a huge positive effect on the (very delicate) test perf/should_run/T21839r But that improvement doesn't show up in this MR by itself. Metric Decrease: MultiLayerModulesRecomp T15703 parsing001 - - - - - f0701585 by Alan Zimmerman at 2024-04-19T02:16:08-04:00 EPA: Fix comments in mkListSyntaxTy0 Also extend the test to confirm. Addresses #24669, 1 of 4 - - - - - b01c01d4 by Serge S. Gulin at 2024-04-19T02:16:51-04:00 JS: set image `x86_64-linux-deb11-emsdk-closure` for build - - - - - c90c6039 by Alan Zimmerman at 2024-04-19T02:17:27-04:00 EPA: Provide correct span for PatBind And remove unused parameter in checkPatBind Contributes to #24669 - - - - - 26036f96 by Alan Zimmerman at 2024-04-19T13:11:08-04:00 EPA: Fix span for PatBuilderAppType Include the location of the prefix @ in the span for InVisPat. Also removes unnecessary annotations from HsTP. Contributes to #24669 - - - - - dba03aab by Matthew Craven at 2024-04-19T13:11:44-04:00 testsuite: Give the pre_cmd for mhu-perf more time - - - - - d31fbf6c by Krzysztof Gogolewski at 2024-04-19T21:04:09-04:00 Fix quantification order for a `op` b and a %m -> b Fixes #23764 Implements https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0640-tyop-quantification-order.rst Updates haddock submodule. - - - - - 385cd1c4 by Sebastian Graf at 2024-04-19T21:04:45-04:00 Make `seq#` a magic Id and inline it in CorePrep (#24124) We can save much code and explanation in Tag Inference and StgToCmm by making `seq#` a known-key Magic Id in `GHC.Internal.IO` and inline this definition in CorePrep. See the updated `Note [seq# magic]`. I also implemented a new `Note [Flatten case-bind]` to get better code for otherwise nested case scrutinees. I renamed the contructors of `ArgInfo` to use an `AI` prefix in order to resolve the clash between `type CpeApp = CoreExpr` and the data constructor of `ArgInfo`, as well as fixed typos in `Note [CorePrep invariants]`. Fixes #24252 and #24124. - - - - - 275e41a9 by Jade at 2024-04-20T11:10:40-04:00 Put the newline after errors instead of before them This mainly has consequences for GHCi but also slightly alters how the output of GHC on the commandline looks. Fixes: #22499 - - - - - dd339c7a by Teo Camarasu at 2024-04-20T11:11:16-04:00 Remove unecessary stage0 packages Historically quite a few packages had to be stage0 as they depended on `template-haskell` and that was stage0. In #23536 we made it so that was no longer the case. This allows us to remove a bunch of packages from this list. A few still remain. A new version of `Win32` is required by `semaphore-compat`. Including `Win32` in the stage0 set requires also including `filepath` because otherwise Hadrian's dependency logic gets confused. Once our boot compiler has a newer version of `Win32` all of these will be able to be dropped. Resolves #24652 - - - - - 2f8e3a25 by Alan Zimmerman at 2024-04-20T11:11:52-04:00 EPA: Avoid duplicated comments in splice decls Contributes to #24669 - - - - - c70b9ddb by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fix typos and namings (fixes #24602) You may noted that I've also changed term of ``` , global "h$vt_double" ||= toJExpr IntV ``` See "IntV" and ``` WaitReadOp -> \[] [fd] -> pure $ PRPrimCall $ returnS (app "h$waidRead" [fd]) ``` See "h$waidRead" - - - - - 3db54f9b by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: trivial checks for variable presence (fixes #24602) - - - - - 777f108f by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fs module imported twice (by emscripten and by ghc-internal). ghc-internal import wrapped in a closure to prevent conflict with emscripten (fixes #24602) Better solution is to use some JavaScript module system like AMD, CommonJS or even UMD. It will be investigated at other issues. At first glance we should try UMD (See https://github.com/umdjs/umd) - - - - - a45a5712 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: thread.js requires h$fds and h$fdReady to be declared for static code analysis, minimal code copied from GHCJS (fixes #24602) I've just copied some old pieces of GHCJS from publicly available sources (See https://github.com/Taneb/shims/blob/a6dd0202dcdb86ad63201495b8b5d9763483eb35/src/io.js#L607). Also I didn't put details to h$fds. I took minimal and left only its object initialization: `var h$fds = {};` - - - - - ad90bf12 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: heap and stack overflows reporting defined as js hard failure (fixes #24602) These errors were treated as a hard failure for browser application. The fix is trivial: just throw error. - - - - - 5962fa52 by Serge S. Gulin at 2024-04-21T16:33:44+03:00 JS: Stubs for code without actual implementation detected by Google Closure Compiler (fixes #24602) These errors were fixed just by introducing stubbed functions with throw for further implementation. - - - - - a0694298 by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add externs to linker (fixes #24602) After enabling jsdoc and built-in google closure compiler types I was needed to deal with the following: 1. Define NodeJS-environment types. I've just copied minimal set of externs from semi-official repo (see https://github.com/externs/nodejs/blob/6c6882c73efcdceecf42e7ba11f1e3e5c9c041f0/v8/nodejs.js#L8). 2. Define Emscripten-environment types: `HEAP8`. Emscripten already provides some externs in our code but it supposed to be run in some module system. And its definitions do not work well in plain bundle. 3. We have some functions which purpose is to add to functions some contextual information via function properties. These functions should be marked as `modifies` to let google closure compiler remove calls if these functions are not used actually by call graph. Such functions are: `h$o`, `h$sti`, `h$init_closure`, `h$setObjInfo`. 4. STG primitives such as registries and stuff from `GHC.StgToJS`. `dXX` properties were already present at externs generator function but they are started from `7`, not from `1`. This message is related: `// fixme does closure compiler bite us here?` - - - - - e58bb29f by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: added both tests: for size and for correctness (fixes #24602) By some reason MacOS builds add to stderr messages like: Ignoring unexpected archive entry: __.SYMDEF ... However I left stderr to `/dev/null` for compatibility with linux CI builds. - - - - - 909f3a9c by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Disable js linker warning for empty symbol table to make js tests running consistent across environments - - - - - 83eb10da by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add special preprocessor for js files due of needing to keep jsdoc comments (fixes #24602) Our js files have defined google closure compiler types at jsdoc entries but these jsdoc entries are removed by cpp preprocessor. I considered that reusing them in javascript-backend would be a nice thing. Right now haskell processor uses `-traditional` option to deal with comments and `//` operators. But now there are following compiler options: `-C` and `-CC`. You can read about them at GCC (see https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#index-CC) and CLang (see https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-CC). It seems that `-CC` works better for javascript jsdoc than `-traditional`. At least it leaves `/* ... */` comments w/o changes. - - - - - e1cf8dc2 by brandon s allbery kf8nh at 2024-04-22T03:48:26-04:00 fix link in CODEOWNERS It seems that our local Gitlab no longer has documentation for the `CODEOWNERS` file, but the master documentation still does. Use that instead. - - - - - 593f4e04 by Fendor at 2024-04-23T10:19:14-04:00 Add performance regression test for '-fwrite-simplified-core' - - - - - 1ba39b05 by Fendor at 2024-04-23T10:19:14-04:00 Typecheck corebindings lazily during bytecode generation This delays typechecking the corebindings until the bytecode generation happens. We also avoid allocating a thunk that is retained by `unsafeInterleaveIO`. In general, we shouldn't retain values of the hydrated `Type`, as not evaluating the bytecode object keeps it alive. It is better if we retain the unhydrated `IfaceType`. See Note [Hydrating Modules] - - - - - e916fc92 by Alan Zimmerman at 2024-04-23T10:19:50-04:00 EPA: Keep comments in a CaseAlt match The comments now live in the surrounding location, not inside the Match. Make sure we keep them. Closes #24707 - - - - - d2b17f32 by Cheng Shao at 2024-04-23T15:01:22-04:00 driver: force merge objects when building dynamic objects This patch forces the driver to always merge objects when building dynamic objects even when ar -L is supported. It is an oversight of !8887: original rationale of that patch is favoring the relatively cheap ar -L operation over object merging when ar -L is supported, which makes sense but only if we are building static objects! Omitting check for whether we are building dynamic objects will result in broken .so files with undefined reference errors at executable link time when building GHC with llvm-ar. Fixes #22210. - - - - - 209d09f5 by Julian Ospald at 2024-04-23T15:02:03-04:00 Allow non-absolute values for bootstrap GHC variable Fixes #24682 - - - - - 3fff0977 by Matthew Pickering at 2024-04-23T15:02:38-04:00 Don't depend on registerPackage function in Cabal More recent versions of Cabal modify the behaviour of libAbiHash which breaks our usage of registerPackage. It is simpler to inline the part of registerPackage that we need and avoid any additional dependency and complication using the higher-level function introduces. - - - - - c62dc317 by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: remove obsolete ln script This commit removes an obsolete ln script in ghc-bignum/gmp. See 060251c24ad160264ae8553efecbb8bed2f06360 for its original intention, but it's been obsolete for a long time, especially since the removal of the make build system. Hence the house cleaning. - - - - - 6399d52b by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: update gmp to 6.3.0 This patch bumps the gmp-tarballs submodule and updates gmp to 6.3.0. The tarball format is now xz, and gmpsrc.patch has been patched into the tarball so hadrian no longer needs to deal with patching logic when building in-tree GMP. - - - - - 65b4b92f by Cheng Shao at 2024-04-25T01:32:02-04:00 hadrian: remove obsolete Patch logic This commit removes obsolete Patch logic from hadrian, given we no longer need to patch the gmp tarball when building in-tree GMP. - - - - - 71f28958 by Cheng Shao at 2024-04-25T01:32:02-04:00 autoconf: remove obsolete patch detection This commit removes obsolete deletection logic of the patch command from autoconf scripts, given we no longer need to patch anything in the GHC build process. - - - - - daeda834 by Sylvain Henry at 2024-04-25T01:32:43-04:00 JS: correctly handle RUBBISH literals (#24664) - - - - - 8a06ddf6 by Matthew Pickering at 2024-04-25T11:16:16-04:00 Linearise ghc-internal and base build This is achieved by requesting the final package database for ghc-internal, which mandates it is fully built as a dependency of configuring the `base` package. This is at the expense of cross-package parrallelism between ghc-internal and the base package. Fixes #24436 - - - - - 94da9365 by Andrei Borzenkov at 2024-04-25T11:16:54-04:00 Fix tuple puns renaming (24702) Move tuple renaming short cutter from `isBuiltInOcc_maybe` to `isPunOcc_maybe`, so we consider incoming module. I also fixed some hidden bugs that raised after the change was done. - - - - - fa03b1fb by Fendor at 2024-04-26T18:03:13-04:00 Refactor the Binary serialisation interface The goal is simplifiy adding deduplication tables to `ModIface` interface serialisation. We identify two main points of interest that make this difficult: 1. UserData hardcodes what `Binary` instances can have deduplication tables. Moreover, it heavily uses partial functions. 2. GHC.Iface.Binary hardcodes the deduplication tables for 'Name' and 'FastString', making it difficult to add more deduplication. Instead of having a single `UserData` record with fields for all the types that can have deduplication tables, we allow to provide custom serialisers for any `Typeable`. These are wrapped in existentials and stored in a `Map` indexed by their respective `TypeRep`. The `Binary` instance of the type to deduplicate still needs to explicitly look up the decoder via `findUserDataReader` and `findUserDataWriter`, which is no worse than the status-quo. `Map` was chosen as microbenchmarks indicate it is the fastest for a small number of keys (< 10). To generalise the deduplication table serialisation mechanism, we introduce the types `ReaderTable` and `WriterTable` which provide a simple interface that is sufficient to implement a general purpose deduplication mechanism for `writeBinIface` and `readBinIface`. This allows us to provide a list of deduplication tables for serialisation that can be extended more easily, for example for `IfaceTyCon`, see the issue https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for more motivation. In addition to this refactoring, we split `UserData` into `ReaderUserData` and `WriterUserData`, to avoid partial functions and reduce overall memory usage, as we need fewer mutable variables. Bump haddock submodule to accomodate for `UserData` split. ------------------------- Metric Increase: MultiLayerModulesTH_Make MultiLayerModulesRecomp T21839c ------------------------- - - - - - bac57298 by Fendor at 2024-04-26T18:03:13-04:00 Split `BinHandle` into `ReadBinHandle` and `WriteBinHandle` A `BinHandle` contains too much information for reading data. For example, it needs to keep a `FastMutInt` and a `IORef BinData`, when the non-mutable variants would suffice. Additionally, this change has the benefit that anyone can immediately tell whether the `BinHandle` is used for reading or writing. Bump haddock submodule BinHandle split. - - - - - 4d6394dd by Simon Peyton Jones at 2024-04-26T18:03:49-04:00 Fix missing escaping-kind check in tcPatSynSig Note [Escaping kind in type signatures] explains how we deal with escaping kinds in type signatures, e.g. f :: forall r (a :: TYPE r). a where the kind of the body is (TYPE r), but `r` is not in scope outside the forall-type. I had missed this subtlety in tcPatSynSig, leading to #24686. This MR fixes it; and a similar bug in tc_top_lhs_type. (The latter is tested by T24686a.) - - - - - 981c2c2c by Alan Zimmerman at 2024-04-26T18:04:25-04:00 EPA: check-exact: check that the roundtrip reproduces the source Closes #24670 - - - - - a8616747 by Andrew Lelechenko at 2024-04-26T18:05:01-04:00 Document that setEnv is not thread-safe - - - - - 1e41de83 by Bryan Richter at 2024-04-26T18:05:37-04:00 CI: Work around frequent Signal 9 errors - - - - - a6d5f9da by Naïm Favier at 2024-04-27T17:52:40-04:00 ghc-internal: add MonadFix instance for (,) Closes https://gitlab.haskell.org/ghc/ghc/-/issues/24288, implements CLC proposal https://github.com/haskell/core-libraries-committee/issues/238. Adds a MonadFix instance for tuples, permitting value recursion in the "native" writer monad and bringing consistency with the existing instance for transformers's WriterT (and, to a lesser extent, for Solo). - - - - - 64feadcd by Rodrigo Mesquita at 2024-04-27T17:53:16-04:00 bindist: Fix xattr cleaning The original fix (725343aa) was incorrect because it used the shell bracket syntax which is the quoting syntax in autoconf, making the test for existence be incorrect and therefore `xattr` was never run. Fixes #24554 - - - - - e2094df3 by damhiya at 2024-04-28T23:52:00+09:00 Make read accepts binary integer formats CLC proposal : https://github.com/haskell/core-libraries-committee/issues/177 - - - - - 1c2fd963 by Alan Zimmerman at 2024-04-29T23:17:00-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 - - - - - 4189d17e by Sylvain Henry at 2024-04-29T23:17:42-04:00 LLVM: better unreachable default destination in Switch (#24717) See added note. Co-authored-by: Siddharth Bhat <siddu.druid at gmail.com> - - - - - a3725c88 by Cheng Shao at 2024-04-29T23:18:20-04:00 ci: enable wasm jobs for MRs with wasm label This patch enables wasm jobs for MRs with wasm label. Previously the wasm label didn't actually have any effect on the CI pipeline, and full-ci needed to be applied to run wasm jobs which was a waste of runners when working on the wasm backend, hence the fix here. - - - - - 702f7964 by Matthew Pickering at 2024-04-29T23:18:56-04:00 Make interface files and object files depend on inplace .conf file A potential fix for #24737 - - - - - 728af21e by Cheng Shao at 2024-04-30T05:30:23-04:00 utils: remove obsolete vagrant scripts Vagrantfile has long been removed in !5288. This commit further removes the obsolete vagrant scripts in the tree. - - - - - 36f2c342 by Cheng Shao at 2024-04-30T05:31:00-04:00 Update autoconf scripts Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 - - - - - ecbf22a6 by Ben Gamari at 2024-04-30T05:31:36-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 64a51487 by Oleg Grenrus at 2024-05-03T00:00:38+03:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d6a73ab7 by Oleg Grenrus at 2024-05-03T00:03:50+03:00 Add reflections of GHC.TypeLits/Nats type families - - - - - 18 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - .gitmodules - CODEOWNERS - compiler/GHC.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c299dcd130c5116f6a378e791e2327ab5afc50c4...d6a73ab775116782c8f624b1b3a0644a37f182d6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c299dcd130c5116f6a378e791e2327ab5afc50c4...d6a73ab775116782c8f624b1b3a0644a37f182d6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu May 2 22:31:50 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Thu, 02 May 2024 18:31:50 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/az/T24755-epa-checktyclhdr-comments Message-ID: <6634145683765_1a3d2459da7d818183d@gitlab.mail> Alan Zimmerman pushed new branch wip/az/T24755-epa-checktyclhdr-comments at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/T24755-epa-checktyclhdr-comments You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 06:04:08 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 03 May 2024 02:04:08 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Add DCoVarSet to PluginProv (!12037) Message-ID: <66347e57eeebc_10d81b586dd0374a9@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 664cf291 by Mikolaj Konarski at 2024-05-03T02:03:46-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - 7f530196 by Ben Gamari at 2024-05-03T02:03:47-04:00 Bump time submodule to 1.14 As requested in #24528. - - - - - 75ae54f3 by Ben Gamari at 2024-05-03T02:03:47-04:00 Bump terminfo submodule to current master - - - - - 5450d270 by Cheng Shao at 2024-05-03T02:03:48-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 7962839d by Alan Zimmerman at 2024-05-03T02:03:48-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - 30 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Tc/TyCl/Utils.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/RepType.hs - compiler/GHC/Types/TyThing/Ppr.hs - compiler/GHC/Types/Unique/DSet.hs - compiler/GHC/Types/Var/Set.hs - compiler/GHC/Utils/FV.hs - compiler/ghc.cabal.in - docs/users_guide/9.12.1-notes.rst - docs/users_guide/extending_ghc.rst - ghc/ghc-bin.cabal.in - libraries/Cabal - libraries/directory - libraries/hpc The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3ea00c12e33215cceefa8db0841c9411e358e151...7962839dff8d46daca9b8d40c529308436944e81 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3ea00c12e33215cceefa8db0841c9411e358e151...7962839dff8d46daca9b8d40c529308436944e81 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 07:04:55 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Fri, 03 May 2024 03:04:55 -0400 Subject: [Git][ghc/ghc][wip/romes/egraphs-pmc-2] The rest of the owl Message-ID: <66348c97b0a59_10d81bd023ac4361a@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/egraphs-pmc-2 at Glasgow Haskell Compiler / GHC Commits: 9abd4a94 by Rodrigo Mesquita at 2024-05-03T08:00:04+01:00 The rest of the owl Drawing of multiple owls Keep drawing WIP MORE WIP ALMOST WIP... WIP.; whitsepac Ww Better Outputable instance mergeNotConCt can't use implications only now...? Sometimes we can omit implied nalts Fixes + debugging STAGE 1 BUILDS WITHOUT FAILURES. depstest submodule update - - - - - 7 changed files: - + TODO - compiler/GHC/Core.hs - compiler/GHC/Core/Equality.hs - compiler/GHC/HsToCore/Pmc/Solver.hs - compiler/GHC/HsToCore/Pmc/Solver/Types.hs - libraries/hegg - testsuite/tests/count-deps/CountDepsParser.stdout Changes: ===================================== TODO ===================================== @@ -0,0 +1,9 @@ +The current failures might be because congruence isn't being maintained properly downwards, I think...? +Instead, we might do this manually for merging positive constructor info in the e-graphs analysis modify function? + +If this works, the major todos are +* Propagating strictness annotations to underlying newtypes (likely modify analysis) +* Clean up equality + * How to do Ord Type? +* Clean up solver + * Merge args of data cons when merging by congruence (likely modify analysis as well) ===================================== compiler/GHC/Core.hs ===================================== @@ -294,6 +294,7 @@ data AltCon -- The instance adheres to the order described in Note [Case expression invariants] instance Ord AltCon where compare (DataAlt con1) (DataAlt con2) = + -- ROMES:TODO: Couldn't simply do this right by comparing the dataConName of the cons? assert (dataConTyCon con1 == dataConTyCon con2) $ compare (dataConTag con1) (dataConTag con2) compare (DataAlt _) _ = GT ===================================== compiler/GHC/Core/Equality.hs ===================================== @@ -17,7 +17,6 @@ import GHC.Core.TyCo.Rep import GHC.Core.Map.Type import GHC.Types.Var import GHC.Types.Literal -import GHC.Types.Tickish import Data.Equality.Graph as EG import Data.Equality.Analysis.Monadic @@ -91,7 +90,7 @@ instance Ord AltCon' where -- we might as well make it a better suited representation for the e-graph... -- keeping the on-fly debruijn is harder representCoreExprEgr :: forall a m - . Analysis m a CoreExprF + . AnalysisM m a CoreExprF => CoreExpr -> EGraph a CoreExprF -> m (ClassId, EGraph a CoreExprF) @@ -134,7 +133,7 @@ representCoreExprEgr expr egr = EGM.runEGraphMT egr (runReaderT (go expr) emptyC e' <- local (`extendCMEs` bs) $ go e return (AltF (AC' c) (map (const ()) bs) e') - addE :: Analysis m a CoreExprF => CoreExprF ClassId -> ReaderT CmEnv (EGM.EGraphMT a CoreExprF m) ClassId + addE :: AnalysisM m a CoreExprF => CoreExprF ClassId -> ReaderT CmEnv (EGM.EGraphMT a CoreExprF m) ClassId addE e = lift $ EGM.addM $ Node e {-# INLINEABLE representCoreExprEgr #-} @@ -142,6 +141,9 @@ type CoreExprF = ExprF type CoreAltF = AltF type CoreBindF = BindF +instance Outputable (EG.ENode CoreExprF) where + ppr (EG.Node n) = text (show n) + -- cmpDeBruijnTickish :: DeBruijn CoreTickish -> DeBruijn CoreTickish -> Ordering -- cmpDeBruijnTickish (D env1 t1) (D env2 t2) = go t1 t2 where -- go (Breakpoint lext lid lids _) (Breakpoint rext rid rids _) ===================================== compiler/GHC/HsToCore/Pmc/Solver.hs ===================================== @@ -1,6 +1,13 @@ -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE TupleSections #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE MultiWayIf #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE RankNTypes, GADTs #-} +{-# OPTIONS_GHC -Wno-orphans #-} -- Analysis........ {- Authors: George Karachalias @@ -48,22 +55,22 @@ import GHC.Data.Bag import GHC.Types.CompleteMatch import GHC.Types.Unique.Set import GHC.Types.Unique.DSet -import GHC.Types.Unique.SDFM import GHC.Types.Id import GHC.Types.Name import GHC.Types.Var (EvVar) import GHC.Types.Var.Env -import GHC.Types.Var.Set import GHC.Types.Unique.Supply import GHC.Core +import GHC.Core.Equality import GHC.Core.FVs (exprFreeVars) import GHC.Core.TyCo.Compare( eqType ) -import GHC.Core.Map.Expr +import GHC.Core.Map.Type (deBruijnize) import GHC.Core.Predicate (typeDeterminesValue) import GHC.Core.SimpleOpt (simpleOptExpr, exprIsConApp_maybe) import GHC.Core.Utils (exprType) -import GHC.Core.Make (mkListExpr, mkCharExpr, mkImpossibleExpr) +import GHC.Core.Make (mkListExpr, mkCharExpr, mkImpossibleExpr, mkCoreApp) +import GHC.Types.Id.Make (unboxedUnitExpr) import GHC.Data.FastString import GHC.Types.SrcLoc @@ -97,6 +104,14 @@ import Data.List (sortBy, find) import qualified Data.List.NonEmpty as NE import Data.Ord (comparing) +import Data.Equality.Analysis.Monadic +import Data.Equality.Graph (ClassId) +import Data.Equality.Graph.Lens +import qualified Data.Equality.Graph as EG +import qualified Data.Equality.Graph.Monad as EGM +import Data.Function ((&)) +import qualified Data.IntSet as IS + -- -- * Main exports -- @@ -602,8 +617,10 @@ addPhiCts :: Nabla -> PhiCts -> DsM (Maybe Nabla) -- See Note [TmState invariants]. addPhiCts nabla cts = runMaybeT $ do let (ty_cts, tm_cts) = partitionPhiCts cts - nabla' <- addTyCts nabla (listToBag ty_cts) + nabla' <- addTyCts nabla (listToBag ty_cts) nabla'' <- foldlM addPhiTmCt nabla' (listToBag tm_cts) + lift $ tracePm "addPhiCts, doing inhabitationTest" (ppr nabla'') + -- ROMES:TODO: Should the ty_st be nabla' or nabla'' !? inhabitationTest initFuel (nabla_ty_st nabla) nabla'' partitionPhiCts :: PhiCts -> ([PredType], [PhiCt]) @@ -666,7 +683,7 @@ addPhiTmCt nabla (PhiConCt x con tvs dicts args) = do -- PhiConCt correspond to the higher-level φ constraints from the paper with -- bindings semantics. It disperses into lower-level δ constraints that the -- 'add*Ct' functions correspond to. - nabla' <- addTyCts nabla (listToBag dicts) + nabla' <- addTyCts nabla (listToBag dicts) nabla'' <- addConCt nabla' x con tvs args foldlM addNotBotCt nabla'' (filterUnliftedFields con args) addPhiTmCt nabla (PhiNotConCt x con) = addNotConCt nabla x con @@ -682,33 +699,68 @@ filterUnliftedFields con args = -- surely diverges. Quite similar to 'addConCt', only that it only cares about -- ⊥. addBotCt :: Nabla -> Id -> MaybeT DsM Nabla -addBotCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ ts_facts=env } } x = do - let (y, vi at VI { vi_bot = bot }) = lookupVarInfoNT (nabla_tm_st nabla) x - case bot of - IsNotBot -> mzero -- There was x ≁ ⊥. Contradiction! - IsBot -> pure nabla -- There already is x ~ ⊥. Nothing left to do - MaybeBot -- We add x ~ ⊥ - | definitelyUnliftedType (idType x) - -- Case (3) in Note [Strict fields and variables of unlifted type] - -> mzero -- unlifted vars can never be ⊥ - | otherwise - -> do - let vi' = vi{ vi_bot = IsBot } - pure nabla{ nabla_tm_st = ts{ts_facts = addToUSDFM env y vi' } } +addBotCt nabla0 at MkNabla{nabla_tm_st = ts0} x = do + let (y, vi at VI { vi_bot = bot0 }) = lookupVarInfoNT ts0 x + -- NOTE FOR REVIEWER: + -- we were previously using the idType of |x|, but I think it should rather + -- be |y|, since, if y /= x, then x is a newtype and newtypes cannot be + -- unlifted + bot1 <- mergeBots (idType y) IsBot bot0 + let vi' = vi{ vi_bot = bot1 } + + (yid, nabla1) <- representId y nabla0 + + pure (nabla1 & nabla_egr._class yid._data .~ Just vi') -- | Adds the constraint @x ~/ ⊥@ to 'Nabla'. Quite similar to 'addNotConCt', -- but only cares for the ⊥ "constructor". addNotBotCt :: Nabla -> Id -> MaybeT DsM Nabla -addNotBotCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ts_facts=env} } x = do - let (y, vi at VI { vi_bot = bot }) = lookupVarInfoNT (nabla_tm_st nabla) x - case bot of - IsBot -> mzero -- There was x ~ ⊥. Contradiction! - IsNotBot -> pure nabla -- There already is x ≁ ⊥. Nothing left to do - MaybeBot -> do -- We add x ≁ ⊥ and test if x is still inhabited - -- Mark dirty for a delayed inhabitation test - let vi' = vi{ vi_bot = IsNotBot} - pure $ markDirty y - $ nabla{ nabla_tm_st = ts{ ts_facts = addToUSDFM env y vi' } } +addNotBotCt nabla0 at MkNabla{ nabla_tm_st = ts0 } x = do + let (y, vi at VI { vi_bot = bot0 }) = lookupVarInfoNT ts0 x + bot1 <- mergeBots (idType y) IsNotBot bot0 + let vi' = vi{ vi_bot = bot1 } + + (yid, nabla1) <- representId y nabla0 + let + marked + = case bot0 of + -- Mark dirty for a delayed inhabitation test (see comment in 'mergeBots' as well) + MaybeBot -> markDirty y + _ -> id + return $ + marked + (nabla1 & nabla_egr._class yid._data .~ Just vi') + +mergeBots :: Type + -- ^ The type of the pattern whose 'BotInfo's are being merged + -> BotInfo + -> BotInfo + -> MaybeT DsM BotInfo +-- There already is x ~ ⊥. Nothing left to do +mergeBots _ IsBot IsBot = pure IsBot +-- There was x ≁ ⊥. Contradiction! +mergeBots _ IsBot IsNotBot = mzero +-- We add x ~ ⊥ +mergeBots t IsBot MaybeBot + | definitelyUnliftedType t + -- Case (3) in Note [Strict fields and variables of unlifted type] + -- (unlifted vars can never be ⊥) + = mzero + | otherwise + = pure IsBot +-- There was x ~ ⊥. Contradiction! +mergeBots _ IsNotBot IsBot = mzero +-- There already is x ≁ ⊥. Nothing left to do +mergeBots _ IsNotBot IsNotBot = pure IsNotBot +-- We add x ≁ ⊥ and will need to test if x is still inhabited (see addNotBotCt) +-- romes:todo: We don't have the dirty set in the e-graph, so +-- congruence-fueled merging won't mark anything as dirty... hmm... +mergeBots _ IsNotBot MaybeBot = pure IsNotBot +-- Commutativity of 'mergeBots', +-- and trivially merging MaybeBots +mergeBots x MaybeBot IsBot = mergeBots x IsBot MaybeBot +mergeBots x MaybeBot IsNotBot = mergeBots x IsNotBot MaybeBot +mergeBots _ MaybeBot MaybeBot = pure MaybeBot -- | Record a @x ~/ K@ constraint, e.g. that a particular 'Id' @x@ can't -- take the shape of a 'PmAltCon' @K@ in the 'Nabla' and return @Nothing@ if @@ -717,41 +769,44 @@ addNotBotCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ts_facts=env} } x = do addNotConCt :: Nabla -> Id -> PmAltCon -> MaybeT DsM Nabla addNotConCt _ _ (PmAltConLike (RealDataCon dc)) | isNewDataCon dc = mzero -- (3) in Note [Coverage checking Newtype matches] -addNotConCt nabla x nalt = do - (mb_mark_dirty, nabla') <- trvVarInfo go nabla x +addNotConCt nabla0 x nalt = do + (xid, nabla1) <- representId x nabla0 + (mb_mark_dirty, nabla2) <- trvVarInfo (`mergeNotConCt` nalt) nabla1 (xid, x) pure $ case mb_mark_dirty of - Just x -> markDirty x nabla' - Nothing -> nabla' - where - -- Update `x`'s 'VarInfo' entry. Fail ('MaybeT') if contradiction, - -- otherwise return updated entry and `Just x'` if `x` should be marked dirty, - -- where `x'` is the representative of `x`. - go :: VarInfo -> MaybeT DsM (Maybe Id, VarInfo) - go vi@(VI x' pos neg _ rcm) = do - -- 1. Bail out quickly when nalt contradicts a solution - let contradicts nalt sol = eqPmAltCon (paca_con sol) nalt == Equal - guard (not (any (contradicts nalt) pos)) - -- 2. Only record the new fact when it's not already implied by one of the - -- solutions - let implies nalt sol = eqPmAltCon (paca_con sol) nalt == Disjoint - let neg' - | any (implies nalt) pos = neg - -- See Note [Completeness checking with required Thetas] - | hasRequiredTheta nalt = neg - | otherwise = extendPmAltConSet neg nalt - massert (isPmAltConMatchStrict nalt) - let vi' = vi{ vi_neg = neg', vi_bot = IsNotBot } - -- 3. Make sure there's at least one other possible constructor - mb_rcm' <- lift (markMatched nalt rcm) - pure $ case mb_rcm' of - -- If nalt could be removed from a COMPLETE set, we'll get back Just and - -- have to mark x dirty, by returning Just x'. - Just rcm' -> (Just x', vi'{ vi_rcm = rcm' }) - -- Otherwise, nalt didn't occur in any residual COMPLETE set and we - -- don't have to mark it dirty. So we return Nothing, which in the case - -- above would have compromised precision. - -- See Note [Shortcutting the inhabitation test], grep for T17836. - Nothing -> (Nothing, vi') + Just x -> markDirty x nabla2 + Nothing -> nabla2 + +-- Update `x`'s 'VarInfo' entry. Fail ('MaybeT') if contradiction, +-- otherwise return updated entry and `Just x'` if `x` should be marked dirty, +-- where `x'` is the representative of `x`. +mergeNotConCt :: VarInfo -> PmAltCon -> MaybeT DsM (Maybe Id, VarInfo) +mergeNotConCt vi@(VI x' pos neg _ rcm) nalt = do + lift $ tracePm "mergeNotConCt vi nalt" (ppr vi <+> ppr nalt) + -- 1. Bail out quickly when nalt contradicts a solution + let contradicts nalt sol = eqPmAltCon (paca_con sol) nalt == Equal + guard (not (any (contradicts nalt) pos)) + -- 2. Only record the new fact when it's not already implied by one of the + -- solutions + let implies nalt sol = eqPmAltCon (paca_con sol) nalt == Disjoint + let neg' + | any (implies nalt) pos = neg + -- See Note [Completeness checking with required Thetas] + | hasRequiredTheta nalt = neg + | otherwise = extendPmAltConSet neg nalt + massert (isPmAltConMatchStrict nalt) + let vi' = vi{ vi_neg = neg', vi_bot = IsNotBot } + -- 3. Make sure there's at least one other possible constructor + mb_rcm' <- lift (markMatched nalt rcm) + lift $ tracePm "mergeNotConCt vi' (no upd. rcm)" (ppr vi') + pure $ case mb_rcm' of + -- If nalt could be removed from a COMPLETE set, we'll get back Just and + -- have to mark x dirty, by returning Just x'. + Just rcm' -> (Just x', vi'{ vi_rcm = rcm' }) + -- Otherwise, nalt didn't occur in any residual COMPLETE set and we + -- don't have to mark it dirty. So we return Nothing, which in the case + -- above would have compromised precision. + -- See Note [Shortcutting the inhabitation test], grep for T17836. + Nothing -> (Nothing, vi') hasRequiredTheta :: PmAltCon -> Bool hasRequiredTheta (PmAltConLike cl) = notNull req_theta @@ -759,6 +814,10 @@ hasRequiredTheta (PmAltConLike cl) = notNull req_theta (_,_,_,_,req_theta,_,_) = conLikeFullSig cl hasRequiredTheta _ = False +-- | Worth making a lens from Nabla to EGraph, to make changing data operations much easier +nabla_egr :: Functor f => (TmEGraph -> f TmEGraph) -> (Nabla -> f Nabla) +nabla_egr f (MkNabla tyst ts at TmSt{ts_facts=egr}) = (\egr' -> MkNabla tyst ts{ts_facts=egr'}) <$> f egr + -- | Add a @x ~ K tvs args ts@ constraint. -- @addConCt x K tvs args ts@ extends the substitution with a solution -- @x :-> (K, tvs, args)@ if compatible with the negative and positive info we @@ -766,8 +825,42 @@ hasRequiredTheta _ = False -- -- See Note [TmState invariants]. addConCt :: Nabla -> Id -> PmAltCon -> [TyVar] -> [Id] -> MaybeT DsM Nabla -addConCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ ts_facts=env } } x alt tvs args = do - let vi@(VI _ pos neg bot _) = lookupVarInfo ts x +addConCt nabla0 x alt tvs args = do + (xid, nabla1) <- representId x nabla0 + let vi_x = lookupVarInfo (nabla_tm_st nabla1) x + (kid, nabla2) <- fromMaybe (xid, nabla1) <$> representPattern vi_x alt tvs args nabla1 -- VarInfo contains K data in pos info + let k_vi = (emptyVarInfo x){vi_pos=[PACA alt tvs args]} + + nabla3 <- case (alt, args) of + (PmAltConLike (RealDataCon dc), [y]) | isNewDataCon dc -> do + (_yid, nabla3) <- representId y nabla2 + + -- A newtype con and the underlying var are in the same e-class + -- nabla4 <- mergeVarIds xid yid nabla3 + + -- Return the nabla3 and set the k_vi unchanged + pure (nabla3 & nabla_egr._class kid._data .~ Just k_vi) + + -- If the merging y and N y thing works, we won't need this. + -- (UPDT: It didn't work (looped, i Think. Try uncommenting that line above). + -- That means we're not currently moving the strictness information from the NT pattern to the underlying variable. + -- We need to.) + -- Also, if we do that manually here, that means we won't add strictness + -- annotations to underlying NT representatives if merging is done by + -- congruence instead of by manually calling 'addConCt' + -- case bot of + -- MaybeBot -> pure (nabla_with MaybeBot) + -- IsBot -> addBotCt (nabla_with IsBot) y + -- IsNotBot -> addNotBotCt (nabla_with IsNotBot) y + + _ -> assert (isPmAltConMatchStrict alt) + -- Return the nabla2 and set the k_vi with additional IsNotBot info + pure (nabla2 & nabla_egr._class kid._data .~ Just k_vi{vi_bot=IsNotBot}) -- strict match ==> not ⊥ + + mergeVarIds xid kid nabla3 + +mergeConCt :: VarInfo -> PmAltConApp -> StateT TyState (MaybeT DsM) VarInfo +mergeConCt vi@(VI _ pos neg _bot _) paca@(PACA alt tvs _args) = StateT $ \tyst -> do -- First try to refute with a negative fact guard (not (elemPmAltConSet alt neg)) -- Then see if any of the other solutions (remember: each of them is an @@ -777,25 +870,19 @@ addConCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ ts_facts=env } } x alt tvs args = -- Now we should be good! Add (alt, tvs, args) as a possible solution, or -- refine an existing one case find ((== Equal) . eqPmAltCon alt . paca_con) pos of - Just (PACA _con other_tvs other_args) -> do + Just (PACA _con other_tvs _other_args) -> do -- We must unify existentially bound ty vars and arguments! + -- + -- The arguments are handled automatically by representing K in + -- the e-class...! all equivalent things will be merged. + -- + -- So we treat the ty vars: let ty_cts = equateTys (map mkTyVarTy tvs) (map mkTyVarTy other_tvs) - nabla' <- MaybeT $ addPhiCts nabla (listToBag ty_cts) - let add_var_ct nabla (a, b) = addVarCt nabla a b - foldlM add_var_ct nabla' $ zipEqual "addConCt" args other_args + tyst' <- MaybeT (tyOracle tyst (listToBag $ map (\case (PhiTyCt pred) -> pred; _ -> error "impossible") ty_cts)) + return (vi, tyst') -- All good, and we get no new term information. Nothing -> do - let pos' = PACA alt tvs args : pos - let nabla_with bot' = - nabla{ nabla_tm_st = ts{ts_facts = addToUSDFM env x (vi{vi_pos = pos', vi_bot = bot'})} } - -- Do (2) in Note [Coverage checking Newtype matches] - case (alt, args) of - (PmAltConLike (RealDataCon dc), [y]) | isNewDataCon dc -> - case bot of - MaybeBot -> pure (nabla_with MaybeBot) - IsBot -> addBotCt (nabla_with MaybeBot) y - IsNotBot -> addNotBotCt (nabla_with MaybeBot) y - _ -> assert (isPmAltConMatchStrict alt ) - pure (nabla_with IsNotBot) -- strict match ==> not ⊥ + -- Add new con info + return (vi{vi_pos = paca:pos}, tyst) equateTys :: [Type] -> [Type] -> [PhiCt] equateTys ts us = @@ -815,18 +902,22 @@ equateTys ts us = -- -- See Note [TmState invariants]. addVarCt :: Nabla -> Id -> Id -> MaybeT DsM Nabla -addVarCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ ts_facts = env } } x y = - case equateUSDFM env x y of - (Nothing, env') -> pure (nabla{ nabla_tm_st = ts{ ts_facts = env' } }) - -- Add the constraints we had for x to y - (Just vi_x, env') -> do - let nabla_equated = nabla{ nabla_tm_st = ts{ts_facts = env'} } - -- and then gradually merge every positive fact we have on x into y - let add_pos nabla (PACA cl tvs args) = addConCt nabla y cl tvs args - nabla_pos <- foldlM add_pos nabla_equated (vi_pos vi_x) - -- Do the same for negative info - let add_neg nabla nalt = addNotConCt nabla y nalt - foldlM add_neg nabla_pos (pmAltConSetElems (vi_neg vi_x)) +addVarCt nabla0 x y = do + + -- We'd really rather ([xid, yid], nabla1) <- representIds [x,y] nabla0, but that's not exhaustive... + ((xid, yid), nabla1) + <- runStateT ((,) <$> StateT (representId x) <*> StateT (representId y)) nabla0 + + mergeVarIds xid yid nabla1 + +mergeVarIds :: ClassId -> ClassId -> Nabla -> MaybeT DsM Nabla +mergeVarIds xid yid (MkNabla tyst0 (TmSt egr0 is)) = do + + -- @merge env x y@ makes @x@ and @y@ point to the same entry, + -- thereby merging @x@'s class with @y@'s. + (egr1, tyst1) <- runStateT (EG.mergeM xid yid egr0 >>= EG.rebuildM . snd) tyst0 + + return (MkNabla tyst1 (TmSt egr1 is)) -- | Inspects a 'PmCoreCt' @let x = e@ by recording constraints for @x@ based -- on the shape of the 'CoreExpr' @e at . Examples: @@ -894,9 +985,11 @@ addCoreCt nabla x e = do -- @x ~ y at . equate_with_similar_expr :: Id -> CoreExpr -> StateT Nabla (MaybeT DsM) () equate_with_similar_expr x e = do - rep <- StateT $ \nabla -> lift (representCoreExpr nabla e) + rep <- StateT $ \nabla -> representCoreExpr nabla e -- Note that @rep == x@ if we encountered @e@ for the first time. - modifyT (\nabla -> addVarCt nabla x rep) + modifyT (\nabla0 -> do + (xid, nabla1) <- representId x nabla0 + mergeVarIds xid rep nabla1) bind_expr :: CoreExpr -> StateT Nabla (MaybeT DsM) Id bind_expr e = do @@ -951,14 +1044,13 @@ modifyT f = StateT $ fmap ((,) ()) . f -- Which is the @x@ of a @let x = e'@ constraint (with @e@ semantically -- equivalent to @e'@) we encountered earlier, or a fresh identifier if -- there weren't any such constraints. -representCoreExpr :: Nabla -> CoreExpr -> DsM (Id, Nabla) -representCoreExpr nabla at MkNabla{ nabla_tm_st = ts at TmSt{ ts_reps = reps } } e - | Just rep <- lookupCoreMap reps key = pure (rep, nabla) - | otherwise = do - rep <- mkPmId (exprType e) - let reps' = extendCoreMap reps key rep - let nabla' = nabla{ nabla_tm_st = ts{ ts_reps = reps' } } - pure (rep, nabla') +representCoreExpr :: Nabla -> CoreExpr -> MaybeT DsM (ClassId, Nabla) +representCoreExpr (MkNabla tyst ts at TmSt{ ts_facts = egraph }) e = do + ((xid, egr''), tysty') <- (`runStateT` tyst) $ do + (xid, egr') <- representCoreExprEgr key egraph + egr'' <- EG.rebuildM egr' + return (xid, egr'') + return (xid, MkNabla tysty' ts{ts_facts = egr''}) where key = makeDictsCoherent e -- Use a key in which dictionaries for the same type become equal. @@ -969,6 +1061,8 @@ representCoreExpr nabla at MkNabla{ nabla_tm_st = ts at TmSt{ ts_reps = reps } } e -- are considered equal when building a 'CoreMap'. -- -- See Note [Unique dictionaries in the TmOracle CoreMap] +-- ROMES:TODO: I suppose this should be taken into account by the Eq instance of DeBruijnF CoreExprF +-- if we do that there then we're sure that EG.represent takes that into account. makeDictsCoherent :: CoreExpr -> CoreExpr makeDictsCoherent var@(Var v) | let ty = idType v @@ -1271,21 +1365,30 @@ tyStateRefined a b = ty_st_n a /= ty_st_n b markDirty :: Id -> Nabla -> Nabla markDirty x nabla at MkNabla{nabla_tm_st = ts at TmSt{ts_dirty = dirty} } = - nabla{ nabla_tm_st = ts{ ts_dirty = extendDVarSet dirty x } } + case lookupId ts x of + Nothing -> error "Marking as dirty an Id that is not represented in the Nabla" + Just xid -> + nabla{ nabla_tm_st = ts{ ts_dirty = IS.insert xid dirty } } traverseDirty :: Monad m => (VarInfo -> m VarInfo) -> TmState -> m TmState traverseDirty f ts at TmSt{ts_facts = env, ts_dirty = dirty} = - go (uniqDSetToList dirty) env + go (IS.elems dirty) env where go [] env = pure ts{ts_facts=env} - go (x:xs) !env = do - vi' <- f (lookupVarInfo ts x) - go xs (addToUSDFM env x vi') + go (xid:xs) !env = do + vi' <- f' (env ^._class xid._data) + go xs (env & _class xid._data .~ vi') + + f' Nothing = pure Nothing + f' (Just x) = Just <$> f x traverseAll :: Monad m => (VarInfo -> m VarInfo) -> TmState -> m TmState traverseAll f ts at TmSt{ts_facts = env} = do - env' <- traverseUSDFM f env + env' <- (_classes._data) f' env pure ts{ts_facts = env'} + where + f' Nothing = pure Nothing + f' (Just x) = Just <$> f x -- | Makes sure the given 'Nabla' is still inhabited, by trying to instantiate -- all dirty variables (or all variables when the 'TyState' changed) to concrete @@ -1296,48 +1399,50 @@ traverseAll f ts at TmSt{ts_facts = env} = do inhabitationTest :: Int -> TyState -> Nabla -> MaybeT DsM Nabla inhabitationTest 0 _ nabla = pure nabla inhabitationTest fuel old_ty_st nabla at MkNabla{ nabla_tm_st = ts } = {-# SCC "inhabitationTest" #-} do - -- lift $ tracePm "inhabitation test" $ vcat - -- [ ppr fuel - -- , ppr old_ty_st - -- , ppr nabla - -- , text "tyStateRefined:" <+> ppr (tyStateRefined old_ty_st (nabla_ty_st nabla)) - -- ] + lift $ tracePm "inhabitation test" $ vcat + [ ppr fuel + , ppr old_ty_st + , ppr nabla + , text "tyStateRefined:" <+> ppr (tyStateRefined old_ty_st (nabla_ty_st nabla)) + ] -- When type state didn't change, we only need to traverse dirty VarInfos ts' <- if tyStateRefined old_ty_st (nabla_ty_st nabla) then traverseAll test_one ts else traverseDirty test_one ts - pure nabla{ nabla_tm_st = ts'{ts_dirty=emptyDVarSet}} + pure nabla{ nabla_tm_st = ts'{ts_dirty=IS.empty}} where - nabla_not_dirty = nabla{ nabla_tm_st = ts{ts_dirty=emptyDVarSet} } + nabla_not_dirty = nabla{ nabla_tm_st = ts{ts_dirty=IS.empty} } test_one :: VarInfo -> MaybeT DsM VarInfo - test_one vi = + test_one vi = do lift (varNeedsTesting old_ty_st nabla vi) >>= \case True -> do - -- lift $ tracePm "test_one" (ppr vi) + lift $ tracePm "test_one" (ppr vi) -- No solution yet and needs testing -- We have to test with a Nabla where all dirty bits are cleared instantiate (fuel-1) nabla_not_dirty vi - _ -> pure vi + _ -> do + lift $ tracePm "test_one needs no testing" (ppr vi) + pure vi -- | Checks whether the given 'VarInfo' needs to be tested for inhabitants. -- Returns `False` when we can skip the inhabitation test, presuming it would -- say "yes" anyway. See Note [Shortcutting the inhabitation test]. varNeedsTesting :: TyState -> Nabla -> VarInfo -> DsM Bool -varNeedsTesting _ MkNabla{nabla_tm_st=tm_st} vi - | elemDVarSet (vi_id vi) (ts_dirty tm_st) = pure True -varNeedsTesting _ _ vi - | notNull (vi_pos vi) = pure False -varNeedsTesting old_ty_st MkNabla{nabla_ty_st=new_ty_st} _ - -- Same type state => still inhabited - | not (tyStateRefined old_ty_st new_ty_st) = pure False -varNeedsTesting old_ty_st MkNabla{nabla_ty_st=new_ty_st} vi = do - -- These normalisations are relatively expensive, but still better than having - -- to perform a full inhabitation test - (_, _, old_norm_ty) <- tntrGuts <$> pmTopNormaliseType old_ty_st (idType $ vi_id vi) - (_, _, new_norm_ty) <- tntrGuts <$> pmTopNormaliseType new_ty_st (idType $ vi_id vi) - if old_norm_ty `eqType` new_norm_ty - then pure False - else pure True +varNeedsTesting old_ty_st n at MkNabla{nabla_ty_st=new_ty_st,nabla_tm_st=tm_st} vi + = do + Just (xid, _) <- runMaybeT $ representId (vi_id vi) n + if | IS.member xid (IS.map (`EG.find` ts_facts tm_st) $ ts_dirty tm_st) -> pure True + | notNull (vi_pos vi) -> pure False + -- Same type state => still inhabited + | not (tyStateRefined old_ty_st new_ty_st) -> pure False + -- These normalisations are relatively expensive, but still better than having + -- to perform a full inhabitation test + | otherwise -> do + (_, _, old_norm_ty) <- tntrGuts <$> pmTopNormaliseType old_ty_st (idType $ vi_id vi) + (_, _, new_norm_ty) <- tntrGuts <$> pmTopNormaliseType new_ty_st (idType $ vi_id vi) + if old_norm_ty `eqType` new_norm_ty + then pure False + else pure True -- | Returns (Just vi) if at least one member of each ConLike in the COMPLETE -- set satisfies the oracle @@ -1358,8 +1463,10 @@ instBot _fuel nabla vi = {-# SCC "instBot" #-} do pure vi addNormalisedTypeMatches :: Nabla -> Id -> DsM (ResidualCompleteMatches, Nabla) -addNormalisedTypeMatches nabla at MkNabla{ nabla_ty_st = ty_st } x - = trvVarInfo add_matches nabla x +addNormalisedTypeMatches nabla at MkNabla{ nabla_ty_st = ty_st, nabla_tm_st = ts } x + = case lookupId ts x of + Just xid -> trvVarInfo add_matches nabla (xid, x) + Nothing -> error "An Id with a VarInfo (see call site) is not represented in the e-graph..." where add_matches vi at VI{ vi_rcm = rcm } -- important common case, shaving down allocations of PmSeriesG by -5% @@ -2080,3 +2187,135 @@ Note that for -XEmptyCase, we don't want to emit a minimal cover. We arrange that by passing 'CaseSplitTopLevel' to 'generateInhabitingPatterns'. We detect the -XEmptyCase case in 'reportWarnings' by looking for 'ReportEmptyCase'. -} + +------------------------------------------------ +-- * E-graphs for pattern match checking + +representPattern :: VarInfo + -- ^ Var info of e-class in which this pattern is going to be represented... + -- The things we are doing with this should rather be done as + -- an e-graph analysis modify to "downwards" merge in the e-graph the sub-nodes + -- A bit weird that the e-graph doesn't do this, but it seems like it doesn't... (see egraphs zulip discussion) + -> PmAltCon -> [TyVar] -> [Id] -> Nabla -> MaybeT DsM (Maybe (ClassId, Nabla)) +-- We don't need to do anything in the case of PmAltLit. +-- The Constructor information is recorded in the positive info e-class +-- it is represented in, so when we merge we take care of handling this +-- equality right. +-- If we did this even more ideally, we'd just represent PmAltLit in the e-graph and it would fail on merge without having to edit the e-class. +-- Wait, is it even safe to edit the e-class? Won't that *NOT* trigger the merging?? +-- Here I suppose we're creating the e-class. So we can add information at will. When we eventually merge this class with another one, we can do things. +-- But we could definitely check whether the information we're adding isn't colliding with the existing one. +representPattern _ (PmAltLit _) _ _ _ = return Nothing + -- We might need represent patterns alongside expressions -- then we can use the "real" equality instances for the patterns (e.g. eqPmLit) +representPattern (VI _ pos _ _ _) alt@(PmAltConLike conLike) tvs args nab00 = do + (args', nab01) <- representIds args nab00 + + -- rOMES: It is very akward that this is being done here... perhaps it would be best as a modify method in the analysis + -- it certainly won't work for things we learn by congruence... + MkNabla tyst0 ts at TmSt{ts_facts=egr0} <- + case find ((== Equal) . eqPmAltCon alt . paca_con) pos of + Just (PACA _con _other_tvs other_args) -> do + let add_var_ct nabla (a, b) = addVarCt nabla a b + foldlM add_var_ct nab01 $ zipEqual "addConCt" args other_args + Nothing -> pure nab01 + + ((cid, egr1), tyst1) <- (`runStateT` tyst0) $ EGM.runEGraphMT egr0 $ do + -- We must represent the constructor application in the e-graph to make + -- sure the children are recursively merged against other children of + -- other constructors represneted in the same e-class. + -- We need to represent the constructor correctly to ensure existing + -- constructors match or not the new one + -- dsHsConLike basically implements the logic we want. + -- ROMES:TODO: Nevermind, the dsHsConLike won't work because we want to + -- talk about pattern synonyms in their "matching" form, and converting + -- them with dsHsConLike assumes they are used as a constructor, + -- meaning we will fail for unidirectional patterns + desugaredCon <- lift . lift . lift $ ds_hs_con_like_pat conLike -- DsM action to desugar the conlike into the expression we'll represent for this constructor + conLikeId <- StateT $ representCoreExprEgr desugaredCon + tvs' <- mapM (EGM.addM . EG.Node . TypeF . DBT . deBruijnize . TyVarTy) tvs -- ugh... + foldlM (\acc i -> EGM.addM (EG.Node $ AppF acc i)) conLikeId (tvs' ++ args') + return (Just (cid, MkNabla tyst1 ts{ts_facts=egr1})) + where + -- TODO: do something cleaner than the following inlined thing... + + -- We inlined dsHsConLike but use patSynMatcher instead of patSynBuilder + ds_hs_con_like_pat :: ConLike -> DsM CoreExpr + ds_hs_con_like_pat (RealDataCon dc) + = return (varToCoreExpr (dataConWrapId dc)) + ds_hs_con_like_pat (PatSynCon ps) + | (builder_name, _, add_void) <- patSynMatcher ps + = do { builder_id <- dsLookupGlobalId builder_name + ; return (if add_void + then mkCoreApp (text "dsConLike" <+> ppr ps) + (Var builder_id) unboxedUnitExpr + else Var builder_id) } + +representId :: Id -> Nabla -> MaybeT DsM (ClassId, Nabla) +representId x (MkNabla tyst tmst at TmSt{ts_facts=eg0}) + = do + ((xid, tmst'),tyst') <- (`runStateT` tyst) $ do + (xid, eg1) <- EG.addM (EG.Node (FreeVarF x)) eg0 + eg2 <- EG.rebuildM eg1 -- why do this here? I guess a good place as any, and should be cheap anyway (workload is not something like eqsat) + return (xid, tmst{ts_facts=eg2}) + return (xid, MkNabla tyst' tmst') + +representIds :: [Id] -> Nabla -> MaybeT DsM ([ClassId], Nabla) +representIds xs = runStateT (mapM (StateT . representId) xs) + +-- There are too many cycles for this to be in Solver.Types... +-- We need the TyState to check insoluble constraints while merging VarInfos +instance AnalysisM (StateT TyState (MaybeT DsM)) (Maybe VarInfo) ExprF where + {-# INLINE makeA #-} + + -- When an e-class is created for a variable, we create an VarInfo from it. + -- It doesn't matter if this variable is bound or free, since it's the first + -- variable in this e-class (and all others would have to be equivalent to + -- it) + -- + -- Also, the Eq instance for DeBruijn Vars will ensure that two free + -- variables with the same Id are equal and so they will be represented in + -- the same e-class + -- + -- It would be good if we didn't do this always... It might be a bit expensive + makeA (FreeVarF x) = pure $ Just $ emptyVarInfo x + makeA _ = pure $ Nothing + + joinA Nothing Nothing = pure $ Nothing + joinA Nothing (Just b) = pure $ Just b + joinA (Just a) Nothing = pure $ Just a + + -- Merge the 'VarInfo's from @x@ and @y@ + joinA (Just vi_x at VI{ vi_id=_id_x + , vi_pos=pos_x + , vi_neg=neg_x + , vi_bot=bot_x + , vi_rcm=_rcm_x + }) + (Just vi_y) = do + lift . lift $ tracePm "merging vi_x and vi_y" (ppr vi_x <+> ppr vi_y) + -- If we can merge x ~ N y with y too, then we no longer need to worry + -- about propagating the bottomness information, since it will always be + -- right... though I'm not sure if that would be correct + + -- Gradually merge every positive fact we have on x into y + -- The args are merged by congruence, since we represent the + -- constructor in the e-graph in addConCt. + vi_res1 <- foldlM mergeConCt vi_y pos_x + + -- Do the same for negative info + let add_neg vi nalt = lift $ snd <$> mergeNotConCt vi nalt + vi_res2 <- foldlM add_neg vi_res1 (pmAltConSetElems neg_x) + + -- We previously were not merging the bottom information, but now we do. + -- TODO: We don't need to do it yet if we are only trying to be as good as before, but not better + -- Although it might not be so simple if we consider one of the classes is a newtype? + -- (No, I think that situation can occur) + bot_res <- lift $ + mergeBots (idType (vi_id vi_res2)) + bot_x (vi_bot vi_y) + let vi_res3 = vi_res2{vi_bot = bot_res} + + lift . lift $ tracePm "result of merging vi_x and vi_y" (ppr vi_res3) + return (Just vi_res3) + + ===================================== compiler/GHC/HsToCore/Pmc/Solver/Types.hs ===================================== @@ -1,7 +1,11 @@ {-# LANGUAGE ApplicativeDo #-} +{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE MultiWayIf #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeApplications #-} -- | Domain types used in "GHC.HsToCore.Pmc.Solver". -- The ultimate goal is to define 'Nabla', which models normalised refinement @@ -10,13 +14,16 @@ module GHC.HsToCore.Pmc.Solver.Types ( -- * Normalised refinement types - BotInfo(..), PmAltConApp(..), VarInfo(..), TmState(..), TyState(..), - Nabla(..), Nablas(..), initNablas, + BotInfo(..), PmAltConApp(..), VarInfo(..), TmState(..), TyState(..), TmEGraph, + Nabla(..), Nablas(..), initNablas, emptyVarInfo, lookupRefuts, lookupSolution, -- ** Looking up 'VarInfo' lookupVarInfo, lookupVarInfoNT, trvVarInfo, + -- *** Looking up 'ClassId' + lookupId, + -- ** Caching residual COMPLETE sets CompleteMatch, ResidualCompleteMatches(..), getRcm, isRcmInitialised, @@ -42,9 +49,7 @@ import GHC.Prelude import GHC.Data.Bag import GHC.Data.FastString import GHC.Types.Id -import GHC.Types.Var.Set import GHC.Types.Unique.DSet -import GHC.Types.Unique.SDFM import GHC.Types.Name import GHC.Core.DataCon import GHC.Core.ConLike @@ -58,7 +63,6 @@ import GHC.Core.TyCon import GHC.Types.Literal import GHC.Core import GHC.Core.TyCo.Compare( eqType ) -import GHC.Core.Map.Expr import GHC.Core.Utils (exprType) import GHC.Builtin.Names import GHC.Builtin.Types @@ -75,6 +79,18 @@ import Data.Ratio import GHC.Real (Ratio(..)) import qualified Data.Semigroup as Semi +import GHC.Core.Equality +import Data.Functor.Const +import Data.Functor.Compose +import Data.Equality.Graph (EGraph, ClassId) +import Data.Equality.Graph.Lens +import qualified Data.Equality.Graph.Nodes as EGN +import qualified Data.Equality.Graph as EG +import qualified Data.Equality.Graph.Internal as EGI +import Data.IntSet (IntSet) +import qualified Data.IntSet as IS (empty, toList) +import Data.Bifunctor (second) + -- import GHC.Driver.Ppr -- @@ -138,14 +154,12 @@ initTyState = TySt 0 emptyInert -- See Note [TmState invariants] in "GHC.HsToCore.Pmc.Solver". data TmState = TmSt - { ts_facts :: !(UniqSDFM Id VarInfo) - -- ^ Facts about term variables. Deterministic env, so that we generate - -- deterministic error messages. - , ts_reps :: !(CoreMap Id) - -- ^ An environment for looking up whether we already encountered semantically - -- equivalent expressions that we want to represent by the same 'Id' - -- representative. - , ts_dirty :: !DIdSet + { ts_facts :: !TmEGraph + -- ^ Facts about term variables. + + -- ROMES:TODO: ts_dirty looks a bit to me like the bookkeeping done by the + -- analysis rebuilding mechanism, so perhaps we can get rid of it too + , ts_dirty :: !IntSet -- ^ Which 'VarInfo' needs to be checked for inhabitants because of new -- negative constraints (e.g. @x ≁ ⊥@ or @x ≁ K@). } @@ -161,6 +175,7 @@ data VarInfo { vi_id :: !Id -- ^ The 'Id' in question. Important for adding new constraints relative to -- this 'VarInfo' when we don't easily have the 'Id' available. + -- ROMES:TODO: Do we still need this? , vi_pos :: ![PmAltConApp] -- ^ Positive info: 'PmAltCon' apps it is (i.e. @x ~ [Just y, PatSyn z]@), all @@ -168,7 +183,7 @@ data VarInfo -- pattern matches involving pattern synonym -- case x of { Just y -> case x of PatSyn z -> ... } -- However, no more than one RealDataCon in the list, otherwise contradiction - -- because of generativity. + -- because of generativity (which would violate Invariant 1 from the paper). , vi_neg :: !PmAltConSet -- ^ Negative info: A list of 'PmAltCon's that it cannot match. @@ -227,7 +242,13 @@ instance Outputable BotInfo where -- | Not user-facing. instance Outputable TmState where - ppr (TmSt state reps dirty) = ppr state $$ ppr reps $$ ppr dirty + ppr (TmSt state dirty) = + (vcat $ getConst $ _iclasses (\(i,cl) -> Const [ppr i <> text ":" <+> ppr cl]) state) + $$ ppr (IS.toList dirty) + + +instance Outputable (EG.EClass (Maybe VarInfo) CoreExprF) where + ppr cl = ppr (cl^._nodes) $$ ppr (cl^._data) -- | Not user-facing. instance Outputable VarInfo where @@ -248,7 +269,7 @@ instance Outputable VarInfo where -- | Initial state of the term oracle. initTmState :: TmState -initTmState = TmSt emptyUSDFM emptyCoreMap emptyDVarSet +initTmState = TmSt EG.emptyEGraph IS.empty -- | A data type that caches for the 'VarInfo' of @x@ the results of querying -- 'dsGetCompleteMatches' and then striking out all occurrences of @K@ for @@ -302,7 +323,9 @@ emptyVarInfo x lookupVarInfo :: TmState -> Id -> VarInfo -- (lookupVarInfo tms x) tells what we know about 'x' -lookupVarInfo (TmSt env _ _) x = fromMaybe (emptyVarInfo x) (lookupUSDFM env x) +lookupVarInfo ts@(TmSt env _) x = fromMaybe (emptyVarInfo x) $ do + xid <- lookupId ts x + env ^. _class xid . _data -- | Like @lookupVarInfo ts x@, but @lookupVarInfo ts x = (y, vi)@ also looks -- through newtype constructors. We have @x ~ N1 (... (Nk y))@ such that the @@ -324,17 +347,32 @@ lookupVarInfoNT ts x = case lookupVarInfo ts x of | isNewDataCon dc = Just y go _ = Nothing -trvVarInfo :: Functor f => (VarInfo -> f (a, VarInfo)) -> Nabla -> Id -> f (a, Nabla) +trvVarInfo :: forall f a. Functor f => (VarInfo -> f (a, VarInfo)) -> Nabla + -> (ClassId,Id) + -- ^ The ClassId of the VarInfo to traverse, and the Id represented + -- to get it, to determine the empty var info in case it isn't available. + -- ... Feels a bit weird, but let's see if it works at all + -> f (a, Nabla) {-# INLINE trvVarInfo #-} -- This function is called a lot and we want to specilise it, not only -- for the type class, but also for its 'f' function argument. -- Before the INLINE pragma it sometimes inlined and sometimes didn't, -- depending delicately on GHC's optimisations. Better to use a pragma. -trvVarInfo f nabla at MkNabla{ nabla_tm_st = ts at TmSt{ts_facts = env} } x - = set_vi <$> f (lookupVarInfo ts x) +trvVarInfo f nabla at MkNabla{ nabla_tm_st = ts at TmSt{ts_facts = env} } (xid,x) + = second (\g -> nabla{nabla_tm_st = ts{ts_facts=g}}) <$> + updateAccum (_class xid._data.defaultEmpty) f env where - set_vi (a, vi') = - (a, nabla{ nabla_tm_st = ts{ ts_facts = addToUSDFM env (vi_id vi') vi' } }) + updateAccum :: forall f a s c. Functor f => Lens' s a -> (a -> f (c,a)) -> s -> f (c,s) + updateAccum lens g = getCompose . lens @(Compose f ((,) c)) (Compose . g) + + defaultEmpty :: Lens' (Maybe VarInfo) VarInfo + defaultEmpty f s = Just <$> (f (fromMaybe (emptyVarInfo x) s)) + +------------------------------------------ +-- * Utility for looking up Ids in 'Nabla' + +lookupId :: TmState -> Id -> Maybe ClassId +lookupId TmSt{ts_facts = eg0} x = EGN.lookupNM (EG.Node (FreeVarF x)) (EGI.memo eg0) ------------------------------------------------ -- * Exported utility functions querying 'Nabla' @@ -802,3 +840,19 @@ instance Outputable PmAltCon where instance Outputable PmEquality where ppr = text . show + +----------------------------------------------------- +-- * E-graphs to represent normalised refinment types + +type TmEGraph = EGraph (Maybe VarInfo) CoreExprF + +-- TODO delete orphans for showing TmEGraph for debugging reasons +instance Show VarInfo where + show = showPprUnsafe . ppr + +-- | This instance is seriously wrong for general purpose, it's just required for instancing Analysis. +-- There ought to be a better way. +-- ROMES:TODO: +instance Eq VarInfo where + (==) a b = vi_id a == vi_id b -- ROMES:TODO: The rest of the equality comparisons + ===================================== libraries/hegg ===================================== @@ -1 +1 @@ -Subproject commit 68e6b218aade16451ce94d15a485c04d626f3218 +Subproject commit 153fa7d1854270c2a4d154ac686891e33f9eac69 ===================================== testsuite/tests/count-deps/CountDepsParser.stdout ===================================== @@ -20,11 +20,11 @@ GHC.Core.Coercion.Axiom GHC.Core.Coercion.Opt GHC.Core.ConLike GHC.Core.DataCon +GHC.Core.Equality GHC.Core.FVs GHC.Core.FamInstEnv GHC.Core.InstEnv GHC.Core.Make -GHC.Core.Map.Expr GHC.Core.Map.Type GHC.Core.Multiplicity GHC.Core.Opt.Arity @@ -195,7 +195,6 @@ GHC.Types.Unique.DFM GHC.Types.Unique.DSet GHC.Types.Unique.FM GHC.Types.Unique.Map -GHC.Types.Unique.SDFM GHC.Types.Unique.Set GHC.Types.Unique.Supply GHC.Types.Var View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9abd4a9405ce914014a846456d72fa987f0c9208 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9abd4a9405ce914014a846456d72fa987f0c9208 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 08:14:57 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Fri, 03 May 2024 04:14:57 -0400 Subject: [Git][ghc/ghc][wip/fendor/ghc-iface-sharing-avoid-reserialisation] Make sure to always invalidate correctly Message-ID: <66349d01ca0c4_10d81b15a7a70678d2@gitlab.mail> Hannes Siebenhandl pushed to branch wip/fendor/ghc-iface-sharing-avoid-reserialisation at Glasgow Haskell Compiler / GHC Commits: c65210cc by Fendor at 2024-05-03T09:58:44+02:00 Make sure to always invalidate correctly - - - - - 9 changed files: - compiler/GHC.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Unit/Module/ModIface.hs - utils/haddock Changes: ===================================== compiler/GHC.hs ===================================== @@ -98,7 +98,32 @@ module GHC ( lookupGlobalName, findGlobalAnns, mkNamePprCtxForModule, - ModIface, ModIface_(..), + ModIface, + mi_module, + mi_sig_of, + mi_hsc_src, + mi_src_hash, + mi_hi_bytes, + mi_deps, + mi_usages, + mi_exports, + mi_used_th, + mi_fixities, + mi_warns, + mi_anns, + mi_insts, + mi_fam_insts, + mi_rules, + mi_decls, + mi_extra_decls, + mi_globals, + mi_hpc, + mi_trust, + mi_trust_pkg, + mi_complete_matches, + mi_docs, + mi_final_exts, + mi_ext_fields, SafeHaskellMode(..), -- * Printing ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -64,6 +64,7 @@ import Data.Word import System.IO.Unsafe import Data.Typeable (Typeable) import qualified GHC.Data.Strict as Strict +import Data.Function ((&)) -- --------------------------------------------------------------------------- @@ -161,9 +162,9 @@ readBinIface profile name_cache checkHiWay traceBinIface hi_path = do mod_iface <- getIfaceWithExtFields name_cache bh - return mod_iface - { mi_src_hash = src_hash - } + return $ mod_iface + & addSourceFingerprint src_hash + getIfaceWithExtFields :: NameCache -> ReadBinHandle -> IO ModIface getIfaceWithExtFields name_cache bh = do @@ -176,10 +177,9 @@ getIfaceWithExtFields name_cache bh = do seekBinReaderRel bh extFields_p_rel extFields <- get bh modIfaceData <- freezeBinHandle2 bh start - pure mod_iface - { mi_ext_fields = extFields - , mi_hi_bytes = FullIfaceBinHandle $ Strict.Just modIfaceData - } + pure $ mod_iface + & set_mi_ext_fields extFields + & set_mi_hi_bytes (FullIfaceBinHandle $ Strict.Just modIfaceData) -- | This performs a get action after reading the dictionary and symbol ===================================== compiler/GHC/Iface/Load.hs ===================================== @@ -117,6 +117,7 @@ import System.FilePath import System.Directory import GHC.Driver.Env.KnotVars import GHC.Iface.Errors.Types +import Data.Function ((&)) {- ************************************************************************ @@ -515,14 +516,12 @@ loadInterface doc_str mod from ; new_eps_anns <- tcIfaceAnnotations (mi_anns iface) ; new_eps_complete_matches <- tcIfaceCompleteMatches (mi_complete_matches iface) - ; let { final_iface = iface { - mi_decls = panic "No mi_decls in PIT", - mi_insts = panic "No mi_insts in PIT", - mi_fam_insts = panic "No mi_fam_insts in PIT", - mi_rules = panic "No mi_rules in PIT", - mi_anns = panic "No mi_anns in PIT" - } - } + ; let final_iface = iface + & set_mi_decls (panic "No mi_decls in PIT") + & set_mi_insts (panic "No mi_insts in PIT") + & set_mi_fam_insts (panic "No mi_fam_insts in PIT") + & set_mi_rules (panic "No mi_rules in PIT") + & set_mi_anns (panic "No mi_anns in PIT") ; let bad_boot = mi_boot iface == IsBoot && isJust (lookupKnotVars (if_rec_types gbl_env) mod) @@ -1017,13 +1016,13 @@ readIface dflags name_cache wanted_mod file_path = do -- See Note [GHC.Prim] in primops.txt.pp. ghcPrimIface :: ModIface ghcPrimIface - = empty_iface { - mi_exports = ghcPrimExports, - mi_decls = [], - mi_fixities = fixities, - mi_final_exts = (mi_final_exts empty_iface){ mi_fix_fn = mkIfaceFixCache fixities }, - mi_docs = Just ghcPrimDeclDocs -- See Note [GHC.Prim Docs] - } + = empty_iface + & set_mi_exports ghcPrimExports + & set_mi_decls [] + & set_mi_fixities fixities + & set_mi_final_exts ((mi_final_exts empty_iface){ mi_fix_fn = mkIfaceFixCache fixities }) + & set_mi_docs (Just ghcPrimDeclDocs) -- See Note [GHC.Prim Docs] + where empty_iface = emptyFullModIface gHC_PRIM ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -144,7 +144,7 @@ mkFullIface hsc_env partial_iface mb_stg_infos mb_cmm_infos = do full_iface <- {-# SCC "addFingerprints" #-} - addFingerprints hsc_env partial_iface{ mi_decls = decls } + addFingerprints hsc_env (set_mi_decls decls partial_iface) -- Debug printing let unit_state = hsc_units hsc_env @@ -177,10 +177,7 @@ shareIface nc compressionLevel mi = do rbh <- shrinkBinBuffer bh seekBinReader rbh start res <- getIfaceWithExtFields nc rbh - let resiface = res - { mi_src_hash = mi_src_hash mi - , mi_globals = mi_globals mi - } + let resiface = restoreFromOldModIface mi res forceModIface resiface return resiface ===================================== compiler/GHC/Iface/Rename.hs ===================================== @@ -44,6 +44,7 @@ import GHC.Utils.Panic import qualified Data.Traversable as T import Data.IORef +import Data.Function ((&)) tcRnMsgMaybe :: IO (Either (Messages TcRnMessage) a) -> TcM a tcRnMsgMaybe do_this = do @@ -108,13 +109,14 @@ rnModIface hsc_env insts nsubst iface = deps <- rnDependencies (mi_deps iface) -- TODO: -- mi_rules - return iface { mi_module = mod - , mi_sig_of = sig_of - , mi_insts = insts - , mi_fam_insts = fams - , mi_exports = exports - , mi_decls = decls - , mi_deps = deps } + return $ iface + & set_mi_module mod + & set_mi_sig_of sig_of + & set_mi_insts insts + & set_mi_fam_insts fams + & set_mi_exports exports + & set_mi_decls decls + & set_mi_deps deps -- | Rename just the exports of a 'ModIface'. Useful when we're doing -- shaping prior to signature merging. ===================================== compiler/GHC/Tc/Errors/Hole.hs ===================================== @@ -76,7 +76,7 @@ import GHC.Tc.Utils.Unify ( tcSubTypeSigma ) import GHC.HsToCore.Docs ( extractDocs ) import GHC.Hs.Doc -import GHC.Unit.Module.ModIface ( ModIface_(..) ) +import GHC.Unit.Module.ModIface ( mi_docs ) import GHC.Iface.Load ( loadInterfaceForName ) import GHC.Builtin.Utils (knownKeyNames) ===================================== compiler/GHC/Tc/Utils/Backpack.hs ===================================== @@ -87,6 +87,7 @@ import Control.Monad import Data.List (find) import GHC.Iface.Errors.Types +import Data.Function ((&)) checkHsigDeclM :: ModIface -> TyThing -> TyThing -> TcRn () checkHsigDeclM sig_iface sig_thing real_thing = do @@ -369,8 +370,8 @@ tcRnMergeSignatures hsc_env hpm orig_tcg_env iface = thinModIface :: [AvailInfo] -> ModIface -> ModIface thinModIface avails iface = - iface { - mi_exports = avails, + iface + & set_mi_exports avails -- mi_fixities = ..., -- mi_warns = ..., -- mi_anns = ..., @@ -378,10 +379,9 @@ thinModIface avails iface = -- perhaps there might be two IfaceTopBndr that are the same -- OccName but different Name. Requires better understanding -- of invariants here. - mi_decls = exported_decls ++ non_exported_decls ++ dfun_decls + & set_mi_decls (exported_decls ++ non_exported_decls ++ dfun_decls) -- mi_insts = ..., -- mi_fam_insts = ..., - } where decl_pred occs decl = nameOccName (ifName decl) `elemOccSet` occs filter_decls occs = filter (decl_pred occs . snd) (mi_decls iface) ===================================== compiler/GHC/Unit/Module/ModIface.hs ===================================== @@ -8,6 +8,8 @@ module GHC.Unit.Module.ModIface ( ModIface , ModIface_ + , restoreFromOldModIface + , addSourceFingerprint , mi_module , mi_sig_of , mi_hsc_src @@ -210,60 +212,60 @@ data IfaceBinHandle (phase :: ModIfacePhase) where -- strict and others are not. data ModIface_ (phase :: ModIfacePhase) = ModIface { - mi_module :: !Module, -- ^ Name of the module we are for - mi_sig_of :: !(Maybe Module), -- ^ Are we a sig of another mod? + mi_module_ :: !Module, -- ^ Name of the module we are for + mi_sig_of_ :: !(Maybe Module), -- ^ Are we a sig of another mod? - mi_hsc_src :: !HscSource, -- ^ Boot? Signature? + mi_hsc_src_ :: !HscSource, -- ^ Boot? Signature? - mi_deps :: Dependencies, + mi_deps_ :: Dependencies, -- ^ The dependencies of the module. This is -- consulted for directly-imported modules, but not -- for anything else (hence lazy) - mi_usages :: [Usage], + mi_usages_ :: [Usage], -- ^ Usages; kept sorted so that it's easy to decide -- whether to write a new iface file (changing usages -- doesn't affect the hash of this module) -- NOT STRICT! we read this field lazily from the interface file -- It is *only* consulted by the recompilation checker - mi_exports :: ![IfaceExport], + mi_exports_ :: ![IfaceExport], -- ^ Exports -- Kept sorted by (mod,occ), to make version comparisons easier -- Records the modules that are the declaration points for things -- exported by this module, and the 'OccName's of those things - mi_used_th :: !Bool, + mi_used_th_ :: !Bool, -- ^ Module required TH splices when it was compiled. -- This disables recompilation avoidance (see #481). - mi_fixities :: [(OccName,Fixity)], + mi_fixities_ :: [(OccName,Fixity)], -- ^ Fixities -- NOT STRICT! we read this field lazily from the interface file - mi_warns :: IfaceWarnings, + mi_warns_ :: IfaceWarnings, -- ^ Warnings -- NOT STRICT! we read this field lazily from the interface file - mi_anns :: [IfaceAnnotation], + mi_anns_ :: [IfaceAnnotation], -- ^ Annotations -- NOT STRICT! we read this field lazily from the interface file - mi_decls :: [IfaceDeclExts phase], + mi_decls_ :: [IfaceDeclExts phase], -- ^ Type, class and variable declarations -- The hash of an Id changes if its fixity or deprecations change -- (as well as its type of course) -- Ditto data constructors, class operations, except that -- the hash of the parent class/tycon changes - mi_extra_decls :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo], + mi_extra_decls_ :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo], -- ^ Extra variable definitions which are **NOT** exposed but when -- combined with mi_decls allows us to restart code generation. -- See Note [Interface Files with Core Definitions] and Note [Interface File with Core: Sharing RHSs] - mi_globals :: !(Maybe IfGlobalRdrEnv), + mi_globals_ :: !(Maybe IfGlobalRdrEnv), -- ^ Binds all the things defined at the top level in -- the /original source/ code for this module. which -- is NOT the same as mi_exports, nor mi_decls (which @@ -279,36 +281,36 @@ data ModIface_ (phase :: ModIfacePhase) -- 'HomeModInfo', but that leads to more plumbing. -- Instance declarations and rules - mi_insts :: [IfaceClsInst], -- ^ Sorted class instance - mi_fam_insts :: [IfaceFamInst], -- ^ Sorted family instances - mi_rules :: [IfaceRule], -- ^ Sorted rules + mi_insts_ :: [IfaceClsInst], -- ^ Sorted class instance + mi_fam_insts_ :: [IfaceFamInst], -- ^ Sorted family instances + mi_rules_ :: [IfaceRule], -- ^ Sorted rules - mi_hpc :: !AnyHpcUsage, + mi_hpc_ :: !AnyHpcUsage, -- ^ True if this program uses Hpc at any point in the program. - mi_trust :: !IfaceTrustInfo, + mi_trust_ :: !IfaceTrustInfo, -- ^ Safe Haskell Trust information for this module. - mi_trust_pkg :: !Bool, + mi_trust_pkg_ :: !Bool, -- ^ Do we require the package this module resides in be trusted -- to trust this module? This is used for the situation where a -- module is Safe (so doesn't require the package be trusted -- itself) but imports some trustworthy modules from its own -- package (which does require its own package be trusted). -- See Note [Trust Own Package] in GHC.Rename.Names - mi_complete_matches :: ![IfaceCompleteMatch], + mi_complete_matches_ :: ![IfaceCompleteMatch], - mi_docs :: !(Maybe Docs), + mi_docs_ :: !(Maybe Docs), -- ^ Docstrings and related data for use by haddock, the ghci -- @:doc@ command, and other tools. -- -- @Just _@ @<=>@ the module was built with @-haddock at . - mi_final_exts :: !(IfaceBackendExts phase), + mi_final_exts_ :: !(IfaceBackendExts phase), -- ^ Either `()` or `ModIfaceBackend` for -- a fully instantiated interface. - mi_ext_fields :: !ExtensibleFields, + mi_ext_fields_ :: !ExtensibleFields, -- ^ Additional optional fields, where the Map key represents -- the field name, resulting in a (size, serialized data) pair. -- Because the data is intended to be serialized through the @@ -317,9 +319,9 @@ data ModIface_ (phase :: ModIfacePhase) -- chosen over `ByteString`s. -- - mi_src_hash :: !Fingerprint, + mi_src_hash_ :: !Fingerprint, -- ^ Hash of the .hs source, used for recompilation checking. - mi_hi_bytes :: !(IfaceBinHandle phase) + mi_hi_bytes_ :: !(IfaceBinHandle phase) } {- @@ -399,34 +401,34 @@ renameFreeHoles fhs insts = -- See Note [Strictness in ModIface] about where we use lazyPut vs put instance Binary ModIface where put_ bh (ModIface { - mi_module = mod, - mi_sig_of = sig_of, - mi_hsc_src = hsc_src, - mi_src_hash = _src_hash, -- Don't `put_` this in the instance + mi_module_ = mod, + mi_sig_of_ = sig_of, + mi_hsc_src_ = hsc_src, + mi_src_hash_ = _src_hash, -- Don't `put_` this in the instance -- because we are going to write it -- out separately in the actual file - mi_hi_bytes = _hi_bytes, -- TODO: explain - mi_deps = deps, - mi_usages = usages, - mi_exports = exports, - mi_used_th = used_th, - mi_fixities = fixities, - mi_warns = warns, - mi_anns = anns, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_insts = insts, - mi_fam_insts = fam_insts, - mi_rules = rules, - mi_hpc = hpc_info, - mi_trust = trust, - mi_trust_pkg = trust_pkg, - mi_complete_matches = complete_matches, - mi_docs = docs, - mi_ext_fields = _ext_fields, -- Don't `put_` this in the instance so we + mi_hi_bytes_ = _hi_bytes, -- TODO: explain + mi_deps_ = deps, + mi_usages_ = usages, + mi_exports_ = exports, + mi_used_th_ = used_th, + mi_fixities_ = fixities, + mi_warns_ = warns, + mi_anns_ = anns, + mi_decls_ = decls, + mi_extra_decls_ = extra_decls, + mi_insts_ = insts, + mi_fam_insts_ = fam_insts, + mi_rules_ = rules, + mi_hpc_ = hpc_info, + mi_trust_ = trust, + mi_trust_pkg_ = trust_pkg, + mi_complete_matches_ = complete_matches, + mi_docs_ = docs, + mi_ext_fields_ = _ext_fields, -- Don't `put_` this in the instance so we -- can deal with it's pointer in the header -- when we write the actual file - mi_final_exts = ModIfaceBackend { + mi_final_exts_ = ModIfaceBackend { mi_iface_hash = iface_hash, mi_mod_hash = mod_hash, mi_flag_hash = flag_hash, @@ -501,34 +503,34 @@ instance Binary ModIface where complete_matches <- get bh docs <- lazyGetMaybe bh return (ModIface { - mi_module = mod, - mi_sig_of = sig_of, - mi_hsc_src = hsc_src, - mi_src_hash = fingerprint0, -- placeholder because this is dealt + mi_module_ = mod, + mi_sig_of_ = sig_of, + mi_hsc_src_ = hsc_src, + mi_src_hash_ = fingerprint0, -- placeholder because this is dealt -- with specially when the file is read - mi_hi_bytes = FullIfaceBinHandle Strict.Nothing, - mi_deps = deps, - mi_usages = usages, - mi_exports = exports, - mi_used_th = used_th, - mi_anns = anns, - mi_fixities = fixities, - mi_warns = warns, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_globals = Nothing, - mi_insts = insts, - mi_fam_insts = fam_insts, - mi_rules = rules, - mi_hpc = hpc_info, - mi_trust = trust, - mi_trust_pkg = trust_pkg, + mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing, + mi_deps_ = deps, + mi_usages_ = usages, + mi_exports_ = exports, + mi_used_th_ = used_th, + mi_anns_ = anns, + mi_fixities_ = fixities, + mi_warns_ = warns, + mi_decls_ = decls, + mi_extra_decls_ = extra_decls, + mi_globals_ = Nothing, + mi_insts_ = insts, + mi_fam_insts_ = fam_insts, + mi_rules_ = rules, + mi_hpc_ = hpc_info, + mi_trust_ = trust, + mi_trust_pkg_ = trust_pkg, -- And build the cached values - mi_complete_matches = complete_matches, - mi_docs = docs, - mi_ext_fields = emptyExtensibleFields, -- placeholder because this is dealt + mi_complete_matches_ = complete_matches, + mi_docs_ = docs, + mi_ext_fields_ = emptyExtensibleFields, -- placeholder because this is dealt -- with specially when the file is read - mi_final_exts = ModIfaceBackend { + mi_final_exts_ = ModIfaceBackend { mi_iface_hash = iface_hash, mi_mod_hash = mod_hash, mi_flag_hash = flag_hash, @@ -551,39 +553,39 @@ type IfaceExport = AvailInfo emptyPartialModIface :: Module -> PartialModIface emptyPartialModIface mod - = ModIface { mi_module = mod, - mi_sig_of = Nothing, - mi_hsc_src = HsSrcFile, - mi_src_hash = fingerprint0, - mi_hi_bytes = PartialIfaceBinHandle, - mi_deps = noDependencies, - mi_usages = [], - mi_exports = [], - mi_used_th = False, - mi_fixities = [], - mi_warns = IfWarnSome [] [], - mi_anns = [], - mi_insts = [], - mi_fam_insts = [], - mi_rules = [], - mi_decls = [], - mi_extra_decls = Nothing, - mi_globals = Nothing, - mi_hpc = False, - mi_trust = noIfaceTrustInfo, - mi_trust_pkg = False, - mi_complete_matches = [], - mi_docs = Nothing, - mi_final_exts = (), - mi_ext_fields = emptyExtensibleFields + = ModIface { mi_module_ = mod, + mi_sig_of_ = Nothing, + mi_hsc_src_ = HsSrcFile, + mi_src_hash_ = fingerprint0, + mi_hi_bytes_ = PartialIfaceBinHandle, + mi_deps_ = noDependencies, + mi_usages_ = [], + mi_exports_ = [], + mi_used_th_ = False, + mi_fixities_ = [], + mi_warns_ = IfWarnSome [] [], + mi_anns_ = [], + mi_insts_ = [], + mi_fam_insts_ = [], + mi_rules_ = [], + mi_decls_ = [], + mi_extra_decls_ = Nothing, + mi_globals_ = Nothing, + mi_hpc_ = False, + mi_trust_ = noIfaceTrustInfo, + mi_trust_pkg_ = False, + mi_complete_matches_ = [], + mi_docs_ = Nothing, + mi_final_exts_ = (), + mi_ext_fields_ = emptyExtensibleFields } emptyFullModIface :: Module -> ModIface emptyFullModIface mod = (emptyPartialModIface mod) - { mi_decls = [] - , mi_hi_bytes = FullIfaceBinHandle Strict.Nothing - , mi_final_exts = ModIfaceBackend + { mi_decls_ = [] + , mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing + , mi_final_exts_ = ModIfaceBackend { mi_iface_hash = fingerprint0, mi_mod_hash = fingerprint0, mi_flag_hash = fingerprint0, @@ -618,36 +620,36 @@ emptyIfaceHashCache _occ = Nothing instance ( NFData (IfaceBackendExts (phase :: ModIfacePhase)) , NFData (IfaceDeclExts (phase :: ModIfacePhase)) ) => NFData (ModIface_ phase) where - rnf (ModIface{ mi_module, mi_sig_of, mi_hsc_src, mi_deps, mi_usages - , mi_exports, mi_used_th, mi_fixities, mi_warns, mi_anns - , mi_decls, mi_extra_decls, mi_globals, mi_insts - , mi_fam_insts, mi_rules, mi_hpc, mi_trust, mi_trust_pkg - , mi_complete_matches, mi_docs, mi_final_exts - , mi_ext_fields, mi_src_hash }) - = rnf mi_module - `seq` rnf mi_sig_of - `seq` mi_hsc_src - `seq` mi_deps - `seq` mi_usages - `seq` mi_exports - `seq` rnf mi_used_th - `seq` mi_fixities - `seq` rnf mi_warns - `seq` rnf mi_anns - `seq` rnf mi_decls - `seq` rnf mi_extra_decls - `seq` rnf mi_globals - `seq` rnf mi_insts - `seq` rnf mi_fam_insts - `seq` rnf mi_rules - `seq` rnf mi_hpc - `seq` mi_trust - `seq` rnf mi_trust_pkg - `seq` rnf mi_complete_matches - `seq` rnf mi_docs - `seq` mi_final_exts - `seq` mi_ext_fields - `seq` rnf mi_src_hash + rnf (ModIface{ mi_module_, mi_sig_of_, mi_hsc_src_, mi_deps_, mi_usages_ + , mi_exports_, mi_used_th_, mi_fixities_, mi_warns_, mi_anns_ + , mi_decls_, mi_extra_decls_, mi_globals_, mi_insts_ + , mi_fam_insts_, mi_rules_, mi_hpc_, mi_trust_, mi_trust_pkg_ + , mi_complete_matches_, mi_docs_, mi_final_exts_ + , mi_ext_fields_, mi_src_hash_ }) + = rnf mi_module_ + `seq` rnf mi_sig_of_ + `seq` mi_hsc_src_ + `seq` mi_deps_ + `seq` mi_usages_ + `seq` mi_exports_ + `seq` rnf mi_used_th_ + `seq` mi_fixities_ + `seq` rnf mi_warns_ + `seq` rnf mi_anns_ + `seq` rnf mi_decls_ + `seq` rnf mi_extra_decls_ + `seq` rnf mi_globals_ + `seq` rnf mi_insts_ + `seq` rnf mi_fam_insts_ + `seq` rnf mi_rules_ + `seq` rnf mi_hpc_ + `seq` mi_trust_ + `seq` rnf mi_trust_pkg_ + `seq` rnf mi_complete_matches_ + `seq` rnf mi_docs_ + `seq` mi_final_exts_ + `seq` mi_ext_fields_ + `seq` rnf mi_src_hash_ `seq` () instance NFData (ModIfaceBackend) where @@ -694,90 +696,150 @@ completePartialModIface :: PartialModIface -> IfaceBinHandle 'ModIfaceFinal -> ModIface completePartialModIface partial decls extra_decls final_exts hi_bytes = partial - { mi_decls = decls - , mi_extra_decls = extra_decls - , mi_final_exts = final_exts - , mi_hi_bytes = hi_bytes + { mi_decls_ = decls + , mi_extra_decls_ = extra_decls + , mi_final_exts_ = final_exts + , mi_hi_bytes_ = hi_bytes + } + +addSourceFingerprint :: Fingerprint -> ModIface_ 'ModIfaceFinal -> ModIface_ 'ModIfaceFinal +addSourceFingerprint val iface = iface { mi_src_hash_ = val } + +restoreFromOldModIface :: ModIface_ phase -> ModIface_ phase -> ModIface_ phase +restoreFromOldModIface old new = new + { mi_globals_ = mi_globals_ old + , mi_hsc_src_ = mi_hsc_src_ old } set_mi_module :: Module -> ModIface_ phase -> ModIface_ phase -set_mi_module val iface = clear_mi_hi_bytes $ iface { mi_module = val } +set_mi_module val iface = clear_mi_hi_bytes $ iface { mi_module_ = val } set_mi_sig_of :: Maybe Module -> ModIface_ phase -> ModIface_ phase -set_mi_sig_of val iface = clear_mi_hi_bytes $ iface { mi_sig_of = val } +set_mi_sig_of val iface = clear_mi_hi_bytes $ iface { mi_sig_of_ = val } set_mi_hsc_src :: HscSource -> ModIface_ phase -> ModIface_ phase -set_mi_hsc_src val iface = clear_mi_hi_bytes $ iface { mi_hsc_src = val } +set_mi_hsc_src val iface = clear_mi_hi_bytes $ iface { mi_hsc_src_ = val } set_mi_src_hash :: Fingerprint -> ModIface_ phase -> ModIface_ phase -set_mi_src_hash val iface = clear_mi_hi_bytes $ iface { mi_src_hash = val } +set_mi_src_hash val iface = clear_mi_hi_bytes $ iface { mi_src_hash_ = val } set_mi_hi_bytes :: IfaceBinHandle phase -> ModIface_ phase -> ModIface_ phase -set_mi_hi_bytes val iface = iface { mi_hi_bytes = val } +set_mi_hi_bytes val iface = iface { mi_hi_bytes_ = val } set_mi_deps :: Dependencies -> ModIface_ phase -> ModIface_ phase -set_mi_deps val iface = clear_mi_hi_bytes $ iface { mi_deps = val } +set_mi_deps val iface = clear_mi_hi_bytes $ iface { mi_deps_ = val } set_mi_usages :: [Usage] -> ModIface_ phase -> ModIface_ phase -set_mi_usages val iface = clear_mi_hi_bytes $ iface { mi_usages = val } +set_mi_usages val iface = clear_mi_hi_bytes $ iface { mi_usages_ = val } set_mi_exports :: [IfaceExport] -> ModIface_ phase -> ModIface_ phase -set_mi_exports val iface = clear_mi_hi_bytes $ iface { mi_exports = val } +set_mi_exports val iface = clear_mi_hi_bytes $ iface { mi_exports_ = val } set_mi_used_th :: Bool -> ModIface_ phase -> ModIface_ phase -set_mi_used_th val iface = clear_mi_hi_bytes $ iface { mi_used_th = val } +set_mi_used_th val iface = clear_mi_hi_bytes $ iface { mi_used_th_ = val } set_mi_fixities :: [(OccName, Fixity)] -> ModIface_ phase -> ModIface_ phase -set_mi_fixities val iface = clear_mi_hi_bytes $ iface { mi_fixities = val } +set_mi_fixities val iface = clear_mi_hi_bytes $ iface { mi_fixities_ = val } set_mi_warns :: IfaceWarnings -> ModIface_ phase -> ModIface_ phase -set_mi_warns val iface = clear_mi_hi_bytes $ iface { mi_warns = val } +set_mi_warns val iface = clear_mi_hi_bytes $ iface { mi_warns_ = val } set_mi_anns :: [IfaceAnnotation] -> ModIface_ phase -> ModIface_ phase -set_mi_anns val iface = clear_mi_hi_bytes $ iface { mi_anns = val } +set_mi_anns val iface = clear_mi_hi_bytes $ iface { mi_anns_ = val } set_mi_insts :: [IfaceClsInst] -> ModIface_ phase -> ModIface_ phase -set_mi_insts val iface = clear_mi_hi_bytes $ iface { mi_insts = val } +set_mi_insts val iface = clear_mi_hi_bytes $ iface { mi_insts_ = val } set_mi_fam_insts :: [IfaceFamInst] -> ModIface_ phase -> ModIface_ phase -set_mi_fam_insts val iface = clear_mi_hi_bytes $ iface { mi_fam_insts = val } +set_mi_fam_insts val iface = clear_mi_hi_bytes $ iface { mi_fam_insts_ = val } set_mi_rules :: [IfaceRule] -> ModIface_ phase -> ModIface_ phase -set_mi_rules val iface = clear_mi_hi_bytes $ iface { mi_rules = val } +set_mi_rules val iface = clear_mi_hi_bytes $ iface { mi_rules_ = val } set_mi_decls :: [IfaceDeclExts phase] -> ModIface_ phase -> ModIface_ phase -set_mi_decls val iface = clear_mi_hi_bytes $ iface { mi_decls = val } +set_mi_decls val iface = clear_mi_hi_bytes $ iface { mi_decls_ = val } set_mi_extra_decls :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] -> ModIface_ phase -> ModIface_ phase -set_mi_extra_decls val iface = clear_mi_hi_bytes $ iface { mi_extra_decls = val } +set_mi_extra_decls val iface = clear_mi_hi_bytes $ iface { mi_extra_decls_ = val } set_mi_globals :: Maybe IfGlobalRdrEnv -> ModIface_ phase -> ModIface_ phase -set_mi_globals val iface = clear_mi_hi_bytes $ iface { mi_globals = val } +set_mi_globals val iface = clear_mi_hi_bytes $ iface { mi_globals_ = val } set_mi_hpc :: AnyHpcUsage -> ModIface_ phase -> ModIface_ phase -set_mi_hpc val iface = clear_mi_hi_bytes $ iface { mi_hpc = val } +set_mi_hpc val iface = clear_mi_hi_bytes $ iface { mi_hpc_ = val } set_mi_trust :: IfaceTrustInfo -> ModIface_ phase -> ModIface_ phase -set_mi_trust val iface = clear_mi_hi_bytes $ iface { mi_trust = val } +set_mi_trust val iface = clear_mi_hi_bytes $ iface { mi_trust_ = val } set_mi_trust_pkg :: Bool -> ModIface_ phase -> ModIface_ phase -set_mi_trust_pkg val iface = clear_mi_hi_bytes $ iface { mi_trust_pkg = val } +set_mi_trust_pkg val iface = clear_mi_hi_bytes $ iface { mi_trust_pkg_ = val } set_mi_complete_matches :: [IfaceCompleteMatch] -> ModIface_ phase -> ModIface_ phase -set_mi_complete_matches val iface = clear_mi_hi_bytes $ iface { mi_complete_matches = val } +set_mi_complete_matches val iface = clear_mi_hi_bytes $ iface { mi_complete_matches_ = val } set_mi_docs :: Maybe Docs -> ModIface_ phase -> ModIface_ phase -set_mi_docs val iface = clear_mi_hi_bytes $ iface { mi_docs = val } +set_mi_docs val iface = clear_mi_hi_bytes $ iface { mi_docs_ = val } set_mi_final_exts :: IfaceBackendExts phase -> ModIface_ phase -> ModIface_ phase -set_mi_final_exts val iface = clear_mi_hi_bytes $ iface { mi_final_exts = val } +set_mi_final_exts val iface = clear_mi_hi_bytes $ iface { mi_final_exts_ = val } set_mi_ext_fields :: ExtensibleFields -> ModIface_ phase -> ModIface_ phase -set_mi_ext_fields val iface = clear_mi_hi_bytes $ iface { mi_ext_fields = val } +set_mi_ext_fields val iface = clear_mi_hi_bytes $ iface { mi_ext_fields_ = val } clear_mi_hi_bytes :: ModIface_ phase -> ModIface_ phase clear_mi_hi_bytes iface = iface - { mi_hi_bytes = case mi_hi_bytes iface of + { mi_hi_bytes_ = case mi_hi_bytes iface of PartialIfaceBinHandle -> PartialIfaceBinHandle FullIfaceBinHandle _ -> FullIfaceBinHandle Strict.Nothing } + +mi_module :: ModIface_ phase -> Module +mi_module = mi_module_ +mi_sig_of :: ModIface_ phase -> Maybe Module +mi_sig_of = mi_sig_of_ +mi_hsc_src :: ModIface_ phase -> HscSource +mi_hsc_src = mi_hsc_src_ +mi_deps :: ModIface_ phase -> Dependencies +mi_deps = mi_deps_ +mi_usages :: ModIface_ phase -> [Usage] +mi_usages = mi_usages_ +mi_exports :: ModIface_ phase -> [IfaceExport] +mi_exports = mi_exports_ +mi_used_th :: ModIface_ phase -> Bool +mi_used_th = mi_used_th_ +mi_fixities :: ModIface_ phase -> [(OccName, Fixity)] +mi_fixities = mi_fixities_ +mi_warns :: ModIface_ phase -> IfaceWarnings +mi_warns = mi_warns_ +mi_anns :: ModIface_ phase -> [IfaceAnnotation] +mi_anns = mi_anns_ +mi_decls :: ModIface_ phase -> [IfaceDeclExts phase] +mi_decls = mi_decls_ +mi_extra_decls :: ModIface_ phase -> Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] +mi_extra_decls = mi_extra_decls_ +mi_globals :: ModIface_ phase -> Maybe IfGlobalRdrEnv +mi_globals = mi_globals_ +mi_insts :: ModIface_ phase -> [IfaceClsInst] +mi_insts = mi_insts_ +mi_fam_insts :: ModIface_ phase -> [IfaceFamInst] +mi_fam_insts = mi_fam_insts_ +mi_rules :: ModIface_ phase -> [IfaceRule] +mi_rules = mi_rules_ +mi_hpc :: ModIface_ phase -> AnyHpcUsage +mi_hpc = mi_hpc_ +mi_trust :: ModIface_ phase -> IfaceTrustInfo +mi_trust = mi_trust_ +mi_trust_pkg :: ModIface_ phase -> Bool +mi_trust_pkg = mi_trust_pkg_ +mi_complete_matches :: ModIface_ phase -> [IfaceCompleteMatch] +mi_complete_matches = mi_complete_matches_ +mi_docs :: ModIface_ phase -> Maybe Docs +mi_docs = mi_docs_ +mi_final_exts :: ModIface_ phase -> IfaceBackendExts phase +mi_final_exts = mi_final_exts_ +mi_ext_fields :: ModIface_ phase -> ExtensibleFields +mi_ext_fields = mi_ext_fields_ +mi_src_hash :: ModIface_ phase -> Fingerprint +mi_src_hash = mi_src_hash_ +mi_hi_bytes :: ModIface_ phase -> IfaceBinHandle phase +mi_hi_bytes = mi_hi_bytes_ ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit fa76e1ee98906f5bc8fc4598524610020b653412 +Subproject commit eaa6e1870997f09b9023cba09d6b5431cf5b0174 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c65210cc27446f3349375909ebcb84956713fb9a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c65210cc27446f3349375909ebcb84956713fb9a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 08:15:28 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Fri, 03 May 2024 04:15:28 -0400 Subject: [Git][ghc/ghc][wip/fendor/ghc-iface-sharing-avoid-reserialisation] Make sure to always invalidate correctly Message-ID: <66349d207dda1_10d81b15ff3d868031@gitlab.mail> Hannes Siebenhandl pushed to branch wip/fendor/ghc-iface-sharing-avoid-reserialisation at Glasgow Haskell Compiler / GHC Commits: de796302 by Fendor at 2024-05-03T10:14:52+02:00 Make sure to always invalidate correctly Bump haddock submodule - - - - - 9 changed files: - compiler/GHC.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Unit/Module/ModIface.hs - utils/haddock Changes: ===================================== compiler/GHC.hs ===================================== @@ -98,7 +98,32 @@ module GHC ( lookupGlobalName, findGlobalAnns, mkNamePprCtxForModule, - ModIface, ModIface_(..), + ModIface, + mi_module, + mi_sig_of, + mi_hsc_src, + mi_src_hash, + mi_hi_bytes, + mi_deps, + mi_usages, + mi_exports, + mi_used_th, + mi_fixities, + mi_warns, + mi_anns, + mi_insts, + mi_fam_insts, + mi_rules, + mi_decls, + mi_extra_decls, + mi_globals, + mi_hpc, + mi_trust, + mi_trust_pkg, + mi_complete_matches, + mi_docs, + mi_final_exts, + mi_ext_fields, SafeHaskellMode(..), -- * Printing ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -64,6 +64,7 @@ import Data.Word import System.IO.Unsafe import Data.Typeable (Typeable) import qualified GHC.Data.Strict as Strict +import Data.Function ((&)) -- --------------------------------------------------------------------------- @@ -161,9 +162,9 @@ readBinIface profile name_cache checkHiWay traceBinIface hi_path = do mod_iface <- getIfaceWithExtFields name_cache bh - return mod_iface - { mi_src_hash = src_hash - } + return $ mod_iface + & addSourceFingerprint src_hash + getIfaceWithExtFields :: NameCache -> ReadBinHandle -> IO ModIface getIfaceWithExtFields name_cache bh = do @@ -176,10 +177,9 @@ getIfaceWithExtFields name_cache bh = do seekBinReaderRel bh extFields_p_rel extFields <- get bh modIfaceData <- freezeBinHandle2 bh start - pure mod_iface - { mi_ext_fields = extFields - , mi_hi_bytes = FullIfaceBinHandle $ Strict.Just modIfaceData - } + pure $ mod_iface + & set_mi_ext_fields extFields + & set_mi_hi_bytes (FullIfaceBinHandle $ Strict.Just modIfaceData) -- | This performs a get action after reading the dictionary and symbol ===================================== compiler/GHC/Iface/Load.hs ===================================== @@ -117,6 +117,7 @@ import System.FilePath import System.Directory import GHC.Driver.Env.KnotVars import GHC.Iface.Errors.Types +import Data.Function ((&)) {- ************************************************************************ @@ -515,14 +516,12 @@ loadInterface doc_str mod from ; new_eps_anns <- tcIfaceAnnotations (mi_anns iface) ; new_eps_complete_matches <- tcIfaceCompleteMatches (mi_complete_matches iface) - ; let { final_iface = iface { - mi_decls = panic "No mi_decls in PIT", - mi_insts = panic "No mi_insts in PIT", - mi_fam_insts = panic "No mi_fam_insts in PIT", - mi_rules = panic "No mi_rules in PIT", - mi_anns = panic "No mi_anns in PIT" - } - } + ; let final_iface = iface + & set_mi_decls (panic "No mi_decls in PIT") + & set_mi_insts (panic "No mi_insts in PIT") + & set_mi_fam_insts (panic "No mi_fam_insts in PIT") + & set_mi_rules (panic "No mi_rules in PIT") + & set_mi_anns (panic "No mi_anns in PIT") ; let bad_boot = mi_boot iface == IsBoot && isJust (lookupKnotVars (if_rec_types gbl_env) mod) @@ -1017,13 +1016,13 @@ readIface dflags name_cache wanted_mod file_path = do -- See Note [GHC.Prim] in primops.txt.pp. ghcPrimIface :: ModIface ghcPrimIface - = empty_iface { - mi_exports = ghcPrimExports, - mi_decls = [], - mi_fixities = fixities, - mi_final_exts = (mi_final_exts empty_iface){ mi_fix_fn = mkIfaceFixCache fixities }, - mi_docs = Just ghcPrimDeclDocs -- See Note [GHC.Prim Docs] - } + = empty_iface + & set_mi_exports ghcPrimExports + & set_mi_decls [] + & set_mi_fixities fixities + & set_mi_final_exts ((mi_final_exts empty_iface){ mi_fix_fn = mkIfaceFixCache fixities }) + & set_mi_docs (Just ghcPrimDeclDocs) -- See Note [GHC.Prim Docs] + where empty_iface = emptyFullModIface gHC_PRIM ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -144,7 +144,7 @@ mkFullIface hsc_env partial_iface mb_stg_infos mb_cmm_infos = do full_iface <- {-# SCC "addFingerprints" #-} - addFingerprints hsc_env partial_iface{ mi_decls = decls } + addFingerprints hsc_env (set_mi_decls decls partial_iface) -- Debug printing let unit_state = hsc_units hsc_env @@ -177,10 +177,7 @@ shareIface nc compressionLevel mi = do rbh <- shrinkBinBuffer bh seekBinReader rbh start res <- getIfaceWithExtFields nc rbh - let resiface = res - { mi_src_hash = mi_src_hash mi - , mi_globals = mi_globals mi - } + let resiface = restoreFromOldModIface mi res forceModIface resiface return resiface ===================================== compiler/GHC/Iface/Rename.hs ===================================== @@ -44,6 +44,7 @@ import GHC.Utils.Panic import qualified Data.Traversable as T import Data.IORef +import Data.Function ((&)) tcRnMsgMaybe :: IO (Either (Messages TcRnMessage) a) -> TcM a tcRnMsgMaybe do_this = do @@ -108,13 +109,14 @@ rnModIface hsc_env insts nsubst iface = deps <- rnDependencies (mi_deps iface) -- TODO: -- mi_rules - return iface { mi_module = mod - , mi_sig_of = sig_of - , mi_insts = insts - , mi_fam_insts = fams - , mi_exports = exports - , mi_decls = decls - , mi_deps = deps } + return $ iface + & set_mi_module mod + & set_mi_sig_of sig_of + & set_mi_insts insts + & set_mi_fam_insts fams + & set_mi_exports exports + & set_mi_decls decls + & set_mi_deps deps -- | Rename just the exports of a 'ModIface'. Useful when we're doing -- shaping prior to signature merging. ===================================== compiler/GHC/Tc/Errors/Hole.hs ===================================== @@ -76,7 +76,7 @@ import GHC.Tc.Utils.Unify ( tcSubTypeSigma ) import GHC.HsToCore.Docs ( extractDocs ) import GHC.Hs.Doc -import GHC.Unit.Module.ModIface ( ModIface_(..) ) +import GHC.Unit.Module.ModIface ( mi_docs ) import GHC.Iface.Load ( loadInterfaceForName ) import GHC.Builtin.Utils (knownKeyNames) ===================================== compiler/GHC/Tc/Utils/Backpack.hs ===================================== @@ -87,6 +87,7 @@ import Control.Monad import Data.List (find) import GHC.Iface.Errors.Types +import Data.Function ((&)) checkHsigDeclM :: ModIface -> TyThing -> TyThing -> TcRn () checkHsigDeclM sig_iface sig_thing real_thing = do @@ -369,8 +370,8 @@ tcRnMergeSignatures hsc_env hpm orig_tcg_env iface = thinModIface :: [AvailInfo] -> ModIface -> ModIface thinModIface avails iface = - iface { - mi_exports = avails, + iface + & set_mi_exports avails -- mi_fixities = ..., -- mi_warns = ..., -- mi_anns = ..., @@ -378,10 +379,9 @@ thinModIface avails iface = -- perhaps there might be two IfaceTopBndr that are the same -- OccName but different Name. Requires better understanding -- of invariants here. - mi_decls = exported_decls ++ non_exported_decls ++ dfun_decls + & set_mi_decls (exported_decls ++ non_exported_decls ++ dfun_decls) -- mi_insts = ..., -- mi_fam_insts = ..., - } where decl_pred occs decl = nameOccName (ifName decl) `elemOccSet` occs filter_decls occs = filter (decl_pred occs . snd) (mi_decls iface) ===================================== compiler/GHC/Unit/Module/ModIface.hs ===================================== @@ -8,6 +8,8 @@ module GHC.Unit.Module.ModIface ( ModIface , ModIface_ + , restoreFromOldModIface + , addSourceFingerprint , mi_module , mi_sig_of , mi_hsc_src @@ -210,60 +212,60 @@ data IfaceBinHandle (phase :: ModIfacePhase) where -- strict and others are not. data ModIface_ (phase :: ModIfacePhase) = ModIface { - mi_module :: !Module, -- ^ Name of the module we are for - mi_sig_of :: !(Maybe Module), -- ^ Are we a sig of another mod? + mi_module_ :: !Module, -- ^ Name of the module we are for + mi_sig_of_ :: !(Maybe Module), -- ^ Are we a sig of another mod? - mi_hsc_src :: !HscSource, -- ^ Boot? Signature? + mi_hsc_src_ :: !HscSource, -- ^ Boot? Signature? - mi_deps :: Dependencies, + mi_deps_ :: Dependencies, -- ^ The dependencies of the module. This is -- consulted for directly-imported modules, but not -- for anything else (hence lazy) - mi_usages :: [Usage], + mi_usages_ :: [Usage], -- ^ Usages; kept sorted so that it's easy to decide -- whether to write a new iface file (changing usages -- doesn't affect the hash of this module) -- NOT STRICT! we read this field lazily from the interface file -- It is *only* consulted by the recompilation checker - mi_exports :: ![IfaceExport], + mi_exports_ :: ![IfaceExport], -- ^ Exports -- Kept sorted by (mod,occ), to make version comparisons easier -- Records the modules that are the declaration points for things -- exported by this module, and the 'OccName's of those things - mi_used_th :: !Bool, + mi_used_th_ :: !Bool, -- ^ Module required TH splices when it was compiled. -- This disables recompilation avoidance (see #481). - mi_fixities :: [(OccName,Fixity)], + mi_fixities_ :: [(OccName,Fixity)], -- ^ Fixities -- NOT STRICT! we read this field lazily from the interface file - mi_warns :: IfaceWarnings, + mi_warns_ :: IfaceWarnings, -- ^ Warnings -- NOT STRICT! we read this field lazily from the interface file - mi_anns :: [IfaceAnnotation], + mi_anns_ :: [IfaceAnnotation], -- ^ Annotations -- NOT STRICT! we read this field lazily from the interface file - mi_decls :: [IfaceDeclExts phase], + mi_decls_ :: [IfaceDeclExts phase], -- ^ Type, class and variable declarations -- The hash of an Id changes if its fixity or deprecations change -- (as well as its type of course) -- Ditto data constructors, class operations, except that -- the hash of the parent class/tycon changes - mi_extra_decls :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo], + mi_extra_decls_ :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo], -- ^ Extra variable definitions which are **NOT** exposed but when -- combined with mi_decls allows us to restart code generation. -- See Note [Interface Files with Core Definitions] and Note [Interface File with Core: Sharing RHSs] - mi_globals :: !(Maybe IfGlobalRdrEnv), + mi_globals_ :: !(Maybe IfGlobalRdrEnv), -- ^ Binds all the things defined at the top level in -- the /original source/ code for this module. which -- is NOT the same as mi_exports, nor mi_decls (which @@ -279,36 +281,36 @@ data ModIface_ (phase :: ModIfacePhase) -- 'HomeModInfo', but that leads to more plumbing. -- Instance declarations and rules - mi_insts :: [IfaceClsInst], -- ^ Sorted class instance - mi_fam_insts :: [IfaceFamInst], -- ^ Sorted family instances - mi_rules :: [IfaceRule], -- ^ Sorted rules + mi_insts_ :: [IfaceClsInst], -- ^ Sorted class instance + mi_fam_insts_ :: [IfaceFamInst], -- ^ Sorted family instances + mi_rules_ :: [IfaceRule], -- ^ Sorted rules - mi_hpc :: !AnyHpcUsage, + mi_hpc_ :: !AnyHpcUsage, -- ^ True if this program uses Hpc at any point in the program. - mi_trust :: !IfaceTrustInfo, + mi_trust_ :: !IfaceTrustInfo, -- ^ Safe Haskell Trust information for this module. - mi_trust_pkg :: !Bool, + mi_trust_pkg_ :: !Bool, -- ^ Do we require the package this module resides in be trusted -- to trust this module? This is used for the situation where a -- module is Safe (so doesn't require the package be trusted -- itself) but imports some trustworthy modules from its own -- package (which does require its own package be trusted). -- See Note [Trust Own Package] in GHC.Rename.Names - mi_complete_matches :: ![IfaceCompleteMatch], + mi_complete_matches_ :: ![IfaceCompleteMatch], - mi_docs :: !(Maybe Docs), + mi_docs_ :: !(Maybe Docs), -- ^ Docstrings and related data for use by haddock, the ghci -- @:doc@ command, and other tools. -- -- @Just _@ @<=>@ the module was built with @-haddock at . - mi_final_exts :: !(IfaceBackendExts phase), + mi_final_exts_ :: !(IfaceBackendExts phase), -- ^ Either `()` or `ModIfaceBackend` for -- a fully instantiated interface. - mi_ext_fields :: !ExtensibleFields, + mi_ext_fields_ :: !ExtensibleFields, -- ^ Additional optional fields, where the Map key represents -- the field name, resulting in a (size, serialized data) pair. -- Because the data is intended to be serialized through the @@ -317,9 +319,9 @@ data ModIface_ (phase :: ModIfacePhase) -- chosen over `ByteString`s. -- - mi_src_hash :: !Fingerprint, + mi_src_hash_ :: !Fingerprint, -- ^ Hash of the .hs source, used for recompilation checking. - mi_hi_bytes :: !(IfaceBinHandle phase) + mi_hi_bytes_ :: !(IfaceBinHandle phase) } {- @@ -399,34 +401,34 @@ renameFreeHoles fhs insts = -- See Note [Strictness in ModIface] about where we use lazyPut vs put instance Binary ModIface where put_ bh (ModIface { - mi_module = mod, - mi_sig_of = sig_of, - mi_hsc_src = hsc_src, - mi_src_hash = _src_hash, -- Don't `put_` this in the instance + mi_module_ = mod, + mi_sig_of_ = sig_of, + mi_hsc_src_ = hsc_src, + mi_src_hash_ = _src_hash, -- Don't `put_` this in the instance -- because we are going to write it -- out separately in the actual file - mi_hi_bytes = _hi_bytes, -- TODO: explain - mi_deps = deps, - mi_usages = usages, - mi_exports = exports, - mi_used_th = used_th, - mi_fixities = fixities, - mi_warns = warns, - mi_anns = anns, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_insts = insts, - mi_fam_insts = fam_insts, - mi_rules = rules, - mi_hpc = hpc_info, - mi_trust = trust, - mi_trust_pkg = trust_pkg, - mi_complete_matches = complete_matches, - mi_docs = docs, - mi_ext_fields = _ext_fields, -- Don't `put_` this in the instance so we + mi_hi_bytes_ = _hi_bytes, -- TODO: explain + mi_deps_ = deps, + mi_usages_ = usages, + mi_exports_ = exports, + mi_used_th_ = used_th, + mi_fixities_ = fixities, + mi_warns_ = warns, + mi_anns_ = anns, + mi_decls_ = decls, + mi_extra_decls_ = extra_decls, + mi_insts_ = insts, + mi_fam_insts_ = fam_insts, + mi_rules_ = rules, + mi_hpc_ = hpc_info, + mi_trust_ = trust, + mi_trust_pkg_ = trust_pkg, + mi_complete_matches_ = complete_matches, + mi_docs_ = docs, + mi_ext_fields_ = _ext_fields, -- Don't `put_` this in the instance so we -- can deal with it's pointer in the header -- when we write the actual file - mi_final_exts = ModIfaceBackend { + mi_final_exts_ = ModIfaceBackend { mi_iface_hash = iface_hash, mi_mod_hash = mod_hash, mi_flag_hash = flag_hash, @@ -501,34 +503,34 @@ instance Binary ModIface where complete_matches <- get bh docs <- lazyGetMaybe bh return (ModIface { - mi_module = mod, - mi_sig_of = sig_of, - mi_hsc_src = hsc_src, - mi_src_hash = fingerprint0, -- placeholder because this is dealt + mi_module_ = mod, + mi_sig_of_ = sig_of, + mi_hsc_src_ = hsc_src, + mi_src_hash_ = fingerprint0, -- placeholder because this is dealt -- with specially when the file is read - mi_hi_bytes = FullIfaceBinHandle Strict.Nothing, - mi_deps = deps, - mi_usages = usages, - mi_exports = exports, - mi_used_th = used_th, - mi_anns = anns, - mi_fixities = fixities, - mi_warns = warns, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_globals = Nothing, - mi_insts = insts, - mi_fam_insts = fam_insts, - mi_rules = rules, - mi_hpc = hpc_info, - mi_trust = trust, - mi_trust_pkg = trust_pkg, + mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing, + mi_deps_ = deps, + mi_usages_ = usages, + mi_exports_ = exports, + mi_used_th_ = used_th, + mi_anns_ = anns, + mi_fixities_ = fixities, + mi_warns_ = warns, + mi_decls_ = decls, + mi_extra_decls_ = extra_decls, + mi_globals_ = Nothing, + mi_insts_ = insts, + mi_fam_insts_ = fam_insts, + mi_rules_ = rules, + mi_hpc_ = hpc_info, + mi_trust_ = trust, + mi_trust_pkg_ = trust_pkg, -- And build the cached values - mi_complete_matches = complete_matches, - mi_docs = docs, - mi_ext_fields = emptyExtensibleFields, -- placeholder because this is dealt + mi_complete_matches_ = complete_matches, + mi_docs_ = docs, + mi_ext_fields_ = emptyExtensibleFields, -- placeholder because this is dealt -- with specially when the file is read - mi_final_exts = ModIfaceBackend { + mi_final_exts_ = ModIfaceBackend { mi_iface_hash = iface_hash, mi_mod_hash = mod_hash, mi_flag_hash = flag_hash, @@ -551,39 +553,39 @@ type IfaceExport = AvailInfo emptyPartialModIface :: Module -> PartialModIface emptyPartialModIface mod - = ModIface { mi_module = mod, - mi_sig_of = Nothing, - mi_hsc_src = HsSrcFile, - mi_src_hash = fingerprint0, - mi_hi_bytes = PartialIfaceBinHandle, - mi_deps = noDependencies, - mi_usages = [], - mi_exports = [], - mi_used_th = False, - mi_fixities = [], - mi_warns = IfWarnSome [] [], - mi_anns = [], - mi_insts = [], - mi_fam_insts = [], - mi_rules = [], - mi_decls = [], - mi_extra_decls = Nothing, - mi_globals = Nothing, - mi_hpc = False, - mi_trust = noIfaceTrustInfo, - mi_trust_pkg = False, - mi_complete_matches = [], - mi_docs = Nothing, - mi_final_exts = (), - mi_ext_fields = emptyExtensibleFields + = ModIface { mi_module_ = mod, + mi_sig_of_ = Nothing, + mi_hsc_src_ = HsSrcFile, + mi_src_hash_ = fingerprint0, + mi_hi_bytes_ = PartialIfaceBinHandle, + mi_deps_ = noDependencies, + mi_usages_ = [], + mi_exports_ = [], + mi_used_th_ = False, + mi_fixities_ = [], + mi_warns_ = IfWarnSome [] [], + mi_anns_ = [], + mi_insts_ = [], + mi_fam_insts_ = [], + mi_rules_ = [], + mi_decls_ = [], + mi_extra_decls_ = Nothing, + mi_globals_ = Nothing, + mi_hpc_ = False, + mi_trust_ = noIfaceTrustInfo, + mi_trust_pkg_ = False, + mi_complete_matches_ = [], + mi_docs_ = Nothing, + mi_final_exts_ = (), + mi_ext_fields_ = emptyExtensibleFields } emptyFullModIface :: Module -> ModIface emptyFullModIface mod = (emptyPartialModIface mod) - { mi_decls = [] - , mi_hi_bytes = FullIfaceBinHandle Strict.Nothing - , mi_final_exts = ModIfaceBackend + { mi_decls_ = [] + , mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing + , mi_final_exts_ = ModIfaceBackend { mi_iface_hash = fingerprint0, mi_mod_hash = fingerprint0, mi_flag_hash = fingerprint0, @@ -618,36 +620,36 @@ emptyIfaceHashCache _occ = Nothing instance ( NFData (IfaceBackendExts (phase :: ModIfacePhase)) , NFData (IfaceDeclExts (phase :: ModIfacePhase)) ) => NFData (ModIface_ phase) where - rnf (ModIface{ mi_module, mi_sig_of, mi_hsc_src, mi_deps, mi_usages - , mi_exports, mi_used_th, mi_fixities, mi_warns, mi_anns - , mi_decls, mi_extra_decls, mi_globals, mi_insts - , mi_fam_insts, mi_rules, mi_hpc, mi_trust, mi_trust_pkg - , mi_complete_matches, mi_docs, mi_final_exts - , mi_ext_fields, mi_src_hash }) - = rnf mi_module - `seq` rnf mi_sig_of - `seq` mi_hsc_src - `seq` mi_deps - `seq` mi_usages - `seq` mi_exports - `seq` rnf mi_used_th - `seq` mi_fixities - `seq` rnf mi_warns - `seq` rnf mi_anns - `seq` rnf mi_decls - `seq` rnf mi_extra_decls - `seq` rnf mi_globals - `seq` rnf mi_insts - `seq` rnf mi_fam_insts - `seq` rnf mi_rules - `seq` rnf mi_hpc - `seq` mi_trust - `seq` rnf mi_trust_pkg - `seq` rnf mi_complete_matches - `seq` rnf mi_docs - `seq` mi_final_exts - `seq` mi_ext_fields - `seq` rnf mi_src_hash + rnf (ModIface{ mi_module_, mi_sig_of_, mi_hsc_src_, mi_deps_, mi_usages_ + , mi_exports_, mi_used_th_, mi_fixities_, mi_warns_, mi_anns_ + , mi_decls_, mi_extra_decls_, mi_globals_, mi_insts_ + , mi_fam_insts_, mi_rules_, mi_hpc_, mi_trust_, mi_trust_pkg_ + , mi_complete_matches_, mi_docs_, mi_final_exts_ + , mi_ext_fields_, mi_src_hash_ }) + = rnf mi_module_ + `seq` rnf mi_sig_of_ + `seq` mi_hsc_src_ + `seq` mi_deps_ + `seq` mi_usages_ + `seq` mi_exports_ + `seq` rnf mi_used_th_ + `seq` mi_fixities_ + `seq` rnf mi_warns_ + `seq` rnf mi_anns_ + `seq` rnf mi_decls_ + `seq` rnf mi_extra_decls_ + `seq` rnf mi_globals_ + `seq` rnf mi_insts_ + `seq` rnf mi_fam_insts_ + `seq` rnf mi_rules_ + `seq` rnf mi_hpc_ + `seq` mi_trust_ + `seq` rnf mi_trust_pkg_ + `seq` rnf mi_complete_matches_ + `seq` rnf mi_docs_ + `seq` mi_final_exts_ + `seq` mi_ext_fields_ + `seq` rnf mi_src_hash_ `seq` () instance NFData (ModIfaceBackend) where @@ -694,90 +696,150 @@ completePartialModIface :: PartialModIface -> IfaceBinHandle 'ModIfaceFinal -> ModIface completePartialModIface partial decls extra_decls final_exts hi_bytes = partial - { mi_decls = decls - , mi_extra_decls = extra_decls - , mi_final_exts = final_exts - , mi_hi_bytes = hi_bytes + { mi_decls_ = decls + , mi_extra_decls_ = extra_decls + , mi_final_exts_ = final_exts + , mi_hi_bytes_ = hi_bytes + } + +addSourceFingerprint :: Fingerprint -> ModIface_ 'ModIfaceFinal -> ModIface_ 'ModIfaceFinal +addSourceFingerprint val iface = iface { mi_src_hash_ = val } + +restoreFromOldModIface :: ModIface_ phase -> ModIface_ phase -> ModIface_ phase +restoreFromOldModIface old new = new + { mi_globals_ = mi_globals_ old + , mi_hsc_src_ = mi_hsc_src_ old } set_mi_module :: Module -> ModIface_ phase -> ModIface_ phase -set_mi_module val iface = clear_mi_hi_bytes $ iface { mi_module = val } +set_mi_module val iface = clear_mi_hi_bytes $ iface { mi_module_ = val } set_mi_sig_of :: Maybe Module -> ModIface_ phase -> ModIface_ phase -set_mi_sig_of val iface = clear_mi_hi_bytes $ iface { mi_sig_of = val } +set_mi_sig_of val iface = clear_mi_hi_bytes $ iface { mi_sig_of_ = val } set_mi_hsc_src :: HscSource -> ModIface_ phase -> ModIface_ phase -set_mi_hsc_src val iface = clear_mi_hi_bytes $ iface { mi_hsc_src = val } +set_mi_hsc_src val iface = clear_mi_hi_bytes $ iface { mi_hsc_src_ = val } set_mi_src_hash :: Fingerprint -> ModIface_ phase -> ModIface_ phase -set_mi_src_hash val iface = clear_mi_hi_bytes $ iface { mi_src_hash = val } +set_mi_src_hash val iface = clear_mi_hi_bytes $ iface { mi_src_hash_ = val } set_mi_hi_bytes :: IfaceBinHandle phase -> ModIface_ phase -> ModIface_ phase -set_mi_hi_bytes val iface = iface { mi_hi_bytes = val } +set_mi_hi_bytes val iface = iface { mi_hi_bytes_ = val } set_mi_deps :: Dependencies -> ModIface_ phase -> ModIface_ phase -set_mi_deps val iface = clear_mi_hi_bytes $ iface { mi_deps = val } +set_mi_deps val iface = clear_mi_hi_bytes $ iface { mi_deps_ = val } set_mi_usages :: [Usage] -> ModIface_ phase -> ModIface_ phase -set_mi_usages val iface = clear_mi_hi_bytes $ iface { mi_usages = val } +set_mi_usages val iface = clear_mi_hi_bytes $ iface { mi_usages_ = val } set_mi_exports :: [IfaceExport] -> ModIface_ phase -> ModIface_ phase -set_mi_exports val iface = clear_mi_hi_bytes $ iface { mi_exports = val } +set_mi_exports val iface = clear_mi_hi_bytes $ iface { mi_exports_ = val } set_mi_used_th :: Bool -> ModIface_ phase -> ModIface_ phase -set_mi_used_th val iface = clear_mi_hi_bytes $ iface { mi_used_th = val } +set_mi_used_th val iface = clear_mi_hi_bytes $ iface { mi_used_th_ = val } set_mi_fixities :: [(OccName, Fixity)] -> ModIface_ phase -> ModIface_ phase -set_mi_fixities val iface = clear_mi_hi_bytes $ iface { mi_fixities = val } +set_mi_fixities val iface = clear_mi_hi_bytes $ iface { mi_fixities_ = val } set_mi_warns :: IfaceWarnings -> ModIface_ phase -> ModIface_ phase -set_mi_warns val iface = clear_mi_hi_bytes $ iface { mi_warns = val } +set_mi_warns val iface = clear_mi_hi_bytes $ iface { mi_warns_ = val } set_mi_anns :: [IfaceAnnotation] -> ModIface_ phase -> ModIface_ phase -set_mi_anns val iface = clear_mi_hi_bytes $ iface { mi_anns = val } +set_mi_anns val iface = clear_mi_hi_bytes $ iface { mi_anns_ = val } set_mi_insts :: [IfaceClsInst] -> ModIface_ phase -> ModIface_ phase -set_mi_insts val iface = clear_mi_hi_bytes $ iface { mi_insts = val } +set_mi_insts val iface = clear_mi_hi_bytes $ iface { mi_insts_ = val } set_mi_fam_insts :: [IfaceFamInst] -> ModIface_ phase -> ModIface_ phase -set_mi_fam_insts val iface = clear_mi_hi_bytes $ iface { mi_fam_insts = val } +set_mi_fam_insts val iface = clear_mi_hi_bytes $ iface { mi_fam_insts_ = val } set_mi_rules :: [IfaceRule] -> ModIface_ phase -> ModIface_ phase -set_mi_rules val iface = clear_mi_hi_bytes $ iface { mi_rules = val } +set_mi_rules val iface = clear_mi_hi_bytes $ iface { mi_rules_ = val } set_mi_decls :: [IfaceDeclExts phase] -> ModIface_ phase -> ModIface_ phase -set_mi_decls val iface = clear_mi_hi_bytes $ iface { mi_decls = val } +set_mi_decls val iface = clear_mi_hi_bytes $ iface { mi_decls_ = val } set_mi_extra_decls :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] -> ModIface_ phase -> ModIface_ phase -set_mi_extra_decls val iface = clear_mi_hi_bytes $ iface { mi_extra_decls = val } +set_mi_extra_decls val iface = clear_mi_hi_bytes $ iface { mi_extra_decls_ = val } set_mi_globals :: Maybe IfGlobalRdrEnv -> ModIface_ phase -> ModIface_ phase -set_mi_globals val iface = clear_mi_hi_bytes $ iface { mi_globals = val } +set_mi_globals val iface = clear_mi_hi_bytes $ iface { mi_globals_ = val } set_mi_hpc :: AnyHpcUsage -> ModIface_ phase -> ModIface_ phase -set_mi_hpc val iface = clear_mi_hi_bytes $ iface { mi_hpc = val } +set_mi_hpc val iface = clear_mi_hi_bytes $ iface { mi_hpc_ = val } set_mi_trust :: IfaceTrustInfo -> ModIface_ phase -> ModIface_ phase -set_mi_trust val iface = clear_mi_hi_bytes $ iface { mi_trust = val } +set_mi_trust val iface = clear_mi_hi_bytes $ iface { mi_trust_ = val } set_mi_trust_pkg :: Bool -> ModIface_ phase -> ModIface_ phase -set_mi_trust_pkg val iface = clear_mi_hi_bytes $ iface { mi_trust_pkg = val } +set_mi_trust_pkg val iface = clear_mi_hi_bytes $ iface { mi_trust_pkg_ = val } set_mi_complete_matches :: [IfaceCompleteMatch] -> ModIface_ phase -> ModIface_ phase -set_mi_complete_matches val iface = clear_mi_hi_bytes $ iface { mi_complete_matches = val } +set_mi_complete_matches val iface = clear_mi_hi_bytes $ iface { mi_complete_matches_ = val } set_mi_docs :: Maybe Docs -> ModIface_ phase -> ModIface_ phase -set_mi_docs val iface = clear_mi_hi_bytes $ iface { mi_docs = val } +set_mi_docs val iface = clear_mi_hi_bytes $ iface { mi_docs_ = val } set_mi_final_exts :: IfaceBackendExts phase -> ModIface_ phase -> ModIface_ phase -set_mi_final_exts val iface = clear_mi_hi_bytes $ iface { mi_final_exts = val } +set_mi_final_exts val iface = clear_mi_hi_bytes $ iface { mi_final_exts_ = val } set_mi_ext_fields :: ExtensibleFields -> ModIface_ phase -> ModIface_ phase -set_mi_ext_fields val iface = clear_mi_hi_bytes $ iface { mi_ext_fields = val } +set_mi_ext_fields val iface = clear_mi_hi_bytes $ iface { mi_ext_fields_ = val } clear_mi_hi_bytes :: ModIface_ phase -> ModIface_ phase clear_mi_hi_bytes iface = iface - { mi_hi_bytes = case mi_hi_bytes iface of + { mi_hi_bytes_ = case mi_hi_bytes iface of PartialIfaceBinHandle -> PartialIfaceBinHandle FullIfaceBinHandle _ -> FullIfaceBinHandle Strict.Nothing } + +mi_module :: ModIface_ phase -> Module +mi_module = mi_module_ +mi_sig_of :: ModIface_ phase -> Maybe Module +mi_sig_of = mi_sig_of_ +mi_hsc_src :: ModIface_ phase -> HscSource +mi_hsc_src = mi_hsc_src_ +mi_deps :: ModIface_ phase -> Dependencies +mi_deps = mi_deps_ +mi_usages :: ModIface_ phase -> [Usage] +mi_usages = mi_usages_ +mi_exports :: ModIface_ phase -> [IfaceExport] +mi_exports = mi_exports_ +mi_used_th :: ModIface_ phase -> Bool +mi_used_th = mi_used_th_ +mi_fixities :: ModIface_ phase -> [(OccName, Fixity)] +mi_fixities = mi_fixities_ +mi_warns :: ModIface_ phase -> IfaceWarnings +mi_warns = mi_warns_ +mi_anns :: ModIface_ phase -> [IfaceAnnotation] +mi_anns = mi_anns_ +mi_decls :: ModIface_ phase -> [IfaceDeclExts phase] +mi_decls = mi_decls_ +mi_extra_decls :: ModIface_ phase -> Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] +mi_extra_decls = mi_extra_decls_ +mi_globals :: ModIface_ phase -> Maybe IfGlobalRdrEnv +mi_globals = mi_globals_ +mi_insts :: ModIface_ phase -> [IfaceClsInst] +mi_insts = mi_insts_ +mi_fam_insts :: ModIface_ phase -> [IfaceFamInst] +mi_fam_insts = mi_fam_insts_ +mi_rules :: ModIface_ phase -> [IfaceRule] +mi_rules = mi_rules_ +mi_hpc :: ModIface_ phase -> AnyHpcUsage +mi_hpc = mi_hpc_ +mi_trust :: ModIface_ phase -> IfaceTrustInfo +mi_trust = mi_trust_ +mi_trust_pkg :: ModIface_ phase -> Bool +mi_trust_pkg = mi_trust_pkg_ +mi_complete_matches :: ModIface_ phase -> [IfaceCompleteMatch] +mi_complete_matches = mi_complete_matches_ +mi_docs :: ModIface_ phase -> Maybe Docs +mi_docs = mi_docs_ +mi_final_exts :: ModIface_ phase -> IfaceBackendExts phase +mi_final_exts = mi_final_exts_ +mi_ext_fields :: ModIface_ phase -> ExtensibleFields +mi_ext_fields = mi_ext_fields_ +mi_src_hash :: ModIface_ phase -> Fingerprint +mi_src_hash = mi_src_hash_ +mi_hi_bytes :: ModIface_ phase -> IfaceBinHandle phase +mi_hi_bytes = mi_hi_bytes_ ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit fa76e1ee98906f5bc8fc4598524610020b653412 +Subproject commit eaa6e1870997f09b9023cba09d6b5431cf5b0174 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/de7963023a9291fe9c10b44881ae89a6ee129676 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/de7963023a9291fe9c10b44881ae89a6ee129676 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 08:34:49 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Fri, 03 May 2024 04:34:49 -0400 Subject: [Git][ghc/ghc][wip/andreask/late_workfree] 30 commits: Linearise ghc-internal and base build Message-ID: <6634a1a8f2075_10d81b181d4087648@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/late_workfree at Glasgow Haskell Compiler / GHC Commits: 8a06ddf6 by Matthew Pickering at 2024-04-25T11:16:16-04:00 Linearise ghc-internal and base build This is achieved by requesting the final package database for ghc-internal, which mandates it is fully built as a dependency of configuring the `base` package. This is at the expense of cross-package parrallelism between ghc-internal and the base package. Fixes #24436 - - - - - 94da9365 by Andrei Borzenkov at 2024-04-25T11:16:54-04:00 Fix tuple puns renaming (24702) Move tuple renaming short cutter from `isBuiltInOcc_maybe` to `isPunOcc_maybe`, so we consider incoming module. I also fixed some hidden bugs that raised after the change was done. - - - - - fa03b1fb by Fendor at 2024-04-26T18:03:13-04:00 Refactor the Binary serialisation interface The goal is simplifiy adding deduplication tables to `ModIface` interface serialisation. We identify two main points of interest that make this difficult: 1. UserData hardcodes what `Binary` instances can have deduplication tables. Moreover, it heavily uses partial functions. 2. GHC.Iface.Binary hardcodes the deduplication tables for 'Name' and 'FastString', making it difficult to add more deduplication. Instead of having a single `UserData` record with fields for all the types that can have deduplication tables, we allow to provide custom serialisers for any `Typeable`. These are wrapped in existentials and stored in a `Map` indexed by their respective `TypeRep`. The `Binary` instance of the type to deduplicate still needs to explicitly look up the decoder via `findUserDataReader` and `findUserDataWriter`, which is no worse than the status-quo. `Map` was chosen as microbenchmarks indicate it is the fastest for a small number of keys (< 10). To generalise the deduplication table serialisation mechanism, we introduce the types `ReaderTable` and `WriterTable` which provide a simple interface that is sufficient to implement a general purpose deduplication mechanism for `writeBinIface` and `readBinIface`. This allows us to provide a list of deduplication tables for serialisation that can be extended more easily, for example for `IfaceTyCon`, see the issue https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for more motivation. In addition to this refactoring, we split `UserData` into `ReaderUserData` and `WriterUserData`, to avoid partial functions and reduce overall memory usage, as we need fewer mutable variables. Bump haddock submodule to accomodate for `UserData` split. ------------------------- Metric Increase: MultiLayerModulesTH_Make MultiLayerModulesRecomp T21839c ------------------------- - - - - - bac57298 by Fendor at 2024-04-26T18:03:13-04:00 Split `BinHandle` into `ReadBinHandle` and `WriteBinHandle` A `BinHandle` contains too much information for reading data. For example, it needs to keep a `FastMutInt` and a `IORef BinData`, when the non-mutable variants would suffice. Additionally, this change has the benefit that anyone can immediately tell whether the `BinHandle` is used for reading or writing. Bump haddock submodule BinHandle split. - - - - - 4d6394dd by Simon Peyton Jones at 2024-04-26T18:03:49-04:00 Fix missing escaping-kind check in tcPatSynSig Note [Escaping kind in type signatures] explains how we deal with escaping kinds in type signatures, e.g. f :: forall r (a :: TYPE r). a where the kind of the body is (TYPE r), but `r` is not in scope outside the forall-type. I had missed this subtlety in tcPatSynSig, leading to #24686. This MR fixes it; and a similar bug in tc_top_lhs_type. (The latter is tested by T24686a.) - - - - - 981c2c2c by Alan Zimmerman at 2024-04-26T18:04:25-04:00 EPA: check-exact: check that the roundtrip reproduces the source Closes #24670 - - - - - a8616747 by Andrew Lelechenko at 2024-04-26T18:05:01-04:00 Document that setEnv is not thread-safe - - - - - 1e41de83 by Bryan Richter at 2024-04-26T18:05:37-04:00 CI: Work around frequent Signal 9 errors - - - - - a6d5f9da by Naïm Favier at 2024-04-27T17:52:40-04:00 ghc-internal: add MonadFix instance for (,) Closes https://gitlab.haskell.org/ghc/ghc/-/issues/24288, implements CLC proposal https://github.com/haskell/core-libraries-committee/issues/238. Adds a MonadFix instance for tuples, permitting value recursion in the "native" writer monad and bringing consistency with the existing instance for transformers's WriterT (and, to a lesser extent, for Solo). - - - - - 64feadcd by Rodrigo Mesquita at 2024-04-27T17:53:16-04:00 bindist: Fix xattr cleaning The original fix (725343aa) was incorrect because it used the shell bracket syntax which is the quoting syntax in autoconf, making the test for existence be incorrect and therefore `xattr` was never run. Fixes #24554 - - - - - e2094df3 by damhiya at 2024-04-28T23:52:00+09:00 Make read accepts binary integer formats CLC proposal : https://github.com/haskell/core-libraries-committee/issues/177 - - - - - 1c2fd963 by Alan Zimmerman at 2024-04-29T23:17:00-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 - - - - - 4189d17e by Sylvain Henry at 2024-04-29T23:17:42-04:00 LLVM: better unreachable default destination in Switch (#24717) See added note. Co-authored-by: Siddharth Bhat <siddu.druid at gmail.com> - - - - - a3725c88 by Cheng Shao at 2024-04-29T23:18:20-04:00 ci: enable wasm jobs for MRs with wasm label This patch enables wasm jobs for MRs with wasm label. Previously the wasm label didn't actually have any effect on the CI pipeline, and full-ci needed to be applied to run wasm jobs which was a waste of runners when working on the wasm backend, hence the fix here. - - - - - 702f7964 by Matthew Pickering at 2024-04-29T23:18:56-04:00 Make interface files and object files depend on inplace .conf file A potential fix for #24737 - - - - - 728af21e by Cheng Shao at 2024-04-30T05:30:23-04:00 utils: remove obsolete vagrant scripts Vagrantfile has long been removed in !5288. This commit further removes the obsolete vagrant scripts in the tree. - - - - - 36f2c342 by Cheng Shao at 2024-04-30T05:31:00-04:00 Update autoconf scripts Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 - - - - - ecbf22a6 by Ben Gamari at 2024-04-30T05:31:36-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 173549e8 by Andreas Klebinger at 2024-05-03T10:34:35+02:00 -fprof-late: Only insert cost centres on functions/non-workfree cafs. They are usually useless and doing so for data values comes with a large compile time/code size overhead. Fixes #24103 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/LateCC.hs - compiler/GHC/Core/LateCC/TopLevelBinds.hs - compiler/GHC/Core/LateCC/Types.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Ext/Fields.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Recomp/Binary.hs - compiler/GHC/Iface/Recomp/Flags.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/StgToJS/Apply.hs - compiler/GHC/StgToJS/Arg.hs - compiler/GHC/StgToJS/Closure.hs - compiler/GHC/StgToJS/CodeGen.hs - compiler/GHC/StgToJS/Expr.hs - compiler/GHC/StgToJS/Heap.hs - compiler/GHC/StgToJS/Object.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dc1664c88cee8bddbcee911ea991492e7d19ed31...173549e8bb69067a705295f22877337ef76cb6df -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dc1664c88cee8bddbcee911ea991492e7d19ed31...173549e8bb69067a705295f22877337ef76cb6df You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 09:15:06 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Fri, 03 May 2024 05:15:06 -0400 Subject: [Git][ghc/ghc][wip/fendor/ghc-iface-sharing-avoid-reserialisation] Make sure to always invalidate correctly Message-ID: <6634ab1a7df1e_10d81b1d9942c1011a4@gitlab.mail> Hannes Siebenhandl pushed to branch wip/fendor/ghc-iface-sharing-avoid-reserialisation at Glasgow Haskell Compiler / GHC Commits: 4bcd2b69 by Fendor at 2024-05-03T11:14:49+02:00 Make sure to always invalidate correctly Bump haddock submodule - - - - - 9 changed files: - compiler/GHC.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Unit/Module/ModIface.hs - utils/haddock Changes: ===================================== compiler/GHC.hs ===================================== @@ -98,7 +98,32 @@ module GHC ( lookupGlobalName, findGlobalAnns, mkNamePprCtxForModule, - ModIface, ModIface_(..), + ModIface, + mi_module, + mi_sig_of, + mi_hsc_src, + mi_src_hash, + mi_hi_bytes, + mi_deps, + mi_usages, + mi_exports, + mi_used_th, + mi_fixities, + mi_warns, + mi_anns, + mi_insts, + mi_fam_insts, + mi_rules, + mi_decls, + mi_extra_decls, + mi_globals, + mi_hpc, + mi_trust, + mi_trust_pkg, + mi_complete_matches, + mi_docs, + mi_final_exts, + mi_ext_fields, SafeHaskellMode(..), -- * Printing ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -64,6 +64,7 @@ import Data.Word import System.IO.Unsafe import Data.Typeable (Typeable) import qualified GHC.Data.Strict as Strict +import Data.Function ((&)) -- --------------------------------------------------------------------------- @@ -161,9 +162,9 @@ readBinIface profile name_cache checkHiWay traceBinIface hi_path = do mod_iface <- getIfaceWithExtFields name_cache bh - return mod_iface - { mi_src_hash = src_hash - } + return $ mod_iface + & addSourceFingerprint src_hash + getIfaceWithExtFields :: NameCache -> ReadBinHandle -> IO ModIface getIfaceWithExtFields name_cache bh = do @@ -176,10 +177,9 @@ getIfaceWithExtFields name_cache bh = do seekBinReaderRel bh extFields_p_rel extFields <- get bh modIfaceData <- freezeBinHandle2 bh start - pure mod_iface - { mi_ext_fields = extFields - , mi_hi_bytes = FullIfaceBinHandle $ Strict.Just modIfaceData - } + pure $ mod_iface + & set_mi_ext_fields extFields + & set_mi_hi_bytes (FullIfaceBinHandle $ Strict.Just modIfaceData) -- | This performs a get action after reading the dictionary and symbol ===================================== compiler/GHC/Iface/Load.hs ===================================== @@ -117,6 +117,7 @@ import System.FilePath import System.Directory import GHC.Driver.Env.KnotVars import GHC.Iface.Errors.Types +import Data.Function ((&)) {- ************************************************************************ @@ -515,14 +516,12 @@ loadInterface doc_str mod from ; new_eps_anns <- tcIfaceAnnotations (mi_anns iface) ; new_eps_complete_matches <- tcIfaceCompleteMatches (mi_complete_matches iface) - ; let { final_iface = iface { - mi_decls = panic "No mi_decls in PIT", - mi_insts = panic "No mi_insts in PIT", - mi_fam_insts = panic "No mi_fam_insts in PIT", - mi_rules = panic "No mi_rules in PIT", - mi_anns = panic "No mi_anns in PIT" - } - } + ; let final_iface = iface + & set_mi_decls (panic "No mi_decls in PIT") + & set_mi_insts (panic "No mi_insts in PIT") + & set_mi_fam_insts (panic "No mi_fam_insts in PIT") + & set_mi_rules (panic "No mi_rules in PIT") + & set_mi_anns (panic "No mi_anns in PIT") ; let bad_boot = mi_boot iface == IsBoot && isJust (lookupKnotVars (if_rec_types gbl_env) mod) @@ -1017,13 +1016,13 @@ readIface dflags name_cache wanted_mod file_path = do -- See Note [GHC.Prim] in primops.txt.pp. ghcPrimIface :: ModIface ghcPrimIface - = empty_iface { - mi_exports = ghcPrimExports, - mi_decls = [], - mi_fixities = fixities, - mi_final_exts = (mi_final_exts empty_iface){ mi_fix_fn = mkIfaceFixCache fixities }, - mi_docs = Just ghcPrimDeclDocs -- See Note [GHC.Prim Docs] - } + = empty_iface + & set_mi_exports ghcPrimExports + & set_mi_decls [] + & set_mi_fixities fixities + & set_mi_final_exts ((mi_final_exts empty_iface){ mi_fix_fn = mkIfaceFixCache fixities }) + & set_mi_docs (Just ghcPrimDeclDocs) -- See Note [GHC.Prim Docs] + where empty_iface = emptyFullModIface gHC_PRIM ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -144,7 +144,7 @@ mkFullIface hsc_env partial_iface mb_stg_infos mb_cmm_infos = do full_iface <- {-# SCC "addFingerprints" #-} - addFingerprints hsc_env partial_iface{ mi_decls = decls } + addFingerprints hsc_env (set_mi_decls decls partial_iface) -- Debug printing let unit_state = hsc_units hsc_env @@ -177,10 +177,7 @@ shareIface nc compressionLevel mi = do rbh <- shrinkBinBuffer bh seekBinReader rbh start res <- getIfaceWithExtFields nc rbh - let resiface = res - { mi_src_hash = mi_src_hash mi - , mi_globals = mi_globals mi - } + let resiface = restoreFromOldModIface mi res forceModIface resiface return resiface ===================================== compiler/GHC/Iface/Rename.hs ===================================== @@ -44,6 +44,7 @@ import GHC.Utils.Panic import qualified Data.Traversable as T import Data.IORef +import Data.Function ((&)) tcRnMsgMaybe :: IO (Either (Messages TcRnMessage) a) -> TcM a tcRnMsgMaybe do_this = do @@ -108,13 +109,14 @@ rnModIface hsc_env insts nsubst iface = deps <- rnDependencies (mi_deps iface) -- TODO: -- mi_rules - return iface { mi_module = mod - , mi_sig_of = sig_of - , mi_insts = insts - , mi_fam_insts = fams - , mi_exports = exports - , mi_decls = decls - , mi_deps = deps } + return $ iface + & set_mi_module mod + & set_mi_sig_of sig_of + & set_mi_insts insts + & set_mi_fam_insts fams + & set_mi_exports exports + & set_mi_decls decls + & set_mi_deps deps -- | Rename just the exports of a 'ModIface'. Useful when we're doing -- shaping prior to signature merging. ===================================== compiler/GHC/Tc/Errors/Hole.hs ===================================== @@ -76,7 +76,7 @@ import GHC.Tc.Utils.Unify ( tcSubTypeSigma ) import GHC.HsToCore.Docs ( extractDocs ) import GHC.Hs.Doc -import GHC.Unit.Module.ModIface ( ModIface_(..) ) +import GHC.Unit.Module.ModIface ( mi_docs ) import GHC.Iface.Load ( loadInterfaceForName ) import GHC.Builtin.Utils (knownKeyNames) ===================================== compiler/GHC/Tc/Utils/Backpack.hs ===================================== @@ -87,6 +87,7 @@ import Control.Monad import Data.List (find) import GHC.Iface.Errors.Types +import Data.Function ((&)) checkHsigDeclM :: ModIface -> TyThing -> TyThing -> TcRn () checkHsigDeclM sig_iface sig_thing real_thing = do @@ -369,8 +370,8 @@ tcRnMergeSignatures hsc_env hpm orig_tcg_env iface = thinModIface :: [AvailInfo] -> ModIface -> ModIface thinModIface avails iface = - iface { - mi_exports = avails, + iface + & set_mi_exports avails -- mi_fixities = ..., -- mi_warns = ..., -- mi_anns = ..., @@ -378,10 +379,9 @@ thinModIface avails iface = -- perhaps there might be two IfaceTopBndr that are the same -- OccName but different Name. Requires better understanding -- of invariants here. - mi_decls = exported_decls ++ non_exported_decls ++ dfun_decls + & set_mi_decls (exported_decls ++ non_exported_decls ++ dfun_decls) -- mi_insts = ..., -- mi_fam_insts = ..., - } where decl_pred occs decl = nameOccName (ifName decl) `elemOccSet` occs filter_decls occs = filter (decl_pred occs . snd) (mi_decls iface) ===================================== compiler/GHC/Unit/Module/ModIface.hs ===================================== @@ -8,6 +8,8 @@ module GHC.Unit.Module.ModIface ( ModIface , ModIface_ + , restoreFromOldModIface + , addSourceFingerprint , mi_module , mi_sig_of , mi_hsc_src @@ -210,60 +212,60 @@ data IfaceBinHandle (phase :: ModIfacePhase) where -- strict and others are not. data ModIface_ (phase :: ModIfacePhase) = ModIface { - mi_module :: !Module, -- ^ Name of the module we are for - mi_sig_of :: !(Maybe Module), -- ^ Are we a sig of another mod? + mi_module_ :: !Module, -- ^ Name of the module we are for + mi_sig_of_ :: !(Maybe Module), -- ^ Are we a sig of another mod? - mi_hsc_src :: !HscSource, -- ^ Boot? Signature? + mi_hsc_src_ :: !HscSource, -- ^ Boot? Signature? - mi_deps :: Dependencies, + mi_deps_ :: Dependencies, -- ^ The dependencies of the module. This is -- consulted for directly-imported modules, but not -- for anything else (hence lazy) - mi_usages :: [Usage], + mi_usages_ :: [Usage], -- ^ Usages; kept sorted so that it's easy to decide -- whether to write a new iface file (changing usages -- doesn't affect the hash of this module) -- NOT STRICT! we read this field lazily from the interface file -- It is *only* consulted by the recompilation checker - mi_exports :: ![IfaceExport], + mi_exports_ :: ![IfaceExport], -- ^ Exports -- Kept sorted by (mod,occ), to make version comparisons easier -- Records the modules that are the declaration points for things -- exported by this module, and the 'OccName's of those things - mi_used_th :: !Bool, + mi_used_th_ :: !Bool, -- ^ Module required TH splices when it was compiled. -- This disables recompilation avoidance (see #481). - mi_fixities :: [(OccName,Fixity)], + mi_fixities_ :: [(OccName,Fixity)], -- ^ Fixities -- NOT STRICT! we read this field lazily from the interface file - mi_warns :: IfaceWarnings, + mi_warns_ :: IfaceWarnings, -- ^ Warnings -- NOT STRICT! we read this field lazily from the interface file - mi_anns :: [IfaceAnnotation], + mi_anns_ :: [IfaceAnnotation], -- ^ Annotations -- NOT STRICT! we read this field lazily from the interface file - mi_decls :: [IfaceDeclExts phase], + mi_decls_ :: [IfaceDeclExts phase], -- ^ Type, class and variable declarations -- The hash of an Id changes if its fixity or deprecations change -- (as well as its type of course) -- Ditto data constructors, class operations, except that -- the hash of the parent class/tycon changes - mi_extra_decls :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo], + mi_extra_decls_ :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo], -- ^ Extra variable definitions which are **NOT** exposed but when -- combined with mi_decls allows us to restart code generation. -- See Note [Interface Files with Core Definitions] and Note [Interface File with Core: Sharing RHSs] - mi_globals :: !(Maybe IfGlobalRdrEnv), + mi_globals_ :: !(Maybe IfGlobalRdrEnv), -- ^ Binds all the things defined at the top level in -- the /original source/ code for this module. which -- is NOT the same as mi_exports, nor mi_decls (which @@ -279,36 +281,36 @@ data ModIface_ (phase :: ModIfacePhase) -- 'HomeModInfo', but that leads to more plumbing. -- Instance declarations and rules - mi_insts :: [IfaceClsInst], -- ^ Sorted class instance - mi_fam_insts :: [IfaceFamInst], -- ^ Sorted family instances - mi_rules :: [IfaceRule], -- ^ Sorted rules + mi_insts_ :: [IfaceClsInst], -- ^ Sorted class instance + mi_fam_insts_ :: [IfaceFamInst], -- ^ Sorted family instances + mi_rules_ :: [IfaceRule], -- ^ Sorted rules - mi_hpc :: !AnyHpcUsage, + mi_hpc_ :: !AnyHpcUsage, -- ^ True if this program uses Hpc at any point in the program. - mi_trust :: !IfaceTrustInfo, + mi_trust_ :: !IfaceTrustInfo, -- ^ Safe Haskell Trust information for this module. - mi_trust_pkg :: !Bool, + mi_trust_pkg_ :: !Bool, -- ^ Do we require the package this module resides in be trusted -- to trust this module? This is used for the situation where a -- module is Safe (so doesn't require the package be trusted -- itself) but imports some trustworthy modules from its own -- package (which does require its own package be trusted). -- See Note [Trust Own Package] in GHC.Rename.Names - mi_complete_matches :: ![IfaceCompleteMatch], + mi_complete_matches_ :: ![IfaceCompleteMatch], - mi_docs :: !(Maybe Docs), + mi_docs_ :: !(Maybe Docs), -- ^ Docstrings and related data for use by haddock, the ghci -- @:doc@ command, and other tools. -- -- @Just _@ @<=>@ the module was built with @-haddock at . - mi_final_exts :: !(IfaceBackendExts phase), + mi_final_exts_ :: !(IfaceBackendExts phase), -- ^ Either `()` or `ModIfaceBackend` for -- a fully instantiated interface. - mi_ext_fields :: !ExtensibleFields, + mi_ext_fields_ :: !ExtensibleFields, -- ^ Additional optional fields, where the Map key represents -- the field name, resulting in a (size, serialized data) pair. -- Because the data is intended to be serialized through the @@ -317,9 +319,9 @@ data ModIface_ (phase :: ModIfacePhase) -- chosen over `ByteString`s. -- - mi_src_hash :: !Fingerprint, + mi_src_hash_ :: !Fingerprint, -- ^ Hash of the .hs source, used for recompilation checking. - mi_hi_bytes :: !(IfaceBinHandle phase) + mi_hi_bytes_ :: !(IfaceBinHandle phase) } {- @@ -399,34 +401,34 @@ renameFreeHoles fhs insts = -- See Note [Strictness in ModIface] about where we use lazyPut vs put instance Binary ModIface where put_ bh (ModIface { - mi_module = mod, - mi_sig_of = sig_of, - mi_hsc_src = hsc_src, - mi_src_hash = _src_hash, -- Don't `put_` this in the instance + mi_module_ = mod, + mi_sig_of_ = sig_of, + mi_hsc_src_ = hsc_src, + mi_src_hash_ = _src_hash, -- Don't `put_` this in the instance -- because we are going to write it -- out separately in the actual file - mi_hi_bytes = _hi_bytes, -- TODO: explain - mi_deps = deps, - mi_usages = usages, - mi_exports = exports, - mi_used_th = used_th, - mi_fixities = fixities, - mi_warns = warns, - mi_anns = anns, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_insts = insts, - mi_fam_insts = fam_insts, - mi_rules = rules, - mi_hpc = hpc_info, - mi_trust = trust, - mi_trust_pkg = trust_pkg, - mi_complete_matches = complete_matches, - mi_docs = docs, - mi_ext_fields = _ext_fields, -- Don't `put_` this in the instance so we + mi_hi_bytes_ = _hi_bytes, -- TODO: explain + mi_deps_ = deps, + mi_usages_ = usages, + mi_exports_ = exports, + mi_used_th_ = used_th, + mi_fixities_ = fixities, + mi_warns_ = warns, + mi_anns_ = anns, + mi_decls_ = decls, + mi_extra_decls_ = extra_decls, + mi_insts_ = insts, + mi_fam_insts_ = fam_insts, + mi_rules_ = rules, + mi_hpc_ = hpc_info, + mi_trust_ = trust, + mi_trust_pkg_ = trust_pkg, + mi_complete_matches_ = complete_matches, + mi_docs_ = docs, + mi_ext_fields_ = _ext_fields, -- Don't `put_` this in the instance so we -- can deal with it's pointer in the header -- when we write the actual file - mi_final_exts = ModIfaceBackend { + mi_final_exts_ = ModIfaceBackend { mi_iface_hash = iface_hash, mi_mod_hash = mod_hash, mi_flag_hash = flag_hash, @@ -501,34 +503,34 @@ instance Binary ModIface where complete_matches <- get bh docs <- lazyGetMaybe bh return (ModIface { - mi_module = mod, - mi_sig_of = sig_of, - mi_hsc_src = hsc_src, - mi_src_hash = fingerprint0, -- placeholder because this is dealt + mi_module_ = mod, + mi_sig_of_ = sig_of, + mi_hsc_src_ = hsc_src, + mi_src_hash_ = fingerprint0, -- placeholder because this is dealt -- with specially when the file is read - mi_hi_bytes = FullIfaceBinHandle Strict.Nothing, - mi_deps = deps, - mi_usages = usages, - mi_exports = exports, - mi_used_th = used_th, - mi_anns = anns, - mi_fixities = fixities, - mi_warns = warns, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_globals = Nothing, - mi_insts = insts, - mi_fam_insts = fam_insts, - mi_rules = rules, - mi_hpc = hpc_info, - mi_trust = trust, - mi_trust_pkg = trust_pkg, + mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing, + mi_deps_ = deps, + mi_usages_ = usages, + mi_exports_ = exports, + mi_used_th_ = used_th, + mi_anns_ = anns, + mi_fixities_ = fixities, + mi_warns_ = warns, + mi_decls_ = decls, + mi_extra_decls_ = extra_decls, + mi_globals_ = Nothing, + mi_insts_ = insts, + mi_fam_insts_ = fam_insts, + mi_rules_ = rules, + mi_hpc_ = hpc_info, + mi_trust_ = trust, + mi_trust_pkg_ = trust_pkg, -- And build the cached values - mi_complete_matches = complete_matches, - mi_docs = docs, - mi_ext_fields = emptyExtensibleFields, -- placeholder because this is dealt + mi_complete_matches_ = complete_matches, + mi_docs_ = docs, + mi_ext_fields_ = emptyExtensibleFields, -- placeholder because this is dealt -- with specially when the file is read - mi_final_exts = ModIfaceBackend { + mi_final_exts_ = ModIfaceBackend { mi_iface_hash = iface_hash, mi_mod_hash = mod_hash, mi_flag_hash = flag_hash, @@ -551,39 +553,39 @@ type IfaceExport = AvailInfo emptyPartialModIface :: Module -> PartialModIface emptyPartialModIface mod - = ModIface { mi_module = mod, - mi_sig_of = Nothing, - mi_hsc_src = HsSrcFile, - mi_src_hash = fingerprint0, - mi_hi_bytes = PartialIfaceBinHandle, - mi_deps = noDependencies, - mi_usages = [], - mi_exports = [], - mi_used_th = False, - mi_fixities = [], - mi_warns = IfWarnSome [] [], - mi_anns = [], - mi_insts = [], - mi_fam_insts = [], - mi_rules = [], - mi_decls = [], - mi_extra_decls = Nothing, - mi_globals = Nothing, - mi_hpc = False, - mi_trust = noIfaceTrustInfo, - mi_trust_pkg = False, - mi_complete_matches = [], - mi_docs = Nothing, - mi_final_exts = (), - mi_ext_fields = emptyExtensibleFields + = ModIface { mi_module_ = mod, + mi_sig_of_ = Nothing, + mi_hsc_src_ = HsSrcFile, + mi_src_hash_ = fingerprint0, + mi_hi_bytes_ = PartialIfaceBinHandle, + mi_deps_ = noDependencies, + mi_usages_ = [], + mi_exports_ = [], + mi_used_th_ = False, + mi_fixities_ = [], + mi_warns_ = IfWarnSome [] [], + mi_anns_ = [], + mi_insts_ = [], + mi_fam_insts_ = [], + mi_rules_ = [], + mi_decls_ = [], + mi_extra_decls_ = Nothing, + mi_globals_ = Nothing, + mi_hpc_ = False, + mi_trust_ = noIfaceTrustInfo, + mi_trust_pkg_ = False, + mi_complete_matches_ = [], + mi_docs_ = Nothing, + mi_final_exts_ = (), + mi_ext_fields_ = emptyExtensibleFields } emptyFullModIface :: Module -> ModIface emptyFullModIface mod = (emptyPartialModIface mod) - { mi_decls = [] - , mi_hi_bytes = FullIfaceBinHandle Strict.Nothing - , mi_final_exts = ModIfaceBackend + { mi_decls_ = [] + , mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing + , mi_final_exts_ = ModIfaceBackend { mi_iface_hash = fingerprint0, mi_mod_hash = fingerprint0, mi_flag_hash = fingerprint0, @@ -618,36 +620,36 @@ emptyIfaceHashCache _occ = Nothing instance ( NFData (IfaceBackendExts (phase :: ModIfacePhase)) , NFData (IfaceDeclExts (phase :: ModIfacePhase)) ) => NFData (ModIface_ phase) where - rnf (ModIface{ mi_module, mi_sig_of, mi_hsc_src, mi_deps, mi_usages - , mi_exports, mi_used_th, mi_fixities, mi_warns, mi_anns - , mi_decls, mi_extra_decls, mi_globals, mi_insts - , mi_fam_insts, mi_rules, mi_hpc, mi_trust, mi_trust_pkg - , mi_complete_matches, mi_docs, mi_final_exts - , mi_ext_fields, mi_src_hash }) - = rnf mi_module - `seq` rnf mi_sig_of - `seq` mi_hsc_src - `seq` mi_deps - `seq` mi_usages - `seq` mi_exports - `seq` rnf mi_used_th - `seq` mi_fixities - `seq` rnf mi_warns - `seq` rnf mi_anns - `seq` rnf mi_decls - `seq` rnf mi_extra_decls - `seq` rnf mi_globals - `seq` rnf mi_insts - `seq` rnf mi_fam_insts - `seq` rnf mi_rules - `seq` rnf mi_hpc - `seq` mi_trust - `seq` rnf mi_trust_pkg - `seq` rnf mi_complete_matches - `seq` rnf mi_docs - `seq` mi_final_exts - `seq` mi_ext_fields - `seq` rnf mi_src_hash + rnf (ModIface{ mi_module_, mi_sig_of_, mi_hsc_src_, mi_deps_, mi_usages_ + , mi_exports_, mi_used_th_, mi_fixities_, mi_warns_, mi_anns_ + , mi_decls_, mi_extra_decls_, mi_globals_, mi_insts_ + , mi_fam_insts_, mi_rules_, mi_hpc_, mi_trust_, mi_trust_pkg_ + , mi_complete_matches_, mi_docs_, mi_final_exts_ + , mi_ext_fields_, mi_src_hash_ }) + = rnf mi_module_ + `seq` rnf mi_sig_of_ + `seq` mi_hsc_src_ + `seq` mi_deps_ + `seq` mi_usages_ + `seq` mi_exports_ + `seq` rnf mi_used_th_ + `seq` mi_fixities_ + `seq` rnf mi_warns_ + `seq` rnf mi_anns_ + `seq` rnf mi_decls_ + `seq` rnf mi_extra_decls_ + `seq` rnf mi_globals_ + `seq` rnf mi_insts_ + `seq` rnf mi_fam_insts_ + `seq` rnf mi_rules_ + `seq` rnf mi_hpc_ + `seq` mi_trust_ + `seq` rnf mi_trust_pkg_ + `seq` rnf mi_complete_matches_ + `seq` rnf mi_docs_ + `seq` mi_final_exts_ + `seq` mi_ext_fields_ + `seq` rnf mi_src_hash_ `seq` () instance NFData (ModIfaceBackend) where @@ -694,90 +696,151 @@ completePartialModIface :: PartialModIface -> IfaceBinHandle 'ModIfaceFinal -> ModIface completePartialModIface partial decls extra_decls final_exts hi_bytes = partial - { mi_decls = decls - , mi_extra_decls = extra_decls - , mi_final_exts = final_exts - , mi_hi_bytes = hi_bytes + { mi_decls_ = decls + , mi_extra_decls_ = extra_decls + , mi_final_exts_ = final_exts + , mi_hi_bytes_ = hi_bytes + } + +addSourceFingerprint :: Fingerprint -> ModIface_ 'ModIfaceFinal -> ModIface_ 'ModIfaceFinal +addSourceFingerprint val iface = iface { mi_src_hash_ = val } + +restoreFromOldModIface :: ModIface_ phase -> ModIface_ phase -> ModIface_ phase +restoreFromOldModIface old new = new + { mi_globals_ = mi_globals_ old + , mi_hsc_src_ = mi_hsc_src_ old + , mi_src_hash_ = mi_src_hash_ old } set_mi_module :: Module -> ModIface_ phase -> ModIface_ phase -set_mi_module val iface = clear_mi_hi_bytes $ iface { mi_module = val } +set_mi_module val iface = clear_mi_hi_bytes $ iface { mi_module_ = val } set_mi_sig_of :: Maybe Module -> ModIface_ phase -> ModIface_ phase -set_mi_sig_of val iface = clear_mi_hi_bytes $ iface { mi_sig_of = val } +set_mi_sig_of val iface = clear_mi_hi_bytes $ iface { mi_sig_of_ = val } set_mi_hsc_src :: HscSource -> ModIface_ phase -> ModIface_ phase -set_mi_hsc_src val iface = clear_mi_hi_bytes $ iface { mi_hsc_src = val } +set_mi_hsc_src val iface = clear_mi_hi_bytes $ iface { mi_hsc_src_ = val } set_mi_src_hash :: Fingerprint -> ModIface_ phase -> ModIface_ phase -set_mi_src_hash val iface = clear_mi_hi_bytes $ iface { mi_src_hash = val } +set_mi_src_hash val iface = clear_mi_hi_bytes $ iface { mi_src_hash_ = val } set_mi_hi_bytes :: IfaceBinHandle phase -> ModIface_ phase -> ModIface_ phase -set_mi_hi_bytes val iface = iface { mi_hi_bytes = val } +set_mi_hi_bytes val iface = iface { mi_hi_bytes_ = val } set_mi_deps :: Dependencies -> ModIface_ phase -> ModIface_ phase -set_mi_deps val iface = clear_mi_hi_bytes $ iface { mi_deps = val } +set_mi_deps val iface = clear_mi_hi_bytes $ iface { mi_deps_ = val } set_mi_usages :: [Usage] -> ModIface_ phase -> ModIface_ phase -set_mi_usages val iface = clear_mi_hi_bytes $ iface { mi_usages = val } +set_mi_usages val iface = clear_mi_hi_bytes $ iface { mi_usages_ = val } set_mi_exports :: [IfaceExport] -> ModIface_ phase -> ModIface_ phase -set_mi_exports val iface = clear_mi_hi_bytes $ iface { mi_exports = val } +set_mi_exports val iface = clear_mi_hi_bytes $ iface { mi_exports_ = val } set_mi_used_th :: Bool -> ModIface_ phase -> ModIface_ phase -set_mi_used_th val iface = clear_mi_hi_bytes $ iface { mi_used_th = val } +set_mi_used_th val iface = clear_mi_hi_bytes $ iface { mi_used_th_ = val } set_mi_fixities :: [(OccName, Fixity)] -> ModIface_ phase -> ModIface_ phase -set_mi_fixities val iface = clear_mi_hi_bytes $ iface { mi_fixities = val } +set_mi_fixities val iface = clear_mi_hi_bytes $ iface { mi_fixities_ = val } set_mi_warns :: IfaceWarnings -> ModIface_ phase -> ModIface_ phase -set_mi_warns val iface = clear_mi_hi_bytes $ iface { mi_warns = val } +set_mi_warns val iface = clear_mi_hi_bytes $ iface { mi_warns_ = val } set_mi_anns :: [IfaceAnnotation] -> ModIface_ phase -> ModIface_ phase -set_mi_anns val iface = clear_mi_hi_bytes $ iface { mi_anns = val } +set_mi_anns val iface = clear_mi_hi_bytes $ iface { mi_anns_ = val } set_mi_insts :: [IfaceClsInst] -> ModIface_ phase -> ModIface_ phase -set_mi_insts val iface = clear_mi_hi_bytes $ iface { mi_insts = val } +set_mi_insts val iface = clear_mi_hi_bytes $ iface { mi_insts_ = val } set_mi_fam_insts :: [IfaceFamInst] -> ModIface_ phase -> ModIface_ phase -set_mi_fam_insts val iface = clear_mi_hi_bytes $ iface { mi_fam_insts = val } +set_mi_fam_insts val iface = clear_mi_hi_bytes $ iface { mi_fam_insts_ = val } set_mi_rules :: [IfaceRule] -> ModIface_ phase -> ModIface_ phase -set_mi_rules val iface = clear_mi_hi_bytes $ iface { mi_rules = val } +set_mi_rules val iface = clear_mi_hi_bytes $ iface { mi_rules_ = val } set_mi_decls :: [IfaceDeclExts phase] -> ModIface_ phase -> ModIface_ phase -set_mi_decls val iface = clear_mi_hi_bytes $ iface { mi_decls = val } +set_mi_decls val iface = clear_mi_hi_bytes $ iface { mi_decls_ = val } set_mi_extra_decls :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] -> ModIface_ phase -> ModIface_ phase -set_mi_extra_decls val iface = clear_mi_hi_bytes $ iface { mi_extra_decls = val } +set_mi_extra_decls val iface = clear_mi_hi_bytes $ iface { mi_extra_decls_ = val } set_mi_globals :: Maybe IfGlobalRdrEnv -> ModIface_ phase -> ModIface_ phase -set_mi_globals val iface = clear_mi_hi_bytes $ iface { mi_globals = val } +set_mi_globals val iface = clear_mi_hi_bytes $ iface { mi_globals_ = val } set_mi_hpc :: AnyHpcUsage -> ModIface_ phase -> ModIface_ phase -set_mi_hpc val iface = clear_mi_hi_bytes $ iface { mi_hpc = val } +set_mi_hpc val iface = clear_mi_hi_bytes $ iface { mi_hpc_ = val } set_mi_trust :: IfaceTrustInfo -> ModIface_ phase -> ModIface_ phase -set_mi_trust val iface = clear_mi_hi_bytes $ iface { mi_trust = val } +set_mi_trust val iface = clear_mi_hi_bytes $ iface { mi_trust_ = val } set_mi_trust_pkg :: Bool -> ModIface_ phase -> ModIface_ phase -set_mi_trust_pkg val iface = clear_mi_hi_bytes $ iface { mi_trust_pkg = val } +set_mi_trust_pkg val iface = clear_mi_hi_bytes $ iface { mi_trust_pkg_ = val } set_mi_complete_matches :: [IfaceCompleteMatch] -> ModIface_ phase -> ModIface_ phase -set_mi_complete_matches val iface = clear_mi_hi_bytes $ iface { mi_complete_matches = val } +set_mi_complete_matches val iface = clear_mi_hi_bytes $ iface { mi_complete_matches_ = val } set_mi_docs :: Maybe Docs -> ModIface_ phase -> ModIface_ phase -set_mi_docs val iface = clear_mi_hi_bytes $ iface { mi_docs = val } +set_mi_docs val iface = clear_mi_hi_bytes $ iface { mi_docs_ = val } set_mi_final_exts :: IfaceBackendExts phase -> ModIface_ phase -> ModIface_ phase -set_mi_final_exts val iface = clear_mi_hi_bytes $ iface { mi_final_exts = val } +set_mi_final_exts val iface = clear_mi_hi_bytes $ iface { mi_final_exts_ = val } set_mi_ext_fields :: ExtensibleFields -> ModIface_ phase -> ModIface_ phase -set_mi_ext_fields val iface = clear_mi_hi_bytes $ iface { mi_ext_fields = val } +set_mi_ext_fields val iface = clear_mi_hi_bytes $ iface { mi_ext_fields_ = val } clear_mi_hi_bytes :: ModIface_ phase -> ModIface_ phase clear_mi_hi_bytes iface = iface - { mi_hi_bytes = case mi_hi_bytes iface of + { mi_hi_bytes_ = case mi_hi_bytes iface of PartialIfaceBinHandle -> PartialIfaceBinHandle FullIfaceBinHandle _ -> FullIfaceBinHandle Strict.Nothing } + +mi_module :: ModIface_ phase -> Module +mi_module = mi_module_ +mi_sig_of :: ModIface_ phase -> Maybe Module +mi_sig_of = mi_sig_of_ +mi_hsc_src :: ModIface_ phase -> HscSource +mi_hsc_src = mi_hsc_src_ +mi_deps :: ModIface_ phase -> Dependencies +mi_deps = mi_deps_ +mi_usages :: ModIface_ phase -> [Usage] +mi_usages = mi_usages_ +mi_exports :: ModIface_ phase -> [IfaceExport] +mi_exports = mi_exports_ +mi_used_th :: ModIface_ phase -> Bool +mi_used_th = mi_used_th_ +mi_fixities :: ModIface_ phase -> [(OccName, Fixity)] +mi_fixities = mi_fixities_ +mi_warns :: ModIface_ phase -> IfaceWarnings +mi_warns = mi_warns_ +mi_anns :: ModIface_ phase -> [IfaceAnnotation] +mi_anns = mi_anns_ +mi_decls :: ModIface_ phase -> [IfaceDeclExts phase] +mi_decls = mi_decls_ +mi_extra_decls :: ModIface_ phase -> Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] +mi_extra_decls = mi_extra_decls_ +mi_globals :: ModIface_ phase -> Maybe IfGlobalRdrEnv +mi_globals = mi_globals_ +mi_insts :: ModIface_ phase -> [IfaceClsInst] +mi_insts = mi_insts_ +mi_fam_insts :: ModIface_ phase -> [IfaceFamInst] +mi_fam_insts = mi_fam_insts_ +mi_rules :: ModIface_ phase -> [IfaceRule] +mi_rules = mi_rules_ +mi_hpc :: ModIface_ phase -> AnyHpcUsage +mi_hpc = mi_hpc_ +mi_trust :: ModIface_ phase -> IfaceTrustInfo +mi_trust = mi_trust_ +mi_trust_pkg :: ModIface_ phase -> Bool +mi_trust_pkg = mi_trust_pkg_ +mi_complete_matches :: ModIface_ phase -> [IfaceCompleteMatch] +mi_complete_matches = mi_complete_matches_ +mi_docs :: ModIface_ phase -> Maybe Docs +mi_docs = mi_docs_ +mi_final_exts :: ModIface_ phase -> IfaceBackendExts phase +mi_final_exts = mi_final_exts_ +mi_ext_fields :: ModIface_ phase -> ExtensibleFields +mi_ext_fields = mi_ext_fields_ +mi_src_hash :: ModIface_ phase -> Fingerprint +mi_src_hash = mi_src_hash_ +mi_hi_bytes :: ModIface_ phase -> IfaceBinHandle phase +mi_hi_bytes = mi_hi_bytes_ ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit fa76e1ee98906f5bc8fc4598524610020b653412 +Subproject commit eaa6e1870997f09b9023cba09d6b5431cf5b0174 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4bcd2b69c92d8ea2cb465a0d3188a669abdfefde -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4bcd2b69c92d8ea2cb465a0d3188a669abdfefde You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 09:43:47 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Fri, 03 May 2024 05:43:47 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/hugepages-9.8 Message-ID: <6634b1d351964_10d81b20a5a941028c1@gitlab.mail> Teo Camarasu pushed new branch wip/hugepages-9.8 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/hugepages-9.8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 09:45:26 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Fri, 03 May 2024 05:45:26 -0400 Subject: [Git][ghc/ghc][wip/hugepages] Implement support for 2MB hugepages Message-ID: <6634b236b8e41_10d81b20dde1c103066@gitlab.mail> Teo Camarasu pushed to branch wip/hugepages at Glasgow Haskell Compiler / GHC Commits: 0feb436c by Teo Camarasu at 2024-05-03T10:45:13+01:00 Implement support for 2MB hugepages We enable/disable it through a runtime flag (-xH). When enabled we ensure we only (de)allocate in aligned multiples of 2MB. - - - - - 4 changed files: - rts/include/rts/Constants.h - rts/posix/OSMem.c - rts/sm/BlockAlloc.c - rts/sm/OSMem.h Changes: ===================================== rts/include/rts/Constants.h ===================================== @@ -170,7 +170,7 @@ #define BLOCK_SHIFT 12 /* The size of a megablock (2^MBLOCK_SHIFT bytes) */ -#define MBLOCK_SHIFT 21 +#define MBLOCK_SHIFT 20 /* ----------------------------------------------------------------------------- Bitmap/size fields (used in info tables) ===================================== rts/posix/OSMem.c ===================================== @@ -60,12 +60,6 @@ # endif #endif -#if defined(HAVE_LINUX_MMAN_H) -#include - -#define HUGEPAGE_SIZE (2*1024*1024) -#define HUGEPAGE_FLAGS (MAP_HUGETLB | MAP_HUGE_2MB) -#endif #if !defined(darwin_HOST_OS) # undef RESERVE_FLAGS @@ -244,19 +238,19 @@ my_mmap (void *addr, W_ size, int operation) # endif } else if (operation == MEM_COMMIT) { flags = MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE; -#if defined(HUGEPAGE_SIZE) +#if defined(HUGEPAGE_FLAGS) if ( RtsFlags.GcFlags.hugepages && (size & (HUGEPAGE_SIZE - 1)) == 0) { huge_tried += 1; flags |= HUGEPAGE_FLAGS; } -#endif /* defined(HUGEPAGE_SIZE) */ +#endif /* defined(HUGEPAGE_FLAGS) */ } else { flags = MAP_ANON | MAP_PRIVATE; } ret = mmap(addr, size, prot, flags, -1, 0); -#if defined(HUGEPAGE_SIZE) +#if defined(HUGEPAGE_FLAGS) // If the mmap failed, and we tried with HUGEPAGE_FLAGS // then retry without. if (ret == MAP_FAILED && flags & HUGEPAGE_FLAGS){ @@ -698,6 +692,10 @@ void osDecommitMemory(void *at, W_ size) if(r < 0) sysErrorBelch("unable to make released memory unaccessible"); #endif + if(RtsFlags.GcFlags.hugepages) { + ASSERT( ((HUGEPAGE_SIZE - 1) & (uintptr_t)at) == 0); + ASSERT( ((HUGEPAGE_SIZE - 1) & size) == 0); + } #if defined(MADV_FREE) // See Note [MADV_FREE and MADV_DONTNEED]. ===================================== rts/sm/BlockAlloc.c ===================================== @@ -25,7 +25,8 @@ #include -static void initMBlock(void *mblock, uint32_t node); +static void initMBlock(void *mblock, uint32_t node); +static void free_mega_group (bdescr *mg); /* * By default the DEBUG RTS is built with block allocator assertions @@ -478,13 +479,30 @@ alloc_mega_group (uint32_t node, StgWord mblocks) else { void *mblock; + StgWord hugepage_mblocks; + if(RtsFlags.GcFlags.hugepages) { + // Round up allocation to hugepage size + hugepage_mblocks = MBLOCK_ROUND_UP_HUGEPAGE(mblocks); + } + else { + hugepage_mblocks = mblocks; + } + if (RtsFlags.GcFlags.numa) { - mblock = getMBlocksOnNode(node, mblocks); + mblock = getMBlocksOnNode(node, hugepage_mblocks); } else { - mblock = getMBlocks(mblocks); + mblock = getMBlocks(hugepage_mblocks); } initMBlock(mblock, node); // only need to init the 1st one bd = FIRST_BDESCR(mblock); + + // Free the slop + if(hugepage_mblocks > mblocks) { + bdescr *mblock_slop_bd = FIRST_BDESCR((uintptr_t)mblock + (uintptr_t)mblocks*MBLOCK_SIZE); + initMBlock(MBLOCK_ROUND_DOWN(mblock_slop_bd), node); + mblock_slop_bd->blocks = MBLOCK_GROUP_BLOCKS(hugepage_mblocks-mblocks); + free_mega_group(mblock_slop_bd); + } } bd->blocks = MBLOCK_GROUP_BLOCKS(mblocks); return bd; @@ -812,7 +830,7 @@ coalesce_mblocks (bdescr *p) return q; } -static void +void free_mega_group (bdescr *mg) { bdescr *bd, *prev; @@ -1199,10 +1217,15 @@ uint32_t returnMemoryToOS(uint32_t n /* megablocks */) return 0; #else bdescr *bd; + bdescr *rejects; + bdescr *next; uint32_t node; - StgWord size; + StgWord size, unaligned_size, freeable_size; uint32_t init_n; init_n = n; + if(RtsFlags.GcFlags.hugepages) { + n = MBLOCK_ROUND_DOWN_HUGEPAGE(n); + } // TODO: This is inefficient because this loop will essentially result in // quadratic runtime behavior: for each call to `freeMBlocks`, the @@ -1215,22 +1238,66 @@ uint32_t returnMemoryToOS(uint32_t n /* megablocks */) // ToDo: not fair, we free all the memory starting with node 0. for (node = 0; n > 0 && node < n_numa_nodes; node++) { bd = free_mblock_list[node]; + rejects = NULL; while ((n > 0) && (bd != NULL)) { size = BLOCKS_TO_MBLOCKS(bd->blocks); - if (size > n) { - StgWord newSize = size - n; - char *freeAddr = MBLOCK_ROUND_DOWN(bd->start); - freeAddr += newSize * MBLOCK_SIZE; - bd->blocks = MBLOCK_GROUP_BLOCKS(newSize); - freeMBlocks(freeAddr, n); - n = 0; - } + next = bd->link; + char *aligned_start; + + if(RtsFlags.GcFlags.hugepages) { + aligned_start = (char*)MBLOCK_ROUND_DOWN(bd) + ((uintptr_t)MBLOCK_ROUND_DOWN(bd) & HUGEPAGE_MASK); + unaligned_size = (aligned_start - (char*)MBLOCK_ROUND_DOWN(bd)) / MBLOCK_SIZE; + freeable_size = MBLOCK_ROUND_DOWN_HUGEPAGE(size - unaligned_size); + } else { - char *freeAddr = MBLOCK_ROUND_DOWN(bd->start); - n -= size; - bd = bd->link; - freeMBlocks(freeAddr, size); + aligned_start = (char*)MBLOCK_ROUND_DOWN(bd); + unaligned_size = 0; + freeable_size = size; } + + // We cannot free more than n + freeable_size = stg_min(n, freeable_size); + + // Place the front unaligned section back on the list. + // If we can't free any of it then this is the entire thing. + if (unaligned_size > 0 || freeable_size == 0) { + bd->link = rejects; + rejects = bd; + // If we are freeing some mblocks from the middle then initialise + // the first MBlock and update the sizes. + if (freeable_size > 0) { + bd->blocks = MBLOCK_GROUP_BLOCKS(unaligned_size); + bdescr *aligned_bd; + aligned_bd = FIRST_BDESCR(aligned_start); + aligned_bd->blocks = MBLOCK_GROUP_BLOCKS(freeable_size); + initMBlock(aligned_bd, node); + } + } + + if(freeable_size > 0) { + n -= freeable_size; + freeMBlocks(aligned_start, freeable_size); + // add the slop to the rejects list + if (size - unaligned_size - freeable_size > 0) + { + void *slop = aligned_start + freeable_size * MBLOCK_SIZE; + bdescr* slop_bd = FIRST_BDESCR(slop); + initMBlock(slop_bd, node); + slop_bd->blocks = MBLOCK_GROUP_BLOCKS(size - unaligned_size - freeable_size); + slop_bd->link = rejects; + rejects = slop_bd; + } + } + bd = next; + } + // Place the rejected mblocks back on the free list. + while(rejects) { + // pop the top of the rejects list. + next = rejects; + rejects = next->link; + // place it back on the free list. + next->link = bd; + bd = next; } free_mblock_list[node] = bd; } ===================================== rts/sm/OSMem.h ===================================== @@ -10,6 +10,20 @@ #include "BeginPrivate.h" +#if defined(HAVE_LINUX_MMAN_H) +#include + +#define HUGEPAGE_SHIFT 21 +#define HUGEPAGE_FLAGS (MAP_HUGETLB | MAP_HUGE_2MB) +#else +#define HUGEPAGE_SHIFT 20 +#endif + +#define HUGEPAGE_SIZE (1 << HUGEPAGE_SHIFT) +#define HUGEPAGE_MASK ((1 << HUGEPAGE_SHIFT) - 1) +#define MBLOCK_ROUND_DOWN_HUGEPAGE(x) ((x) & ~(HUGEPAGE_SHIFT - MBLOCK_SHIFT)) +#define MBLOCK_ROUND_UP_HUGEPAGE(x) ((x) + ((x) & (HUGEPAGE_SHIFT - MBLOCK_SHIFT))) + void osMemInit(void); void *osGetMBlocks(uint32_t n); void osFreeMBlocks(void *addr, uint32_t n); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0feb436c982dfa95acf0224accea55a0c617ef83 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0feb436c982dfa95acf0224accea55a0c617ef83 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 10:24:35 2024 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Fri, 03 May 2024 06:24:35 -0400 Subject: [Git][ghc/ghc][wip/T24548-2] 8 commits: testsuite: fix req_target_smp predicate Message-ID: <6634bb6310e84_10d81b28e69241227b0@gitlab.mail> Cheng Shao pushed to branch wip/T24548-2 at Glasgow Haskell Compiler / GHC Commits: a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 6f3bce15 by Ben Gamari at 2024-05-03T10:24:07+00:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 1dd1b4b3 by Ben Gamari at 2024-05-03T10:24:17+00:00 Bump terminfo submodule to current master - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Parser.y - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Eval/Types.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/StgToByteCode.hs - − compiler/GHC/Types/BreakInfo.hs - + compiler/GHC/Types/Breakpoint.hs - compiler/ghc.cabal.in - ghc/GHCi/UI.hs - ghc/ghc-bin.cabal.in - hadrian/src/Settings/Builders/RunTest.hs - libraries/Cabal - libraries/directory - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/Run.hs - libraries/hpc - libraries/terminfo - libraries/time - rts/Exception.cmm - rts/Interpreter.c - rts/STM.c - rts/STM.h - rts/Schedule.c - rts/include/stg/SMP.h - testsuite/config/ghc - testsuite/driver/testglobals.py - testsuite/driver/testlib.py The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/40152f70bbb992de96c38870c88db2c55ef9eb57...1dd1b4b3cabf494c8736d6117ec15669d2a2aaee -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/40152f70bbb992de96c38870c88db2c55ef9eb57...1dd1b4b3cabf494c8736d6117ec15669d2a2aaee You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 10:31:48 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 03 May 2024 06:31:48 -0400 Subject: [Git][ghc/ghc][wip/enable-late-ccs-release] 738 commits: Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) Message-ID: <6634bd14321f4_10d81b2a6818012351d@gitlab.mail> Matthew Pickering pushed to branch wip/enable-late-ccs-release at Glasgow Haskell Compiler / GHC Commits: fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Bignum: fix right shift of negative BigNat with native backend - - - - - cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - 72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - f9436990 by John Ericson at 2023-10-18T19:41:01-04:00 Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Fixes #24091 Progress on #23966 Issue #24091 reports that `@ProjectVersion@` is no longer being substituted in the GHC user's guide. I assume this is a recent issue, but I am not sure how it's worked since c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and configure are trying to substitute the same `.in` file! Now only Hadrian does. That is better anyways; already something that issue #23966 requested. It seems like we were missing some dependencies in Hadrian. (I really, really hate that this is possible!) Hopefully it is fixed now. - - - - - b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00 `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to be defined. (Guaranteed including a test in the testsuite.) - - - - - 0295375a by John Ericson at 2023-10-18T19:41:37-04:00 Generate `ghcversion.h` from a `.in` file Now that there are no conditional sections (see the previous commit), we can just a do simple substitution rather than pasting it together line by line. Progress on #23966 - - - - - 740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00 Add a regression test for #24064 - - - - - 921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00 CLC Proposal #182: Export List from Data.List Proposal link: https://github.com/haskell/core-libraries-committee/issues/182 - - - - - 4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00 rts: fix small argument passing on big-endian arch (fix #23387) - - - - - b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00 Interpreter: fix literal alignment on big-endian architectures (fix #19261) Literals weren't correctly aligned on big-endian, despite what the comment said. - - - - - a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00 Testsuite: recomp011 and recomp015 are fixed on powerpc These tests have been fixed but not tested and re-enabled on big-endian powerpc (see comments in #11260 and #11323) - - - - - fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00 CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102) - - - - - 02efc181 by John Ericson at 2023-10-22T02:48:55-04:00 Move function checks to RTS configure Some of these functions are used in `base` too, but we can copy the checks over to its configure if that's an issue. - - - - - 5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00 Move over a number of C-style checks to RTS configure - - - - - 5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00 Move/Copy more `AC_DEFINE` to RTS config Only exception is the LLVM version macros, which are used for GHC itself. - - - - - b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00 Define `TABLES_NEXT_TO_CODE` in the RTS configure We create a new cabal flag to facilitate this. - - - - - 4a40271e by John Ericson at 2023-10-22T02:48:55-04:00 Configure scripts: `checkOS`: Make a bit more robust `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This allows us to cope with configs/triples that we haven't normalized extra being what GNU `config.sub` does. - - - - - 16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00 Generate `ghcplatform.h` from RTS configure We create a new cabal flag to facilitate this. - - - - - 7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00 Get rid of all mention of `mk/config.h` The RTS configure script is now solely responsible for managing its headers; the top level configure script does not help. - - - - - c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00 rts: drop stale mentions of MIN_UPD_SIZE We used to have MIN_UPD_SIZE macro that describes the minimum reserved size for thunks, so that the thunk can be overwritten in place as indirections or blackholes. However, this macro has not been actually defined or used anywhere since a long time ago; StgThunkHeader already reserves a padding word for this purpose. Hence this patch which drops stale mentions of MIN_UPD_SIZE. - - - - - d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00 base changelog: move non-backported entries from 4.19 section to 4.20 Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational) nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip) were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section. Also minor stylistic changes to other entries, bringing them to a uniform form. - - - - - de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00 EPA Some tweaks to annotations - Fix span for GRHS - Move TrailingAnns from last match to FunBind - Fix GADT 'where' clause span - Capture full range for a CaseAlt Match - - - - - d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00 Update primitives.rst - - - - - 4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00 JS/userguide: add explanation of writing jsbits - - - - - 07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00 testsuite: increase timeout of ghc-api tests for wasm32 ghc-api tests for wasm32 are more likely to timeout due to the large wasm module sizes, especially when testing with wasm native tail calls, given wasmtime's handling of tail call opcodes are suboptimal at the moment. It makes sense to increase timeout specifically for these tests on wasm32. This doesn't affect other targets, and for wasm32 we don't increase timeout for all tests, so not to risk letting major performance regressions slip through the testsuite. - - - - - 0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00 Explicitly require RLIMIT_AS before use in OSMem.c This is done elsewhere in the source tree. It also suddenly is required on OpenBSD. - - - - - 9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00 Modularity: modularize external linker Decouple runLink from DynFlags to allow calling runLink more easily. This is preliminary work for calling Emscripten's linker (emcc) from our JavaScript linker. - - - - - e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00 js: add JStg IR, remove unsaturated constructor - Major step towards #22736 and adding the optimizer in #22261 - - - - - 35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00 Fix a bug in tail calls with ticks See #24078 for the diagnosis. The change affects only the Tick case of occurrence analysis. It's a bit hard to test, so no regression test (yet anyway). - - - - - 9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00 Teach tag-inference about SeqOp/seq# Fixes the STG/tag-inference analogue of #15226. Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00 [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra 48e391952c17ff7eab10b0b1456e3f2a2af28a9b introduced `SYM_TYPE_DUP_DISCARD` to the bitfield. The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value. Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions. - - - - - 5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00 Fix and test for issue #24111, TH.Ppr output of pattern synonyms - - - - - 723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00 EPA: print doc comments as normal comments And ignore the ones allocated in haddock processing. It does not guarantee that every original haddock-like comment appears in the output, as it discards ones that have no legal attachment point. closes #23459 - - - - - 21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00 Fix non-termination bug in equality solver constraint left-to-right then right to left, forever. Easily fixed. - - - - - 270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00 ghc-toolchain: build with `-package-env=-` (#24131) Otherwise globally installed libraries (via `cabal install --lib`) break the build. Fixes #24131. - - - - - 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - cc1c7c54 by Duncan Coutts at 2023-11-05T00:23:44-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 2e448f98 by Cheng Shao at 2023-11-05T00:23:44-04:00 Skip the IOManager test on wasm32 arch. The test relies on the sockets API which are not (yet) available. - - - - - fe50eb35 by Cheng Shao at 2023-11-05T00:24:20-04:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - af771148 by Cheng Shao at 2023-11-05T00:24:20-04:00 testsuite: fix optasm tests for wasm32 - - - - - 1b90735c by Matthew Pickering at 2023-11-05T00:24:20-04:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - db9a6496 by Alan Zimmerman at 2023-11-05T00:24:55-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 833e250c by Simon Peyton Jones at 2023-11-05T00:25:31-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - e451139f by Andreas Klebinger at 2023-11-05T00:26:07-04:00 Remove an accidental git conflict marker from a comment. - - - - - 30baac7a by Tobias Haslop at 2023-11-06T10:50:32+00:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - df626f00 by Tobias Haslop at 2023-11-07T02:20:37-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 8217acb8 by Alan Zimmerman at 2023-11-07T02:21:12-05:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - dd88a260 by Luite Stegeman at 2023-11-07T02:21:53-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - 455524a2 by Matthew Craven at 2023-11-09T08:41:59-05:00 Create specially-solved DataToTag class Closes #20532. This implements CLC proposal 104: https://github.com/haskell/core-libraries-committee/issues/104 The design is explained in Note [DataToTag overview] in GHC.Tc.Instance.Class. This replaces the existing `dataToTag#` primop. These metric changes are not "real"; they represent Unique-related flukes triggering on a different set of jobs than they did previously. See also #19414. Metric Decrease: T13386 T8095 Metric Increase: T13386 T8095 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - a05f4554 by Alan Zimmerman at 2023-11-09T08:42:35-05:00 EPA: get rid of glRR and friends in GHC/Parser.y With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead Metric Decrease: MultiLayerModulesTH_Make - - - - - 18498538 by Cheng Shao at 2023-11-09T16:58:12+00:00 ci: bump ci-images for wasi-sdk upgrade - - - - - 52c0fc69 by PHO at 2023-11-09T19:16:22-05:00 Don't assume the current locale is *.UTF-8, set the encoding explicitly primops.txt contains Unicode characters: > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226) Hadrian must also avoid using readFile' to read primops.txt because it tries to decode the file with a locale-specific encoding. - - - - - 7233b3b1 by PHO at 2023-11-09T19:17:01-05:00 Use '[' instead of '[[' because the latter is a Bash-ism It doesn't work on platforms where /bin/sh is something other than Bash. - - - - - 6dbab180 by Simon Peyton Jones at 2023-11-09T19:17:36-05:00 Add an extra check in kcCheckDeclHeader_sig Fix #24083 by checking for a implicitly-scoped type variable that is not actually bound. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures. Metric Decrease: MultiLayerModulesTH_Make - - - - - 22551364 by Sven Tennie at 2023-11-11T06:35:22-05:00 AArch64: Delete unused LDATA pseudo-instruction Though there were consuming functions for LDATA, there were no producers. Thus, the removed code was "dead". - - - - - 2a0ec8eb by Alan Zimmerman at 2023-11-11T06:35:59-05:00 EPA: harmonise acsa and acsA in GHC/Parser.y With the HasLoc class, we can remove the acsa helper function, using acsA instead. - - - - - 7ae517a0 by Teo Camarasu at 2023-11-12T08:04:12-05:00 nofib: bump submodule This includes changes that: - fix building a benchmark with HEAD - remove a Makefile-ism that causes errors in bash scripts Resolves #24178 - - - - - 3f0036ec by Alan Zimmerman at 2023-11-12T08:04:47-05:00 EPA: Replace Anchor with EpaLocation An Anchor has a location and an operation, which is either that it is unchanged or that it has moved with a DeltaPos data Anchor = Anchor { anchor :: RealSrcSpan , anchor_op :: AnchorOperation } An EpaLocation also has either a location or a DeltaPos data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] Now that we do not care about always having a location in the anchor, we remove Anchor and replace it with EpaLocation We do this with a type alias initially, to ease the transition. The alias will be removed in time. We also have helpers to reconstruct the AnchorOperation from an EpaLocation. This is also temporary. Updates Haddock submodule - - - - - a7492048 by Alan Zimmerman at 2023-11-12T13:43:07+00:00 EPA: get rid of AnchorOperation Now that the Anchor type is an alias for EpaLocation, remove AnchorOperation. Updates haddock submodule - - - - - 0745c34d by Andrew Lelechenko at 2023-11-13T16:25:07-05:00 Add since annotation for showHFloat - - - - - e98051a5 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 Suppress duplicate librares linker warning of new macOS linker Fixes #24167 XCode 15 introduced a new linker which warns on duplicate libraries being linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as suggested by Brad King in CMake issue #25297. This flag isn't necessarily available to other linkers on darwin, so we must only configure it into the CC linker arguments if valid. - - - - - c411c431 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Encoding test witnesses recent iconv bug is fragile A regression in the new iconv() distributed with XCode 15 and MacOS Sonoma causes the test 'encoding004' to fail in the CP936 roundrip. We mark this test as fragile until this is fixed upstream (rather than broken, since previous versions of iconv pass the test) See #24161 - - - - - ce7fe5a9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Update to LC_ALL=C no longer being ignored in darwin MacOS seems to have fixed an issue where it used to ignore the variable `LC_ALL` in program invocations and default to using Unicode. Since the behaviour seems to be fixed to account for the locale variable, we mark tests that were previously broken in spite of it as fragile (since they now pass in recent macOS distributions) See #24161 - - - - - e6c803f7 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 929ba2f9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Skip MultiLayerModulesTH_Make on darwin The recent toolchain upgrade on darwin machines resulted in the MultiLayerModulesTH_Make test metrics varying too much from the baseline, ultimately blocking the CI pipelines. This commit skips the test on darwin to temporarily avoid failures due to the environment change in the runners. However, the metrics divergence is being investigated still (tracked in #24177) - - - - - af261ccd by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 configure: check target (not build) understands -no_compact_unwind Previously, we were branching on whether the build system was darwin to shortcut this check, but we really want to branch on whether the target system (which is what we are configuring ld_prog for) is darwin. - - - - - 2125c176 by Luite Stegeman at 2023-11-15T13:19:38-05:00 JS: Fix missing variable declarations The JStg IR update was missing some local variable declarations that were present earlier, causing global variables to be used implicitly (or an error in JavaScript strict mode). This adds the local variable declarations again. - - - - - 99ced73b by Krzysztof Gogolewski at 2023-11-15T13:20:14-05:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - 2aff2361 by Zubin Duggal at 2023-11-15T13:20:50-05:00 users-guide: Fix links to libraries from the users-guide. The unit-ids generated in c1a3ecde720b3bddc2c8616daaa06ee324e602ab include the package name, so we don't need to explicitly add it to the links. Fixes #24151 - - - - - 27981fac by Alan Zimmerman at 2023-11-15T13:21:25-05:00 EPA: splitLHsForAllTyInvis does not return ann We did not use the annotations returned from splitLHsForAllTyInvis, so do not return them. - - - - - a6467834 by Krzysztof Gogolewski at 2023-11-15T22:22:59-05:00 Document defaulting of RuntimeReps Fixes #24099 - - - - - 2776920e by Simon Peyton Jones at 2023-11-15T22:23:35-05:00 Second fix to #24083 My earlier fix turns out to be too aggressive for data/type families See wrinkle (DTV1) in Note [Disconnected type variables] - - - - - cee81370 by Sylvain Henry at 2023-11-16T09:57:46-05:00 Fix unusable units and module reexport interaction (#21097) This commit fixes an issue with ModUnusable introduced in df0f148feae. In mkUnusableModuleNameProvidersMap we traverse the list of unusable units and generate ModUnusable origin for all the modules they contain: exposed modules, hidden modules, and also re-exported modules. To do this we have a two-level map: ModuleName -> Unit:ModuleName (aka Module) -> ModuleOrigin So for each module name "M" in broken unit "u" we have: "M" -> u:M -> ModUnusable reason However in the case of module reexports we were using the *target* module as a key. E.g. if "u:M" is a reexport for "X" from unit "o": "M" -> o:X -> ModUnusable reason Case 1: suppose a reexport without module renaming (u:M -> o:M) from unusable unit u: "M" -> o:M -> ModUnusable reason Here it's claiming that the import of M is unusable because a reexport from u is unusable. But if unit o isn't unusable we could also have in the map: "M" -> o:M -> ModOrigin ... Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModOrigin) Case 2: similarly we could have 2 unusable units reexporting the same module without renaming, say (u:M -> o:M) and (v:M -> o:M) with u and v unusable. It gives: "M" -> o:M -> ModUnusable ... (for u) "M" -> o:M -> ModUnusable ... (for v) Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModUnusable). This led to #21097, #16996, #11050. To fix this, in this commit we make ModUnusable track whether the module used as key is a reexport or not (for better error messages) and we use the re-export module as key. E.g. if "u:M" is a reexport for "o:X" and u is unusable, we now record: "M" -> u:M -> ModUnusable reason reexported=True So now, we have two cases for a reexport u:M -> o:X: - u unusable: "M" -> u:M -> ModUnusable ... reexported=True - u usable: "M" -> o:X -> ModOrigin ... reexportedFrom=u:M The second case is indexed with o:X because in this case the Semigroup instance of ModOrigin is used to combine valid expositions of a module (directly or via reexports). Note that module lookup functions select usable modules first (those who have a ModOrigin value), so it doesn't matter if we add new ModUnusable entries in the map like this: "M" -> { u:M -> ModUnusable ... reexported=True o:M -> ModOrigin ... } The ModOrigin one will be used. Only if there is no ModOrigin or ModHidden entry will the ModUnusable error be printed. See T21097 for an example printing several reasons why an import is unusable. - - - - - 3e606230 by Krzysztof Gogolewski at 2023-11-16T09:58:22-05:00 Fix IPE test A helper function was defined in a different module than used. To reproduce: ./hadrian/build test --test-root-dirs=testsuite/tests/rts/ipe - - - - - 49f5264b by Andreas Klebinger at 2023-11-16T20:52:11-05:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Use rep size rather than rep count to compute the size. Fixes #22309 - - - - - b4f84e4b by James Henri Haydon at 2023-11-16T20:52:53-05:00 Explicit methods for Alternative Compose Explicitly define some and many in Alternative instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/181 - - - - - 9bc0dd1f by Ignat Insarov at 2023-11-16T20:53:34-05:00 Add permutations for non-empty lists. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 5643ecf9 by Andrew Lelechenko at 2023-11-16T20:53:34-05:00 Update changelog and since annotations for Data.List.NonEmpty.permutations Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 94ff2134 by Oleg Alexander at 2023-11-16T20:54:15-05:00 Update doc string for traceShow Updated doc string for traceShow. - - - - - faff671a by Luite Stegeman at 2023-11-17T14:12:51+01:00 JS: clean up some foreign imports - - - - - 856e0a4e by Sven Tennie at 2023-11-18T06:54:11-05:00 AArch64: Remove unused instructions As these aren't ever emitted, we don't even know if they work or will ever be used. If one of them is needed in future, we may easily re-add it. Deleted instructions are: - CMN - ANDS - BIC - BICS - EON - ORN - ROR - TST - STP - LDP - DMBSY - - - - - 615441ef by Alan Zimmerman at 2023-11-18T06:54:46-05:00 EPA: Replace Monoid with NoAnn Remove the final Monoid instances in the exact print infrastructure. For Windows CI Metric Decrease: T5205 - - - - - 5a6c49d4 by David Feuer at 2023-11-20T18:53:18-05:00 Speed up stimes in instance Semigroup Endo As discussed at https://github.com/haskell/core-libraries-committee/issues/4 - - - - - cf9da4b3 by Andrew Lelechenko at 2023-11-20T18:53:18-05:00 base: reflect latest changes in the changelog - - - - - 48bf364e by Alan Zimmerman at 2023-11-20T18:53:54-05:00 EPA: Use SrcSpan in EpaSpan This is more natural, since we already need to deal with invalid RealSrcSpans, and that is exactly what SrcSpan.UnhelpfulSpan is for. Updates haddock submodule. - - - - - 97ec37cc by Sebastian Graf at 2023-11-20T18:54:31-05:00 Add regression test for #6070 Fixes #6070. - - - - - e9d5ae41 by Owen Shepherd at 2023-11-21T18:32:23-05:00 chore: Correct typo in the gitlab MR template [skip ci] - - - - - f158a8d0 by Rodrigo Mesquita at 2023-11-21T18:32:59-05:00 Improve error message when reading invalid `.target` files A `.target` file generated by ghc-toolchain or by configure can become invalid if the target representation (`Toolchain.Target`) is changed while the files are not re-generated by calling `./configure` or `ghc-toolchain` again. There is also the issue of hadrian caching the dependencies on `.target` files, which makes parsing fail when reading reading the cached value if the representation has been updated. This patch provides a better error message in both situations, moving away from a terrible `Prelude.read: no parse` error that you would get otherwise. Fixes #24199 - - - - - 955520c6 by Ben Gamari at 2023-11-21T18:33:34-05:00 users guide: Note that QuantifiedConstraints implies ExplicitForAll Fixes #24025. - - - - - 17ec3e97 by Owen Shepherd at 2023-11-22T09:37:28+01:00 fix: Change type signatures in NonEmpty export comments to reflect reality This fixes several typos in the comments of Data.List.NonEmpty export list items. - - - - - 2fd78f9f by Samuel Thibault at 2023-11-22T11:49:13-05:00 Fix the platform string for GNU/Hurd As commited in Cargo https://github.com/haskell/cabal/pull/9434 there is confusion between "gnu" and "hurd". This got fixed in Cargo, we need the converse in Hadrian. Fixes #24180 - - - - - a79960fe by Alan Zimmerman at 2023-11-22T11:49:48-05:00 EPA: Tuple Present no longer has annotation The Present constructor for a Tuple argument will never have an exact print annotation. So make this impossible. - - - - - 121c9ab7 by David Binder at 2023-11-22T21:12:29-05:00 Unify the hpc testsuites The hpc testsuite was split between testsuite/tests/hpc and the submodule libraries/hpc/test. This commit unifies the two testsuites in the GHC repository in the directory testsuite/tests/hpc. - - - - - d2733a05 by Alan Zimmerman at 2023-11-22T21:13:05-05:00 EPA: empty tup_tail has noAnn In Parser.y, the tup_tail rule had the following option | {- empty -} %shift { return [Left noAnn] } Once this works through PostProcess.hs, it means we add an extra Missing constructor if the last item was a comma. Change the annotation type to a Bool to indicate this, and use the EpAnn Anchor for the print location for the others. - - - - - fa576eb8 by Andreas Klebinger at 2023-11-24T08:29:13-05:00 Fix FMA primops generating broken assembly on x86. `genFMA3Code` assumed that we had to take extra precations to avoid overwriting the result of `getNonClobberedReg`. One of these special cases caused a bug resulting in broken assembly. I believe we don't need to hadle these cases specially at all, which means this MR simply deletes the special cases to fix the bug. Fixes #24160 - - - - - 34d86315 by Alan Zimmerman at 2023-11-24T08:29:49-05:00 EPA: Remove parenthesizeHsType This is called from PostProcess.hs, and adds spurious parens. With the looser version of exact printing we had before we could tolerate this, as they would be swallowed by the original at the same place. But with the next change (remove EpAnnNotUsed) they result in duplicates in the output. For Darwin build: Metric Increase: MultiLayerModulesTH_OneShot - - - - - 3ede659d by Vladislav Zavialov at 2023-11-26T06:43:32-05:00 Add name for -Wdeprecated-type-abstractions (#24154) This warning had no name or flag and was triggered unconditionally. Now it is part of -Wcompat. - - - - - 7902ebf8 by Alan Zimmerman at 2023-11-26T06:44:08-05:00 EPA: Remove EpAnnNotUsed We no longer need the EpAnnNotUsed constructor for EpAnn, as we can represent an unused annotation with an anchor having a EpaDelta of zero, and empty comments and annotations. This simplifies code handling annotations considerably. Updates haddock submodule Metric Increase: parsing001 - - - - - 471b2672 by Mario Blažević at 2023-11-26T06:44:48-05:00 Bumped the upper bound of text to <2.2 - - - - - d1bf25c7 by Vladislav Zavialov at 2023-11-26T11:45:49-05:00 Term variable capture (#23740) This patch changes type variable lookup rules (lookupTypeOccRn) and implicit quantification rules (filterInScope) so that variables bound in the term namespace can be captured at the type level {-# LANGUAGE RequiredTypeArguments #-} f1 x = g1 @x -- `x` used in a type application f2 x = g2 (undefined :: x) -- `x` used in a type annotation f3 x = g3 (type x) -- `x` used in an embedded type f4 x = ... where g4 :: x -> x -- `x` used in a type signature g4 = ... This change alone does not allow us to accept examples shown above, but at least it gets them past the renamer. - - - - - da863d15 by Vladislav Zavialov at 2023-11-26T11:46:26-05:00 Update Note [hsScopedTvs and visible foralls] The Note was written before GHC gained support for visible forall in types of terms. Rewrite a few sentences and use a better example. - - - - - b5213542 by Matthew Pickering at 2023-11-27T12:53:59-05:00 testsuite: Add mechanism to collect generic metrics * Generalise the metric logic by adding an additional field which allows you to specify how to query for the actual value. Previously the method of querying the baseline value was abstracted (but always set to the same thing). * This requires rejigging how the stat collection works slightly but now it's more uniform and hopefully simpler. * Introduce some new "generic" helper functions for writing generic stats tests. - collect_size ( deviation, path ) Record the size of the file as a metric - stat_from_file ( metric, deviation, path ) Read a value from the given path, and store that as a metric - collect_generic_stat ( metric, deviation, get_stat) Provide your own `get_stat` function, `lambda way: <Int>`, which can be used to establish the current value of the metric. - collect_generic_stats ( metric_info ): Like collect_generic_stat but provide the whole dictionary of metric definitions. { metric: { deviation: <Int> current: lambda way: <Int> } } * Introduce two new "size" metrics for keeping track of build products. - `size_hello_obj` - The size of `hello.o` from compiling hello.hs - `libdir` - The total size of the `libdir` folder. * Track the number of modules in the AST tests - CountDepsAst - CountDepsParser This lays the infrastructure for #24191 #22256 #17129 - - - - - 7d9a2e44 by ARATA Mizuki at 2023-11-27T12:54:39-05:00 x86: Don't require -mavx2 when using 256-bit floating-point SIMD primitives Fixes #24222 - - - - - 4e5ff6a4 by Alan Zimmerman at 2023-11-27T12:55:15-05:00 EPA: Remove SrcSpanAnn Now that we only have a single constructor for EpAnn, And it uses a SrcSpan for its location, we can do away with SrcSpanAnn completely. It only existed to wrap the original SrcSpan in a location, and provide a place for the exact print annotation. For darwin only: Metric Increase: MultiLayerModulesTH_OneShot Updates haddock submodule - - - - - e05bca39 by Krzysztof Gogolewski at 2023-11-28T08:00:55-05:00 testsuite: don't initialize testdir to '.' The test directory is removed during cleanup, if there's an interrupt that could remove the entire repository. Fixes #24219 - - - - - af881674 by Alan Zimmerman at 2023-11-28T08:01:30-05:00 EPA: Clean up mkScope in Ast.hs Now that we have HasLoc we can get rid of all the custom variants of mkScope For deb10-numa Metric Increase: libdir - - - - - 292983c8 by Ben Gamari at 2023-11-28T22:44:28-05:00 distrib: Rediscover otool and install_name_tool on Darwin In the bindist configure script we must rediscover the `otool` and `install_name_tool`s since they may be different from the build environment. Fixes #24211. - - - - - dfe1c354 by Stefan Schulze Frielinghaus at 2023-11-28T22:45:04-05:00 llvmGen: Align objects in the data section Objects in the data section may be referenced via tagged pointers. Thus, align those objects to a 4- or 8-byte boundary for 32- or 64-bit platforms, respectively. Note, this may need to be reconsidered if objects with a greater natural alignment requirement are emitted as e.g. 128-bit atomics. Fixes #24163. - - - - - f6c486c3 by Matthew Pickering at 2023-11-29T11:08:13-05:00 metrics: Widen libdir and size_hello_obj acceptance window af8816740d9b8759be1a22af8adcb5f13edeb61d shows that the libdir size can fluctuate quite significantly even when the change is quite small. Therefore we widen the acceptance window to 10%. - - - - - 99a6a49c by Alan Zimmerman at 2023-11-29T11:08:49-05:00 EPA: Clean up TC Monad Utils We no longer need the alternative variant of addLocM (addLocMA) nor wrapLocAM, wrapLocSndMA. aarch64-darwin Metric Increase: MultiLayerModulesTH_OneShot deb10-numa-slow Metric Decrease: libdir - - - - - cbc03fa0 by Sebastian Graf at 2023-11-30T12:37:21-05:00 perf tests: Move comments into new `Note [Sensitivity to unique increment]` (#19414) And additionally to T12545, link from T8095, T13386 to this new Note. - - - - - c7623b22 by Alan Zimmerman at 2023-11-30T12:37:56-05:00 EPA: EpaDelta for comment has no comments EpaLocation is used to position things. It has two constructors, EpaSpan holding a SrcSpan, and EpaDelta with a delta position and a possible list of comments. The comment list is needed because the location in EpaDelta has no absolute information to decide which comments should be emitted before them when printing. But it is also used for specifying the position of a comment. To prevent the absurdity of a comment position having a list of comments in it, we make EpaLocation parameterisable, using comments for the normal case and a constant for within comments. Updates haddock submodule. aarch64-darwin Metric Decrease: MultiLayerModulesTH_OneShot - - - - - bd8acc0c by Krzysztof Gogolewski at 2023-11-30T12:38:32-05:00 Kind-check body of a required forall We now require that in 'forall a -> ty', ty has kind TYPE r for some r. Fixes #24176 - - - - - 010fb784 by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Remove incorrect haddock link quotes in code block - - - - - cda9c12d by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Remove cycle from group haddock example - - - - - 495265b9 by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Use repl haddock syntax in group docs - - - - - d134d1de by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Use list [] notation in group haddock - - - - - dfcf629c by Owen Shepherd at 2023-12-03T00:10:10-05:00 docs(NonEmpty/group): Specify final property of group function in haddock - - - - - cad3b734 by Owen Shepherd at 2023-12-03T00:10:10-05:00 fix: Add missing property of List.group - - - - - bad37656 by Matthew Pickering at 2023-12-03T00:10:46-05:00 testsuite: Fix T21097b test with make 4.1 (deb9) cee81370cd6ef256f66035e3116878d4cb82e28b recently added a test which failed on deb9 because the version of make was emitting the recipe failure to stdout rather than stderr. One way to fix this is to be more precise in the test about which part of the output we care about inspecting. - - - - - 5efdf421 by Matthew Pickering at 2023-12-03T00:11:21-05:00 testsuite: Track size of libdir in bytes For consistency it's better if we track all size metrics in bytes. Metric Increase: libdir - - - - - f5eb0f29 by Matthew Pickering at 2023-12-03T00:11:22-05:00 testsuite: Remove rogue trace in testsuite I accidentally left a trace in the generics metric patch. - - - - - d5610737 by Claudio Bley at 2023-12-06T16:13:33-05:00 Only exit ghci in -e mode when :add command fails Previously, when running `ghci -e ':add Sample.hs'` the process would exit with exit code 1 if the file exists and could be loaded. Fixes #24115 - - - - - 0f0c53a5 by Vladislav Zavialov at 2023-12-06T16:14:09-05:00 T2T in Patterns (#23739) This patch implements the T2T (term-to-type) transformation in patterns. Patterns that are checked against a visible forall can now be written without the `type` keyword: \(type t) (x :: t) -> ... -- old \t (x :: t) -> ... -- new The `t` binder is parsed and renamed as a term pattern (Pat), but then undergoes a conversion to a type pattern (HsTyPat). See the new function pat_to_type_pat in compiler/GHC/Tc/Gen/Pat.hs - - - - - 10a1a6c6 by Sebastian Graf at 2023-12-06T16:14:45-05:00 Pmc: Fix SrcLoc and warning for incomplete irrefutable pats (#24234) Before, the source location would point at the surrounding function definition, causing the confusion in #24234. I also took the opportunity to introduce a new `LazyPatCtx :: HsMatchContext _` to make the warning message say "irrefutable pattern" instead of "pattern binding". - - - - - 36b9a38c by Matthew Pickering at 2023-12-06T16:15:21-05:00 libraries: Bump filepath to 1.4.200.1 and unix to 2.8.4.0 Updates filepath submodule Updates unix submodule Fixes #24240 - - - - - 91ff0971 by Matthew Pickering at 2023-12-06T16:15:21-05:00 Submodule linter: Allow references to tags We modify the submodule linter so that if the bumped commit is a specific tag then the commit is accepted. Fixes #24241 - - - - - 86f652dc by Zubin Duggal at 2023-12-06T16:15:21-05:00 hadrian: set -Wno-deprecations for directory and Win32 The filepath bump to 1.4.200.1 introduces a deprecation warning. See https://gitlab.haskell.org/ghc/ghc/-/issues/24240 https://github.com/haskell/filepath/pull/206 - - - - - 7ac6006e by Sylvain Henry at 2023-12-06T16:16:02-05:00 Zap OccInfo on case binders during StgCse #14895 #24233 StgCse can revive dead binders: case foo of dead { Foo x y -> Foo x y; ... } ===> case foo of dead { Foo x y -> dead; ... } -- dead is no longer dead So we must zap occurrence information on case binders. Fix #14895 and #24233 - - - - - 57c391c4 by Sebastian Graf at 2023-12-06T16:16:37-05:00 Cpr: Turn an assertion into a check to deal with some dead code (#23862) See the new `Note [Dead code may contain type confusions]`. Fixes #23862. - - - - - c1c8abf8 by Zubin Duggal at 2023-12-08T02:25:07-05:00 testsuite: add test for #23944 - - - - - 6329d308 by Zubin Duggal at 2023-12-08T02:25:07-05:00 driver: Only run a dynamic-too pipeline if object files are going to be generated Otherwise we run into a panic in hscMaybeWriteIface: "Unexpected DT_Dyn state when writing simple interface" when dynamic-too is enabled We could remove the panic and just write the interface even if the state is `DT_Dyn`, but it seems pointless to run the pipeline twice when `hscMaybeWriteIface` is already designed to write both `hi` and `dyn_hi` files if dynamic-too is enabled. Fixes #23944. - - - - - 28811f88 by Simon Peyton Jones at 2023-12-08T05:47:18-05:00 Improve duplicate elimination in SpecConstr This partially fixes #24229. See the new Note [Pattern duplicate elimination] in SpecConstr - - - - - fec7894f by Simon Peyton Jones at 2023-12-08T05:47:18-05:00 Make SpecConstr deal with casts better This patch does two things, to fix #23209: * It improves SpecConstr so that it no longer quantifies over coercion variables. See Note [SpecConstr and casts] * It improves the rule matcher to deal nicely with the case where the rule does not quantify over coercion variables, but the the template has a cast in it. See Note [Casts in the template] - - - - - 8db8d2fd by Zubin Duggal at 2023-12-08T05:47:54-05:00 driver: Don't lose track of nodes when we fail to resolve cycles The nodes that take part in a cycle should include both hs-boot and hs files, but when we fail to resolve a cycle, we were only counting the nodes from the graph without boot files. Fixes #24196 - - - - - c5b4efd3 by Zubin Duggal at 2023-12-08T05:48:30-05:00 testsuite: Skip MultiLayerModulesTH_OneShot on darwin See #24177 - - - - - fae472a9 by Wendao Lee at 2023-12-08T05:49:12-05:00 docs(Data.Char):Add more detailed descriptions for some functions Related changed function's docs: -GHC.Unicode.isAlpha -GHC.Unicode.isPrint -GHC.Unicode.isAlphaNum Add more details for what the function will return. Co-authored-by: Bodigrim <andrew.lelechenko at gmail.com> - - - - - ca7510e4 by Malik Ammar Faisal at 2023-12-08T05:49:55-05:00 Fix float parsing in GHC Cmm Lexer Add test case for bug #24224 - - - - - d8baa1bd by Simon Peyton Jones at 2023-12-08T15:40:37+00:00 Take care when simplifying unfoldings This MR fixes a very subtle bug exposed by #24242. See Note [Environment for simplLetUnfolding]. I also updated a bunch of Notes on shadowing - - - - - 03ca551d by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Comments only in FloatIn Relevant to #3458 - - - - - 50c78779 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Comments only in SpecConstr - - - - - 9431e195 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Add test for #22238 - - - - - d9e4c597 by Vladislav Zavialov at 2023-12-11T04:19:34-05:00 Make forall a keyword (#23719) Before this change, GHC used to accept `forall` as a term-level identifier: -- from constraints-0.13 forall :: forall p. (forall a. Dict (p a)) -> Dict (Forall p) forall d = ... Now it is a parse error. The -Wforall-identifier warning has served its purpose and is now a deprecated no-op. - - - - - 58d56644 by Zubin Duggal at 2023-12-11T04:20:10-05:00 driver: Ensure we actually clear the interactive context before reloading Previously we called discardIC, but immediately after set the session back to an old HscEnv that still contained the IC Partially addresses #24107 Fixes #23405 - - - - - 8e5745a0 by Zubin Duggal at 2023-12-11T04:20:10-05:00 driver: Ensure we force the lookup of old build artifacts before returning the build plan This prevents us from retaining all previous build artifacts in memory until a recompile finishes, instead only retaining the exact artifacts we need. Fixes #24118 - - - - - 105c370c by Zubin Duggal at 2023-12-11T04:20:10-05:00 testsuite: add test for #24118 and #24107 MultiLayerModulesDefsGhci was not able to catch the leak because it uses :l which discards the previous environment. Using :r catches both of these leaks - - - - - e822ff88 by Zubin Duggal at 2023-12-11T04:20:10-05:00 compiler: Add some strictness annotations to ImportSpec and related constructors This prevents us from retaining entire HscEnvs. Force these ImportSpecs when forcing the GlobalRdrEltX Adds an NFData instance for Bag Fixes #24107 - - - - - 522c12a4 by Zubin Duggal at 2023-12-11T04:20:10-05:00 compiler: Force IfGlobalRdrEnv in NFData instance. - - - - - 188b280d by Arnaud Spiwack at 2023-12-11T15:33:31+01:00 LinearTypes => MonoLocalBinds - - - - - 8e0446df by Arnaud Spiwack at 2023-12-11T15:44:28+01:00 Linear let and where bindings For expediency, the initial implementation of linear types in GHC made it so that let and where binders would always be considered unrestricted. This was rather unpleasant, and probably a big obstacle to adoption. At any rate, this was not how the proposal was designed. This patch fixes this infelicity. It was surprisingly difficult to build, which explains, in part, why it took so long to materialise. As of this patch, let or where bindings marked with %1 will be linear (respectively %p for an arbitrary multiplicity p). Unmarked let will infer their multiplicity. Here is a prototypical example of program that used to be rejected and is accepted with this patch: ```haskell f :: A %1 -> B g :: B %1 -> C h :: A %1 -> C h x = g y where y = f x ``` Exceptions: - Recursive let are unrestricted, as there isn't a clear semantics of what a linear recursive binding would be. - Destructive lets with lazy bindings are unrestricted, as their desugaring isn't linear (see also #23461). - (Strict) destructive lets with inferred polymorphic type are unrestricted. Because the desugaring isn't linear (See #18461 down-thread). Closes #18461 and #18739 Co-authored-by: @jackohughes - - - - - effa7e2d by Matthew Craven at 2023-12-12T04:37:20-05:00 Introduce `dataToTagSmall#` primop (closes #21710) ...and use it to generate slightly better code when dataToTag# is used at a "small data type" where there is no need to mess with "is_too_big_tag" or potentially look at an info table. Metric Decrease: T18304 - - - - - 35c7aef6 by Matthew Craven at 2023-12-12T04:37:20-05:00 Fix formatting of Note [alg-alt heap check] - - - - - 7397c784 by Oleg Grenrus at 2023-12-12T04:37:56-05:00 Allow untyped brackets in typed splices and vice versa. Resolves #24190 Apparently the check was essentially always (as far as I can trace back: d0d47ba76f8f0501cf3c4966bc83966ab38cac27), and while it does catch some mismatches, the type-checker will catch them too. OTOH, it prevents writing completely reasonable programs. - - - - - a3ee3b99 by Moritz Angermann at 2023-12-12T19:50:58-05:00 Drop hard Xcode dependency XCODE_VERSION calls out to `xcodebuild`, which is only available when having `Xcode` installed. The CommandLineTools are not sufficient. To install Xcode, you must have an apple id to download the Xcode.xip from apple. We do not use xcodebuild anywhere in our build explicilty. At best it appears to be a proxy for checking the linker or the compiler. These should rather be done with ``` xcrun ld -version ``` or similar, and not by proxy through Xcode. The CLR should be sufficient for building software on macOS. - - - - - 1c9496e0 by Vladislav Zavialov at 2023-12-12T19:51:34-05:00 docs: update information on RequiredTypeArguments Update the User's Guide and Release Notes to account for the recent progress in the implementation of RequiredTypeArguments. - - - - - d0b17576 by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Fix off-by-one in assertion Previously we failed to account for the NULL terminator `postString` asserted that there is enough room in the buffer for the string. - - - - - a10f9b9b by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Honor result of ensureRoomForVariableEvent is Previously we would keep plugging along, even if isn't enough room for the event. - - - - - 0e0f41c0 by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Avoid truncating event sizes Previously ensureRoomForVariableEvent would truncate the desired size to 16-bits, resulting in #24197. Fixes #24197. - - - - - 64e724c8 by Artin Ghasivand at 2023-12-13T06:34:20-05:00 Remove the "Derived Constraint" argument of TcPluginSolver, docs - - - - - fe6d97dd by Vladislav Zavialov at 2023-12-13T06:34:56-05:00 EPA: Move tokens into GhcPs extension fields (#23447) Summary of changes * Remove Language.Haskell.Syntax.Concrete * Move all tokens into GhcPs extension fields (LHsToken -> EpToken) * Create new TTG extension fields as needed * Drop the MultAnn wrapper Updates the haddock submodule. Co-authored-by: Alan Zimmerman <alan.zimm at gmail.com> - - - - - 8106e695 by Zubin Duggal at 2023-12-13T06:35:34-05:00 testsuite: use copy_files in T23405 This prevents the tree from being dirtied when the file is modified. - - - - - ed0e4099 by Bryan Richter at 2023-12-14T04:30:53-05:00 Document ghc package's PVP-noncompliance This changes nothing, it just makes the status quo explicit. - - - - - 8bef8d9f by Luite Stegeman at 2023-12-14T04:31:33-05:00 JS: Mark spurious CI failures js_fragile(24259) This marks the spurious test failures on the JS platform as js_fragile(24259), so we don't hold up merge requests while fixing the underlying issues. See #24259 - - - - - 1c79526a by Finley McIlwaine at 2023-12-15T12:24:40-08:00 Late plugins - - - - - 000c3302 by Finley McIlwaine at 2023-12-15T12:24:40-08:00 withTiming on LateCCs and late plugins - - - - - be4551ac by Finley McIlwaine at 2023-12-15T12:24:40-08:00 add test for late plugins - - - - - 7c29da9f by Finley McIlwaine at 2023-12-15T12:24:40-08:00 Document late plugins - - - - - 9a52ae46 by Ben Gamari at 2023-12-20T07:07:26-05:00 Fix thunk update ordering Previously we attempted to ensure soundness of concurrent thunk update by synchronizing on the access of the thunk's info table pointer field. This was believed to be sufficient since the indirectee (which may expose a closure allocated by another core) would not be examined until the info table pointer update is complete. However, it turns out that this can result in data races in the presence of multiple threads racing a update a single thunk. For instance, consider this interleaving under the old scheme: Thread A Thread B --------- --------- t=0 Enter t 1 Push update frame 2 Begin evaluation 4 Pause thread 5 t.indirectee=tso 6 Release t.info=BLACKHOLE 7 ... (e.g. GC) 8 Resume thread 9 Finish evaluation 10 Relaxed t.indirectee=x 11 Load t.info 12 Acquire fence 13 Inspect t.indirectee 14 Release t.info=BLACKHOLE Here Thread A enters thunk `t` but is soon paused, resulting in `t` being lazily blackholed at t=6. Then, at t=10 Thread A finishes evaluation and updates `t.indirectee` with a relaxed store. Meanwhile, Thread B enters the blackhole. Under the old scheme this would introduce an acquire-fence but this would only synchronize with Thread A at t=6. Consequently, the result of the evaluation, `x`, is not visible to Thread B, introducing a data race. We fix this by treating the `indirectee` field as we do all other mutable fields. This means we must always access this field with acquire-loads and release-stores. See #23185. - - - - - f4b53538 by Vladislav Zavialov at 2023-12-20T07:08:02-05:00 docs: Fix link to 051-ghc-base-libraries.rst The proposal is no longer available at the previous URL. - - - - - f7e21fab by Matthew Pickering at 2023-12-21T14:57:40+00:00 hadrian: Build all executables in bin/ folder In the end the bindist creation logic copies them all into the bin folder. There is no benefit to building a specific few binaries in the lib/bin folder anymore. This also removes the ad-hoc logic to copy the touchy and unlit executables from stage0 into stage1. It takes <1s to build so we might as well just build it. - - - - - 0038d052 by Zubin Duggal at 2023-12-22T23:28:00-05:00 testsuite: mark jspace as fragile on i386. This test has been flaky for some time and has been failing consistently on i386-linux since 8e0446df landed. See #24261 - - - - - dfd670a0 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 609e6225 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 865513b2 by Ömer Sinan Ağacan at 2023-12-24T10:11:13-05:00 Fix BNF in user manual 6.6.8.2: formal syntax for instance declarations - - - - - c247b6be by Zubin Duggal at 2023-12-25T16:01:23-05:00 docs: document permissibility of -XOverloadedLabels (#24249) Document the permissibility introduced by https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - e5b7eb59 by Ömer Sinan Ağacan at 2023-12-25T16:02:03-05:00 Fix a code block syntax in user manual sec. 6.8.8.6 - - - - - 2db11c08 by Ben Gamari at 2023-12-29T15:35:48-05:00 genSym: Reimplement via CAS on 32-bit platforms Previously the remaining use of the C implementation on 32-bit platforms resulted in a subtle bug, #24261. This was due to the C object (which used the RTS's `atomic_inc64` macro) being compiled without `-threaded` yet later being used in a threaded compiler. Side-step this issue by using the pure Haskell `genSym` implementation on all platforms. This required implementing `fetchAddWord64Addr#` in terms of CAS on 64-bit platforms. - - - - - 19328a8c by Xiaoyan Ren at 2023-12-29T15:36:30-05:00 Do not color the diagnostic code in error messages (#24172) - - - - - 685b467c by Krzysztof Gogolewski at 2023-12-29T15:37:06-05:00 Enforce that bindings of implicit parameters are lifted Fixes #24298 - - - - - bc4d67b7 by Matthew Craven at 2023-12-31T06:15:42-05:00 StgToCmm: Detect some no-op case-continuations ...and generate no code for them. Fixes #24264. - - - - - 5b603139 by Krzysztof Gogolewski at 2023-12-31T06:16:18-05:00 Revert "testsuite: mark jspace as fragile on i386." This reverts commit 0038d052c8c80b4b430bb2aa1c66d5280be1aa95. The atomicity bug should be fixed by !11802. - - - - - d55216ad by Krzysztof Gogolewski at 2024-01-01T12:05:49-05:00 Refactor: store [[PrimRep]] rather than [Type] in STG StgConApp stored a list of types. This list was used exclusively during unarisation of unboxed sums (mkUbxSum). However, this is at a wrong level of abstraction: STG shouldn't be concerned with Haskell types, only PrimReps. Update the code to store a [[PrimRep]]. Also, there's no point in storing this list when we're not dealing with an unboxed sum. - - - - - 8b340bc7 by Ömer Sinan Ağacan at 2024-01-01T12:06:29-05:00 Kind signatures docs: mention that they're allowed in newtypes - - - - - 989bf8e5 by Zubin Duggal at 2024-01-03T20:08:47-05:00 ci: Ensure we use the correct bindist name for the test artifact when generating release ghcup metadata Fixes #24268 - - - - - 89299a89 by Krzysztof Gogolewski at 2024-01-03T20:09:23-05:00 Refactor: remove calls to typePrimRepArgs The function typePrimRepArgs is just a thin wrapper around typePrimRep, adding a VoidRep if the list is empty. However, in StgToByteCode, we were discarding that VoidRep anyway, so there's no point in calling it. - - - - - c7be0c68 by mmzk1526 at 2024-01-03T20:10:07-05:00 Use "-V" for alex version check for better backward compatibility Fixes #24302. In recent versions of alex, "-v" is used for "--verbose" instead of "-version". - - - - - 67dbcc0a by Krzysztof Gogolewski at 2024-01-05T02:07:18-05:00 Fix VoidRep handling in ghci debugger 'go' inside extractSubTerms was giving a bad result given a VoidRep, attempting to round towards the next multiple of 0. I don't understand much about the debugger but the code should be better than it was. Fixes #24306 - - - - - 90ea574e by Krzysztof Gogolewski at 2024-01-05T02:07:54-05:00 VoidRep-related refactor * In GHC.StgToByteCode, replace bcIdPrimId with idPrimRep, bcIdArgRep with idArgRep, atomPrimRep with stgArgRep1. All of them were duplicates. * In GHC.Stg.Unarise, we were converting a PrimRep to a Type and back to PrimRep. Remove the calls to primRepToType and typePrimRep1 which cancel out. * In GHC.STG.Lint, GHC.StgToCmm, GHC.Types.RepType we were filtering out VoidRep from the result of typePrimRep. But typePrimRep never returns VoidRep - remove the filtering. - - - - - eaf72479 by brian at 2024-01-06T23:03:09-05:00 Add unaligned Addr# primops Implements CLC proposal #154: https://github.com/haskell/core-libraries-committee/issues/154 * add unaligned addr primops * add tests * accept tests * add documentation * fix js primops * uncomment in access ops * use Word64 in tests * apply suggestions * remove extra file * move docs * remove random options * use setByteArray# primop * better naming * update base-exports test * add base-exports for other architectures - - - - - d471d445 by Krzysztof Gogolewski at 2024-01-06T23:03:47-05:00 Remove VoidRep from PrimRep, introduce PrimOrVoidRep This introduces data PrimOrVoidRep = VoidRep | NVRep PrimRep changes typePrimRep1 to return PrimOrVoidRep, and adds a new function typePrimRepU to be used when the argument is definitely non-void. Details in Note [VoidRep] in GHC.Types.RepType. Fixes #19520 - - - - - 48720a07 by Matthew Craven at 2024-01-08T18:57:36-05:00 Apply Note [Sensitivity to unique increment] to LargeRecord - - - - - 9e2e180f by Sebastian Graf at 2024-01-08T18:58:13-05:00 Debugging: Add diffUFM for convenient diffing between UniqFMs - - - - - 948f3e35 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Rename Opt_D_dump_stranal to Opt_D_dump_dmdanal ... and Opt_D_dump_str_signatures to Opt_D_dump_dmd_signatures - - - - - 4e217e3e by Sebastian Graf at 2024-01-08T18:58:13-05:00 Deprecate -ddump-stranal and -ddump-str-signatures ... and suggest -ddump-dmdanal and -ddump-dmd-signatures instead - - - - - 6c613c90 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Move testsuite/tests/stranal to testsuite/tests/dmdanal A separate commit so that the rename is obvious to Git(Lab) - - - - - c929f02b by Sebastian Graf at 2024-01-08T18:58:13-05:00 CoreSubst: Stricten `substBndr` and `cloneBndr` Doing so reduced allocations of `cloneBndr` by about 25%. ``` T9233(normal) ghc/alloc 672,488,656 663,083,216 -1.4% GOOD T9675(optasm) ghc/alloc 423,029,256 415,812,200 -1.7% geo. mean -0.1% minimum -1.7% maximum +0.1% ``` Metric Decrease: T9233 - - - - - e3ca78f3 by Krzysztof Gogolewski at 2024-01-10T17:35:59-05:00 Deprecate -Wsemigroup This warning was used to prepare for Semigroup becoming a superclass of Monoid, and for (<>) being exported from Prelude. This happened in GHC 8.4 in 8ae263ceb3566 and feac0a3bc69fd3. The leftover logic for (<>) has been removed in GHC 9.8, 4d29ecdfcc79. Now the warning does nothing at all and can be deprecated. - - - - - 08d14925 by amesgen at 2024-01-10T17:36:42-05:00 WASM metadata: use correct GHC version - - - - - 7a808419 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Allow SCC declarations in TH (#24081) - - - - - 28827c51 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Fix prettyprinting of SCC pragmas - - - - - ae9cc1a8 by Matthew Craven at 2024-01-10T17:38:01-05:00 Fix loopification in the presence of void arguments This also removes Note [Void arguments in self-recursive tail calls], which was just misleading. It's important to count void args both in the function's arity and at the call site. Fixes #24295. - - - - - b718b145 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: Teach testsuite driver about c++ sources - - - - - 09cb57ad by Zubin Duggal at 2024-01-10T17:38:36-05:00 driver: Set -DPROFILING when compiling C++ sources with profiling Earlier, we used to pass all preprocessor flags to the c++ compiler. This meant that -DPROFILING was passed to the c++ compiler because it was a part of C++ flags However, this was incorrect and the behaviour was changed in 8ff3134ed4aa323b0199ad683f72165e51a59ab6. See #21291. But that commit exposed this bug where -DPROFILING was no longer being passed when compiling c++ sources. The fix is to explicitly include -DPROFILING in `opt_cxx` when profiling is enabled to ensure we pass the correct options for the way to both C and C++ compilers Fixes #24286 - - - - - 2cf9dd96 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: rename objcpp -> objcxx To avoid confusion with C Pre Processsor - - - - - af6932d6 by Simon Peyton Jones at 2024-01-10T17:39:12-05:00 Make TYPE and CONSTRAINT not-apart Issue #24279 showed up a bug in the logic in GHC.Core.Unify.unify_ty which is supposed to make TYPE and CONSTRAINT be not-apart. Easily fixed. - - - - - 4a39b5ff by Zubin Duggal at 2024-01-10T17:39:48-05:00 ci: Fix typo in mk_ghcup_metadata.py There was a missing colon in the fix to #24268 in 989bf8e53c08eb22de716901b914b3607bc8dd08 - - - - - 13503451 by Zubin Duggal at 2024-01-10T17:40:24-05:00 release-ci: remove release-x86_64-linux-deb11-release+boot_nonmoving_gc job There is no reason to have this release build or distribute this variation. This configuration is for testing purposes only. - - - - - afca46a4 by Sebastian Graf at 2024-01-10T17:41:00-05:00 Parser: Add a Note detailing why we need happy's `error` to implement layout - - - - - eaf8a06d by Krzysztof Gogolewski at 2024-01-11T00:43:17+01:00 Turn -Wtype-equality-out-of-scope on by default Also remove -Wnoncanonical-{monoid,monad}-instances from -Wcompat, since they are enabled by default. Refresh wcompat-warnings/ test with new -Wcompat warnings. Part of #24267 Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 42bee5aa by Sebastian Graf at 2024-01-12T21:16:21-05:00 Arity: Require called *exactly once* for eta exp with -fpedantic-bottoms (#24296) In #24296, we had a program in which we eta expanded away an error despite the presence of `-fpedantic-bottoms`. This was caused by turning called *at least once* lambdas into one-shot lambdas, while with `-fpedantic-bottoms` it is only sound to eta expand over lambdas that are called *exactly* once. An example can be found in `Note [Combining arity type with demand info]`. Fixes #24296. - - - - - 7e95f738 by Andreas Klebinger at 2024-01-12T21:16:57-05:00 Aarch64: Enable -mfma by default. Fixes #24311 - - - - - e43788d0 by Jason Shipman at 2024-01-14T12:47:38-05:00 Add more instances for Compose: Fractional, RealFrac, Floating, RealFloat CLC proposal #226 https://github.com/haskell/core-libraries-committee/issues/226 - - - - - ae6d8cd2 by Sebastian Graf at 2024-01-14T12:48:15-05:00 Pmc: COMPLETE pragmas associated with Family TyCons should apply to representation TyCons as well (#24326) Fixes #24326. - - - - - c5fc7304 by sheaf at 2024-01-15T14:15:29-05:00 Use lookupOccRn_maybe in TH.lookupName When looking up a value, we want to be able to find both variables and record fields. So we should not use the lookupSameOccRn_maybe function, as we can't know ahead of time which record field namespace a record field with the given textual name will belong to. Fixes #24293 - - - - - da908790 by Krzysztof Gogolewski at 2024-01-15T14:16:05-05:00 Make the build more strict on documentation errors * Detect undefined labels. This can be tested by adding :ref:`nonexistent` to a documentation rst file; attempting to build docs will fail. Fixed the undefined label in `9.8.1-notes.rst`. * Detect errors. While we have plenty of warnings, we can at least enforce that Sphinx does not report errors. Fixed the error in `required_type_arguments.rst`. Unrelated change: I have documented that the `-dlint` enables `-fcatch-nonexhaustive-cases`, as can be verified by checking `enableDLint`. - - - - - 5077416e by Javier Sagredo at 2024-01-16T15:40:06-05:00 Profiling: Adds an option to not start time profiling at startup Using the functionality provided by d89deeba47ce04a5198a71fa4cbc203fe2c90794, this patch creates a new rts flag `--no-automatic-time-samples` which disables the time profiling when starting a program. It is then expected that the user starts it whenever it is needed. Fixes #24337 - - - - - 5776008c by Matthew Pickering at 2024-01-16T15:40:42-05:00 eventlog: Fix off-by-one error in postIPE We were missing the extra_comma from the calculation of the size of the payload of postIPE. This was causing assertion failures when the event would overflow the buffer by one byte, as ensureRoomForVariable event would report there was enough space for `n` bytes but then we would write `n + 1` bytes into the buffer. Fixes #24287 - - - - - 66dc09b1 by Simon Peyton Jones at 2024-01-16T15:41:18-05:00 Improve SpecConstr (esp nofib/spectral/ansi) This MR makes three improvements to SpecConstr: see #24282 * It fixes an outright (and recently-introduced) bug in `betterPat`, which was wrongly forgetting to compare the lengths of the argument lists. * It enhances ConVal to inclue a boolean for work-free-ness, so that the envt can contain non-work-free constructor applications, so that we can do more: see Note [ConVal work-free-ness] * It rejigs `subsumePats` so that it doesn't reverse the list. This can make a difference because, when patterns overlap, we arbitrarily pick the first. There is no "right" way, but this retains the old pre-subsumePats behaviour, thereby "fixing" the regression in #24282. Nofib results +======================================== | spectral/ansi -21.14% | spectral/hartel/comp_lab_zift -0.12% | spectral/hartel/parstof +0.09% | spectral/last-piece -2.32% | spectral/multiplier +6.03% | spectral/para +0.60% | spectral/simple -0.26% +======================================== | geom mean -0.18% +---------------------------------------- The regression in `multiplier` is sad, but it simply replicates GHC's previous behaviour (e.g. GHC 9.6). - - - - - 65da79b3 by Matthew Pickering at 2024-01-16T15:41:54-05:00 hadrian: Reduce Cabal verbosity The comment claims that `simpleUserHooks` decrease verbosity, and it does, but only for the `postConf` phase. The other phases are too verbose with `-V`. At the moment > 5000 lines of the build log are devoted to output from `cabal copy`. So I take the simple approach and just decrease the verbosity level again. If the output of `postConf` is essential then it would be better to implement our own `UserHooks` which doesn't decrease the verbosity for `postConf`. Fixes #24338 - - - - - 16414d7d by Matthew Pickering at 2024-01-17T10:54:59-05:00 Stop retaining old ModGuts throughout subsequent simplifier phases Each phase of the simplifier typically rewrites the majority of ModGuts, so we want to be able to release the old ModGuts as soon as possible. `name_ppr_ctxt` lives throught the whole optimiser phase and it was retaining a reference to `ModGuts`, so we were failing to release the old `ModGuts` until the end of the phase (potentially doubling peak memory usage for that particular phase). This was discovered using eras profiling (#24332) Fixes #24328 - - - - - 7f0879e1 by Matthew Pickering at 2024-01-17T10:55:35-05:00 Update nofib submodule - - - - - 320454d3 by Cheng Shao at 2024-01-17T23:02:40+00:00 ci: bump ci-images for updated wasm image - - - - - 2eca52b4 by Cheng Shao at 2024-01-17T23:06:44+00:00 base: treat all FDs as "nonblocking" on wasm On posix platforms, when performing read/write on FDs, we check the nonblocking flag first. For FDs without this flag (e.g. stdout), we call fdReady() first, which in turn calls poll() to wait for I/O to be available on that FD. This is problematic for wasm32-wasi: although select()/poll() is supported via the poll_oneoff() wasi syscall, that syscall is rather heavyweight and runtime behavior differs in different wasi implementations. The issue is even worse when targeting browsers, given there's no satisfactory way to implement async I/O as a synchronous syscall, so existing JS polyfills for wasi often give up and simply return ENOSYS. Before we have a proper I/O manager that avoids poll_oneoff() for async I/O on wasm, this patch improves the status quo a lot by merely pretending all FDs are "nonblocking". Read/write on FDs will directly invoke read()/write(), which are much more reliably handled in existing wasi implementations, especially those in browsers. Fixes #23275 and the following test cases: T7773 isEOF001 openFile009 T4808 cgrun025 Approved by CLC proposal #234: https://github.com/haskell/core-libraries-committee/issues/234 - - - - - 83c6c710 by Andrew Lelechenko at 2024-01-18T05:21:49-05:00 base: clarify how to disable warnings about partiality of Data.List.{head,tail} - - - - - c4078f2f by Simon Peyton Jones at 2024-01-18T05:22:25-05:00 Fix four bug in handling of (forall cv. body_ty) These bugs are all described in #24335 It's not easy to provoke the bug, hence no test case. - - - - - 119586ea by Alexis King at 2024-01-19T00:08:00-05:00 Always refresh profiling CCSes after running pending initializers Fixes #24171. - - - - - 9718d970 by Oleg Grenrus at 2024-01-19T00:08:36-05:00 Set default-language: GHC2021 in ghc library Go through compiler/ sources, and remove all BangPatterns (and other GHC2021 enabled extensions in these files). - - - - - 3ef71669 by Matthew Pickering at 2024-01-19T21:55:16-05:00 testsuite: Remove unused have_library function Also remove the hence unused testsuite option `--test-package-db`. Fixes #24342 - - - - - 5b7fa20c by Jade at 2024-01-19T21:55:53-05:00 Fix Spelling in the compiler Tracking: #16591 - - - - - 09875f48 by Matthew Pickering at 2024-01-20T12:20:44-05:00 testsuite: Implement `isInTreeCompiler` in a more robust way Just a small refactoring to avoid redundantly specifying the same strings in two different places. - - - - - 0d12b987 by Jade at 2024-01-20T12:21:20-05:00 Change maintainer email from cvs-ghc at haskell.org to ghc-devs at haskell.org. Fixes #22142 - - - - - 1fa1c00c by Jade at 2024-01-23T19:17:03-05:00 Enhance Documentation of functions exported by Data.Function This patch aims to improve the documentation of functions exported in Data.Function Tracking: #17929 Fixes: #10065 - - - - - ab47a43d by Jade at 2024-01-23T19:17:39-05:00 Improve documentation of hGetLine. - Add explanation for whether a newline is returned - Add examples Fixes #14804 - - - - - dd4af0e5 by Cheng Shao at 2024-01-23T19:18:17-05:00 Fix genapply for cross-compilation by nuking fragile CPP logic This commit fixes incorrectly built genapply when cross compiling (#24347) by nuking all fragile CPP logic in it from the orbit. All target-specific info are now read from DerivedConstants.h at runtime, see added note for details. Also removes a legacy Makefile and adds haskell language server support for genapply. - - - - - 0cda2b8b by Cheng Shao at 2024-01-23T19:18:17-05:00 rts: enable wasm32 register mapping The wasm backend didn't properly make use of all Cmm global registers due to #24347. Now that it is fixed, this patch re-enables full register mapping for wasm32, and we can now generate smaller & faster wasm modules that doesn't always spill arguments onto the stack. Fixes #22460 #24152. - - - - - 0325a6e5 by Greg Steuck at 2024-01-24T01:29:44-05:00 Avoid utf8 in primops.txt.pp comments They don't make it through readFile' without explicitly setting the encoding. See https://gitlab.haskell.org/ghc/ghc/-/issues/17755 - - - - - 1aaf0bd8 by David Binder at 2024-01-24T01:30:20-05:00 Bump hpc and hpc-bin submodule Bump hpc to 0.7.0.1 Bump hpc-bin to commit d1780eb2 - - - - - e693a4e8 by Ben Gamari at 2024-01-24T01:30:56-05:00 testsuite: Ignore stderr in T8089 Otherwise spurious "Killed: 9" messages to stderr may cause the test to fail. Fixes #24361. - - - - - a40f4ab2 by sheaf at 2024-01-24T14:04:33-05:00 Fix FMA instruction on LLVM We were emitting the wrong instructions for fused multiply-add operations on LLVM: - the instruction name is "llvm.fma.f32" or "llvm.fma.f64", not "fmadd" - LLVM does not support other instructions such as "fmsub"; instead we implement these by flipping signs of some arguments - the instruction is an LLVM intrinsic, which requires handling it like a normal function call instead of a machine instruction Fixes #24223 - - - - - 69abc786 by Andrei Borzenkov at 2024-01-24T14:05:09-05:00 Add changelog entry for renaming tuples from (,,...,,) to Tuple<n> (24291) - - - - - 0ac8f385 by Cheng Shao at 2024-01-25T00:27:48-05:00 compiler: remove unused GHC.Linker module The GHC.Linker module is empty and unused, other than as a hack for the make build system. We can remove it now that make is long gone; the note is moved to GHC.Linker.Loader instead. - - - - - 699da01b by Hécate Moonlight at 2024-01-25T00:28:27-05:00 Clarification for newtype constructors when using `coerce` - - - - - b2d8cd85 by Matt Walker at 2024-01-26T09:50:08-05:00 Fix #24308 Add tests for semicolon separated where clauses - - - - - 0da490a1 by Ben Gamari at 2024-01-26T17:34:41-05:00 hsc2hs: Bump submodule - - - - - 3f442fd2 by Ben Gamari at 2024-01-26T17:34:41-05:00 Bump containers submodule to 0.7 - - - - - 82a1c656 by Sebastian Nagel at 2024-01-29T02:32:40-05:00 base: with{Binary}File{Blocking} only annotates own exceptions Fixes #20886 This ensures that inner, unrelated exceptions are not misleadingly annotated with the opened file. - - - - - 9294a086 by Andreas Klebinger at 2024-01-29T02:33:15-05:00 Fix fma warning when using llvm on aarch64. On aarch64 fma is always on so the +fma flag doesn't exist for that target. Hence no need to try and pass +fma to llvm. Fixes #24379 - - - - - ced2e731 by sheaf at 2024-01-29T17:27:12-05:00 No shadowing warnings for NoFieldSelector fields This commit ensures we don't emit shadowing warnings when a user shadows a field defined with NoFieldSelectors. Fixes #24381 - - - - - 8eeadfad by Patrick at 2024-01-29T17:27:51-05:00 Fix bug wrong span of nested_doc_comment #24378 close #24378 1. Update the start position of span in `nested_doc_comment` correctly. and hence the spans of identifiers of haddoc can be computed correctly. 2. add test `HaddockSpanIssueT24378`. - - - - - a557580f by Alexey Radkov at 2024-01-30T19:41:52-05:00 Fix irrelevant dodgy-foreign-imports warning on import f-pointers by value A test *сс018* is attached (not sure about the naming convention though). Note that without the fix, the test fails with the *dodgy-foreign-imports* warning passed to stderr. The warning disappears after the fix. GHC shouldn't warn on imports of natural function pointers from C by value (which is feasible with CApiFFI), such as ```haskell foreign import capi "cc018.h value f" f :: FunPtr (Int -> IO ()) ``` where ```c void (*f)(int); ``` See a related real-world use-case [here](https://gitlab.com/daniel-casanueva/pcre-light/-/merge_requests/17). There, GHC warns on import of C function pointer `pcre_free`. - - - - - ca99efaf by Alexey Radkov at 2024-01-30T19:41:53-05:00 Rename test cc018 -> T24034 - - - - - 88c38dd5 by Ben Gamari at 2024-01-30T19:42:28-05:00 rts/TraverseHeap.c: Ensure that PosixSource.h is included first - - - - - ca2e919e by Simon Peyton Jones at 2024-01-31T09:29:45+00:00 Make decomposeRuleLhs a bit more clever This fixes #24370 by making decomposeRuleLhs undertand dictionary /functions/ as well as plain /dictionaries/ - - - - - 94ce031d by Teo Camarasu at 2024-02-01T05:49:49-05:00 doc: Add -Dn flag to user guide Resolves #24394 - - - - - 31553b11 by Ben Gamari at 2024-02-01T12:21:29-05:00 cmm: Introduce MO_RelaxedRead In hand-written Cmm it can sometimes be necessary to atomically load from memory deep within an expression (e.g. see the `CHECK_GC` macro). This MachOp provides a convenient way to do so without breaking the expression into multiple statements. - - - - - 0785cf81 by Ben Gamari at 2024-02-01T12:21:29-05:00 codeGen: Use relaxed accesses in ticky bumping - - - - - be423dda by Ben Gamari at 2024-02-01T12:21:29-05:00 base: use atomic write when updating timer manager - - - - - 8a310e35 by Ben Gamari at 2024-02-01T12:21:29-05:00 Use relaxed atomics to manipulate TSO status fields - - - - - d6809ee4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Add necessary barriers when manipulating TSO owner - - - - - 39e3ac5d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Use `switch` to branch on why_blocked This is a semantics-preserving refactoring. - - - - - 515eb33d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix synchronization on thread blocking state We now use a release barrier whenever we update a thread's blocking state. This required widening StgTSO.why_blocked as AArch64 does not support atomic writes on 16-bit values. - - - - - eb38812e by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadPaused This only affects an assertion in the debug RTS and only needs relaxed ordering. - - - - - 26c48dd6 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadStatus# - - - - - 6af43ab4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in Interpreter's preemption check - - - - - 9502ad3c by Ben Gamari at 2024-02-01T12:21:29-05:00 rts/Messages: Fix data race - - - - - 60802db5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts/Prof: Fix data race - - - - - ef8ccef5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use relaxed ordering on dirty/clean info tables updates When changing the dirty/clean state of a mutable object we needn't have any particular ordering. - - - - - 76fe2b75 by Ben Gamari at 2024-02-01T12:21:30-05:00 codeGen: Use relaxed-read in closureInfoPtr - - - - - a6316eb4 by Ben Gamari at 2024-02-01T12:21:30-05:00 STM: Use acquire loads when possible Full sequential consistency is not needed here. - - - - - 6bddfd3d by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use fence rather than redundant load Previously we would use an atomic load to ensure acquire ordering. However, we now have `ACQUIRE_FENCE_ON`, which allows us to express this more directly. - - - - - 55c65dbc by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Fix data races in profiling timer - - - - - 856b5e75 by Ben Gamari at 2024-02-01T12:21:30-05:00 Add Note [C11 memory model] - - - - - 6534da24 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: move generic cmm optimization logic in NCG to a standalone module This commit moves GHC.CmmToAsm.cmmToCmm to a standalone module, GHC.Cmm.GenericOpt. The main motivation is enabling this logic to be run in the wasm backend NCG code, which is defined in other modules that's imported by GHC.CmmToAsm, causing a cyclic dependency issue. - - - - - 87e34888 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: explicitly disable PIC in wasm32 NCG This commit explicitly disables the ncgPIC flag for the wasm32 target. The wasm backend doesn't support PIC for the time being. - - - - - c6ce242e by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: enable generic cmm optimizations in wasm backend NCG This commit enables the generic cmm optimizations in other NCGs to be run in the wasm backend as well, followed by a late cmm control-flow optimization pass. The added optimizations do catch some corner cases not handled by the pre-NCG cmm pipeline and are useful in generating smaller CFGs. - - - - - 151dda4e by Andrei Borzenkov at 2024-02-01T12:22:43-05:00 Namespacing for WARNING/DEPRECATED pragmas (#24396) New syntax for WARNING and DEPRECATED pragmas was added, namely namespace specifierss: namespace_spec ::= 'type' | 'data' | {- empty -} warning ::= warning_category namespace_spec namelist strings deprecation ::= namespace_spec namelist strings A new data type was introduced to represent these namespace specifiers: data NamespaceSpecifier = NoSpecifier | TypeNamespaceSpecifier (EpToken "type") | DataNamespaceSpecifier (EpToken "data") Extension field XWarning now contains this NamespaceSpecifier. lookupBindGroupOcc function was changed: it now takes NamespaceSpecifier and checks that the namespace of the found names matches the passed flag. With this change {-# WARNING data D "..." #-} pragma will only affect value namespace and {-# WARNING type D "..." #-} will only affect type namespace. The same logic is applicable to DEPRECATED pragmas. Finding duplicated warnings inside rnSrcWarnDecls now takes into consideration NamespaceSpecifier flag to allow warnings with the same names that refer to different namespaces. - - - - - 38c3afb6 by Bryan Richter at 2024-02-01T12:23:19-05:00 CI: Disable the test-cabal-reinstall job Fixes #24363 - - - - - 27020458 by Matthew Craven at 2024-02-03T01:53:26-05:00 Bump bytestring submodule to something closer to 0.12.1 ...mostly so that 16d6b7e835ffdcf9b894e79f933dd52348dedd0c (which reworks unaligned writes in Builder) and the stuff in https://github.com/haskell/bytestring/pull/631 can see wider testing. The less-terrible code for unaligned writes used in Builder on hosts not known to be ulaigned-friendly also takes less effort for GHC to compile, resulting in a metric decrease for T21839c on some platforms. The metric increase on T21839r is caused by the unrelated commit 750dac33465e7b59100698a330b44de7049a345c. It perhaps warrants further analysis and discussion (see #23822) but is not critical. Metric Decrease: T21839c Metric Increase: T21839r - - - - - cdddeb0f by Rodrigo Mesquita at 2024-02-03T01:54:02-05:00 Work around autotools setting C11 standard in CC/CXX In autoconf >=2.70, C11 is set by default for $CC and $CXX via the -std=...11 flag. In this patch, we split the "-std" flag out of the $CC and $CXX variables, which we traditionally assume to be just the executable name/path, and move it to $CFLAGS/$CXXFLAGS instead. Fixes #24324 - - - - - 5ff7cc26 by Apoorv Ingle at 2024-02-03T13:14:46-06:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - The change is detailed in - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` - Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - Adds new datatypes: - `GHC.Hs.Expr.XXExprGhcRn`: new datatype makes this expansion work easier 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - Ensures warnings such as 1. Pattern match checks 2. Failable patterns 3. non-() return in body statements are preserved - Kill `HsMatchCtxt` in favor of `TcMatchAltChecker` - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) Also repoint haddock to the right submodule so that the test (haddockHypsrcTest) pass Metric Increase 'compile_time/bytes allocated': T9020 The testcase is a pathalogical example of a `do`-block with many statements that do nothing. Given that we are expanding the statements into function binds, we will have to bear a (small) 2% cost upfront in the compiler to unroll the statements. - - - - - 0df8ce27 by Vladislav Zavialov at 2024-02-04T03:55:14-05:00 Reduce parser allocations in allocateCommentsP In the most common case, the comment queue is empty, so we can skip the work of processing it. This reduces allocations by about 10% in the parsing001 test. Metric Decrease: MultiLayerModulesRecomp parsing001 - - - - - cfd68290 by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Stop dropping a case whose binder is demanded This MR fixes #24251. See Note [Case-to-let for strictly-used binders] in GHC.Core.Opt.Simplify.Iteration, plus #24251, for lots of discussion. Final Nofib changes over 0.1%: +----------------------------------------- | imaginary/digits-of-e2 -2.16% | imaginary/rfib -0.15% | real/fluid -0.10% | real/gamteb -1.47% | real/gg -0.20% | real/maillist +0.19% | real/pic -0.23% | real/scs -0.43% | shootout/n-body -0.41% | shootout/spectral-norm -0.12% +======================================== | geom mean -0.05% Pleasingly, overall executable size is down by just over 1%. Compile times (in perf/compiler) wobble around a bit +/- 0.5%, but the geometric mean is -0.1% which seems good. - - - - - e4d137bb by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Add Note [Bangs in Integer functions] ...to document the bangs in the functions in GHC.Num.Integer - - - - - ce90f12f by Andrei Borzenkov at 2024-02-05T17:59:09-05:00 Hide WARNING/DEPRECATED namespacing under -XExplicitNamespaces (#24396) - - - - - e2ea933f by Simon Peyton Jones at 2024-02-06T10:12:04-05:00 Refactoring in preparation for lazy skolemisation * Make HsMatchContext and HsStmtContext be parameterised over the function name itself, rather than over the pass. See [mc_fun field of FunRhs] in Language.Haskell.Syntax.Expr - Replace types HsMatchContext GhcPs --> HsMatchContextPs HsMatchContext GhcRn --> HsMatchContextRn HsMatchContext GhcTc --> HsMatchContextRn (sic! not Tc) HsStmtContext GhcRn --> HsStmtContextRn - Kill off convertHsMatchCtxt * Split GHC.Tc.Type.BasicTypes.TcSigInfo so that TcCompleteSig (describing a complete user-supplied signature) is its own data type. - Split TcIdSigInfo(CompleteSig, PartialSig) into TcCompleteSig(CSig) TcPartialSig(PSig) - Use TcCompleteSig in tcPolyCheck, CheckGen - Rename types and data constructors: TcIdSigInfo --> TcIdSig TcPatSynInfo(TPSI) --> TcPatSynSig(PatSig) - Shuffle around helper functions: tcSigInfoName (moved to GHC.Tc.Types.BasicTypes) completeSigPolyId_maybe (moved to GHC.Tc.Types.BasicTypes) tcIdSigName (inlined and removed) tcIdSigLoc (introduced) - Rearrange the pattern match in chooseInferredQuantifiers * Rename functions and types: tcMatchesCase --> tcCaseMatches tcMatchesFun --> tcFunBindMatches tcMatchLambda --> tcLambdaMatches tcPats --> tcMatchPats matchActualFunTysRho --> matchActualFunTys matchActualFunTySigma --> matchActualFunTy * Add HasDebugCallStack constraints to: mkBigCoreVarTupTy, mkBigCoreTupTy, boxTy, mkPiTy, mkPiTys, splitAppTys, splitTyConAppNoView_maybe * Use `penv` from the outer context in the inner loop of GHC.Tc.Gen.Pat.tcMultiple * Move tcMkVisFunTy, tcMkInvisFunTy, tcMkScaledFunTys down the file, factor out and export tcMkScaledFunTy. * Move isPatSigCtxt down the file. * Formatting and comments Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - f5d3e03c by Andrei Borzenkov at 2024-02-06T10:12:04-05:00 Lazy skolemisation for @a-binders (#17594) This patch is a preparation for @a-binders implementation. The main changes are: * Skolemisation is now prepared to deal with @binders. See Note [Skolemisation overview] in GHC.Tc.Utils.Unify. Most of the action is in - Utils.Unify.matchExpectedFunTys - Gen.Pat.tcMatchPats - Gen.Expr.tcPolyExprCheck - Gen.Binds.tcPolyCheck Some accompanying refactoring: * I found that funTyConAppTy_maybe was doing a lot of allocation, and rejigged userTypeError_maybe to avoid calling it. - - - - - 532993c8 by Zubin Duggal at 2024-02-06T10:12:41-05:00 driver: Really don't lose track of nodes when we fail to resolve cycles This fixes a bug in 8db8d2fd1c881032b1b360c032b6d9d072c11723, where we could lose track of acyclic components at the start of an unresolved cycle. We now ensure we never loose track of any of these components. As T24275 demonstrates, a "cyclic" SCC might not really be a true SCC: When viewed without boot files, we have a single SCC ``` [REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A [main:T24275A {-# SOURCE #-}]] ``` But with boot files this turns into ``` [NONREC main:T24275B {-# SOURCE #-} [], REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A {-# SOURCE #-} [main:T24275B], NONREC main:T24275A [main:T24275A {-# SOURCE #-}]] ``` Note that this is truly not an SCC, as no nodes are reachable from T24275B.hs-boot. However, we treat this entire group as a single "SCC" because it seems so when we analyse the graph without taking boot files into account. Indeed, we must return a single ResolvedCycle element in the BuildPlan for this as described in Note [Upsweep]. However, since after resolving this is not a true SCC anymore, `findCycle` fails to find a cycle and we have a sub-optimal error message as a result. To handle this, I extended `findCycle` to not assume its input is an SCC, and to try harder to find cycles in its input. Fixes #24275 - - - - - b35dd613 by Zubin Duggal at 2024-02-06T10:13:17-05:00 GHCi: Lookup breakpoint CCs in the correct module We need to look up breakpoint CCs in the module that the breakpoint points to, and not the current module. Fixes #24327 - - - - - b09e6958 by Zubin Duggal at 2024-02-06T10:13:17-05:00 testsuite: Add test for #24327 - - - - - 569b4c10 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add compile_artifact, ignore_extension flag In b521354216f2821e00d75f088d74081d8b236810 the testsuite gained the capability to collect generic metrics. But this assumed that the test was not linking and producing artifacts and we only wanted to track object files, interface files, or build artifacts from the compiler build. However, some backends, such as the JS backend, produce artifacts when compiling, such as the jsexe directory which we want to track. This patch: - tweaks the testsuite to collect generic metrics on any build artifact in the test directory. - expands the exe_extension function to consider windows and adds the ignore_extension flag. - Modifies certain tests to add the ignore_extension flag. Tests such as heaprof002 expect a .ps file, but on windows without ignore_extensions the testsuite will look for foo.exe.ps. Hence the flag. - adds the size_hello_artifact test - - - - - 75a31379 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add wasm_arch, heapprof002 wasm extension - - - - - c9731d6d by Rodrigo Mesquita at 2024-02-07T03:07:03-05:00 Synchronize bindist configure for #24324 In cdddeb0f1280b40cc194028bbaef36e127175c4c, we set up a workaround for #24324 in the in-tree configure script, but forgot to update the bindist configure script accordingly. This updates it. - - - - - d309f4e7 by Matthew Pickering at 2024-02-07T03:07:38-05:00 distrib/configure: Fix typo in CONF_GCC_LINKER_OPTS_STAGE2 variable Instead we were setting CONF_GCC_LINK_OPTS_STAGE2 which meant that we were missing passing `--target` when invoking the linker. Fixes #24414 - - - - - 77db84ab by Ben Gamari at 2024-02-08T00:35:22-05:00 llvmGen: Adapt to allow use of new pass manager. We now must use `-passes` in place of `-O<n>` due to #21936. Closes #21936. - - - - - 3c9ddf97 by Matthew Pickering at 2024-02-08T00:35:59-05:00 testsuite: Mark length001 as fragile on javascript Modifying the timeout multiplier is not a robust way to get this test to reliably fail. Therefore we mark it as fragile until/if javascript ever supports the stack limit. - - - - - 20b702b5 by Matthew Pickering at 2024-02-08T00:35:59-05:00 Javascript: Don't filter out rtsDeps list This logic appears to be incorrect as it would drop any dependency which was not in a direct dependency of the package being linked. In the ghc-internals split this started to cause errors because `ghc-internal` is not a direct dependency of most packages, and hence important symbols to keep which are hard coded into the js runtime were getting dropped. - - - - - 2df96366 by Ben Gamari at 2024-02-08T00:35:59-05:00 base: Cleanup whitespace in cbits - - - - - 44f6557a by Ben Gamari at 2024-02-08T00:35:59-05:00 Move `base` to `ghc-internal` Here we move a good deal of the implementation of `base` into a new package, `ghc-internal` such that it can be evolved independently from the user-visible interfaces of `base`. While we want to isolate implementation from interfaces, naturally, we would like to avoid turning `base` into a mere set of module re-exports. However, this is a non-trivial undertaking for a variety of reasons: * `base` contains numerous known-key and wired-in things, requiring corresponding changes in the compiler * `base` contains a significant amount of C code and corresponding autoconf logic, which is very fragile and difficult to break apart * `base` has numerous import cycles, which are currently dealt with via carefully balanced `hs-boot` files * We must not break existing users To accomplish this migration, I tried the following approaches: * [Split-GHC.Base]: Break apart the GHC.Base knot to allow incremental migration of modules into ghc-internal: this knot is simply too intertwined to be easily pulled apart, especially given the rather tricky import cycles that it contains) * [Move-Core]: Moving the "core" connected component of base (roughly 150 modules) into ghc-internal. While the Haskell side of this seems tractable, the C dependencies are very subtle to break apart. * [Move-Incrementally]: 1. Move all of base into ghc-internal 2. Examine the module structure and begin moving obvious modules (e.g. leaves of the import graph) back into base 3. Examine the modules remaining in ghc-internal, refactor as necessary to facilitate further moves 4. Go to (2) iterate until the cost/benefit of further moves is insufficient to justify continuing 5. Rename the modules moved into ghc-internal to ensure that they don't overlap with those in base 6. For each module moved into ghc-internal, add a shim module to base with the declarations which should be exposed and any requisite Haddocks (thus guaranteeing that base will be insulated from changes in the export lists of modules in ghc-internal Here I am using the [Move-Incrementally] approach, which is empirically the least painful of the unpleasant options above Bumps haddock submodule. Metric Decrease: haddock.Cabal haddock.base Metric Increase: MultiComponentModulesRecomp T16875 size_hello_artifact - - - - - e8fb2451 by Vladislav Zavialov at 2024-02-08T00:36:36-05:00 Haddock comments on infix constructors (#24221) Rewrite the `HasHaddock` instance for `ConDecl GhcPs` to account for infix constructors. This change fixes a Haddock regression (introduced in 19e80b9af252) that affected leading comments on infix data constructor declarations: -- | Docs for infix constructor | Int :* Bool The comment should be associated with the data constructor (:*), not with its left-hand side Int. - - - - - 9060d55b by Ben Gamari at 2024-02-08T00:37:13-05:00 Add os-string as a boot package Introduces `os-string` submodule. This will be necessary for `filepath-1.5`. - - - - - 9d65235a by Ben Gamari at 2024-02-08T00:37:13-05:00 gitignore: Ignore .hadrian_ghci_multi/ - - - - - d7ee12ea by Ben Gamari at 2024-02-08T00:37:13-05:00 hadrian: Set -this-package-name When constructing the GHC flags for a package Hadrian must take care to set `-this-package-name` in addition to `-this-unit-id`. This hasn't broken until now as we have not had any uses of qualified package imports. However, this will change with `filepath-1.5` and the corresponding `unix` bump, breaking `hadrian/multi-ghci`. - - - - - f2dffd2e by Ben Gamari at 2024-02-08T00:37:13-05:00 Bump filepath to 1.5.0.0 Required bumps of the following submodules: * `directory` * `filepath` * `haskeline` * `process` * `unix` * `hsc2hs` * `Win32` * `semaphore-compat` and the addition of `os-string` as a boot package. - - - - - ab533e71 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Use specific clang assembler when compiling with -fllvm There are situations where LLVM will produce assembly which older gcc toolchains can't handle. For example on Deb10, it seems that LLVM >= 13 produces assembly which the default gcc doesn't support. A more robust solution in the long term is to require a specific LLVM compatible assembler when using -fllvm. Fixes #16354 - - - - - c32b6426 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update CI images with LLVM 15, ghc-9.6.4 and cabal-install-3.10.2.0 - - - - - 5fcd58be by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update bootstrap plans for 9.4.8 and 9.6.4 - - - - - 707a32f5 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Add alpine 3_18 release job This is mainly experimental and future proofing to enable a smooth transition to newer alpine releases once 3_12 is too old. - - - - - c37931b3 by John Ericson at 2024-02-08T06:39:05-05:00 Generate LLVM min/max bound policy via Hadrian Per #23966, I want the top-level configure to only generate configuration data for Hadrian, not do any "real" tasks on its own. This is part of that effort --- one less file generated by it. (It is still done with a `.in` file, so in a future world non-Hadrian also can easily create this file.) Split modules: - GHC.CmmToLlvm.Config - GHC.CmmToLlvm.Version - GHC.CmmToLlvm.Version.Bounds - GHC.CmmToLlvm.Version.Type This also means we can get rid of the silly `unused.h` introduced in !6803 / 7dfcab2f4bcb7206174ea48857df1883d05e97a2 as temporary kludge. Part of #23966 - - - - - 9f987235 by Apoorv Ingle at 2024-02-08T06:39:42-05:00 Enable mdo statements to use HsExpansions Fixes: #24411 Added test T24411 for regression - - - - - 762b2120 by Jade at 2024-02-08T15:17:15+00:00 Improve Monad, Functor & Applicative docs This patch aims to improve the documentation of Functor, Applicative, Monad and related symbols. The main goal is to make it more consistent and make accessible. See also: !10979 (closed) and !10985 (closed) Ticket #17929 Updates haddock submodule - - - - - 151770ca by Josh Meredith at 2024-02-10T14:28:15-05:00 JavaScript codegen: Use GHC's tag inference where JS backend-specific evaluation inference was previously used (#24309) - - - - - 2e880635 by Zubin Duggal at 2024-02-10T14:28:51-05:00 ci: Allow release-hackage-lint to fail Otherwise it blocks the ghcup metadata pipeline from running. - - - - - b0293f78 by Matthew Pickering at 2024-02-10T14:29:28-05:00 rts: eras profiling mode The eras profiling mode is useful for tracking the life-time of closures. When a closure is written, the current era is recorded in the profiling header. This records the era in which the closure was created. * Enable with -he * User mode: Use functions ghc-experimental module GHC.Profiling.Eras to modify the era * Automatically: --automatic-era-increment, increases the user era on major collections * The first era is era 1 * -he<era> can be used with other profiling modes to select a specific era If you just want to record the era but not to perform heap profiling you can use `-he --no-automatic-heap-samples`. https://well-typed.com/blog/2024/01/ghc-eras-profiling/ Fixes #24332 - - - - - be674a2c by Jade at 2024-02-10T14:30:04-05:00 Adjust error message for trailing whitespace in as-pattern. Fixes #22524 - - - - - 53ef83f9 by doyougnu at 2024-02-10T14:30:47-05:00 gitlab: js: add codeowners Fixes: - #24409 Follow on from: - #21078 and MR !9133 - When we added the JS backend this was forgotten. This patch adds the rightful codeowners. - - - - - 8bbe12f2 by Matthew Pickering at 2024-02-10T14:31:23-05:00 Bump CI images so that alpine3_18 image includes clang15 The only changes here are that clang15 is now installed on the alpine-3_18 image. - - - - - df9fd9f7 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: handle stored null StablePtr Some Haskell codes unsafely cast StablePtr into ptr to compare against NULL. E.g. in direct-sqlite: if castStablePtrToPtr aggStPtr /= nullPtr then where `aggStPtr` is read (`peek`) from zeroed memory initially. We fix this by giving these StablePtr the same representation as other null pointers. It's safe because StablePtr at offset 0 is unused (for this exact reason). - - - - - 55346ede by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: disable MergeObjsMode test This isn't implemented for JS backend objects. - - - - - aef587f6 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: add support for linking C sources Support linking C sources with JS output of the JavaScript backend. See the added documentation in the users guide. The implementation simply extends the JS linker to use the objects (.o) that were already produced by the emcc compiler and which were filtered out previously. I've also added some options to control the link with C functions (see the documentation about pragmas). With this change I've successfully compiled the direct-sqlite package which embeds the sqlite.c database code. Some wrappers are still required (see the documentation about wrappers) but everything generic enough to be reused for other libraries have been integrated into rts/js/mem.js. - - - - - b71b392f by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: avoid EMCC logging spurious failure emcc would sometime output messages like: cache:INFO: generating system asset: symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json" for subsequent builds) cache:INFO: - ok Cf https://github.com/emscripten-core/emscripten/issues/18607 This breaks our tests matching the stderr output. We avoid this by setting EMCC_LOGGING=0 - - - - - ff2c0cc9 by Simon Peyton Jones at 2024-02-12T12:19:17-05:00 Remove a dead comment Just remove an out of date block of commented-out code, and tidy up the relevant Notes. See #8317. - - - - - bedb4f0d by Teo Camarasu at 2024-02-12T18:50:33-05:00 nonmoving: Add support for heap profiling Add support for heap profiling while using the nonmoving collector. We greatly simply the implementation by disabling concurrent collection for GCs when heap profiling is enabled. This entails that the marked objects on the nonmoving heap are exactly the live objects. Note that we match the behaviour for live bytes accounting by taking the size of objects on the nonmoving heap to be that of the segment's block rather than the object itself. Resolves #22221 - - - - - d0d5acb5 by Teo Camarasu at 2024-02-12T18:51:09-05:00 doc: Add requires prof annotation to options that require it Resolves #24421 - - - - - 57bb8c92 by Cheng Shao at 2024-02-13T14:07:49-05:00 deriveConstants: add needed constants for wasm backend This commit adds needed constants to deriveConstants. They are used by RTS code in the wasm backend to support the JSFFI logic. - - - - - 615eb855 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms The pure Haskell implementation causes i386 regression in unrelated work that can be fixed by using C-based atomic increment, see added comment for details. - - - - - a9918891 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow JSFFI for wasm32 This commit allows the javascript calling convention to be used when the target platform is wasm32. - - - - - 8771a53b by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow boxed JSVal as a foreign type This commit allows the boxed JSVal type to be used as a foreign argument/result type. - - - - - 053c92b3 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: ensure ctors have the right priority on wasm32 This commit fixes the priorities of ctors generated by GHC codegen on wasm32, see the referred note for details. - - - - - b7942e0a by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JSFFI desugar logic for wasm32 This commit adds JSFFI desugar logic for the wasm backend. - - - - - 2c1dca76 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JavaScriptFFI to supported extension list on wasm32 This commit adds JavaScriptFFI as a supported extension when the target platform is wasm32. - - - - - 9ad0e2b4 by Cheng Shao at 2024-02-13T14:07:49-05:00 rts/ghc-internal: add JSFFI support logic for wasm32 This commit adds rts/ghc-internal logic to support the wasm backend's JSFFI functionality. - - - - - e9ebea66 by Cheng Shao at 2024-02-13T14:07:49-05:00 ghc-internal: fix threadDelay for wasm in browsers This commit fixes broken threadDelay for wasm when it runs in browsers, see added note for detailed explanation. - - - - - f85f3fdb by Cheng Shao at 2024-02-13T14:07:49-05:00 utils: add JSFFI utility code This commit adds JavaScript util code to utils to support the wasm backend's JSFFI functionality: - jsffi/post-link.mjs, a post-linker to process the linked wasm module and emit a small complement JavaScript ESM module to be used with it at runtime - jsffi/prelude.js, a tiny bit of prelude code as the JavaScript side of runtime logic - jsffi/test-runner.mjs, run the jsffi test cases Co-authored-by: amesgen <amesgen at amesgen.de> - - - - - 77e91500 by Cheng Shao at 2024-02-13T14:07:49-05:00 hadrian: distribute jsbits needed for wasm backend's JSFFI support The post-linker.mjs/prelude.js files are now distributed in the bindist libdir, so when using the wasm backend's JSFFI feature, the user wouldn't need to fetch them from a ghc checkout manually. - - - - - c47ba1c3 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add opts.target_wrapper This commit adds opts.target_wrapper which allows overriding the target wrapper on a per test case basis when testing a cross target. This is used when testing the wasm backend's JSFFI functionality; the rest of the cases are tested using wasmtime, though the jsffi cases are tested using the node.js based test runner. - - - - - 8e048675 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: T22774 should work for wasm JSFFI T22774 works since the wasm backend now supports the JSFFI feature. - - - - - 1d07f9a6 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add JSFFI test cases for wasm backend This commit adds a few test cases for the wasm backend's JSFFI functionality, as well as a simple README to instruct future contributors to add new test cases. - - - - - b8997080 by Cheng Shao at 2024-02-13T14:07:49-05:00 docs: add documentation for wasm backend JSFFI This commit adds changelog and user facing documentation for the wasm backend's JSFFI feature. - - - - - ffeb000d by David Binder at 2024-02-13T14:08:30-05:00 Add tests from libraries/process/tests and libraries/Win32/tests to GHC These tests were previously part of the libraries, which themselves are submodules of the GHC repository. This commit moves the tests directly to the GHC repository. - - - - - 5a932cf2 by David Binder at 2024-02-13T14:08:30-05:00 Do not execute win32 tests on non-windows runners - - - - - 500d8cb8 by Jade at 2024-02-13T14:09:07-05:00 prevent GHCi (and runghc) from suggesting other symbols when not finding main Fixes: #23996 - - - - - b19ec331 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: update xxHash to v0.8.2 - - - - - 4a97bdb8 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: use XXH3_64bits hash on all 64-bit platforms This commit enables XXH3_64bits hash to be used on all 64-bit platforms. Previously it was only enabled on x86_64, so platforms like aarch64 silently falls back to using XXH32 which degrades the hashing function quality. - - - - - ee01de7d by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: define XXH_INLINE_ALL This commit cleans up how we include the xxhash.h header and only define XXH_INLINE_ALL, which is sufficient to inline the xxHash functions without symbol collision. - - - - - 0e01e1db by Alan Zimmerman at 2024-02-14T02:13:22-05:00 EPA: Move EpAnn out of extension points Leaving a few that are too tricky, maybe some other time. Also - remove some unneeded helpers from Parser.y - reduce allocations with strictness annotations Updates haddock submodule Metric Decrease: parsing001 - - - - - de589554 by Andreas Klebinger at 2024-02-14T02:13:59-05:00 Fix ffi callbacks with >6 args and non-64bit args. Check for ptr/int arguments rather than 64-bit width arguments when counting integer register arguments. The old approach broke when we stopped using exclusively W64-sized types to represent sub-word sized integers. Fixes #24314 - - - - - 325b7613 by Ben Gamari at 2024-02-14T14:27:45-05:00 rts/EventLog: Place eliminate duplicate strlens Previously many of the `post*` implementations would first compute the length of the event's strings in order to determine the event length. Later we would then end up computing the length yet again in `postString`. Now we instead pass the string length to `postStringLen`, avoiding the repeated work. - - - - - 8aafa51c by Ben Gamari at 2024-02-14T14:27:46-05:00 rts/eventlog: Place upper bound on IPE string field lengths The strings in IPE events may be of unbounded length. Limit the lengths of these fields to 64k characters to ensure that we don't exceed the maximum event length. - - - - - 0e60d52c by Zubin Duggal at 2024-02-14T14:27:46-05:00 rts: drop unused postString function - - - - - d8d1333a by Cheng Shao at 2024-02-14T14:28:23-05:00 compiler/rts: fix wasm unreg regression This commit fixes two wasm unreg regressions caught by a nightly pipeline: - Unknown stg_scheduler_loopzh symbol when compiling scheduler.cmm - Invalid _hs_constructor(101) function name when handling ctor - - - - - 264a4fa9 by Owen Shepherd at 2024-02-15T09:41:06-05:00 feat: Add sortOn to Data.List.NonEmpty Adds `sortOn` to `Data.List.NonEmpty`, and adds comments describing when to use it, compared to `sortWith` or `sortBy . comparing`. The aim is to smooth out the API between `Data.List`, and `Data.List.NonEmpty`. This change has been discussed in the [clc issue](https://github.com/haskell/core-libraries-committee/issues/227). - - - - - b57200de by Fendor at 2024-02-15T09:41:47-05:00 Prefer RdrName over OccName for looking up locations in doc renaming step Looking up by OccName only does not take into account when functions are only imported in a qualified way. Fixes issue #24294 Bump haddock submodule to include regression test - - - - - 8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00 JS: add simple optimizer The simple optimizer reduces the size of the code generated by the JavaScript backend without the complexity and performance penalty of the optimizer in GHCJS. Also see #22736 Metric Decrease: libdir size_hello_artifact - - - - - 20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00 base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and modifies the base API to reflect the new RTS flag. CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243 Fixes #24337 - - - - - 08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00 base: export System.Mem.performBlockingMajorGC The corresponding C function was introduced in ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264. Resolves #24228 The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230 Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00 Fix C output for modern C initiative GCC 14 on aarch64 rejects the C code written by GHC with this kind of error: error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion] 68 | *(ffi_arg*)resp = cret; | ^ Add the correct cast. For more information on this see: https://fedoraproject.org/wiki/Changes/PortingToModernC Tested-by: Richard W.M. Jones <rjones at redhat.com> - - - - - 5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00 Bump bytestring submodule to 0.12.1.0 - - - - - 902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00 Add missing BCO handling in scavenge_one. - - - - - 97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Make cast between words and floats real primops (#24331) First step towards fixing #24331. Replace foreign prim imports with real primops. - - - - - a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: add constant folding for bitcast between float and word (#24331) - - - - - 5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: replace stack checks with assertions in casting primops There are RESERVED_STACK_WORDS free words (currently 21) on the stack, so omit the checks. Suggested by Cheng Shao. - - - - - 401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00 Reexport primops from GHC.Float + add deprecation - - - - - 4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00 rts/Hash: Don't iterate over chunks if we don't need to free data When freeing a `HashTable` there is no reason to walk over the hash list before freeing it if the user has not given us a `dataFreeFun`. Noticed while looking at #24410. - - - - - bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00 compiler: add SEQ_CST fence support In addition to existing Acquire/Release fences, this commit adds SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a fence that enforces total memory ordering. The following logic is added: - The MO_SeqCstFence callish MachOp - The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h - MO_SeqCstFence lowering logic in every single GHC codegen backend - - - - - 2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00 testsuite: fix hs_try_putmvar002 for targets without pthread.h hs_try_putmvar002 includes pthread.h and doesn't work on targets without this header (e.g. wasm32). It doesn't need to include this header at all. This was previously unnoticed by wasm CI, though recent toolchain upgrade brought in upstream changes that completely removes pthread.h in the single-threaded wasm32-wasi sysroot, therefore we need to handle that change. - - - - - 1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00 ci: bump ci-images to use updated wasm image This commit bumps our ci-images revision to use updated wasm image. - - - - - 56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00 Bump submodule text to 2.1.1 T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a. Metric Decrease: T17123 - - - - - a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00 rts: remove redundant rCCCS initialization This commit removes the redundant logic of initializing each Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before initProfiling() is called during RTS startup, each Capability's rCCCS has already been assigned CCS_SYSTEM when they're first initialized. - - - - - 7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00 Parser, renamer, type checker for @a-binders (#17594) GHC Proposal 448 introduces binders for invisible type arguments (@a-binders) in various contexts. This patch implements @-binders in lambda patterns and function equations: {-# LANGUAGE TypeAbstractions #-} id1 :: a -> a id1 @t x = x :: t -- @t-binder on the LHS of a function equation higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16) higherRank f = (f 42, f 42) ex :: (Int8, Int16) ex = higherRank (\ @a x -> maxBound @a - x ) -- @a-binder in a lambda pattern in an argument -- to a higher-order function Syntax ------ To represent those @-binders in the AST, the list of patterns in Match now uses ArgPat instead of Pat: data Match p body = Match { ... - m_pats :: [LPat p], + m_pats :: [LArgPat p], ... } + data ArgPat pass + = VisPat (XVisPat pass) (LPat pass) + | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass)) + | XArgPat !(XXArgPat pass) The VisPat constructor represents patterns for visible arguments, which include ordinary value-level arguments and required type arguments (neither is prefixed with a @), while InvisPat represents invisible type arguments (prefixed with a @). Parser ------ In the grammar (Parser.y), the lambda and lambda-cases productions of aexp non-terminal were updated to accept argpats instead of apats: aexp : ... - | '\\' apats '->' exp + | '\\' argpats '->' exp ... - | '\\' 'lcases' altslist(apats) + | '\\' 'lcases' altslist(argpats) ... + argpat : apat + | PREFIX_AT atype Function left-hand sides did not require any changes to the grammar, as they were already parsed with productions capable of parsing @-binders. Those binders were being rejected in post-processing (isFunLhs), and now we accept them. In Parser.PostProcess, patterns are constructed with the help of PatBuilder, which is used as an intermediate data structure when disambiguating between FunBind and PatBind. In this patch we define ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived data structure produced in isFunLhs and consumed in checkFunBind. Renamer ------- Renaming of @-binders builds upon prior work on type patterns, implemented in 2afbddb0f24, which guarantees proper scoping and shadowing behavior of bound type variables. This patch merely defines rnLArgPatsAndThen to process a mix of visible and invisible patterns: + rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn] + rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where + rnArgPatAndThen (VisPat x p) = ... rnLPatAndThen ... + rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ... Common logic between rnArgPats and rnPats is factored out into the rn_pats_general helper. Type checker ------------ Type-checking of @-binders builds upon prior work on lazy skolemisation, implemented in f5d3e03c56f. This patch extends tcMatchPats to handle @-binders. Now it takes and returns a list of LArgPat rather than LPat: tcMatchPats :: ... - -> [LPat GhcRn] + -> [LArgPat GhcRn] ... - -> TcM ([LPat GhcTc], a) + -> TcM ([LArgPat GhcTc], a) Invisible binders in the Match are matched up with invisible (Specified) foralls in the type. This is done with a new clause in the `loop` worker of tcMatchPats: loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a) loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys) ... -- NEW CLAUSE: | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis = ... In addition to that, tcMatchPats no longer discards type patterns. This is done by filterOutErasedPats in the desugarer instead. x86_64-linux-deb10-validate+debug_info Metric Increase: MultiLayerModulesTH_OneShot - - - - - 486979b0 by Jade at 2024-02-19T07:12:13-05:00 Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246 Fixes: #24346 - - - - - 17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00 Fix reST in users guide It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax. - - - - - 35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00 Fix searching for errors in sphinx build - - - - - 4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00 hadrian: fix wasm backend post linker script permissions The post-link.mjs script was incorrectly copied and installed as a regular data file without executable permission, this commit fixes it. - - - - - a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00 testsuite: mark T23540 as fragile on i386 See #24449 for details. - - - - - 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 8a8ac65a by Matthew Craven at 2024-03-23T00:20:52-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 0c48f2b9 by Apoorv Ingle at 2024-03-23T00:21:28-04:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - b72705e9 by Simon Peyton Jones at 2024-03-23T00:22:04-04:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 8f7cfc7e by Tristan Cacqueray at 2024-03-23T00:22:44-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - 5bd8ed53 by Andreas Klebinger at 2024-03-23T16:18:33-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8d67f247 by Ben Gamari at 2024-03-23T16:19:09-04:00 docs: Drop old release notes, add for 9.12.1 - - - - - 7db8c992 by Cheng Shao at 2024-03-25T13:45:46-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. - - - - - 237194ce by Sylvain Henry at 2024-03-25T13:46:27-04:00 Lexer: fix imports for Alex 3.5.1 (#24583) - - - - - 810660b7 by Cheng Shao at 2024-03-25T22:19:16-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - d2ba41e8 by Alan Zimmerman at 2024-03-25T22:19:51-04:00 EPA: do not duplicate comments in signature RHS - - - - - 32a8103f by Rodrigo Mesquita at 2024-03-26T21:16:12-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. - - - - - bf65a7c3 by Rodrigo Mesquita at 2024-03-26T21:16:48-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 - - - - - cfeb70d3 by Rodrigo Mesquita at 2024-03-26T21:17:24-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 13223f6d by Serge S. Gulin at 2024-03-27T07:28:51-04:00 JS: `h$rts_isProfiled` is removed from `profiling` and left its version at `rts/js/config.js` - - - - - 0acfe391 by Alan Zimmerman at 2024-03-27T07:29:27-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. - - - - - cd0fb82f by Alan Zimmerman at 2024-03-27T19:33:08+00:00 EPA: Fix FamDecl range The span was incorrect if opt_datafam_kind_sig was empty - - - - - f8f384a8 by Ben Gamari at 2024-03-29T01:23:03-04:00 Fix type of _get_osfhandle foreign import Fixes #24601. - - - - - 00d3ecf0 by Alan Zimmerman at 2024-03-29T12:19:10+00:00 EPA: Extend StringLiteral range to include trailing commas This goes slightly against the exact printing philosophy where trailing decorations should be in an annotation, but the practicalities of adding it to the WarningTxt environment, and the problems caused by deviating do not make a more principles approach worthwhile. - - - - - efab3649 by brandon s allbery kf8nh at 2024-03-31T20:04:01-04:00 clarify Note [Preproccesing invocations] - - - - - c8a4c050 by Ben Gamari at 2024-04-02T12:50:35-04:00 rts: Fix TSAN_ENABLED CPP guard This should be `#if defined(TSAN_ENABLED)`, not `#if TSAN_ENABLED`, lest we suffer warnings. - - - - - e91dad93 by Cheng Shao at 2024-04-02T12:50:35-04:00 rts: fix errors when compiling with TSAN This commit fixes rts compilation errors when compiling with TSAN: - xxx_FENCE macros are redefined and trigger CPP warnings. - Use SIZEOF_W. WORD_SIZE_IN_BITS is provided by MachDeps.h which Cmm.h doesn't include by default. - - - - - a9ab9455 by Cheng Shao at 2024-04-02T12:50:35-04:00 rts: fix clang-specific errors when compiling with TSAN This commit fixes clang-specific rts compilation errors when compiling with TSAN: - clang doesn't have -Wtsan flag - Fix prototype of ghc_tsan_* helper functions - __tsan_atomic_* functions aren't clang built-ins and sanitizer/tsan_interface_atomic.h needs to be included - On macOS, TSAN runtime library is libclang_rt.tsan_osx_dynamic.dylib, not libtsan. -fsanitize-thread as a link-time flag will take care of linking the TSAN runtime library anyway so remove tsan as an rts extra library - - - - - 865bd717 by Cheng Shao at 2024-04-02T12:50:35-04:00 compiler: fix github link to __tsan_memory_order in a comment - - - - - 07cb627c by Cheng Shao at 2024-04-02T12:50:35-04:00 ci: improve TSAN CI jobs - Run TSAN jobs with +thread_sanitizer_cmm which enables Cmm instrumentation as well. - Run TSAN jobs in deb12 which ships gcc-12, a reasonably recent gcc that @bgamari confirms he's using in #GHC:matrix.org. Ideally we should be using latest clang release for latest improvements in sanitizers, though that's left as future work. - Mark TSAN jobs as manual+allow_failure in validate pipelines. The purpose is to demonstrate that we have indeed at least fixed building of TSAN mode in CI without blocking the patch to land, and once merged other people can begin playing with TSAN using their own dev setups and feature branches. - - - - - a1c18c7b by Andrei Borzenkov at 2024-04-02T12:51:11-04:00 Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy (#24299, #23639) This patch implements refactoring which is a prerequisite to updating kind checking of type patterns. This is a huge simplification of the main worker that checks kind of HsType. It also fixes the issues caused by previous code duplication, e.g. that we didn't add module finalizers from splices in inference mode. - - - - - 817e8936 by Rodrigo Mesquita at 2024-04-02T20:13:05-04:00 th: Hide the Language.Haskell.TH.Lib.Internal module from haddock Fixes #24562 - - - - - b36ee57b by Sylvain Henry at 2024-04-02T20:13:46-04:00 JS: reenable h$appendToHsString optimization (#24495) The optimization introducing h$appendToHsString wasn't kicking in anymore (while it did in 9.8.1) because of the changes introduced in #23270 (7e0c8b3bab30). This patch reenables the optimization by matching on case-expression, as done in Cmm for unpackCString# standard thunks. The test is also T24495 added in the next commits (two commits for ease of backporting to 9.8). - - - - - 527616e9 by Sylvain Henry at 2024-04-02T20:13:46-04:00 JS: fix h$appendToHsString implementation (#24495) h$appendToHsString needs to wrap its argument in an updatable thunk to behave like unpackAppendCString#. Otherwise if a SingleEntry thunk is passed, it is stored as-is in a CONS cell, making the resulting list impossible to deepseq (forcing the thunk doesn't update the contents of the CONS cell)! The added test checks that the optimization kicks in and that h$appendToHsString works as intended. Fix #24495 - - - - - faa30b41 by Simon Peyton Jones at 2024-04-02T20:14:22-04:00 Deal with duplicate tyvars in type declarations GHC was outright crashing before this fix: #24604 - - - - - e0b0c717 by Simon Peyton Jones at 2024-04-02T20:14:58-04:00 Try using MCoercion in exprIsConApp_maybe This is just a simple refactor that makes exprIsConApp_maybe a little bit more direct, simple, and efficient. Metrics: compile_time/bytes allocated geo. mean -0.1% minimum -2.0% maximum -0.0% Not a big gain, but worthwhile given that the code is, if anything, easier to grok. - - - - - 15f4d867 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Initial ./configure support for selecting I/O managers In this patch we just define new CPP vars, but don't yet use them or replace the existing approach. That will follow. The intention here is that every I/O manager can be enabled/disabled at GHC build time (subject to some constraints). More than one I/O manager can be enabled to be built. At least one I/O manager supporting the non-threaded RTS must be enabled as well as at least one supporting the non-threaded RTS. The I/O managers enabled here will become the choices available at runtime at RTS startup (in later patches). The choice can be made with RTS flags. There are separate sets of choices for the threaded and non-threaded RTS ways, because most I/O managers are specific to these ways. Furthermore we must establish a default I/O manager for the threaded and non-threaded RTS. Most I/O managers are platform-specific so there are checks to ensure each one can be enabled on the platform. Such checks are also where (in future) any system dependencies (e.g. libraries) can be checked. The output is a set of CPP flags (in the mk/config.h file), with one flag per named I/O manager: * IOMGR_BUILD_<name> : which ones should be built (some) * IOMGR_DEFAULT_NON_THREADED_<name> : which one is default (exactly one) * IOMGR_DEFAULT_THREADED_<name> : which one is default (exactly one) and a set of derived flags in IOManager.h * IOMGR_ENABLED_<name> : enabled for the current RTS way Note that IOMGR_BUILD_<name> just says that an I/O manager will be built for _some_ RTS way (i.e. threaded or non-threaded). The derived flags IOMGR_ENABLED_<name> in IOManager.h say if each I/O manager is enabled in the "current" RTS way. These are the ones that can be used for conditional compilation of the I/O manager code. Co-authored-by: Pi Delport <pi at well-typed.com> - - - - - 85b0f87a by Duncan Coutts at 2024-04-03T01:27:17-04:00 Change the handling of the RTS flag --io-manager= Now instead of it being just used on Windows to select between the WinIO vs the MIO or Win32-legacy I/O managers, it is now used on all platforms for selecting the I/O manager to use. Right now it remains the case that there is only an actual choice on Windows, but that will change later. Document the --io-manager flag in the user guide. This change is also reflected in the RTS flags types in the base library. Deprecate the export of IoSubSystem from GHC.RTS.Flags with a message to import it from GHC.IO.Subsystem. The way the 'IoSubSystem' is detected also changes. Instead of looking at the RTS flag, there is now a C bool global var in the RTS which gets set on startup when the I/O manager is selected. This bool var says whether the selected I/O manager classifies as "native" on Windows, which in practice means the WinIO I/O manager has been selected. Similarly, the is_io_mng_native_p RTS helper function is re-implemented in terms of the selected I/O manager, rather than based on the RTS flags. We do however remove the ./configure --native-io-manager flag because we're bringing the WinIO/MIO/Win32-legacy choice under the new general scheme for selecting I/O managers, and that new scheme involves no ./configure time user choices, just runtime RTS flag choices. - - - - - 1a8f020f by Duncan Coutts at 2024-04-03T01:27:17-04:00 Convert {init,stop,exit}IOManager to switch style Rather than ad-hoc cpp conitionals on THREADED_RTS and mingw32_HOST_OS, we use a style where we switch on the I/O manager impl, with cases for each I/O manager impl. - - - - - a5bad3d2 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Split up the CapIOManager content by I/O manager Using the new IOMGR_ENABLED_<name> CPP defines. - - - - - 1d36e609 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Convert initIOManagerAfterFork and wakeupIOManager to switch style - - - - - c2f26f36 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move most of waitRead#/Write# from cmm to C Moves it into the IOManager.c where we can follow the new pattern of switching on the selected I/O manager. - - - - - 457705a8 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move most of the delay# impl from cmm to C Moves it into the IOManager.c where we can follow the new pattern of switching on the selected I/O manager. Uses a new IOManager API: syncDelay, following the naming convention of sync* for thread-synchronous I/O & timer/delay operations. As part of porting from cmm to C, we maintain the rule that the why_blocked gets accessed using load acquire and store release atomic memory operations. There was one exception to this rule: in the delay# primop cmm code on posix (not win32), the why_blocked was being updated using a store relaxed, not a store release. I've no idea why. In this convesion I'm playing it safe here and using store release consistently. - - - - - e93058e0 by Duncan Coutts at 2024-04-03T01:27:18-04:00 insertIntoSleepingQueue is no longer public No longer defined in IOManager.h, just a private function in IOManager.c. Since it is no longer called from cmm code, just from syncDelay. It ought to get moved further into the select() I/O manager impl, rather than living in IOManager.c. On the other hand appendToIOBlockedQueue is still called from cmm code in the win32-legacy I/O manager primops async{Read,Write}#, and it is also used by the select() I/O manager. Update the CPP and comments to reflect this. - - - - - 60ce9910 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move anyPendingTimeoutsOrIO impl from .h to .c The implementation is eventually going to need to use more private things, which will drag in unwanted includes into IOManager.h, so it's better to move the impl out of the header file and into the .c file, at the slight cost of it no longer being inline. At the same time, change to the "switch (iomgr_type)" style. - - - - - f70b8108 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Take a simpler approach to gcc warnings in IOManager.c We have lots of functions with conditional implementations for different I/O managers. Some functions, for some I/O managers, naturally have implementations that do nothing or barf. When only one such I/O manager is enabled then the whole function implementation will have an implementation that does nothing or barfs. This then results in warnings from gcc that parameters are unused, or that the function should be marked with attribute noreturn (since barf does not return). The USED_IF_THREADS trick for fine-grained warning supression is fine for just two cases, but an equivalent here would need USED_IF_THE_ONLY_ENABLED_IOMGR_IS_X_OR_Y which would have combinitorial blowup. So we take a coarse grained approach and simply disable these two warnings for the whole file. So we use a GCC pragma, with its handy push/pop support: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsuggest-attribute=noreturn" #pragma GCC diagnostic ignored "-Wunused-parameter" ... #pragma GCC diagnostic pop - - - - - b48805b9 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add a new trace class for the iomanager It makes sense now for it to be separate from the scheduler class of tracers. Enabled with +RTS -Do. Document the -Do debug flag in the user guide. - - - - - f0c1f862 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Have the throwTo impl go via (new) IOManager APIs rather than directly operating on the IO manager's data structures. Specifically, when thowing an async exception to a thread that is blocked waiting for I/O or waiting for a timer, then we want to cancel that I/O waiting or cancel the timer. Currently this is done directly in removeFromQueues() in RaiseAsync.c. We want it to go via proper APIs both for modularity but also to let us support multiple I/O managers. So add sync{IO,Delay}Cancel, which is the cancellation for the corresponding sync{IO,Delay}. The implementations of these use the usual "switch (iomgr_type)" style. - - - - - 4f9e9c4e by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move awaitEvent into a proper IOManager API and have the scheduler use it. Previously the scheduler calls awaitEvent directly, and awaitEvent is implemented directly in the RTS I/O managers (select, win32). This relies on the old scheme where there's a single active I/O manager for each platform and RTS way. We want to move that to go via an API in IOManager.{h,c} which can then call out to the active I/O manager. Also take the opportunity to split awaitEvent into two. The existing awaitEvent has a bool wait parameter, to say if the call should be blocking or non-blocking. We split this into two separate functions: pollCompletedTimeoutsOrIO and awaitCompletedTimeoutsOrIO. We split them for a few reasons: they have different post-conditions (specifically the await version is supposed to guarantee that there are threads runnable when it completes). Secondly, it is also anticipated that in future I/O managers the implementations of the two cases will be simpler if they are separated. - - - - - 5ad4b30f by Duncan Coutts at 2024-04-03T01:27:18-04:00 Rename awaitEvent in select and win32 I/O managers These are now just called from IOManager.c and are the per-I/O manager backend impls (whereas previously awaitEvent was the entry point). Follow the new naming convention in the IOManager.{h,c} of awaitCompletedTimeoutsOrIO, with the I/O manager's name as a suffix: so awaitCompletedTimeoutsOrIO{Select,Win32}. - - - - - d30c6bc6 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Tidy up a couple things in Select.{h,c} Use the standard #include {Begin,End}Private.h style rather than RTS_PRIVATE on individual decls. And conditionally build the code for the select I/O manager based on the new CPP IOMGR_ENABLED_SELECT rather than on THREADED_RTS. - - - - - 4161f516 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add an IOManager API for scavenging TSO blocked_info When the GC scavenges a TSO it needs to scavenge the tso->blocked_info but the blocked_info is a big union and what lives there depends on the two->why_blocked, which for I/O-related reasons is something that in principle is the responsibility of the I/O manager and not the GC. So the right thing to do is for the GC to ask the I/O manager to sscavenge the blocked_info if it encounters any I/O-related why_blocked reasons. So we add scavengeTSOIOManager in IOManager.{h,c} with the usual style. Now as it happens, right now, there is no special scavenging to do, so the implementation of scavengeTSOIOManager is a fancy no-op. That's because the select I/O manager uses only the fd and target members, which are not GC pointers, and the win32-legacy I/O manager _ought_ to be using GC-managed heap objects for the StgAsyncIOResult but it is actually usingthe C heap, so again no GC pointers. If the win32-legacy were doing this more sensibly, then scavengeTSOIOManager would be the right place to do the GC magic. Future I/O managers will need GC heap objects in the tso->blocked_info and will make use of this functionality. - - - - - 94a87d21 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add I/O manager API notifyIOManagerCapabilitiesChanged Used in setNumCapabilities. It only does anything for MIO on Posix. Previously it always invoked Haskell code, but that code only did anything on non-Windows (and non-JS), and only threaded. That currently effectively means the MIO I/O manager on Posix. So now it only invokes it for the MIO Posix case. - - - - - 3be6d591 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Select an I/O manager early in RTS startup We need to select the I/O manager to use during startup before the per-cap I/O manager initialisation. - - - - - aaa294d0 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Make struct CapIOManager be fully opaque Provide an opaque (forward) definition in Capability.h (since the cap contains a *CapIOManager) and then only provide a full definition in a new file IOManagerInternals.h. This new file is only supposed to be included by the IOManager implementation, not by its users. So that means IOManager.c and individual I/O manager implementations. The posix/Signals.c still needs direct access, but that should be eliminated. Anything that needs direct access either needs to be clearly part of an I/O manager (e.g. the sleect() one) or go via a proper API. - - - - - 877a2a80 by Duncan Coutts at 2024-04-03T01:27:18-04:00 The select() I/O manager does have some global initialisation It's just to make sure an exception CAF is a GC root. - - - - - 9c51473b by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add tracing for the main I/O manager actions Using the new tracer class. Note: The unconditional definition of showIOManager should be compatible with the debugTrace change in 7c7d1f6. Co-authored-by: Pi Delport <pi at well-typed.com> - - - - - c7d3e3a3 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Include the default I/O manager in the +RTS --info output Document the extra +RTS --info output in the user guide - - - - - 8023bad4 by Duncan Coutts at 2024-04-03T01:27:18-04:00 waitRead# / waitWrite# do not work for win32-legacy I/O manager Previously it was unclear that they did not work because the code path was shared with other I/O managers (in particular select()). Following the code carefully shows that what actually happens is that the calling thread would block forever: the thread will be put into the blocked queue, but no other action is scheduled that will ever result in it getting unblocked. It's better to just fail loudly in case anyone accidentally calls it, also it's less confusing code. - - - - - 83a74d20 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Conditionally ignore some GCC warnings Some GCC versions don't know about some warnings, and they complain that we're ignoring unknown warnings. So we try to ignore the warning based on the GCC version. - - - - - 1adc6fa4 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Accept changes to base-exports All the changes are in fact not changes at all. Previously, the IoSubSystem data type was defined in GHC.RTS.Flags and exported from both GHC.RTS.Flags and GHC.IO.SubSystem. Now, the data type is defined in GHC.IO.SubSystem and still exported from both modules. Therefore, the same exports and same instances are still available from both modules. But the base-exports records only the defining module, and so it looks like a change when it is fully compatible. Related: we do add a deprecation to the export of the type via GHC.RTS.Flags, telling people to use the export from GHC.IO.SubSystem. Also the sort order for some unrelated Show instances changed. No idea why. The same changes apply in the other versions, with a few more changes due to sort order weirdness. - - - - - 8d950968 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Accept metric decrease in T12227 I can't think of any good reason that anything in this MR should have changed the number of allocations, up or down. (Yes this is an empty commit.) Metric Decrease: T12227 - - - - - e869605e by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Several improvements to the handling of coercions * Make `mkSymCo` and `mkInstCo` smarter Fixes #23642 * Fix return role of `SelCo` in the coercion optimiser. Fixes #23617 * Make the coercion optimiser `opt_trans_rule` work better for newtypes Fixes #23619 - - - - - 1efd0714 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 FloatOut: improve floating for join point See the new Note [Floating join point bindings]. * Completely get rid of the complicated join_ceiling nonsense, which I have never understood. * Do not float join points at all, except perhaps to top level. * Some refactoring around wantToFloat, to treat Rec and NonRec more uniformly - - - - - 9c00154d by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Improve eta-expansion through call stacks See Note [Eta expanding through CallStacks] in GHC.Core.Opt.Arity This is a one-line change, that fixes an inconsistency - || isCallStackPredTy ty + || isCallStackPredTy ty || isCallStackTy ty - - - - - 95a9a172 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Spelling, layout, pretty-printing only - - - - - bdf1660f by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Improve exprIsConApp_maybe a little Eliminate a redundant case at birth. This sometimes reduces Simplifier iterations. See Note [Case elim in exprIsConApp_maybe]. - - - - - 609cd32c by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Inline GHC.HsToCore.Pmc.Solver.Types.trvVarInfo When exploring compile-time regressions after meddling with the Simplifier, I discovered that GHC.HsToCore.Pmc.Solver.Types.trvVarInfo was very delicately balanced. It's a small, heavily used, overloaded function and it's important that it inlines. By a fluke it was before, but at various times in my journey it stopped doing so. So I just added an INLINE pragma to it; no sense in depending on a delicately-balanced fluke. - - - - - ae24c9bc by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Slight improvement in WorkWrap Ensure that WorkWrap preserves lambda binders, in case of join points. Sadly I have forgotten why I made this change (it was while I was doing a lot of meddling in the Simplifier, but * it does no harm, * it is slightly more efficient, and * presumably it made something better! Anyway I have kept it in a separate commit. - - - - - e9297181 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Use named record fields for the CastIt { ... } data constructor This is a pure refactor - - - - - b4581e23 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Remove a long-commented-out line Pure refactoring - - - - - e026bdf2 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The main changes are below. There are also many new or rewritten Notes. Avoiding simplifying repeatedly ~~~~~~~~~~~~~~~ See Note [Avoiding simplifying repeatedly] * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env. Currently used only for the next point: avoiding repeatedly simplifying coercions. * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] * Improve the case-merge transformation: - Move the main code to `GHC.Core.Utils.mergeCaseAlts`, to join `filterAlts` and friends. See Note [Merge Nested Cases] in GHC.Core.Utils. - Add a new case for `tagToEnum#`; see wrinkle (MC3). - Add a new case to look through join points: see wrinkle (MC4) postInlineUnconditionally ~~~~~~~~~~~~~~~~~~~~~~~~~ * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. * Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. * Improve occurrence analyis for bottoming function calls, to help postInlineUnconditionally. See Note [Bottoming function calls] in GHC.Core.Opt.OccurAnal Inlining generally ~~~~~~~~~~~~~~~~~~ * In GHC.Core.Opt.Simplify.Utils.interestingCallContext, use RhsCtxt NonRecursive (not BoringCtxt) for a plain-seq case. See Note [Seq is boring] Also, wrinkle (SB1), inline in that `seq` context only for INLINE functions (UnfWhen guidance). * In GHC.Core.Opt.Simplify.Utils.interestingArg, - return ValueArg for OtherCon [c1,c2, ...], but - return NonTrivArg for OtherCon [] This makes a function a little less likely to inline if all we know is that the argument is evaluated, but nothing else. * isConLikeUnfolding is no longer true for OtherCon {}. This propagates to exprIsConLike. Con-like-ness has /positive/ information. Join points ~~~~~~~~~~~ * Be very careful about inlining join points. See these two long Notes Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline * When making join points, don't do so if the join point is so small it will immediately be inlined; check uncondInlineJoin. * In GHC.Core.Opt.Simplify.Inline.tryUnfolding, improve the inlining heuristics for join points. In general we /do not/ want to inline join points /even if they are small/. See Note [Duplicating join points] GHC.Core.Opt.Simplify.Iteration. But sometimes we do: see Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline; and the new `isBetterUnfoldingThan` function. * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * In GHC.Core.Unfold.sizeExpr, make jumps small, so that we don't penalise having a non-inlined join point. Performance changes ~~~~~~~~~~~~~~~~~~~ * Binary sizes fall by around 2.6%, according to nofib. * Compile times improve slightly. Here are the figures over 1%. I investiate the biggest differnce in T18304. It's a very small module, just a few hundred nodes. The large percentage difffence is due to a single function that didn't quite inline before, and does now, making code size a bit bigger. I decided gains outweighed the losses. Metrics: compile_time/bytes allocated (changes over +/- 1%) ------------------------------------------------ CoOpt_Singletons(normal) -9.2% GOOD LargeRecord(normal) -23.5% GOOD MultiComponentModulesRecomp(normal) +1.2% MultiLayerModulesTH_OneShot(normal) +4.1% BAD PmSeriesS(normal) -3.8% PmSeriesV(normal) -1.5% T11195(normal) -1.3% T12227(normal) -20.4% GOOD T12545(normal) -3.2% T12707(normal) -2.1% GOOD T13253(normal) -1.2% T13253-spj(normal) +8.1% BAD T13386(normal) -3.1% GOOD T14766(normal) -2.6% GOOD T15164(normal) -1.4% T15304(normal) +1.2% T15630(normal) -8.2% T15630a(normal) NEW T15703(normal) -14.7% GOOD T16577(normal) -2.3% GOOD T17516(normal) -39.7% GOOD T18140(normal) +1.2% T18223(normal) -17.1% GOOD T18282(normal) -5.0% GOOD T18304(normal) +10.8% BAD T18923(normal) -2.9% GOOD T1969(normal) +1.0% T19695(normal) -1.5% T20049(normal) -12.7% GOOD T21839c(normal) -4.1% GOOD T3064(normal) -1.5% T3294(normal) +1.2% BAD T4801(normal) +1.2% T5030(normal) -15.2% GOOD T5321Fun(normal) -2.2% GOOD T6048(optasm) -16.8% GOOD T783(normal) -1.2% T8095(normal) -6.0% GOOD T9630(normal) -4.7% GOOD T9961(normal) +1.9% BAD WWRec(normal) -1.4% info_table_map_perf(normal) -1.3% parsing001(normal) +1.5% geo. mean -2.0% minimum -39.7% maximum +10.8% * Runtimes generally improve. In the testsuite perf/should_run gives: Metrics: runtime/bytes allocated ------------------------------------------ Conversions(normal) -0.3% T13536a(optasm) -41.7% GOOD T4830(normal) -0.1% haddock.Cabal(normal) -0.1% haddock.base(normal) -0.1% haddock.compiler(normal) -0.1% geo. mean -0.8% minimum -41.7% maximum +0.0% * For runtime, nofib is a better test. The news is mostly good. Here are the number more than +/- 0.1%: # bytes allocated ==========================++========== imaginary/digits-of-e1 || -14.40% imaginary/digits-of-e2 || -4.41% imaginary/paraffins || -0.17% imaginary/rfib || -0.15% imaginary/wheel-sieve2 || -0.10% real/compress || -0.47% real/fluid || -0.10% real/fulsom || +0.14% real/gamteb || -1.47% real/gg || -0.20% real/infer || +0.24% real/pic || -0.23% real/prolog || -0.36% real/scs || -0.46% real/smallpt || +4.03% shootout/k-nucleotide || -20.23% shootout/n-body || -0.42% shootout/spectral-norm || -0.13% spectral/boyer2 || -3.80% spectral/constraints || -0.27% spectral/hartel/ida || -0.82% spectral/mate || -20.34% spectral/para || +0.46% spectral/rewrite || +1.30% spectral/sphere || -0.14% ==========================++========== geom mean || -0.59% real/smallpt has a huge nest of local definitions, and I could not pin down a reason for a regression. But there are three big wins! Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12707 T13386 T13536a T14766 T15703 T16577 T17516 T18223 T18282 T18923 T21839c T20049 T5321Fun T5030 T6048 T8095 T9630 T783 Metric Increase: MultiLayerModulesTH_OneShot T13253-spj T18304 T18698a T9961 T3294 - - - - - 27db3c5e by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Testsuite message changes from simplifier improvements - - - - - 271a7812 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Account for bottoming functions in OccurAnal This fixes #24582, a small but long-standing bug - - - - - 0fde229f by Ben Gamari at 2024-04-04T07:04:58-04:00 testsuite: Introduce template-haskell-exports test - - - - - 0c4a9686 by Luite Stegeman at 2024-04-04T07:05:39-04:00 Update correct counter in bumpTickyAllocd - - - - - 5f085d3a by Fendor at 2024-04-04T14:47:33-04:00 Replace `SizedSeq` with `FlatBag` for flattened structure LinkedLists are notoriously memory ineffiecient when all we do is traversing a structure. As 'UnlinkedBCO' has been identified as a data structure that impacts the overall memory usage of GHCi sessions, we avoid linked lists and prefer flattened structure for storing. We introduce a new memory efficient representation of sequential elements that has special support for the cases: * Empty * Singleton * Tuple Elements This improves sharing in the 'Empty' case and avoids the overhead of 'Array' until its constant overhead is justified. - - - - - 82cfe10c by Fendor at 2024-04-04T14:47:33-04:00 Compact FlatBag array representation `Array` contains three additional `Word`'s we do not need in `FlatBag`. Move `FlatBag` to `SmallArray`. Expand the API of SmallArray by `sizeofSmallArray` and add common traversal functions, such as `mapSmallArray` and `foldMapSmallArray`. Additionally, allow users to force the elements of a `SmallArray` via `rnfSmallArray`. - - - - - 36a75b80 by Andrei Borzenkov at 2024-04-04T14:48:10-04:00 Change how invisible patterns represented in haskell syntax and TH AST (#24557) Before this patch: data ArgPat p = InvisPat (LHsType p) | VisPat (LPat p) With this patch: data Pat p = ... | InvisPat (LHsType p) ... And the same transformation in the TH land. The rest of the changes is just updating code to handle new AST and writing tests to check if it is possible to create invalid states using TH. Metric Increase: MultiLayerModulesTH_OneShot - - - - - 28009fbc by Matthew Pickering at 2024-04-04T14:48:46-04:00 Fix off by one error in seekBinNoExpand and seekBin - - - - - 9b9e031b by Ben Gamari at 2024-04-04T21:30:08-04:00 compiler: Allow more types in GHCForeignImportPrim For many, many years `GHCForeignImportPrim` has suffered from the rather restrictive limitation of not allowing any non-trivial types in arguments or results. This limitation was justified by the code generator allegely barfing in the presence of such types. However, this restriction appears to originate well before the NCG rewrite and the new NCG does not appear to have any trouble with such types (see the added `T24598` test). Lift this restriction. Fixes #24598. - - - - - 1324b862 by Alan Zimmerman at 2024-04-04T21:30:44-04:00 EPA: Use EpaLocation not SrcSpan in ForeignDecls This allows us to update them for makeDeltaAst in ghc-exactprint - - - - - 19883a23 by Alan Zimmerman at 2024-04-05T16:58:17-04:00 EPA: Use EpaLocation for RecFieldsDotDot So we can update it to a delta position in makeDeltaAst if needed. - - - - - e8724327 by Matthew Pickering at 2024-04-05T16:58:53-04:00 Remove accidentally committed test.hs - - - - - 88cb3e10 by Fendor at 2024-04-08T09:03:34-04:00 Avoid UArray when indexing is not required `UnlinkedBCO`'s can occur many times in the heap. Each `UnlinkedBCO` references two `UArray`'s but never indexes them. They are only needed to encode the elements into a `ByteArray#`. The three words for the lower bound, upper bound and number of elements are essentially unused, thus we replace `UArray` with a wrapper around `ByteArray#`. This saves us up to three words for each `UnlinkedBCO`. Further, to avoid re-allocating these words for `ResolvedBCO`, we repeat the procedure for `ResolvedBCO` and add custom `Binary` and `Show` instances. For example, agda's repl session has around 360_000 UnlinkedBCO's, so avoiding these three words is already saving us around 8MB residency. - - - - - f2cc1107 by Fendor at 2024-04-08T09:04:11-04:00 Never UNPACK `FastMutInt` for counting z-encoded `FastString`s In `FastStringTable`, we count the number of z-encoded FastStrings that exist in a GHC session. We used to UNPACK the counters to not waste memory, but live retainer analysis showed that we allocate a lot of `FastMutInt`s, retained by `mkFastZString`. We lazily compute the `FastZString`, only incrementing the counter when the `FastZString` is forced. The function `mkFastStringWith` calls `mkZFastString` and boxes the `FastMutInt`, leading to the following core: mkFastStringWith = \ mk_fs _ -> = case stringTable of { FastStringTable _ n_zencs segments# _ -> ... case ((mk_fs (I# ...) (FastMutInt n_zencs)) `cast` <Co:2> :: ...) ... Marking this field as `NOUNPACK` avoids this reboxing, eliminating the allocation of a fresh `FastMutInt` on every `FastString` allocation. - - - - - c6def949 by Matthew Pickering at 2024-04-08T16:06:51-04:00 Force in_multi to avoid retaining entire hsc_env - - - - - fbb91a63 by Fendor at 2024-04-08T16:06:51-04:00 Eliminate name thunk in declaration fingerprinting Thunk analysis showed that we have about 100_000 thunks (in agda and `-fwrite-simplified-core`) pointing to the name of the name decl. Forcing this thunk fixes this issue. The thunk created here is retained by the thunk created by forkM, it is better to eagerly force this because the result (a `Name`) is already retained indirectly via the `IfaceDecl`. - - - - - 3b7b0c1c by Alan Zimmerman at 2024-04-08T16:07:27-04:00 EPA: Use EpaLocation in WarningTxt This allows us to use an EpDelta if needed when using makeDeltaAst. - - - - - 12b997df by Alan Zimmerman at 2024-04-08T16:07:27-04:00 EPA: Move DeltaPos and EpaLocation' into GHC.Types.SrcLoc This allows us to use a NoCommentsLocation for the possibly trailing comma location in a StringLiteral. This in turn allows us to correctly roundtrip via makeDeltaAst. - - - - - 868c8a78 by Fendor at 2024-04-09T08:51:50-04:00 Prefer packed representation for CompiledByteCode As there are many 'CompiledByteCode' objects alive during a GHCi session, representing its element in a more packed manner improves space behaviour at a minimal cost. When running GHCi on the agda codebase, we find around 380 live 'CompiledByteCode' objects. Packing their respective 'UnlinkedByteCode' can save quite some pointers. - - - - - be3bddde by Alan Zimmerman at 2024-04-09T08:52:26-04:00 EPA: Capture all comments in a ClassDecl Hopefully the final fix needed for #24533 - - - - - 3d0806fc by Jade at 2024-04-10T05:39:53-04:00 Validate -main-is flag using parseIdentifier Fixes #24368 - - - - - dd530bb7 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: free error message before returning Fixes a memory leak in rts/linker/PEi386.c - - - - - e008a19a by Alexis King at 2024-04-10T05:40:29-04:00 linker: Avoid linear search when looking up Haskell symbols via dlsym See the primary Note [Looking up symbols in the relevant objects] for a more in-depth explanation. When dynamically loading a Haskell symbol (typical when running a splice or GHCi expression), before this commit we would search for the symbol in all dynamic libraries that were loaded. However, this could be very inefficient when too many packages are loaded (which can happen if there are many package dependencies) because the time to lookup the would be linear in the number of packages loaded. This commit drastically improves symbol loading performance by introducing a mapping from units to the handles of corresponding loaded dlls. These handles are returned by dlopen when we load a dll, and can then be used to look up in a specific dynamic library. Looking up a given Name is now much more precise because we can get lookup its unit in the mapping and lookup the symbol solely in the handles of the dynamic libraries loaded for that unit. In one measurement, the wait time before the expression was executed went from +-38 seconds down to +-2s. This commit also includes Note [Symbols may not be found in pkgs_loaded], explaining the fallback to the old behaviour in case no dll can be found in the unit mapping for a given Name. Fixes #23415 Co-authored-by: Rodrigo Mesquita (@alt-romes) - - - - - dcfaa190 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: Make addDLL a wrapper around loadNativeObj Rewrite the implementation of `addDLL` as a wrapper around the more principled `loadNativeObj` rts linker function. The latter should be preferred while the former is preserved for backwards compatibility. `loadNativeObj` was previously only available on ELF platforms, so this commit further refactors the rts linker to transform loadNativeObj_ELF into loadNativeObj_POSIX, which is available in ELF and MachO platforms. The refactor made it possible to remove the `dl_mutex` mutex in favour of always using `linker_mutex` (rather than a combination of both). Lastly, we implement `loadNativeObj` for Windows too. - - - - - 12931698 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 Use symbol cache in internal interpreter too This commit makes the symbol cache that was used by the external interpreter available for the internal interpreter too. This follows from the analysis in #23415 that suggests the internal interpreter could benefit from this cache too, and that there is no good reason not to have the cache for it too. It also makes it a bit more uniform to have the symbol cache range over both the internal and external interpreter. This commit also refactors the cache into a function which is used by both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the caching logic to `lookupSymbolInDLL` too. - - - - - dccd3ea1 by Ben Gamari at 2024-04-10T05:40:29-04:00 testsuite: Add test for lookupSymbolInNativeObj - - - - - 1b1a92bd by Alan Zimmerman at 2024-04-10T05:41:05-04:00 EPA: Remove unnecessary XRec in CompleteMatchSig The XRec for [LIdP pass] is not needed for exact printing, remove it. - - - - - 6e18ce2b by Ben Gamari at 2024-04-12T08:16:09-04:00 users-guide: Clarify language extension documentation Over the years the users guide's language extension documentation has gone through quite a few refactorings. In the process some of the descriptions have been rendered non-sensical. For instance, the description of `NoImplicitPrelude` actually describes the semantics of `ImplicitPrelude`. To fix this we: * ensure that all extensions are named in their "positive" sense (e.g. `ImplicitPrelude` rather than `NoImplicitPrelude`). * rework the documentation to avoid flag-oriented wording like "enable" and "disable" * ensure that the polarity of the documentation is consistent with reality. Fixes #23895. - - - - - a933aff3 by Zubin Duggal at 2024-04-12T08:16:45-04:00 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - 23c3e624 by Andreas Klebinger at 2024-04-12T08:17:21-04:00 RTS: Emit warning when -M < -H Fixes #24487 - - - - - d23afb8c by Ben Gamari at 2024-04-12T08:17:56-04:00 testsuite: Add broken test for CApiFFI with -fprefer-bytecode See #24634. - - - - - a4bb3a51 by Ben Gamari at 2024-04-12T08:18:32-04:00 base: Deprecate GHC.Pack As proposed in #21461. Closes #21540. - - - - - 55eb8c98 by Ben Gamari at 2024-04-12T08:19:08-04:00 ghc-internal: Fix mentions of ghc-internal in deprecation warnings Closes #24609. - - - - - b0fbd181 by Ben Gamari at 2024-04-12T08:19:44-04:00 rts: Implement set_initial_registers for AArch64 Fixes #23680. - - - - - 14c9ec62 by Ben Gamari at 2024-04-12T08:20:20-04:00 ghcup-metadata: Use Debian 9 binaries on Ubuntu 16, 17 Closes #24646. - - - - - 35a1621e by Ben Gamari at 2024-04-12T08:20:55-04:00 Bump unix submodule to 2.8.5.1 Closes #24640. - - - - - a1c24df0 by Finley McIlwaine at 2024-04-12T08:21:31-04:00 Correct default -funfolding-use-threshold in docs - - - - - 0255d03c by Oleg Grenrus at 2024-04-12T08:22:07-04:00 FastString is a __Modified__ UTF-8 - - - - - c3489547 by Matthew Pickering at 2024-04-12T13:13:44-04:00 rts: Improve tracing message when nursery is resized It is sometimes more useful to know how much bigger or smaller the nursery got when it is resized. In particular I am trying to investigate situations where we end up with fragmentation due to the nursery (#24577) - - - - - 5e4f4ba8 by Simon Peyton Jones at 2024-04-12T13:14:20-04:00 Don't generate wrappers for `type data` constructors with StrictData Previously, the logic for checking if a data constructor needs a wrapper or not would take into account whether the constructor's fields have explicit strictness (e.g., `data T = MkT !Int`), but the logic would _not_ take into account whether `StrictData` was enabled. This meant that something like `type data T = MkT Int` would incorrectly generate a wrapper for `MkT` if `StrictData` was enabled, leading to the horrible errors seen in #24620. To fix this, we disable generating wrappers for `type data` constructors altogether. Fixes #24620. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - dbdf1995 by Alex Mason at 2024-04-15T15:28:26+10:00 Implements MO_S_Mul2 and MO_U_Mul2 using the UMULH, UMULL and SMULH instructions for AArch64 Also adds a test for MO_S_Mul2 - - - - - 42bd0407 by Teo Camarasu at 2024-04-16T20:06:39-04:00 Make template-haskell a stage1 package Promoting template-haskell from a stage0 to a stage1 package means that we can much more easily refactor template-haskell. We implement this by duplicating the in-tree `template-haskell`. A new `template-haskell-next` library is autogenerated to mirror `template-haskell` `stage1:ghc` to depend on the new interface of the library including the `Binary` instances without adding an explicit dependency on `template-haskell`. This is controlled by the `bootstrap-th` cabal flag When building `template-haskell` modules as part of this vendoring we do not have access to quote syntax, so we cannot use variable quote notation (`'Just`). So we either replace these with hand-written `Name`s or hide the code behind CPP. We can remove the `th_hack` from hadrian, which was required when building stage0 packages using the in-tree `template-haskell` library. For more details see Note [Bootstrapping Template Haskell]. Resolves #23536 Co-Authored-By: Sebastian Graf <sgraf1337 at gmail.com> Co-Authored-By: Matthew Craven <5086-clyring at users.noreply.gitlab.haskell.org> - - - - - 3d973e47 by Ben Gamari at 2024-04-16T20:07:15-04:00 Bump parsec submodule to 3.1.17.0 - - - - - 9d38bfa0 by Simon Peyton Jones at 2024-04-16T20:07:51-04:00 Clone CoVars in CorePrep This MR addresses #24463. It's all explained in the new Note [Cloning CoVars and TyVars] - - - - - 0fe2b410 by Andreas Klebinger at 2024-04-16T20:08:27-04:00 NCG: Fix a bug where we errounously removed a required jump instruction. Add a new method to the Instruction class to check if we can eliminate a jump in favour of fallthrough control flow. Fixes #24507 - - - - - 9f99126a by Teo Camarasu at 2024-04-16T20:09:04-04:00 Fix documentation preview from doc-tarball job - Include all the .html files and assets in the job artefacts - Include all the .pdf files in the job artefacts - Mark the artefact as an "exposed" artefact meaning it turns up in the UI. Resolves #24651 - - - - - 3a0642ea by Ben Gamari at 2024-04-16T20:09:39-04:00 rts: Ignore EINTR while polling in timerfd itimer implementation While the RTS does attempt to mask signals, it may be that a foreign library unmasks them. This previously caused benign warnings which we now ignore. See #24610. - - - - - 9a53cd3f by Alan Zimmerman at 2024-04-16T20:10:15-04:00 EPA: Add additional comments field to AnnsModule This is used in exact printing to store comments coming after the `where` keyword but before any comments allocated to imports or decls. It is used in ghc-exactprint, see https://github.com/alanz/ghc-exactprint/commit/44bbed311fd8f0d053053fef195bf47c17d34fa7 - - - - - e5c43259 by Bryan Richter at 2024-04-16T20:10:51-04:00 Remove unrunnable FreeBSD CI jobs FreeBSD runner supply is inelastic. Currently there is only one, and it's unavailable because of a hardware issue. - - - - - 914eb49a by Ben Gamari at 2024-04-16T20:11:27-04:00 rel-eng: Fix mktemp usage in recompress-all We need a temporary directory, not a file. - - - - - f30e4984 by Teo Camarasu at 2024-04-16T20:12:03-04:00 Fix ghc API link in docs/index.html This was missing part of the unit ID meaning it would 404. Resolves #24674 - - - - - d7a3d6b5 by Ben Gamari at 2024-04-16T20:12:39-04:00 template-haskell: Declare TH.Lib.Internal as not-home Rather than `hide`. Closes #24659. - - - - - 5eaa46e7 by Matthew Pickering at 2024-04-19T02:14:55-04:00 testsuite: Rename isCross() predicate to needsTargetWrapper() isCross() was a misnamed because it assumed that all cross targets would provide a target wrapper, but the two most common cross targets (javascript, wasm) don't need a target wrapper. Therefore we rename this predicate to `needsTargetWrapper()` so situations in the testsuite where we can check whether running executables requires a target wrapper or not. - - - - - 55a9d699 by Simon Peyton Jones at 2024-04-19T02:15:32-04:00 Do not float HNFs out of lambdas This MR adjusts SetLevels so that it is less eager to float a HNF (lambda or constructor application) out of a lambda, unless it gets to top level. Data suggests that this change is a small net win: * nofib bytes-allocated falls by -0.09% (but a couple go up) * perf/should_compile bytes-allocated falls by -0.5% * perf/should_run bytes-allocated falls by -0.1% See !12410 for more detail. When fiddling elsewhere, I also found that this patch had a huge positive effect on the (very delicate) test perf/should_run/T21839r But that improvement doesn't show up in this MR by itself. Metric Decrease: MultiLayerModulesRecomp T15703 parsing001 - - - - - f0701585 by Alan Zimmerman at 2024-04-19T02:16:08-04:00 EPA: Fix comments in mkListSyntaxTy0 Also extend the test to confirm. Addresses #24669, 1 of 4 - - - - - b01c01d4 by Serge S. Gulin at 2024-04-19T02:16:51-04:00 JS: set image `x86_64-linux-deb11-emsdk-closure` for build - - - - - c90c6039 by Alan Zimmerman at 2024-04-19T02:17:27-04:00 EPA: Provide correct span for PatBind And remove unused parameter in checkPatBind Contributes to #24669 - - - - - 26036f96 by Alan Zimmerman at 2024-04-19T13:11:08-04:00 EPA: Fix span for PatBuilderAppType Include the location of the prefix @ in the span for InVisPat. Also removes unnecessary annotations from HsTP. Contributes to #24669 - - - - - dba03aab by Matthew Craven at 2024-04-19T13:11:44-04:00 testsuite: Give the pre_cmd for mhu-perf more time - - - - - d31fbf6c by Krzysztof Gogolewski at 2024-04-19T21:04:09-04:00 Fix quantification order for a `op` b and a %m -> b Fixes #23764 Implements https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0640-tyop-quantification-order.rst Updates haddock submodule. - - - - - 385cd1c4 by Sebastian Graf at 2024-04-19T21:04:45-04:00 Make `seq#` a magic Id and inline it in CorePrep (#24124) We can save much code and explanation in Tag Inference and StgToCmm by making `seq#` a known-key Magic Id in `GHC.Internal.IO` and inline this definition in CorePrep. See the updated `Note [seq# magic]`. I also implemented a new `Note [Flatten case-bind]` to get better code for otherwise nested case scrutinees. I renamed the contructors of `ArgInfo` to use an `AI` prefix in order to resolve the clash between `type CpeApp = CoreExpr` and the data constructor of `ArgInfo`, as well as fixed typos in `Note [CorePrep invariants]`. Fixes #24252 and #24124. - - - - - 275e41a9 by Jade at 2024-04-20T11:10:40-04:00 Put the newline after errors instead of before them This mainly has consequences for GHCi but also slightly alters how the output of GHC on the commandline looks. Fixes: #22499 - - - - - dd339c7a by Teo Camarasu at 2024-04-20T11:11:16-04:00 Remove unecessary stage0 packages Historically quite a few packages had to be stage0 as they depended on `template-haskell` and that was stage0. In #23536 we made it so that was no longer the case. This allows us to remove a bunch of packages from this list. A few still remain. A new version of `Win32` is required by `semaphore-compat`. Including `Win32` in the stage0 set requires also including `filepath` because otherwise Hadrian's dependency logic gets confused. Once our boot compiler has a newer version of `Win32` all of these will be able to be dropped. Resolves #24652 - - - - - 2f8e3a25 by Alan Zimmerman at 2024-04-20T11:11:52-04:00 EPA: Avoid duplicated comments in splice decls Contributes to #24669 - - - - - c70b9ddb by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fix typos and namings (fixes #24602) You may noted that I've also changed term of ``` , global "h$vt_double" ||= toJExpr IntV ``` See "IntV" and ``` WaitReadOp -> \[] [fd] -> pure $ PRPrimCall $ returnS (app "h$waidRead" [fd]) ``` See "h$waidRead" - - - - - 3db54f9b by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: trivial checks for variable presence (fixes #24602) - - - - - 777f108f by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fs module imported twice (by emscripten and by ghc-internal). ghc-internal import wrapped in a closure to prevent conflict with emscripten (fixes #24602) Better solution is to use some JavaScript module system like AMD, CommonJS or even UMD. It will be investigated at other issues. At first glance we should try UMD (See https://github.com/umdjs/umd) - - - - - a45a5712 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: thread.js requires h$fds and h$fdReady to be declared for static code analysis, minimal code copied from GHCJS (fixes #24602) I've just copied some old pieces of GHCJS from publicly available sources (See https://github.com/Taneb/shims/blob/a6dd0202dcdb86ad63201495b8b5d9763483eb35/src/io.js#L607). Also I didn't put details to h$fds. I took minimal and left only its object initialization: `var h$fds = {};` - - - - - ad90bf12 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: heap and stack overflows reporting defined as js hard failure (fixes #24602) These errors were treated as a hard failure for browser application. The fix is trivial: just throw error. - - - - - 5962fa52 by Serge S. Gulin at 2024-04-21T16:33:44+03:00 JS: Stubs for code without actual implementation detected by Google Closure Compiler (fixes #24602) These errors were fixed just by introducing stubbed functions with throw for further implementation. - - - - - a0694298 by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add externs to linker (fixes #24602) After enabling jsdoc and built-in google closure compiler types I was needed to deal with the following: 1. Define NodeJS-environment types. I've just copied minimal set of externs from semi-official repo (see https://github.com/externs/nodejs/blob/6c6882c73efcdceecf42e7ba11f1e3e5c9c041f0/v8/nodejs.js#L8). 2. Define Emscripten-environment types: `HEAP8`. Emscripten already provides some externs in our code but it supposed to be run in some module system. And its definitions do not work well in plain bundle. 3. We have some functions which purpose is to add to functions some contextual information via function properties. These functions should be marked as `modifies` to let google closure compiler remove calls if these functions are not used actually by call graph. Such functions are: `h$o`, `h$sti`, `h$init_closure`, `h$setObjInfo`. 4. STG primitives such as registries and stuff from `GHC.StgToJS`. `dXX` properties were already present at externs generator function but they are started from `7`, not from `1`. This message is related: `// fixme does closure compiler bite us here?` - - - - - e58bb29f by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: added both tests: for size and for correctness (fixes #24602) By some reason MacOS builds add to stderr messages like: Ignoring unexpected archive entry: __.SYMDEF ... However I left stderr to `/dev/null` for compatibility with linux CI builds. - - - - - 909f3a9c by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Disable js linker warning for empty symbol table to make js tests running consistent across environments - - - - - 83eb10da by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add special preprocessor for js files due of needing to keep jsdoc comments (fixes #24602) Our js files have defined google closure compiler types at jsdoc entries but these jsdoc entries are removed by cpp preprocessor. I considered that reusing them in javascript-backend would be a nice thing. Right now haskell processor uses `-traditional` option to deal with comments and `//` operators. But now there are following compiler options: `-C` and `-CC`. You can read about them at GCC (see https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#index-CC) and CLang (see https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-CC). It seems that `-CC` works better for javascript jsdoc than `-traditional`. At least it leaves `/* ... */` comments w/o changes. - - - - - e1cf8dc2 by brandon s allbery kf8nh at 2024-04-22T03:48:26-04:00 fix link in CODEOWNERS It seems that our local Gitlab no longer has documentation for the `CODEOWNERS` file, but the master documentation still does. Use that instead. - - - - - 593f4e04 by Fendor at 2024-04-23T10:19:14-04:00 Add performance regression test for '-fwrite-simplified-core' - - - - - 1ba39b05 by Fendor at 2024-04-23T10:19:14-04:00 Typecheck corebindings lazily during bytecode generation This delays typechecking the corebindings until the bytecode generation happens. We also avoid allocating a thunk that is retained by `unsafeInterleaveIO`. In general, we shouldn't retain values of the hydrated `Type`, as not evaluating the bytecode object keeps it alive. It is better if we retain the unhydrated `IfaceType`. See Note [Hydrating Modules] - - - - - e916fc92 by Alan Zimmerman at 2024-04-23T10:19:50-04:00 EPA: Keep comments in a CaseAlt match The comments now live in the surrounding location, not inside the Match. Make sure we keep them. Closes #24707 - - - - - d2b17f32 by Cheng Shao at 2024-04-23T15:01:22-04:00 driver: force merge objects when building dynamic objects This patch forces the driver to always merge objects when building dynamic objects even when ar -L is supported. It is an oversight of !8887: original rationale of that patch is favoring the relatively cheap ar -L operation over object merging when ar -L is supported, which makes sense but only if we are building static objects! Omitting check for whether we are building dynamic objects will result in broken .so files with undefined reference errors at executable link time when building GHC with llvm-ar. Fixes #22210. - - - - - 209d09f5 by Julian Ospald at 2024-04-23T15:02:03-04:00 Allow non-absolute values for bootstrap GHC variable Fixes #24682 - - - - - 3fff0977 by Matthew Pickering at 2024-04-23T15:02:38-04:00 Don't depend on registerPackage function in Cabal More recent versions of Cabal modify the behaviour of libAbiHash which breaks our usage of registerPackage. It is simpler to inline the part of registerPackage that we need and avoid any additional dependency and complication using the higher-level function introduces. - - - - - c62dc317 by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: remove obsolete ln script This commit removes an obsolete ln script in ghc-bignum/gmp. See 060251c24ad160264ae8553efecbb8bed2f06360 for its original intention, but it's been obsolete for a long time, especially since the removal of the make build system. Hence the house cleaning. - - - - - 6399d52b by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: update gmp to 6.3.0 This patch bumps the gmp-tarballs submodule and updates gmp to 6.3.0. The tarball format is now xz, and gmpsrc.patch has been patched into the tarball so hadrian no longer needs to deal with patching logic when building in-tree GMP. - - - - - 65b4b92f by Cheng Shao at 2024-04-25T01:32:02-04:00 hadrian: remove obsolete Patch logic This commit removes obsolete Patch logic from hadrian, given we no longer need to patch the gmp tarball when building in-tree GMP. - - - - - 71f28958 by Cheng Shao at 2024-04-25T01:32:02-04:00 autoconf: remove obsolete patch detection This commit removes obsolete deletection logic of the patch command from autoconf scripts, given we no longer need to patch anything in the GHC build process. - - - - - daeda834 by Sylvain Henry at 2024-04-25T01:32:43-04:00 JS: correctly handle RUBBISH literals (#24664) - - - - - 8a06ddf6 by Matthew Pickering at 2024-04-25T11:16:16-04:00 Linearise ghc-internal and base build This is achieved by requesting the final package database for ghc-internal, which mandates it is fully built as a dependency of configuring the `base` package. This is at the expense of cross-package parrallelism between ghc-internal and the base package. Fixes #24436 - - - - - 94da9365 by Andrei Borzenkov at 2024-04-25T11:16:54-04:00 Fix tuple puns renaming (24702) Move tuple renaming short cutter from `isBuiltInOcc_maybe` to `isPunOcc_maybe`, so we consider incoming module. I also fixed some hidden bugs that raised after the change was done. - - - - - fa03b1fb by Fendor at 2024-04-26T18:03:13-04:00 Refactor the Binary serialisation interface The goal is simplifiy adding deduplication tables to `ModIface` interface serialisation. We identify two main points of interest that make this difficult: 1. UserData hardcodes what `Binary` instances can have deduplication tables. Moreover, it heavily uses partial functions. 2. GHC.Iface.Binary hardcodes the deduplication tables for 'Name' and 'FastString', making it difficult to add more deduplication. Instead of having a single `UserData` record with fields for all the types that can have deduplication tables, we allow to provide custom serialisers for any `Typeable`. These are wrapped in existentials and stored in a `Map` indexed by their respective `TypeRep`. The `Binary` instance of the type to deduplicate still needs to explicitly look up the decoder via `findUserDataReader` and `findUserDataWriter`, which is no worse than the status-quo. `Map` was chosen as microbenchmarks indicate it is the fastest for a small number of keys (< 10). To generalise the deduplication table serialisation mechanism, we introduce the types `ReaderTable` and `WriterTable` which provide a simple interface that is sufficient to implement a general purpose deduplication mechanism for `writeBinIface` and `readBinIface`. This allows us to provide a list of deduplication tables for serialisation that can be extended more easily, for example for `IfaceTyCon`, see the issue https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for more motivation. In addition to this refactoring, we split `UserData` into `ReaderUserData` and `WriterUserData`, to avoid partial functions and reduce overall memory usage, as we need fewer mutable variables. Bump haddock submodule to accomodate for `UserData` split. ------------------------- Metric Increase: MultiLayerModulesTH_Make MultiLayerModulesRecomp T21839c ------------------------- - - - - - bac57298 by Fendor at 2024-04-26T18:03:13-04:00 Split `BinHandle` into `ReadBinHandle` and `WriteBinHandle` A `BinHandle` contains too much information for reading data. For example, it needs to keep a `FastMutInt` and a `IORef BinData`, when the non-mutable variants would suffice. Additionally, this change has the benefit that anyone can immediately tell whether the `BinHandle` is used for reading or writing. Bump haddock submodule BinHandle split. - - - - - 4d6394dd by Simon Peyton Jones at 2024-04-26T18:03:49-04:00 Fix missing escaping-kind check in tcPatSynSig Note [Escaping kind in type signatures] explains how we deal with escaping kinds in type signatures, e.g. f :: forall r (a :: TYPE r). a where the kind of the body is (TYPE r), but `r` is not in scope outside the forall-type. I had missed this subtlety in tcPatSynSig, leading to #24686. This MR fixes it; and a similar bug in tc_top_lhs_type. (The latter is tested by T24686a.) - - - - - 981c2c2c by Alan Zimmerman at 2024-04-26T18:04:25-04:00 EPA: check-exact: check that the roundtrip reproduces the source Closes #24670 - - - - - a8616747 by Andrew Lelechenko at 2024-04-26T18:05:01-04:00 Document that setEnv is not thread-safe - - - - - 1e41de83 by Bryan Richter at 2024-04-26T18:05:37-04:00 CI: Work around frequent Signal 9 errors - - - - - a6d5f9da by Naïm Favier at 2024-04-27T17:52:40-04:00 ghc-internal: add MonadFix instance for (,) Closes https://gitlab.haskell.org/ghc/ghc/-/issues/24288, implements CLC proposal https://github.com/haskell/core-libraries-committee/issues/238. Adds a MonadFix instance for tuples, permitting value recursion in the "native" writer monad and bringing consistency with the existing instance for transformers's WriterT (and, to a lesser extent, for Solo). - - - - - 64feadcd by Rodrigo Mesquita at 2024-04-27T17:53:16-04:00 bindist: Fix xattr cleaning The original fix (725343aa) was incorrect because it used the shell bracket syntax which is the quoting syntax in autoconf, making the test for existence be incorrect and therefore `xattr` was never run. Fixes #24554 - - - - - e2094df3 by damhiya at 2024-04-28T23:52:00+09:00 Make read accepts binary integer formats CLC proposal : https://github.com/haskell/core-libraries-committee/issues/177 - - - - - 1c2fd963 by Alan Zimmerman at 2024-04-29T23:17:00-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 - - - - - 4189d17e by Sylvain Henry at 2024-04-29T23:17:42-04:00 LLVM: better unreachable default destination in Switch (#24717) See added note. Co-authored-by: Siddharth Bhat <siddu.druid at gmail.com> - - - - - a3725c88 by Cheng Shao at 2024-04-29T23:18:20-04:00 ci: enable wasm jobs for MRs with wasm label This patch enables wasm jobs for MRs with wasm label. Previously the wasm label didn't actually have any effect on the CI pipeline, and full-ci needed to be applied to run wasm jobs which was a waste of runners when working on the wasm backend, hence the fix here. - - - - - 702f7964 by Matthew Pickering at 2024-04-29T23:18:56-04:00 Make interface files and object files depend on inplace .conf file A potential fix for #24737 - - - - - 728af21e by Cheng Shao at 2024-04-30T05:30:23-04:00 utils: remove obsolete vagrant scripts Vagrantfile has long been removed in !5288. This commit further removes the obsolete vagrant scripts in the tree. - - - - - 36f2c342 by Cheng Shao at 2024-04-30T05:31:00-04:00 Update autoconf scripts Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 - - - - - ecbf22a6 by Ben Gamari at 2024-04-30T05:31:36-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 173549e8 by Andreas Klebinger at 2024-05-03T10:34:35+02:00 -fprof-late: Only insert cost centres on functions/non-workfree cafs. They are usually useless and doing so for data values comes with a large compile time/code size overhead. Fixes #24103 - - - - - d654fa80 by Matthew Pickering at 2024-05-03T11:30:58+01:00 packaging: Enable late-ccs for perf (and hence release) flavours This enables late cost centres when building profiled libraries and subsequently greatly improves the resolution of cost centre stacks when profiling. Fixes #21732 - - - - - 19 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/merge_request_templates/Default.md - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - .gitmodules - CODEOWNERS - compiler/GHC.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4a301a1de2bf5bb65d330133028a32e8c5390b91...d654fa80bc6a8b0ebe0a351b3e3835a21c9f314e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4a301a1de2bf5bb65d330133028a32e8c5390b91...d654fa80bc6a8b0ebe0a351b3e3835a21c9f314e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 10:43:12 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 03 May 2024 06:43:12 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/widen-stats-window2 Message-ID: <6634bfc0d26d4_3a57aac8bb8298cd@gitlab.mail> Matthew Pickering pushed new branch wip/widen-stats-window2 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/widen-stats-window2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 10:43:54 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 03 May 2024 06:43:54 -0400 Subject: [Git][ghc/ghc][wip/widen-stats-window2] tests: Widen acceptance window for dir and so size tests Message-ID: <6634bfea1da8b_3a57aa10142c3007b@gitlab.mail> Matthew Pickering pushed to branch wip/widen-stats-window2 at Glasgow Haskell Compiler / GHC Commits: f32bffc6 by Matthew Pickering at 2024-05-03T11:43:24+01:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 1 changed file: - testsuite/tests/perf/size/all.T Changes: ===================================== testsuite/tests/perf/size/all.T ===================================== @@ -3,77 +3,79 @@ test('size_hello_obj', [collect_size(5, 'size_hello_obj.o')], compile, ['']) test('size_hello_artifact', [collect_size(5, 'size_hello_artifact' + exe_extension())], compile_artifact, ['']) -test('array_dir' ,[collect_size_ghc_pkg(5 , 'array')] , static_stats , [] ) -test('base_dir' ,[collect_size_ghc_pkg(5 , 'base')] , static_stats , [] ) -test('binary_dir' ,[collect_size_ghc_pkg(5 , 'binary')] , static_stats , [] ) -test('bytestring_dir' ,[collect_size_ghc_pkg(5 , 'bytestring')] , static_stats , [] ) -test('cabal_dir' ,[collect_size_ghc_pkg(5 , 'Cabal')] , static_stats , [] ) -test('cabal_syntax_dir' ,[collect_size_ghc_pkg(5 , 'Cabal-syntax')] , static_stats , [] ) -test('containers_dir' ,[collect_size_ghc_pkg(5 , 'containers')] , static_stats , [] ) -test('deepseq_dir' ,[collect_size_ghc_pkg(5 , 'deepseq')] , static_stats , [] ) -test('directory_dir' ,[collect_size_ghc_pkg(5 , 'directory')] , static_stats , [] ) -test('exceptions_dir' ,[collect_size_ghc_pkg(5 , 'exceptions')] , static_stats , [] ) -test('ghc_bignum_dir' ,[collect_size_ghc_pkg(5 , 'ghc-bignum')] , static_stats , [] ) -test('ghc_boot_dir' ,[collect_size_ghc_pkg(5 , 'ghc-boot')] , static_stats , [] ) -test('ghc_boot_th_dir' ,[collect_size_ghc_pkg(5 , 'ghc-boot-th')] , static_stats , [] ) -test('ghc_compact_dir' ,[collect_size_ghc_pkg(5 , 'ghc-compact')] , static_stats , [] ) -test('ghc_dir' ,[collect_size_ghc_pkg(5 , 'ghc')] , static_stats , [] ) -test('ghc_experimental_dir',[collect_size_ghc_pkg(5 , 'ghc-experimental')], static_stats , [] ) -test('ghc_heap_dir' ,[collect_size_ghc_pkg(5 , 'ghc-heap')] , static_stats , [] ) -test('ghc_internal_dir' ,[collect_size_ghc_pkg(5 , 'ghc-internal')] , static_stats , [] ) -test('ghc_platform_dir' ,[collect_size_ghc_pkg(5 , 'ghc-platform')] , static_stats , [] ) -test('ghc_prim_dir' ,[collect_size_ghc_pkg(5 , 'ghc-prim')] , static_stats , [] ) -test('ghc_toolchain_dir' ,[collect_size_ghc_pkg(5 , 'ghc-toolchain')] , static_stats , [] ) -test('haskeline_dir' ,[collect_size_ghc_pkg(5 , 'haskeline')] , static_stats , [] ) -test('hpc_dir' ,[collect_size_ghc_pkg(5 , 'hpc')] , static_stats , [] ) -test('integer_gmp_dir' ,[collect_size_ghc_pkg(5 , 'integer-gmp')] , static_stats , [] ) -test('mtl_dir' ,[collect_size_ghc_pkg(5 , 'mtl')] , static_stats , [] ) -test('os_string_dir' ,[collect_size_ghc_pkg(5 , 'os-string')] , static_stats , [] ) -test('parsec_dir' ,[collect_size_ghc_pkg(5 , 'parsec')] , static_stats , [] ) -test('pretty_dir' ,[collect_size_ghc_pkg(5 , 'pretty')] , static_stats , [] ) -test('process_dir' ,[collect_size_ghc_pkg(5 , 'process')] , static_stats , [] ) -test('time_dir' ,[collect_size_ghc_pkg(5 , 'time')] , static_stats , [] ) -test('xhtml_dir' ,[collect_size_ghc_pkg(5 , 'xhtml')] , static_stats , [] ) +size_acceptance_threshold = 100 + +test('array_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'array')] , static_stats , [] ) +test('base_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'base')] , static_stats , [] ) +test('binary_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'binary')] , static_stats , [] ) +test('bytestring_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'bytestring')] , static_stats , [] ) +test('cabal_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'Cabal')] , static_stats , [] ) +test('cabal_syntax_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'Cabal-syntax')] , static_stats , [] ) +test('containers_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'containers')] , static_stats , [] ) +test('deepseq_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'deepseq')] , static_stats , [] ) +test('directory_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'directory')] , static_stats , [] ) +test('exceptions_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'exceptions')] , static_stats , [] ) +test('ghc_bignum_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-bignum')] , static_stats , [] ) +test('ghc_boot_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-boot')] , static_stats , [] ) +test('ghc_boot_th_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-boot-th')] , static_stats , [] ) +test('ghc_compact_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-compact')] , static_stats , [] ) +test('ghc_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc')] , static_stats , [] ) +test('ghc_experimental_dir',[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-experimental')], static_stats , [] ) +test('ghc_heap_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-heap')] , static_stats , [] ) +test('ghc_internal_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-internal')] , static_stats , [] ) +test('ghc_platform_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-platform')] , static_stats , [] ) +test('ghc_prim_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-prim')] , static_stats , [] ) +test('ghc_toolchain_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-toolchain')] , static_stats , [] ) +test('haskeline_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'haskeline')] , static_stats , [] ) +test('hpc_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'hpc')] , static_stats , [] ) +test('integer_gmp_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'integer-gmp')] , static_stats , [] ) +test('mtl_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'mtl')] , static_stats , [] ) +test('os_string_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'os-string')] , static_stats , [] ) +test('parsec_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'parsec')] , static_stats , [] ) +test('pretty_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'pretty')] , static_stats , [] ) +test('process_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'process')] , static_stats , [] ) +test('time_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'time')] , static_stats , [] ) +test('xhtml_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'xhtml')] , static_stats , [] ) # size of the entire libdir test('libdir' ,[collect_size_dir(10, config.libdir)] , static_stats , [] ) # skip these on windows -test('unix_dir' ,[windows_skip, collect_size_ghc_pkg(5, 'unix')] , static_stats, [] ) -test('terminfo_dir' ,[windows_skip, js_skip, collect_size_ghc_pkg(5, 'terminfo')], static_stats, [] ) +test('unix_dir' ,[windows_skip, collect_size_ghc_pkg(size_acceptance_threshold, 'unix')] , static_stats, [] ) +test('terminfo_dir' ,[windows_skip, js_skip, collect_size_ghc_pkg(size_acceptance_threshold, 'terminfo')], static_stats, [] ) # skip the shared object file tests on windows -test('array_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "array")] , static_stats, [] ) -test('base_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "base")] , static_stats, [] ) -test('binary_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "binary")] , static_stats, [] ) -test('bytestring_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "bytestring")] , static_stats, [] ) -test('cabal_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "Cabal")] , static_stats, [] ) -test('cabal_syntax_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "Cabal-syntax")] , static_stats, [] ) -test('containers_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "containers")] , static_stats, [] ) -test('deepseq_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "deepseq")] , static_stats, [] ) -test('directory_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "directory")] , static_stats, [] ) -test('exceptions_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "exceptions")] , static_stats, [] ) -test('filepath_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "filepath")] , static_stats, [] ) -test('ghc_bignum_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-bignum")] , static_stats, [] ) -test('ghc_boot_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-boot")] , static_stats, [] ) -test('ghc_boot_th_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-boot-th")] , static_stats, [] ) -test('ghc_experimental_so',[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-experimental")] , static_stats, [] ) -test('ghc_heap_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-heap")] , static_stats, [] ) -test('ghc_platform_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-platform")] , static_stats, [] ) -test('ghc_prim_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-prim")] , static_stats, [] ) -test('ghc_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc")] , static_stats, [] ) -test('ghc_toolchain_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-toolchain")] , static_stats, [] ) -test('ghci_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghci")] , static_stats, [] ) -test('haskeline_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "haskeline")] , static_stats, [] ) -test('hpc_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "hpc")] , static_stats, [] ) -test('mtl_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "mtl")] , static_stats, [] ) -test('os_string_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "os-string")] , static_stats, [] ) -test('parsec_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "parsec")] , static_stats, [] ) -test('process_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "process")] , static_stats, [] ) -test('rts_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "rts", True)] , static_stats, [] ) -test('template_haskell_so',[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "template-haskell")] , static_stats, [] ) -test('terminfo_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "terminfo")] , static_stats, [] ) -test('text_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "text")] , static_stats, [] ) -test('time_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "time")] , static_stats, [] ) -test('transformers_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "transformers")] , static_stats, [] ) -test('xhtml_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "xhtml")] , static_stats, [] ) +test('array_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "array")] , static_stats, [] ) +test('base_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "base")] , static_stats, [] ) +test('binary_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "binary")] , static_stats, [] ) +test('bytestring_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "bytestring")] , static_stats, [] ) +test('cabal_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "Cabal")] , static_stats, [] ) +test('cabal_syntax_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "Cabal-syntax")] , static_stats, [] ) +test('containers_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "containers")] , static_stats, [] ) +test('deepseq_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "deepseq")] , static_stats, [] ) +test('directory_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "directory")] , static_stats, [] ) +test('exceptions_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "exceptions")] , static_stats, [] ) +test('filepath_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "filepath")] , static_stats, [] ) +test('ghc_bignum_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-bignum")] , static_stats, [] ) +test('ghc_boot_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-boot")] , static_stats, [] ) +test('ghc_boot_th_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-boot-th")] , static_stats, [] ) +test('ghc_experimental_so',[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-experimental")] , static_stats, [] ) +test('ghc_heap_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-heap")] , static_stats, [] ) +test('ghc_platform_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-platform")] , static_stats, [] ) +test('ghc_prim_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-prim")] , static_stats, [] ) +test('ghc_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc")] , static_stats, [] ) +test('ghc_toolchain_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-toolchain")] , static_stats, [] ) +test('ghci_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghci")] , static_stats, [] ) +test('haskeline_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "haskeline")] , static_stats, [] ) +test('hpc_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "hpc")] , static_stats, [] ) +test('mtl_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "mtl")] , static_stats, [] ) +test('os_string_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "os-string")] , static_stats, [] ) +test('parsec_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "parsec")] , static_stats, [] ) +test('process_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "process")] , static_stats, [] ) +test('rts_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "rts", True)] , static_stats, [] ) +test('template_haskell_so',[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "template-haskell")] , static_stats, [] ) +test('terminfo_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "terminfo")] , static_stats, [] ) +test('text_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "text")] , static_stats, [] ) +test('time_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "time")] , static_stats, [] ) +test('transformers_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "transformers")] , static_stats, [] ) +test('xhtml_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "xhtml")] , static_stats, [] ) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f32bffc6d6c6da78d43bf3cbdc7f4f98ae6feff9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f32bffc6d6c6da78d43bf3cbdc7f4f98ae6feff9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 10:54:36 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 03 May 2024 06:54:36 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 10 commits: Expose constructors of SNat, SChar and SSymbol in ghc-internal Message-ID: <6634c26c1cdb1_3a57aa3537343476d@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 67e7c9cd by Oleg Grenrus at 2024-05-03T06:54:19-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - 9d3351d2 by Mikolaj Konarski at 2024-05-03T06:54:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - cc65de9c by Serge S. Gulin at 2024-05-03T06:54:24-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - a8ccf5cd by Simon Peyton Jones at 2024-05-03T06:54:25-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - f68f4bdd by Simon Peyton Jones at 2024-05-03T06:54:25-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 15029051 by Simon Peyton Jones at 2024-05-03T06:54:25-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - fb874da5 by Simon Peyton Jones at 2024-05-03T06:54:25-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 2039c5ce by Cheng Shao at 2024-05-03T06:54:28-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - e2a87175 by Cheng Shao at 2024-05-03T06:54:29-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 9c336027 by Alan Zimmerman at 2024-05-03T06:54:30-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - 30 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Stg/Subst.hs - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/StgToJS/Linker/Utils.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Utils.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7962839dff8d46daca9b8d40c529308436944e81...9c3360279088e30380917414aa09c53cf8409b34 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7962839dff8d46daca9b8d40c529308436944e81...9c3360279088e30380917414aa09c53cf8409b34 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 11:23:29 2024 From: gitlab at gitlab.haskell.org (Ryan Scott (@RyanGlScott)) Date: Fri, 03 May 2024 07:23:29 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24750 Message-ID: <6634c9314a005_3a57aa8501745028e@gitlab.mail> Ryan Scott pushed new branch wip/T24750 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24750 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 11:32:46 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Fri, 03 May 2024 07:32:46 -0400 Subject: [Git][ghc/ghc][wip/hugepages] Implement support for 2MB hugepages Message-ID: <6634cb5eb7a3_3a57aaa1db286345c@gitlab.mail> Teo Camarasu pushed to branch wip/hugepages at Glasgow Haskell Compiler / GHC Commits: d1d829ab by Teo Camarasu at 2024-05-03T12:32:27+01:00 Implement support for 2MB hugepages We enable/disable it through a runtime flag (-xH). When enabled we ensure we only (de)allocate in aligned multiples of 2MB. - - - - - 4 changed files: - rts/include/rts/Constants.h - rts/posix/OSMem.c - rts/sm/BlockAlloc.c - rts/sm/OSMem.h Changes: ===================================== rts/include/rts/Constants.h ===================================== @@ -170,7 +170,7 @@ #define BLOCK_SHIFT 12 /* The size of a megablock (2^MBLOCK_SHIFT bytes) */ -#define MBLOCK_SHIFT 21 +#define MBLOCK_SHIFT 20 /* ----------------------------------------------------------------------------- Bitmap/size fields (used in info tables) ===================================== rts/posix/OSMem.c ===================================== @@ -60,12 +60,6 @@ # endif #endif -#if defined(HAVE_LINUX_MMAN_H) -#include - -#define HUGEPAGE_SIZE (2*1024*1024) -#define HUGEPAGE_FLAGS (MAP_HUGETLB | MAP_HUGE_2MB) -#endif #if !defined(darwin_HOST_OS) # undef RESERVE_FLAGS @@ -244,19 +238,19 @@ my_mmap (void *addr, W_ size, int operation) # endif } else if (operation == MEM_COMMIT) { flags = MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE; -#if defined(HUGEPAGE_SIZE) +#if defined(HUGEPAGE_FLAGS) if ( RtsFlags.GcFlags.hugepages && (size & (HUGEPAGE_SIZE - 1)) == 0) { huge_tried += 1; flags |= HUGEPAGE_FLAGS; } -#endif /* defined(HUGEPAGE_SIZE) */ +#endif /* defined(HUGEPAGE_FLAGS) */ } else { flags = MAP_ANON | MAP_PRIVATE; } ret = mmap(addr, size, prot, flags, -1, 0); -#if defined(HUGEPAGE_SIZE) +#if defined(HUGEPAGE_FLAGS) // If the mmap failed, and we tried with HUGEPAGE_FLAGS // then retry without. if (ret == MAP_FAILED && flags & HUGEPAGE_FLAGS){ @@ -698,6 +692,10 @@ void osDecommitMemory(void *at, W_ size) if(r < 0) sysErrorBelch("unable to make released memory unaccessible"); #endif + if(RtsFlags.GcFlags.hugepages) { + ASSERT( ((HUGEPAGE_SIZE - 1) & (uintptr_t)at) == 0); + ASSERT( ((HUGEPAGE_SIZE - 1) & size) == 0); + } #if defined(MADV_FREE) // See Note [MADV_FREE and MADV_DONTNEED]. ===================================== rts/sm/BlockAlloc.c ===================================== @@ -25,7 +25,8 @@ #include -static void initMBlock(void *mblock, uint32_t node); +static void initMBlock(void *mblock, uint32_t node); +static void free_mega_group (bdescr *mg); /* * By default the DEBUG RTS is built with block allocator assertions @@ -478,13 +479,30 @@ alloc_mega_group (uint32_t node, StgWord mblocks) else { void *mblock; + StgWord hugepage_mblocks; + if(RtsFlags.GcFlags.hugepages) { + // Round up allocation to hugepage size + hugepage_mblocks = MBLOCK_ROUND_UP_HUGEPAGE(mblocks); + } + else { + hugepage_mblocks = mblocks; + } + if (RtsFlags.GcFlags.numa) { - mblock = getMBlocksOnNode(node, mblocks); + mblock = getMBlocksOnNode(node, hugepage_mblocks); } else { - mblock = getMBlocks(mblocks); + mblock = getMBlocks(hugepage_mblocks); } initMBlock(mblock, node); // only need to init the 1st one bd = FIRST_BDESCR(mblock); + + // Free the slop + if(hugepage_mblocks > mblocks) { + bdescr *mblock_slop_bd = FIRST_BDESCR((uintptr_t)mblock + (uintptr_t)mblocks*MBLOCK_SIZE); + initMBlock(MBLOCK_ROUND_DOWN(mblock_slop_bd), node); + mblock_slop_bd->blocks = MBLOCK_GROUP_BLOCKS(hugepage_mblocks-mblocks); + free_mega_group(mblock_slop_bd); + } } bd->blocks = MBLOCK_GROUP_BLOCKS(mblocks); return bd; @@ -812,7 +830,7 @@ coalesce_mblocks (bdescr *p) return q; } -static void +void free_mega_group (bdescr *mg) { bdescr *bd, *prev; @@ -1199,10 +1217,15 @@ uint32_t returnMemoryToOS(uint32_t n /* megablocks */) return 0; #else bdescr *bd; + bdescr *rejects; + bdescr *next; uint32_t node; - StgWord size; + StgWord size, unaligned_size, freeable_size; uint32_t init_n; init_n = n; + if(RtsFlags.GcFlags.hugepages) { + n = MBLOCK_ROUND_DOWN_HUGEPAGE(n); + } // TODO: This is inefficient because this loop will essentially result in // quadratic runtime behavior: for each call to `freeMBlocks`, the @@ -1215,22 +1238,64 @@ uint32_t returnMemoryToOS(uint32_t n /* megablocks */) // ToDo: not fair, we free all the memory starting with node 0. for (node = 0; n > 0 && node < n_numa_nodes; node++) { bd = free_mblock_list[node]; + rejects = NULL; while ((n > 0) && (bd != NULL)) { size = BLOCKS_TO_MBLOCKS(bd->blocks); - if (size > n) { - StgWord newSize = size - n; - char *freeAddr = MBLOCK_ROUND_DOWN(bd->start); - freeAddr += newSize * MBLOCK_SIZE; - bd->blocks = MBLOCK_GROUP_BLOCKS(newSize); - freeMBlocks(freeAddr, n); - n = 0; - } + next = bd->link; + char *aligned_start; + + if(RtsFlags.GcFlags.hugepages) { + aligned_start = (char*)MBLOCK_ROUND_DOWN(bd) + ((uintptr_t)MBLOCK_ROUND_DOWN(bd) & HUGEPAGE_MASK); + unaligned_size = (aligned_start - (char*)MBLOCK_ROUND_DOWN(bd)) / MBLOCK_SIZE; + freeable_size = MBLOCK_ROUND_DOWN_HUGEPAGE(size - unaligned_size); + } else { - char *freeAddr = MBLOCK_ROUND_DOWN(bd->start); - n -= size; - bd = bd->link; - freeMBlocks(freeAddr, size); + aligned_start = (char*)MBLOCK_ROUND_DOWN(bd); + unaligned_size = 0; + freeable_size = size; } + + // We cannot free more than n + freeable_size = stg_min(n, freeable_size); + + // Place the front unaligned section back on the list. + // If we can't free any of it then this is the entire thing. + if (unaligned_size > 0 || freeable_size == 0) { + bd->link = rejects; + rejects = bd; + // If we are freeing some mblocks from the middle then initialise + // the first MBlock and update the sizes. + if (freeable_size > 0) { + bd->blocks = MBLOCK_GROUP_BLOCKS(unaligned_size); + bdescr *aligned_bd; + aligned_bd = FIRST_BDESCR(aligned_start); + aligned_bd->blocks = MBLOCK_GROUP_BLOCKS(freeable_size); + } + } + + if(freeable_size > 0) { + n -= freeable_size; + freeMBlocks(aligned_start, freeable_size); + // add the slop to the rejects list + if (size - unaligned_size - freeable_size > 0) + { + void *slop = aligned_start + freeable_size * MBLOCK_SIZE; + bdescr* slop_bd = FIRST_BDESCR(slop); + slop_bd->blocks = MBLOCK_GROUP_BLOCKS(size - unaligned_size - freeable_size); + slop_bd->link = rejects; + rejects = slop_bd; + } + } + bd = next; + } + // Place the rejected mblocks back on the free list. + while(rejects) { + // pop the top of the rejects list. + next = rejects; + rejects = next->link; + // place it back on the free list. + next->link = bd; + bd = next; } free_mblock_list[node] = bd; } ===================================== rts/sm/OSMem.h ===================================== @@ -10,6 +10,20 @@ #include "BeginPrivate.h" +#if defined(HAVE_LINUX_MMAN_H) +#include + +#define HUGEPAGE_SHIFT 21 +#define HUGEPAGE_FLAGS (MAP_HUGETLB | MAP_HUGE_2MB) +#else +#define HUGEPAGE_SHIFT 20 +#endif + +#define HUGEPAGE_SIZE (1 << HUGEPAGE_SHIFT) +#define HUGEPAGE_MASK ((1 << HUGEPAGE_SHIFT) - 1) +#define MBLOCK_ROUND_DOWN_HUGEPAGE(x) ((x) & ~(HUGEPAGE_SHIFT - MBLOCK_SHIFT)) +#define MBLOCK_ROUND_UP_HUGEPAGE(x) ((x) + ((x) & (HUGEPAGE_SHIFT - MBLOCK_SHIFT))) + void osMemInit(void); void *osGetMBlocks(uint32_t n); void osFreeMBlocks(void *addr, uint32_t n); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d1d829ab9d0f4128cd0a19efcab1097d98c744e1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d1d829ab9d0f4128cd0a19efcab1097d98c744e1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 11:47:18 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Fri, 03 May 2024 07:47:18 -0400 Subject: [Git][ghc/ghc][wip/andreask/late_workfree] -fprof-late: Only insert cost centres on functions/non-workfree cafs. Message-ID: <6634cec6cccd7_3a57aac21be06701f@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/late_workfree at Glasgow Haskell Compiler / GHC Commits: 757f0d6c by Andreas Klebinger at 2024-05-03T13:47:07+02:00 -fprof-late: Only insert cost centres on functions/non-workfree cafs. They are usually useless and doing so for data values comes with a large compile time/code size overhead. Fixes #24103 - - - - - 8 changed files: - compiler/GHC/Core/LateCC.hs - compiler/GHC/Core/LateCC/TopLevelBinds.hs - compiler/GHC/Core/LateCC/Types.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Types/RepType.hs - docs/users_guide/9.12.1-notes.rst - docs/users_guide/profiling.rst Changes: ===================================== compiler/GHC/Core/LateCC.hs ===================================== @@ -21,6 +21,7 @@ import GHC.Types.SrcLoc import GHC.Utils.Error import GHC.Utils.Logger import GHC.Utils.Outputable +import GHC.Types.RepType (mightBeFunTy) -- | Late cost center insertion logic used by the driver addLateCostCenters :: @@ -78,8 +79,11 @@ addLateCostCenters logger LateCCConfig{..} core_binds = do top_level_cc_pred :: CoreExpr -> Bool top_level_cc_pred = case lateCCConfig_whichBinds of - LateCCAllBinds -> - const True + LateCCBinds -> \rhs -> + -- Make sure we record any functions. Even if it's something like `f = g`. + mightBeFunTy (exprType rhs) || + -- If the RHS is a CAF doing work also insert a CC. + not (exprIsWorkFree rhs) LateCCOverloadedBinds -> isOverloadedTy . exprType LateCCNone -> ===================================== compiler/GHC/Core/LateCC/TopLevelBinds.hs ===================================== @@ -3,16 +3,18 @@ module GHC.Core.LateCC.TopLevelBinds where import GHC.Prelude -import GHC.Core --- import GHC.Core.LateCC import GHC.Core.LateCC.Types import GHC.Core.LateCC.Utils + +import GHC.Core import GHC.Core.Opt.Monad import GHC.Driver.DynFlags import GHC.Types.Id import GHC.Types.Name import GHC.Unit.Module.ModGuts +import Data.Maybe + {- Note [Collecting late cost centres] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Usually cost centres defined by a module are collected @@ -26,7 +28,7 @@ us from collecting them here when we run this pass before tidy. Note [Adding late cost centres to top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The basic idea is very simple. For every top level binder +The basic idea is very simple. For a top level binder `f = rhs` we compile it as if the user had written `f = {-# SCC f #-} rhs`. @@ -37,6 +39,21 @@ might inhibit optimizations at the call site. For this reason we provide flags for both approaches as they have different tradeoffs. +To reduce overhead we ignore workfree bindings because they don't contribute +meaningfully to a performance profile. This reduces code size massively as it +allows us to allocate definitions like `val = Just 32` at compile time instead +of turning them into a CAF of the form `val = let x = Just 32 in x` which +would be the alternative. + +We make an exception for rhss with function types. This allows us to get +cost centres on eta-reduced definitions like `f = g`. By putting a tick onto +`f`s rhs we end up with + + f = \eta1 eta2 ... etan -> + g eta1 ... etan + +Which can make it easier to understand call graphs of an application. + We also don't add a cost centre for any binder that is a constructor worker or wrapper. These will never meaningfully enrich the resulting profile so we improve efficiency by omitting those. @@ -89,15 +106,20 @@ topLevelBindsCC pred core_bind = doBndr :: Id -> CoreExpr -> LateCCM s CoreExpr doBndr bndr rhs - -- Cost centres on constructor workers are pretty much useless - -- so we don't emit them if we are looking at the rhs of a constructor - -- binding. - | Just _ <- isDataConId_maybe bndr = pure rhs - | otherwise = if pred rhs then addCC bndr rhs else pure rhs + -- Not a constructor worker. + -- Cost centres on constructor workers are pretty much useless so we don't emit them + -- if we are looking at the rhs of a constructor binding. + | isNothing (isDataConId_maybe bndr) + , pred rhs + = addCC bndr rhs + | otherwise = pure rhs -- We want to put the cost centre below the lambda as we only care about - -- executions of the RHS. + -- executions of the RHS. Note that the lambdas might be hidden under ticks + -- or casts. So look through these as well. addCC :: Id -> CoreExpr -> LateCCM s CoreExpr + addCC bndr (Cast rhs co) = pure Cast <*> addCC bndr rhs <*> pure co + addCC bndr (Tick t rhs) = (Tick t) <$> addCC bndr rhs addCC bndr (Lam b rhs) = Lam b <$> addCC bndr rhs addCC bndr rhs = do let name = idName bndr ===================================== compiler/GHC/Core/LateCC/Types.hs ===================================== @@ -34,7 +34,7 @@ data LateCCConfig = -- | The types of top-level bindings we support adding cost centers to. data LateCCBindSpec = LateCCNone - | LateCCAllBinds + | LateCCBinds | LateCCOverloadedBinds -- | Late cost centre insertion environment ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -1954,6 +1954,8 @@ isPiTy ty = case coreFullView ty of _ -> False -- | Is this a function? +-- Note: `forall {b}. Show b => b -> IO b` will not be considered a function by this function. +-- It would merely be a forall wrapping a function type. isFunTy :: Type -> Bool isFunTy ty | FunTy {} <- coreFullView ty = True ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -1805,7 +1805,7 @@ hscGenHardCode hsc_env cgguts location output_filename = do if gopt Opt_ProfLateInlineCcs dflags then LateCCNone else if gopt Opt_ProfLateCcs dflags then - LateCCAllBinds + LateCCBinds else if gopt Opt_ProfLateOverloadedCcs dflags then LateCCOverloadedBinds else ===================================== compiler/GHC/Types/RepType.hs ===================================== @@ -693,6 +693,9 @@ mightBeFunTy :: Type -> Bool -- AK: It would be nice to figure out and document the difference -- between this and isFunTy at some point. mightBeFunTy ty + -- Currently ghc has no unlifted functions. + | definitelyUnliftedType ty + = False | [BoxedRep _] <- typePrimRep ty , Just tc <- tyConAppTyCon_maybe (unwrapType ty) , isDataTyCon tc ===================================== docs/users_guide/9.12.1-notes.rst ===================================== @@ -26,6 +26,16 @@ Language Compiler ~~~~~~~~ +- The flag `-fprof-late` will no longer prevent top level constructors from being statically allocated. + + It used to be the case that we would add a cost centre for bindings like `foo = Just bar`. + This turned the binding into a caf that would allocate the constructor on first evaluation. + + However without the cost centre `foo` can be allocated at compile time. This reduces code-bloat and + reduces overhead for short-running applications. + + The tradeoff is that calling `whoCreated` on top level value definitions like `foo` will be less informative. + GHCi ~~~~ ===================================== docs/users_guide/profiling.rst ===================================== @@ -483,10 +483,12 @@ of your profiled program will be different to that of the unprofiled one. :since: 9.4.1 - Adds an automatic ``SCC`` annotation to all top level bindings late in the compilation pipeline after - the optimizer has run and unfoldings have been created. This means these cost centres will not interfere with core-level optimizations + Adds an automatic ``SCC`` annotation to all top level bindings which might perform work. + This is done late in the compilation pipeline after the optimizer has run and unfoldings have been created. + This means these cost centres will not interfere with core-level optimizations and the resulting profile will be closer to the performance profile of an optimized non-profiled executable. + While the results of this are generally informative, some of the compiler internal names will leak into the profile. Further if a function is inlined into a use site it's costs will be counted against the caller's cost center. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/757f0d6c2c05006fc7556cce949816c54e19e2cb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/757f0d6c2c05006fc7556cce949816c54e19e2cb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 11:51:38 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 03 May 2024 07:51:38 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/mr-12520 Message-ID: <6634cfcab9f19_3a57aad97510735a9@gitlab.mail> Matthew Pickering pushed new branch wip/mr-12520 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/mr-12520 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 13:54:26 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 03 May 2024 09:54:26 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24504 Message-ID: <6634ec92d1e90_3a57aa1c54b98102551@gitlab.mail> Ben Gamari pushed new branch wip/T24504 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24504 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 13:54:54 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 03 May 2024 09:54:54 -0400 Subject: [Git][ghc/ghc][wip/T24504] IPE: Eliminate dependency on Read Message-ID: <6634ecaeac68c_3a57aa1c7b89c1027f3@gitlab.mail> Ben Gamari pushed to branch wip/T24504 at Glasgow Haskell Compiler / GHC Commits: 691ee135 by Ben Gamari at 2024-05-03T09:54:33-04:00 IPE: Eliminate dependency on Read Instead of encoding the closure type as decimal string we now simply represent it as an integer, eliminating the need for `Read` in `GHC.Internal.InfoProv.Types.peekInfoProv`. Closes #24504. - - - - - 4 changed files: - compiler/GHC/StgToCmm/InfoTableProv.hs - libraries/ghc-internal/src/GHC/Internal/InfoProv/Types.hsc - rts/IPE.c - rts/include/rts/IPE.h Changes: ===================================== compiler/GHC/StgToCmm/InfoTableProv.hs ===================================== @@ -178,7 +178,7 @@ toIpeBufferEntries byte_order cg_ipes = to_ipe_buf_ent :: CgInfoProvEnt -> [Word32] to_ipe_buf_ent cg_ipe = [ ipeTableName cg_ipe - , ipeClosureDesc cg_ipe + , fromIntegral $ ipeClosureDesc cg_ipe , ipeTypeDesc cg_ipe , ipeLabel cg_ipe , ipeSrcFile cg_ipe @@ -193,7 +193,6 @@ toIpeBufferEntries byte_order cg_ipes = toCgIPE :: Platform -> SDocContext -> InfoProvEnt -> State StringTable CgInfoProvEnt toCgIPE platform ctx ipe = do table_name <- lookupStringTable $ ST.pack $ renderWithContext ctx (pprCLabel platform (infoTablePtr ipe)) - closure_desc <- lookupStringTable $ ST.pack $ show (infoProvEntClosureType ipe) type_desc <- lookupStringTable $ ST.pack $ infoTableType ipe let label_str = maybe "" ((\(LexicalFastString s) -> unpackFS s) . snd) (infoTableProv ipe) let (src_loc_file, src_loc_span) = @@ -208,7 +207,7 @@ toCgIPE platform ctx ipe = do src_span <- lookupStringTable $ ST.pack src_loc_span return $ CgInfoProvEnt { ipeInfoTablePtr = infoTablePtr ipe , ipeTableName = table_name - , ipeClosureDesc = closure_desc + , ipeClosureDesc = fromIntegral (infoProvEntClosureType ipe) , ipeTypeDesc = type_desc , ipeLabel = label , ipeSrcFile = src_file @@ -218,7 +217,7 @@ toCgIPE platform ctx ipe = do data CgInfoProvEnt = CgInfoProvEnt { ipeInfoTablePtr :: !CLabel , ipeTableName :: !StrTabOffset - , ipeClosureDesc :: !StrTabOffset + , ipeClosureDesc :: !Word32 , ipeTypeDesc :: !StrTabOffset , ipeLabel :: !StrTabOffset , ipeSrcFile :: !StrTabOffset ===================================== libraries/ghc-internal/src/GHC/Internal/InfoProv/Types.hsc ===================================== @@ -18,8 +18,9 @@ module GHC.Internal.InfoProv.Types ) where import GHC.Internal.Base -import GHC.Internal.Data.Maybe import GHC.Internal.Enum +import GHC.Internal.Real (fromIntegral) +import GHC.Internal.Word (Word32) import GHC.Internal.Show (Show) import GHC.Internal.Ptr (Ptr(..), plusPtr) import GHC.Internal.Foreign.C.String.Encoding (CString, peekCString) @@ -28,7 +29,6 @@ import GHC.Internal.Foreign.Marshal.Alloc (allocaBytes) import GHC.Internal.IO.Encoding (utf8) import GHC.Internal.Foreign.Storable (peekByteOff) import GHC.Internal.ClosureTypes -import GHC.Internal.Text.Read import GHC.Prim (whereFrom##) data InfoProv = InfoProv { @@ -70,9 +70,11 @@ getIPE obj fail k = allocaBytes (#size InfoProvEnt) $ \p -> IO $ \s -> ipeProv :: Ptr InfoProvEnt -> Ptr InfoProv ipeProv p = (#ptr InfoProvEnt, prov) p -peekIpName, peekIpDesc, peekIpLabel, peekIpUnitId, peekIpModule, peekIpSrcFile, peekIpSrcSpan, peekIpTyDesc :: Ptr InfoProv -> IO CString -peekIpName p = (# peek InfoProv, table_name) p +peekIpDesc :: Ptr InfoProv -> IO Word32 peekIpDesc p = (# peek InfoProv, closure_desc) p + +peekIpName, peekIpLabel, peekIpUnitId, peekIpModule, peekIpSrcFile, peekIpSrcSpan, peekIpTyDesc :: Ptr InfoProv -> IO CString +peekIpName p = (# peek InfoProv, table_name) p peekIpLabel p = (# peek InfoProv, label) p peekIpUnitId p = (# peek InfoProv, unit_id) p peekIpModule p = (# peek InfoProv, module) p @@ -83,7 +85,7 @@ peekIpTyDesc p = (# peek InfoProv, ty_desc) p peekInfoProv :: Ptr InfoProv -> IO InfoProv peekInfoProv infop = do name <- peekCString utf8 =<< peekIpName infop - desc <- peekCString utf8 =<< peekIpDesc infop + desc <- peekIpDesc infop tyDesc <- peekCString utf8 =<< peekIpTyDesc infop label <- peekCString utf8 =<< peekIpLabel infop unit_id <- peekCString utf8 =<< peekIpUnitId infop @@ -94,7 +96,7 @@ peekInfoProv infop = do ipName = name, -- The INVALID_OBJECT case should be impossible as we -- control the C code generating these values. - ipDesc = maybe INVALID_OBJECT toEnum . readMaybe @Int $ desc, + ipDesc = toEnum $ fromIntegral desc, ipTyDesc = tyDesc, ipLabel = label, ipUnitId = unit_id, ===================================== rts/IPE.c ===================================== @@ -105,7 +105,7 @@ static InfoProvEnt ipeBufferEntryToIpe(const IpeBufferListNode *node, uint32_t i .info = node->tables[idx], .prov = { .table_name = &strings[ent->table_name], - .closure_desc = &strings[ent->closure_desc], + .closure_desc = ent->closure_desc, .ty_desc = &strings[ent->ty_desc], .label = &strings[ent->label], .unit_id = &strings[node->unit_id], ===================================== rts/include/rts/IPE.h ===================================== @@ -15,7 +15,7 @@ typedef struct InfoProv_ { const char *table_name; - const char *closure_desc; + uint32_t closure_desc; // closure type const char *ty_desc; const char *label; const char *unit_id; @@ -54,7 +54,7 @@ typedef uint32_t StringIdx; // to ensure correct packing. typedef struct { StringIdx table_name; - StringIdx closure_desc; + uint32_t closure_desc; // closure type StringIdx ty_desc; StringIdx label; StringIdx src_file; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/691ee135cd7ab8f7e392c252c4e3a9c94d7b5e1b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/691ee135cd7ab8f7e392c252c4e3a9c94d7b5e1b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 13:58:09 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 03 May 2024 09:58:09 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/ghc-platform-setup Message-ID: <6634ed718b801_3a57aa1da28241091b4@gitlab.mail> Ben Gamari pushed new branch wip/ghc-platform-setup at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ghc-platform-setup You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 13:58:57 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 03 May 2024 09:58:57 -0400 Subject: [Git][ghc/ghc][wip/T24741] 30 commits: Refactor the Binary serialisation interface Message-ID: <6634eda1af3db_3a57aa1e820b4110954@gitlab.mail> Ben Gamari pushed to branch wip/T24741 at Glasgow Haskell Compiler / GHC Commits: fa03b1fb by Fendor at 2024-04-26T18:03:13-04:00 Refactor the Binary serialisation interface The goal is simplifiy adding deduplication tables to `ModIface` interface serialisation. We identify two main points of interest that make this difficult: 1. UserData hardcodes what `Binary` instances can have deduplication tables. Moreover, it heavily uses partial functions. 2. GHC.Iface.Binary hardcodes the deduplication tables for 'Name' and 'FastString', making it difficult to add more deduplication. Instead of having a single `UserData` record with fields for all the types that can have deduplication tables, we allow to provide custom serialisers for any `Typeable`. These are wrapped in existentials and stored in a `Map` indexed by their respective `TypeRep`. The `Binary` instance of the type to deduplicate still needs to explicitly look up the decoder via `findUserDataReader` and `findUserDataWriter`, which is no worse than the status-quo. `Map` was chosen as microbenchmarks indicate it is the fastest for a small number of keys (< 10). To generalise the deduplication table serialisation mechanism, we introduce the types `ReaderTable` and `WriterTable` which provide a simple interface that is sufficient to implement a general purpose deduplication mechanism for `writeBinIface` and `readBinIface`. This allows us to provide a list of deduplication tables for serialisation that can be extended more easily, for example for `IfaceTyCon`, see the issue https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for more motivation. In addition to this refactoring, we split `UserData` into `ReaderUserData` and `WriterUserData`, to avoid partial functions and reduce overall memory usage, as we need fewer mutable variables. Bump haddock submodule to accomodate for `UserData` split. ------------------------- Metric Increase: MultiLayerModulesTH_Make MultiLayerModulesRecomp T21839c ------------------------- - - - - - bac57298 by Fendor at 2024-04-26T18:03:13-04:00 Split `BinHandle` into `ReadBinHandle` and `WriteBinHandle` A `BinHandle` contains too much information for reading data. For example, it needs to keep a `FastMutInt` and a `IORef BinData`, when the non-mutable variants would suffice. Additionally, this change has the benefit that anyone can immediately tell whether the `BinHandle` is used for reading or writing. Bump haddock submodule BinHandle split. - - - - - 4d6394dd by Simon Peyton Jones at 2024-04-26T18:03:49-04:00 Fix missing escaping-kind check in tcPatSynSig Note [Escaping kind in type signatures] explains how we deal with escaping kinds in type signatures, e.g. f :: forall r (a :: TYPE r). a where the kind of the body is (TYPE r), but `r` is not in scope outside the forall-type. I had missed this subtlety in tcPatSynSig, leading to #24686. This MR fixes it; and a similar bug in tc_top_lhs_type. (The latter is tested by T24686a.) - - - - - 981c2c2c by Alan Zimmerman at 2024-04-26T18:04:25-04:00 EPA: check-exact: check that the roundtrip reproduces the source Closes #24670 - - - - - a8616747 by Andrew Lelechenko at 2024-04-26T18:05:01-04:00 Document that setEnv is not thread-safe - - - - - 1e41de83 by Bryan Richter at 2024-04-26T18:05:37-04:00 CI: Work around frequent Signal 9 errors - - - - - a6d5f9da by Naïm Favier at 2024-04-27T17:52:40-04:00 ghc-internal: add MonadFix instance for (,) Closes https://gitlab.haskell.org/ghc/ghc/-/issues/24288, implements CLC proposal https://github.com/haskell/core-libraries-committee/issues/238. Adds a MonadFix instance for tuples, permitting value recursion in the "native" writer monad and bringing consistency with the existing instance for transformers's WriterT (and, to a lesser extent, for Solo). - - - - - 64feadcd by Rodrigo Mesquita at 2024-04-27T17:53:16-04:00 bindist: Fix xattr cleaning The original fix (725343aa) was incorrect because it used the shell bracket syntax which is the quoting syntax in autoconf, making the test for existence be incorrect and therefore `xattr` was never run. Fixes #24554 - - - - - e2094df3 by damhiya at 2024-04-28T23:52:00+09:00 Make read accepts binary integer formats CLC proposal : https://github.com/haskell/core-libraries-committee/issues/177 - - - - - 1c2fd963 by Alan Zimmerman at 2024-04-29T23:17:00-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 - - - - - 4189d17e by Sylvain Henry at 2024-04-29T23:17:42-04:00 LLVM: better unreachable default destination in Switch (#24717) See added note. Co-authored-by: Siddharth Bhat <siddu.druid at gmail.com> - - - - - a3725c88 by Cheng Shao at 2024-04-29T23:18:20-04:00 ci: enable wasm jobs for MRs with wasm label This patch enables wasm jobs for MRs with wasm label. Previously the wasm label didn't actually have any effect on the CI pipeline, and full-ci needed to be applied to run wasm jobs which was a waste of runners when working on the wasm backend, hence the fix here. - - - - - 702f7964 by Matthew Pickering at 2024-04-29T23:18:56-04:00 Make interface files and object files depend on inplace .conf file A potential fix for #24737 - - - - - 728af21e by Cheng Shao at 2024-04-30T05:30:23-04:00 utils: remove obsolete vagrant scripts Vagrantfile has long been removed in !5288. This commit further removes the obsolete vagrant scripts in the tree. - - - - - 36f2c342 by Cheng Shao at 2024-04-30T05:31:00-04:00 Update autoconf scripts Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 - - - - - ecbf22a6 by Ben Gamari at 2024-04-30T05:31:36-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 79efdf1e by Ben Gamari at 2024-05-03T09:58:50-04:00 Introduce GHC.Tc.Plugin.lookupTHName As proposed in #24741. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - compiler/GHC.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Ext/Fields.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Recomp/Binary.hs - compiler/GHC/Iface/Recomp/Flags.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Eval/Types.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/StgToJS/Apply.hs - compiler/GHC/StgToJS/Arg.hs - compiler/GHC/StgToJS/Closure.hs - compiler/GHC/StgToJS/CodeGen.hs - compiler/GHC/StgToJS/Expr.hs - compiler/GHC/StgToJS/Heap.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a13b05b14b181fbad9ed24663a62bb19fbda3324...79efdf1e7f21cb3cf04a16539777704f7bca2996 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a13b05b14b181fbad9ed24663a62bb19fbda3324...79efdf1e7f21cb3cf04a16539777704f7bca2996 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 15:20:41 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 03 May 2024 11:20:41 -0400 Subject: [Git][ghc/ghc][wip/widen-stats-window2] Disable rts_so test Message-ID: <663500c93d502_3a57aa2bd26881211d3@gitlab.mail> Matthew Pickering pushed to branch wip/widen-stats-window2 at Glasgow Haskell Compiler / GHC Commits: 6941ffb7 by Matthew Pickering at 2024-05-03T16:19:18+01:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - 1 changed file: - testsuite/tests/perf/size/all.T Changes: ===================================== testsuite/tests/perf/size/all.T ===================================== @@ -72,7 +72,8 @@ test('mtl_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_obje test('os_string_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "os-string")] , static_stats, [] ) test('parsec_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "parsec")] , static_stats, [] ) test('process_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "process")] , static_stats, [] ) -test('rts_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "rts", True)] , static_stats, [] ) +# Disabled as extremely unstable +#test('rts_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "rts", True)] , static_stats, [] ) test('template_haskell_so',[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "template-haskell")] , static_stats, [] ) test('terminfo_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "terminfo")] , static_stats, [] ) test('text_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "text")] , static_stats, [] ) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6941ffb74300878b8b176d53e26f91539f0d49f5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6941ffb74300878b8b176d53e26f91539f0d49f5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 15:51:10 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Fri, 03 May 2024 11:51:10 -0400 Subject: [Git][ghc/ghc][wip/reinstallable-th] 66 commits: testsuite: Rename isCross() predicate to needsTargetWrapper() Message-ID: <663507ee802a9_3a57aa301c3101307c9@gitlab.mail> Teo Camarasu pushed to branch wip/reinstallable-th at Glasgow Haskell Compiler / GHC Commits: 5eaa46e7 by Matthew Pickering at 2024-04-19T02:14:55-04:00 testsuite: Rename isCross() predicate to needsTargetWrapper() isCross() was a misnamed because it assumed that all cross targets would provide a target wrapper, but the two most common cross targets (javascript, wasm) don't need a target wrapper. Therefore we rename this predicate to `needsTargetWrapper()` so situations in the testsuite where we can check whether running executables requires a target wrapper or not. - - - - - 55a9d699 by Simon Peyton Jones at 2024-04-19T02:15:32-04:00 Do not float HNFs out of lambdas This MR adjusts SetLevels so that it is less eager to float a HNF (lambda or constructor application) out of a lambda, unless it gets to top level. Data suggests that this change is a small net win: * nofib bytes-allocated falls by -0.09% (but a couple go up) * perf/should_compile bytes-allocated falls by -0.5% * perf/should_run bytes-allocated falls by -0.1% See !12410 for more detail. When fiddling elsewhere, I also found that this patch had a huge positive effect on the (very delicate) test perf/should_run/T21839r But that improvement doesn't show up in this MR by itself. Metric Decrease: MultiLayerModulesRecomp T15703 parsing001 - - - - - f0701585 by Alan Zimmerman at 2024-04-19T02:16:08-04:00 EPA: Fix comments in mkListSyntaxTy0 Also extend the test to confirm. Addresses #24669, 1 of 4 - - - - - b01c01d4 by Serge S. Gulin at 2024-04-19T02:16:51-04:00 JS: set image `x86_64-linux-deb11-emsdk-closure` for build - - - - - c90c6039 by Alan Zimmerman at 2024-04-19T02:17:27-04:00 EPA: Provide correct span for PatBind And remove unused parameter in checkPatBind Contributes to #24669 - - - - - 26036f96 by Alan Zimmerman at 2024-04-19T13:11:08-04:00 EPA: Fix span for PatBuilderAppType Include the location of the prefix @ in the span for InVisPat. Also removes unnecessary annotations from HsTP. Contributes to #24669 - - - - - dba03aab by Matthew Craven at 2024-04-19T13:11:44-04:00 testsuite: Give the pre_cmd for mhu-perf more time - - - - - d31fbf6c by Krzysztof Gogolewski at 2024-04-19T21:04:09-04:00 Fix quantification order for a `op` b and a %m -> b Fixes #23764 Implements https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0640-tyop-quantification-order.rst Updates haddock submodule. - - - - - 385cd1c4 by Sebastian Graf at 2024-04-19T21:04:45-04:00 Make `seq#` a magic Id and inline it in CorePrep (#24124) We can save much code and explanation in Tag Inference and StgToCmm by making `seq#` a known-key Magic Id in `GHC.Internal.IO` and inline this definition in CorePrep. See the updated `Note [seq# magic]`. I also implemented a new `Note [Flatten case-bind]` to get better code for otherwise nested case scrutinees. I renamed the contructors of `ArgInfo` to use an `AI` prefix in order to resolve the clash between `type CpeApp = CoreExpr` and the data constructor of `ArgInfo`, as well as fixed typos in `Note [CorePrep invariants]`. Fixes #24252 and #24124. - - - - - 275e41a9 by Jade at 2024-04-20T11:10:40-04:00 Put the newline after errors instead of before them This mainly has consequences for GHCi but also slightly alters how the output of GHC on the commandline looks. Fixes: #22499 - - - - - dd339c7a by Teo Camarasu at 2024-04-20T11:11:16-04:00 Remove unecessary stage0 packages Historically quite a few packages had to be stage0 as they depended on `template-haskell` and that was stage0. In #23536 we made it so that was no longer the case. This allows us to remove a bunch of packages from this list. A few still remain. A new version of `Win32` is required by `semaphore-compat`. Including `Win32` in the stage0 set requires also including `filepath` because otherwise Hadrian's dependency logic gets confused. Once our boot compiler has a newer version of `Win32` all of these will be able to be dropped. Resolves #24652 - - - - - 2f8e3a25 by Alan Zimmerman at 2024-04-20T11:11:52-04:00 EPA: Avoid duplicated comments in splice decls Contributes to #24669 - - - - - c70b9ddb by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fix typos and namings (fixes #24602) You may noted that I've also changed term of ``` , global "h$vt_double" ||= toJExpr IntV ``` See "IntV" and ``` WaitReadOp -> \[] [fd] -> pure $ PRPrimCall $ returnS (app "h$waidRead" [fd]) ``` See "h$waidRead" - - - - - 3db54f9b by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: trivial checks for variable presence (fixes #24602) - - - - - 777f108f by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fs module imported twice (by emscripten and by ghc-internal). ghc-internal import wrapped in a closure to prevent conflict with emscripten (fixes #24602) Better solution is to use some JavaScript module system like AMD, CommonJS or even UMD. It will be investigated at other issues. At first glance we should try UMD (See https://github.com/umdjs/umd) - - - - - a45a5712 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: thread.js requires h$fds and h$fdReady to be declared for static code analysis, minimal code copied from GHCJS (fixes #24602) I've just copied some old pieces of GHCJS from publicly available sources (See https://github.com/Taneb/shims/blob/a6dd0202dcdb86ad63201495b8b5d9763483eb35/src/io.js#L607). Also I didn't put details to h$fds. I took minimal and left only its object initialization: `var h$fds = {};` - - - - - ad90bf12 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: heap and stack overflows reporting defined as js hard failure (fixes #24602) These errors were treated as a hard failure for browser application. The fix is trivial: just throw error. - - - - - 5962fa52 by Serge S. Gulin at 2024-04-21T16:33:44+03:00 JS: Stubs for code without actual implementation detected by Google Closure Compiler (fixes #24602) These errors were fixed just by introducing stubbed functions with throw for further implementation. - - - - - a0694298 by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add externs to linker (fixes #24602) After enabling jsdoc and built-in google closure compiler types I was needed to deal with the following: 1. Define NodeJS-environment types. I've just copied minimal set of externs from semi-official repo (see https://github.com/externs/nodejs/blob/6c6882c73efcdceecf42e7ba11f1e3e5c9c041f0/v8/nodejs.js#L8). 2. Define Emscripten-environment types: `HEAP8`. Emscripten already provides some externs in our code but it supposed to be run in some module system. And its definitions do not work well in plain bundle. 3. We have some functions which purpose is to add to functions some contextual information via function properties. These functions should be marked as `modifies` to let google closure compiler remove calls if these functions are not used actually by call graph. Such functions are: `h$o`, `h$sti`, `h$init_closure`, `h$setObjInfo`. 4. STG primitives such as registries and stuff from `GHC.StgToJS`. `dXX` properties were already present at externs generator function but they are started from `7`, not from `1`. This message is related: `// fixme does closure compiler bite us here?` - - - - - e58bb29f by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: added both tests: for size and for correctness (fixes #24602) By some reason MacOS builds add to stderr messages like: Ignoring unexpected archive entry: __.SYMDEF ... However I left stderr to `/dev/null` for compatibility with linux CI builds. - - - - - 909f3a9c by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Disable js linker warning for empty symbol table to make js tests running consistent across environments - - - - - 83eb10da by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add special preprocessor for js files due of needing to keep jsdoc comments (fixes #24602) Our js files have defined google closure compiler types at jsdoc entries but these jsdoc entries are removed by cpp preprocessor. I considered that reusing them in javascript-backend would be a nice thing. Right now haskell processor uses `-traditional` option to deal with comments and `//` operators. But now there are following compiler options: `-C` and `-CC`. You can read about them at GCC (see https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#index-CC) and CLang (see https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-CC). It seems that `-CC` works better for javascript jsdoc than `-traditional`. At least it leaves `/* ... */` comments w/o changes. - - - - - e1cf8dc2 by brandon s allbery kf8nh at 2024-04-22T03:48:26-04:00 fix link in CODEOWNERS It seems that our local Gitlab no longer has documentation for the `CODEOWNERS` file, but the master documentation still does. Use that instead. - - - - - 593f4e04 by Fendor at 2024-04-23T10:19:14-04:00 Add performance regression test for '-fwrite-simplified-core' - - - - - 1ba39b05 by Fendor at 2024-04-23T10:19:14-04:00 Typecheck corebindings lazily during bytecode generation This delays typechecking the corebindings until the bytecode generation happens. We also avoid allocating a thunk that is retained by `unsafeInterleaveIO`. In general, we shouldn't retain values of the hydrated `Type`, as not evaluating the bytecode object keeps it alive. It is better if we retain the unhydrated `IfaceType`. See Note [Hydrating Modules] - - - - - e916fc92 by Alan Zimmerman at 2024-04-23T10:19:50-04:00 EPA: Keep comments in a CaseAlt match The comments now live in the surrounding location, not inside the Match. Make sure we keep them. Closes #24707 - - - - - d2b17f32 by Cheng Shao at 2024-04-23T15:01:22-04:00 driver: force merge objects when building dynamic objects This patch forces the driver to always merge objects when building dynamic objects even when ar -L is supported. It is an oversight of !8887: original rationale of that patch is favoring the relatively cheap ar -L operation over object merging when ar -L is supported, which makes sense but only if we are building static objects! Omitting check for whether we are building dynamic objects will result in broken .so files with undefined reference errors at executable link time when building GHC with llvm-ar. Fixes #22210. - - - - - 209d09f5 by Julian Ospald at 2024-04-23T15:02:03-04:00 Allow non-absolute values for bootstrap GHC variable Fixes #24682 - - - - - 3fff0977 by Matthew Pickering at 2024-04-23T15:02:38-04:00 Don't depend on registerPackage function in Cabal More recent versions of Cabal modify the behaviour of libAbiHash which breaks our usage of registerPackage. It is simpler to inline the part of registerPackage that we need and avoid any additional dependency and complication using the higher-level function introduces. - - - - - c62dc317 by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: remove obsolete ln script This commit removes an obsolete ln script in ghc-bignum/gmp. See 060251c24ad160264ae8553efecbb8bed2f06360 for its original intention, but it's been obsolete for a long time, especially since the removal of the make build system. Hence the house cleaning. - - - - - 6399d52b by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: update gmp to 6.3.0 This patch bumps the gmp-tarballs submodule and updates gmp to 6.3.0. The tarball format is now xz, and gmpsrc.patch has been patched into the tarball so hadrian no longer needs to deal with patching logic when building in-tree GMP. - - - - - 65b4b92f by Cheng Shao at 2024-04-25T01:32:02-04:00 hadrian: remove obsolete Patch logic This commit removes obsolete Patch logic from hadrian, given we no longer need to patch the gmp tarball when building in-tree GMP. - - - - - 71f28958 by Cheng Shao at 2024-04-25T01:32:02-04:00 autoconf: remove obsolete patch detection This commit removes obsolete deletection logic of the patch command from autoconf scripts, given we no longer need to patch anything in the GHC build process. - - - - - daeda834 by Sylvain Henry at 2024-04-25T01:32:43-04:00 JS: correctly handle RUBBISH literals (#24664) - - - - - 8a06ddf6 by Matthew Pickering at 2024-04-25T11:16:16-04:00 Linearise ghc-internal and base build This is achieved by requesting the final package database for ghc-internal, which mandates it is fully built as a dependency of configuring the `base` package. This is at the expense of cross-package parrallelism between ghc-internal and the base package. Fixes #24436 - - - - - 94da9365 by Andrei Borzenkov at 2024-04-25T11:16:54-04:00 Fix tuple puns renaming (24702) Move tuple renaming short cutter from `isBuiltInOcc_maybe` to `isPunOcc_maybe`, so we consider incoming module. I also fixed some hidden bugs that raised after the change was done. - - - - - fa03b1fb by Fendor at 2024-04-26T18:03:13-04:00 Refactor the Binary serialisation interface The goal is simplifiy adding deduplication tables to `ModIface` interface serialisation. We identify two main points of interest that make this difficult: 1. UserData hardcodes what `Binary` instances can have deduplication tables. Moreover, it heavily uses partial functions. 2. GHC.Iface.Binary hardcodes the deduplication tables for 'Name' and 'FastString', making it difficult to add more deduplication. Instead of having a single `UserData` record with fields for all the types that can have deduplication tables, we allow to provide custom serialisers for any `Typeable`. These are wrapped in existentials and stored in a `Map` indexed by their respective `TypeRep`. The `Binary` instance of the type to deduplicate still needs to explicitly look up the decoder via `findUserDataReader` and `findUserDataWriter`, which is no worse than the status-quo. `Map` was chosen as microbenchmarks indicate it is the fastest for a small number of keys (< 10). To generalise the deduplication table serialisation mechanism, we introduce the types `ReaderTable` and `WriterTable` which provide a simple interface that is sufficient to implement a general purpose deduplication mechanism for `writeBinIface` and `readBinIface`. This allows us to provide a list of deduplication tables for serialisation that can be extended more easily, for example for `IfaceTyCon`, see the issue https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for more motivation. In addition to this refactoring, we split `UserData` into `ReaderUserData` and `WriterUserData`, to avoid partial functions and reduce overall memory usage, as we need fewer mutable variables. Bump haddock submodule to accomodate for `UserData` split. ------------------------- Metric Increase: MultiLayerModulesTH_Make MultiLayerModulesRecomp T21839c ------------------------- - - - - - bac57298 by Fendor at 2024-04-26T18:03:13-04:00 Split `BinHandle` into `ReadBinHandle` and `WriteBinHandle` A `BinHandle` contains too much information for reading data. For example, it needs to keep a `FastMutInt` and a `IORef BinData`, when the non-mutable variants would suffice. Additionally, this change has the benefit that anyone can immediately tell whether the `BinHandle` is used for reading or writing. Bump haddock submodule BinHandle split. - - - - - 4d6394dd by Simon Peyton Jones at 2024-04-26T18:03:49-04:00 Fix missing escaping-kind check in tcPatSynSig Note [Escaping kind in type signatures] explains how we deal with escaping kinds in type signatures, e.g. f :: forall r (a :: TYPE r). a where the kind of the body is (TYPE r), but `r` is not in scope outside the forall-type. I had missed this subtlety in tcPatSynSig, leading to #24686. This MR fixes it; and a similar bug in tc_top_lhs_type. (The latter is tested by T24686a.) - - - - - 981c2c2c by Alan Zimmerman at 2024-04-26T18:04:25-04:00 EPA: check-exact: check that the roundtrip reproduces the source Closes #24670 - - - - - a8616747 by Andrew Lelechenko at 2024-04-26T18:05:01-04:00 Document that setEnv is not thread-safe - - - - - 1e41de83 by Bryan Richter at 2024-04-26T18:05:37-04:00 CI: Work around frequent Signal 9 errors - - - - - a6d5f9da by Naïm Favier at 2024-04-27T17:52:40-04:00 ghc-internal: add MonadFix instance for (,) Closes https://gitlab.haskell.org/ghc/ghc/-/issues/24288, implements CLC proposal https://github.com/haskell/core-libraries-committee/issues/238. Adds a MonadFix instance for tuples, permitting value recursion in the "native" writer monad and bringing consistency with the existing instance for transformers's WriterT (and, to a lesser extent, for Solo). - - - - - 64feadcd by Rodrigo Mesquita at 2024-04-27T17:53:16-04:00 bindist: Fix xattr cleaning The original fix (725343aa) was incorrect because it used the shell bracket syntax which is the quoting syntax in autoconf, making the test for existence be incorrect and therefore `xattr` was never run. Fixes #24554 - - - - - e2094df3 by damhiya at 2024-04-28T23:52:00+09:00 Make read accepts binary integer formats CLC proposal : https://github.com/haskell/core-libraries-committee/issues/177 - - - - - 1c2fd963 by Alan Zimmerman at 2024-04-29T23:17:00-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 - - - - - 4189d17e by Sylvain Henry at 2024-04-29T23:17:42-04:00 LLVM: better unreachable default destination in Switch (#24717) See added note. Co-authored-by: Siddharth Bhat <siddu.druid at gmail.com> - - - - - a3725c88 by Cheng Shao at 2024-04-29T23:18:20-04:00 ci: enable wasm jobs for MRs with wasm label This patch enables wasm jobs for MRs with wasm label. Previously the wasm label didn't actually have any effect on the CI pipeline, and full-ci needed to be applied to run wasm jobs which was a waste of runners when working on the wasm backend, hence the fix here. - - - - - 702f7964 by Matthew Pickering at 2024-04-29T23:18:56-04:00 Make interface files and object files depend on inplace .conf file A potential fix for #24737 - - - - - 728af21e by Cheng Shao at 2024-04-30T05:30:23-04:00 utils: remove obsolete vagrant scripts Vagrantfile has long been removed in !5288. This commit further removes the obsolete vagrant scripts in the tree. - - - - - 36f2c342 by Cheng Shao at 2024-04-30T05:31:00-04:00 Update autoconf scripts Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 - - - - - ecbf22a6 by Ben Gamari at 2024-04-30T05:31:36-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - ff893fff by Teo Camarasu at 2024-05-03T16:50:47+01:00 WIP: Make template-haskell re-installable - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - CODEOWNERS - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Ext/Fields.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Recomp/Binary.hs - compiler/GHC/Iface/Recomp/Flags.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b992f34551d25f74aa76b047d6800183382a30c7...ff893fff4cb1e68d2b478f06bae70a96d210688d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b992f34551d25f74aa76b047d6800183382a30c7...ff893fff4cb1e68d2b478f06bae70a96d210688d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 16:26:38 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Fri, 03 May 2024 12:26:38 -0400 Subject: [Git][ghc/ghc][wip/reinstallable-th] WIP: Make template-haskell re-installable Message-ID: <6635103eba254_36c4de10c96c257fa@gitlab.mail> Teo Camarasu pushed to branch wip/reinstallable-th at Glasgow Haskell Compiler / GHC Commits: c2baabef by Teo Camarasu at 2024-05-03T17:26:22+01:00 WIP: Make template-haskell re-installable - - - - - 30 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Plugins.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Gen/Splice.hs-boot - compiler/GHC/Tc/Types/TH.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Unit/Types.hs - compiler/ghc.cabal.in - hadrian/src/Packages.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/ToolArgs.hs - hadrian/src/Settings/Default.hs - hadrian/src/Settings/Packages.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs → libraries/ghc-boot-th/GHC/Internal/TH/Lib.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Map.hs → libraries/ghc-boot-th/GHC/Internal/TH/Lib/Map.hs - + libraries/ghc-boot-th/GHC/Internal/TH/Ppr.hs - + libraries/ghc-boot-th/GHC/Internal/TH/PprLib.hs - + libraries/ghc-boot-th/GHC/Internal/TH/Quote.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Syntax.hs → libraries/ghc-boot-th/GHC/Internal/TH/Syntax.hs - libraries/ghc-boot-th/ghc-boot-th.cabal.in - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/TH/Binary.hs - libraries/ghci/ghci.cabal.in - libraries/template-haskell/Language/Haskell/TH/Lib.hs - libraries/template-haskell/Language/Haskell/TH/Ppr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c2baabefe5db632f6adec257f6b1ab2e0460b29d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c2baabefe5db632f6adec257f6b1ab2e0460b29d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 16:35:44 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 03 May 2024 12:35:44 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 13 commits: Expose constructors of SNat, SChar and SSymbol in ghc-internal Message-ID: <663512608b9aa_36c4de3872b4277d9@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: efd3525a by Oleg Grenrus at 2024-05-03T12:35:20-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - 5ab9d134 by Mikolaj Konarski at 2024-05-03T12:35:20-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - 87a45031 by Serge S. Gulin at 2024-05-03T12:35:23-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - 2ec95db3 by Simon Peyton Jones at 2024-05-03T12:35:23-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - d58353d6 by Simon Peyton Jones at 2024-05-03T12:35:23-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - e4efab0c by Simon Peyton Jones at 2024-05-03T12:35:23-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - 6a15a511 by Simon Peyton Jones at 2024-05-03T12:35:23-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 3aadc50e by Cheng Shao at 2024-05-03T12:35:26-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 284d4231 by Ben Gamari at 2024-05-03T12:35:27-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - a8293acb by Ben Gamari at 2024-05-03T12:35:27-04:00 Bump terminfo submodule to current master - - - - - 6e58865d by Cheng Shao at 2024-05-03T12:35:28-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 66582348 by Cheng Shao at 2024-05-03T12:35:29-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - e242c503 by Alan Zimmerman at 2024-05-03T12:35:30-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - 30 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Stg/Subst.hs - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/StgToJS/Linker/Utils.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Utils.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9c3360279088e30380917414aa09c53cf8409b34...e242c503c45f46043807a9924fa5b7ca71b7c7bc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9c3360279088e30380917414aa09c53cf8409b34...e242c503c45f46043807a9924fa5b7ca71b7c7bc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 18:00:28 2024 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Fri, 03 May 2024 14:00:28 -0400 Subject: [Git][ghc/ghc][wip/t24277] 11 commits: Fix TH dependencies (#22229) Message-ID: <6635263c84713_36c4dedc71d45392c@gitlab.mail> Finley McIlwaine pushed to branch wip/t24277 at Glasgow Haskell Compiler / GHC Commits: 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - c7461264 by Finley McIlwaine at 2024-05-03T10:57:44-07:00 ghc-internal: Add CostCentreId, currentCallStackIds, ccsToIds, ccId Add functions for gettings the IDs of cost centres to the interface of `GHC.Internal.Stack`, `GHC.Internal.Stack.CCS`, and `GHC.Internal.Exts`. Also add an opaque type for cost center ids, `CostCentreId`, with appropriate instances. Resolves #24277 - - - - - 20 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/StgToJS/Apply.hs - compiler/GHC/StgToJS/Arg.hs - compiler/GHC/StgToJS/Closure.hs - compiler/GHC/StgToJS/CodeGen.hs - compiler/GHC/StgToJS/Expr.hs - compiler/GHC/StgToJS/Heap.hs - compiler/GHC/StgToJS/Rts/Rts.hs - compiler/GHC/StgToJS/Stack.hs - compiler/GHC/StgToJS/Types.hs - hadrian/src/Rules/Dependencies.hs - hadrian/src/Settings/Builders/RunTest.hs - libraries/ghc-internal/src/GHC/Internal/Base.hs - libraries/ghc-internal/src/GHC/Internal/Exts.hs - libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc - libraries/ghc-internal/src/GHC/Internal/Stack.hs - libraries/ghc-internal/src/GHC/Internal/Stack/CCS.hsc - libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/807da9090b0446c11d548856ae20963ee844b685...c74612643455f2ebe0d9be428cd1bc770d0d06e7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/807da9090b0446c11d548856ae20963ee844b685...c74612643455f2ebe0d9be428cd1bc770d0d06e7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 18:02:57 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Fri, 03 May 2024 14:02:57 -0400 Subject: [Git][ghc/ghc][wip/az/T24755-epa-checktyclhdr-comments] EPA: preserve comments in class and data decls Message-ID: <663526d179ed9_36c4dee92938542d3@gitlab.mail> Alan Zimmerman pushed to branch wip/az/T24755-epa-checktyclhdr-comments at Glasgow Haskell Compiler / GHC Commits: 0f1763a5 by Alan Zimmerman at 2024-05-03T19:02:46+01:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 - - - - - 4 changed files: - compiler/GHC/Parser/PostProcess.hs - testsuite/tests/printer/Makefile - + testsuite/tests/printer/Test24755.hs - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -204,11 +204,11 @@ mkClassDecl :: SrcSpan -> P (LTyClDecl GhcPs) mkClassDecl loc' (L _ (mcxt, tycl_hdr)) fds where_cls layout annsIn - = do { let loc = noAnnSrcSpan loc' - ; (binds, sigs, ats, at_defs, _, docs) <- cvBindsAndSigs where_cls - ; (cls, tparams, fixity, ann) <- checkTyClHdr True tycl_hdr + = do { (binds, sigs, ats, at_defs, _, docs) <- cvBindsAndSigs where_cls + ; (cls, tparams, fixity, ann, cs) <- checkTyClHdr True tycl_hdr ; tyvars <- checkTyVars (text "class") whereDots cls tparams ; let anns' = annsIn Semi.<> ann + ; let loc = EpAnn (spanAsAnchor loc') noAnn cs ; return (L loc (ClassDecl { tcdCExt = (anns', layout, NoAnnSortKey) , tcdCtxt = mcxt , tcdLName = cls, tcdTyVars = tyvars @@ -231,12 +231,12 @@ mkTyData :: SrcSpan -> P (LTyClDecl GhcPs) mkTyData loc' is_type_data new_or_data cType (L _ (mcxt, tycl_hdr)) ksig data_cons (L _ maybe_deriv) annsIn - = do { let loc = noAnnSrcSpan loc' - ; (tc, tparams, fixity, ann) <- checkTyClHdr False tycl_hdr + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False tycl_hdr ; tyvars <- checkTyVars (ppr new_or_data) equalsDots tc tparams ; let anns' = annsIn Semi.<> ann - ; data_cons <- checkNewOrData (locA loc) (unLoc tc) is_type_data new_or_data data_cons + ; data_cons <- checkNewOrData loc' (unLoc tc) is_type_data new_or_data data_cons ; defn <- mkDataDefn cType mcxt ksig data_cons maybe_deriv + ; let loc = EpAnn (spanAsAnchor loc') noAnn cs ; return (L loc (DataDecl { tcdDExt = anns', tcdLName = tc, tcdTyVars = tyvars, tcdFixity = fixity, @@ -263,14 +263,14 @@ mkTySynonym :: SrcSpan -> [AddEpAnn] -> P (LTyClDecl GhcPs) mkTySynonym loc lhs rhs annsIn - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs ; tyvars <- checkTyVars (text "type") equalsDots tc tparams ; let anns' = annsIn Semi.<> ann - ; return (L (noAnnSrcSpan loc) (SynDecl - { tcdSExt = anns' - , tcdLName = tc, tcdTyVars = tyvars - , tcdFixity = fixity - , tcdRhs = rhs })) } + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (SynDecl { tcdSExt = anns' + , tcdLName = tc, tcdTyVars = tyvars + , tcdFixity = fixity + , tcdRhs = rhs })) } mkStandaloneKindSig :: SrcSpan @@ -303,8 +303,9 @@ mkTyFamInstEqn :: SrcSpan -> [AddEpAnn] -> P (LTyFamInstEqn GhcPs) mkTyFamInstEqn loc bndrs lhs rhs anns - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs - ; return (L (noAnnSrcSpan loc) $ FamEqn + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' $ FamEqn { feqn_ext = anns `mappend` ann , feqn_tycon = tc , feqn_bndrs = bndrs @@ -324,10 +325,11 @@ mkDataFamInst :: SrcSpan -> P (LInstDecl GhcPs) mkDataFamInst loc new_or_data cType (mcxt, bndrs, tycl_hdr) ksig data_cons (L _ maybe_deriv) anns - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False tycl_hdr + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False tycl_hdr ; data_cons <- checkNewOrData loc (unLoc tc) False new_or_data data_cons ; defn <- mkDataDefn cType mcxt ksig data_cons maybe_deriv - ; return (L (noAnnSrcSpan loc) (DataFamInstD noExtField (DataFamInstDecl + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (DataFamInstD noExtField (DataFamInstDecl (FamEqn { feqn_ext = ann Semi.<> anns , feqn_tycon = tc , feqn_bndrs = bndrs @@ -368,10 +370,10 @@ mkFamDecl :: SrcSpan -> [AddEpAnn] -> P (LTyClDecl GhcPs) mkFamDecl loc info topLevel lhs ksig injAnn annsIn - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs ; tyvars <- checkTyVars (ppr info) equals_or_where tc tparams - ; return (L (noAnnSrcSpan loc) (FamDecl noExtField - (FamilyDecl + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (FamDecl noExtField (FamilyDecl { fdExt = annsIn Semi.<> ann , fdTopLevel = topLevel , fdInfo = info, fdLName = tc @@ -1040,45 +1042,46 @@ checkTyClHdr :: Bool -- True <=> class header -> P (LocatedN RdrName, -- the head symbol (type or class name) [LHsTypeArg GhcPs], -- parameters of head symbol LexicalFixity, -- the declaration is in infix format - [AddEpAnn]) -- API Annotation for HsParTy + [AddEpAnn], -- API Annotation for HsParTy -- when stripping parens + EpAnnComments) -- Accumulated comments from re-arranging -- Well-formedness check and decomposition of type and class heads. -- Decomposes T ty1 .. tyn into (T, [ty1, ..., tyn]) -- Int :*: Bool into (:*:, [Int, Bool]) -- returning the pieces checkTyClHdr is_cls ty - = goL ty [] [] [] Prefix + = goL emptyComments ty [] [] [] Prefix where - goL (L l ty) acc ops cps fix = go l ty acc ops cps fix + goL cs (L l ty) acc ops cps fix = go cs l ty acc ops cps fix -- workaround to define '*' despite StarIsType - go ll (HsParTy an (L l (HsStarTy _ isUni))) acc ops' cps' fix + go cs ll (HsParTy an (L l (HsStarTy _ isUni))) acc ops' cps' fix = do { addPsMessage (locA l) PsWarnStarBinder ; let name = mkOccNameFS tcClsName (starSym isUni) ; let a' = newAnns ll l an ; return (L a' (Unqual name), acc, fix - , (reverse ops') ++ cps') } + , (reverse ops') ++ cps', cs) } - go _ (HsTyVar _ _ ltc@(L _ tc)) acc ops cps fix - | isRdrTc tc = return (ltc, acc, fix, (reverse ops) ++ cps) - go _ (HsOpTy _ _ t1 ltc@(L _ tc) t2) acc ops cps _fix - | isRdrTc tc = return (ltc, lhs:rhs:acc, Infix, (reverse ops) ++ cps) + go cs l (HsTyVar _ _ ltc@(L _ tc)) acc ops cps fix + | isRdrTc tc = return (ltc, acc, fix, (reverse ops) ++ cps, cs Semi.<> comments l) + go cs l (HsOpTy _ _ t1 ltc@(L _ tc) t2) acc ops cps _fix + | isRdrTc tc = return (ltc, lhs:rhs:acc, Infix, (reverse ops) ++ cps, cs Semi.<> comments l) where lhs = HsValArg noExtField t1 rhs = HsValArg noExtField t2 - go l (HsParTy _ ty) acc ops cps fix = goL ty acc (o:ops) (c:cps) fix + go cs l (HsParTy _ ty) acc ops cps fix = goL (cs Semi.<> comments l) ty acc (o:ops) (c:cps) fix where (o,c) = mkParensEpAnn (realSrcSpan (locA l)) - go _ (HsAppTy _ t1 t2) acc ops cps fix = goL t1 (HsValArg noExtField t2:acc) ops cps fix - go _ (HsAppKindTy at ty ki) acc ops cps fix = goL ty (HsTypeArg at ki:acc) ops cps fix - go l (HsTupleTy _ HsBoxedOrConstraintTuple ts) [] ops cps fix + go cs l (HsAppTy _ t1 t2) acc ops cps fix = goL (cs Semi.<> comments l) t1 (HsValArg noExtField t2:acc) ops cps fix + go cs l (HsAppKindTy at ty ki) acc ops cps fix = goL (cs Semi.<> comments l) ty (HsTypeArg at ki:acc) ops cps fix + go cs l (HsTupleTy _ HsBoxedOrConstraintTuple ts) [] ops cps fix = return (L (l2l l) (nameRdrName tup_name) - , map (HsValArg noExtField) ts, fix, (reverse ops)++cps) + , map (HsValArg noExtField) ts, fix, (reverse ops)++cps, cs Semi.<> comments l) where arity = length ts tup_name | is_cls = cTupleTyConName arity | otherwise = getName (tupleTyCon Boxed arity) -- See Note [Unit tuples] in GHC.Hs.Type (TODO: is this still relevant?) - go l _ _ _ _ _ + go _ l _ _ _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope (locA l) $ (PsErrMalformedTyOrClDecl ty) ===================================== testsuite/tests/printer/Makefile ===================================== @@ -856,3 +856,8 @@ Test24749: Test24754: $(CHECK_PPR) $(LIBDIR) Test24754.hs $(CHECK_EXACT) $(LIBDIR) Test24754.hs + +.PHONY: Test24755 +Test24755: + $(CHECK_PPR) $(LIBDIR) Test24755.hs + $(CHECK_EXACT) $(LIBDIR) Test24755.hs ===================================== testsuite/tests/printer/Test24755.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeOperators #-} +module Test24755 where + +class + a -- Before operator + :+ + b -- After operator ===================================== testsuite/tests/printer/all.T ===================================== @@ -204,3 +204,4 @@ test('Test24748', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24748']) test('DataDeclShort', [ignore_stderr, req_ppr_deps], makefile_test, ['DataDeclShort']) test('Test24749', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24749']) test('Test24754', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24754']) +test('Test24755', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24755']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0f1763a51973ea37fa041901acb8efc4a38d9cd0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0f1763a51973ea37fa041901acb8efc4a38d9cd0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 19:04:10 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 03 May 2024 15:04:10 -0400 Subject: [Git][ghc/ghc][wip/T23109] Make class datacons be have-no-unfolding Message-ID: <6635352a510ed_36c4de164fdb05798c@gitlab.mail> Simon Peyton Jones pushed to branch wip/T23109 at Glasgow Haskell Compiler / GHC Commits: 1bb6212a by Simon Peyton Jones at 2024-05-03T20:02:59+01:00 Make class datacons be have-no-unfolding Fixes the problem reported in #20689 @Mikolaj - - - - - 2 changed files: - compiler/GHC/Types/Id.hs - compiler/GHC/Types/Id/Make.hs Changes: ===================================== compiler/GHC/Types/Id.hs ===================================== @@ -146,22 +146,27 @@ import GHC.Types.Var( Id, CoVar, JoinId, import qualified GHC.Types.Var as Var import GHC.Core.Type -import GHC.Types.RepType +import GHC.Core.TyCon( isClassTyCon ) import GHC.Core.DataCon +import GHC.Core.Class +import GHC.Core.Multiplicity + +import GHC.Types.RepType import GHC.Types.Demand import GHC.Types.Cpr import GHC.Types.Name -import GHC.Unit.Module -import GHC.Core.Class -import {-# SOURCE #-} GHC.Builtin.PrimOps (PrimOp) import GHC.Types.ForeignCall -import GHC.Data.Maybe import GHC.Types.SrcLoc import GHC.Types.Unique -import GHC.Builtin.Uniques (mkBuiltinUnique) import GHC.Types.Unique.Supply + +import {-# SOURCE #-} GHC.Builtin.PrimOps (PrimOp) +import GHC.Builtin.Uniques (mkBuiltinUnique) + import GHC.Data.FastString -import GHC.Core.Multiplicity +import GHC.Data.Maybe + +import GHC.Unit.Module import GHC.Utils.Misc import GHC.Utils.Outputable @@ -595,8 +600,13 @@ hasNoBinding id = case Var.idDetails id of -- PrimOpId _ lev_poly -> lev_poly -- TEMPORARILY commented out FCallId _ -> True - DataConWorkId dc -> isUnboxedTupleDataCon dc || isUnboxedSumDataCon dc - _ -> isCompulsoryUnfolding (realIdUnfolding id) + DataConWorkId dc -> isUnboxedTupleDataCon dc + || isUnboxedSumDataCon dc + || isClassTyCon (dataConTyCon dc) + -- We don't generate bindings for newtype + -- classes, so express that here + -- ToDo explain! + _ -> isCompulsoryUnfolding (realIdUnfolding id) -- Note: this function must be very careful not to force -- any of the fields that aren't the 'uf_src' field of -- the 'Unfolding' of the 'Id'. This is because these fields are computed ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -505,11 +505,9 @@ mkDictSelId name clas info | new_tycon -- Same as non-new case; ToDo: explain = base_info `setRuleInfo` mkRuleInfo [rule] `setInlinePragInfo` neverInlinePragma - `setUnfoldingInfo` mkInlineUnfoldingWithArity defaultSimpleOpts - StableSystemSrc 1 - (mkDictSelRhs clas val_index) -- See Note [Single-method classes] in GHC.Tc.TyCl.Instance -- for why alwaysInlinePragma + -- TODO Fix this comment! | otherwise = base_info `setRuleInfo` mkRuleInfo [rule] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1bb6212a5787cd5fec0c417ad5168c3ec9397f90 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1bb6212a5787cd5fec0c417ad5168c3ec9397f90 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 19:18:50 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 03 May 2024 15:18:50 -0400 Subject: [Git][ghc/ghc][wip/T23109] wibble Message-ID: <6635389a79005_36c4de18c86786448d@gitlab.mail> Simon Peyton Jones pushed to branch wip/T23109 at Glasgow Haskell Compiler / GHC Commits: a8392414 by Simon Peyton Jones at 2024-05-03T20:18:30+01:00 wibble - - - - - 1 changed file: - compiler/GHC/Types/Id.hs Changes: ===================================== compiler/GHC/Types/Id.hs ===================================== @@ -606,7 +606,7 @@ hasNoBinding id = case Var.idDetails id of -- We don't generate bindings for newtype -- classes, so express that here -- ToDo explain! - _ -> isCompulsoryUnfolding (realIdUnfolding id) + _ -> isCompulsoryUnfolding (realIdUnfolding id) -- Note: this function must be very careful not to force -- any of the fields that aren't the 'uf_src' field of -- the 'Unfolding' of the 'Id'. This is because these fields are computed View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a8392414f8db23997e039f76a738d253a3c006d3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a8392414f8db23997e039f76a738d253a3c006d3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 20:19:03 2024 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Fri, 03 May 2024 16:19:03 -0400 Subject: [Git][ghc/ghc][wip/t24277] ghc-internal: Add CostCentreId, currentCallStackIds, ccsToIds, ccId Message-ID: <663546b727566_36c4de2112d9c677c0@gitlab.mail> Finley McIlwaine pushed to branch wip/t24277 at Glasgow Haskell Compiler / GHC Commits: 1ff65c75 by Finley McIlwaine at 2024-05-03T13:18:49-07:00 ghc-internal: Add CostCentreId, currentCallStackIds, ccsToIds, ccId Add functions for gettings the IDs of cost centres to the interface of `GHC.Internal.Stack`, `GHC.Internal.Stack.CCS`, and `GHC.Internal.Exts`. Also add an opaque type for cost center ids, `CostCentreId`, with appropriate instances. Resolves #24277 - - - - - 7 changed files: - libraries/ghc-internal/src/GHC/Internal/Exts.hs - libraries/ghc-internal/src/GHC/Internal/Stack.hs - libraries/ghc-internal/src/GHC/Internal/Stack/CCS.hsc - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 Changes: ===================================== libraries/ghc-internal/src/GHC/Internal/Exts.hs ===================================== @@ -103,6 +103,8 @@ module GHC.Internal.Exts -- ** The call stack currentCallStack, + currentCallStackIds, + CostCentreId, -- * Ids with special behaviour inline, noinline, lazy, oneShot, considerAccessible, seq#, ===================================== libraries/ghc-internal/src/GHC/Internal/Stack.hs ===================================== @@ -24,6 +24,7 @@ module GHC.Internal.Stack ( -- * Profiling call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * HasCallStack call stacks @@ -38,14 +39,17 @@ module GHC.Internal.Stack ( -- * Internals CostCentreStack, CostCentre, + CostCentreId, getCurrentCCS, getCCSOf, clearCCS, ccsCC, ccsParent, + ccId, ccLabel, ccModule, ccSrcSpan, + ccsToIds, ccsToStrings, renderStack ) where ===================================== libraries/ghc-internal/src/GHC/Internal/Stack/CCS.hsc ===================================== @@ -16,14 +16,17 @@ ----------------------------------------------------------------------------- {-# LANGUAGE UnboxedTuples, MagicHash, NoImplicitPrelude #-} +{-# LANGUAGE DerivingStrategies, GeneralizedNewtypeDeriving #-} module GHC.Internal.Stack.CCS ( -- * Call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * Internals CostCentreStack, CostCentre, + CostCentreId, getCurrentCCS, getCCSOf, clearCCS, @@ -31,7 +34,9 @@ module GHC.Internal.Stack.CCS ( ccsParent, ccLabel, ccModule, + ccId, ccSrcSpan, + ccsToIds, ccsToStrings, renderStack, ) where @@ -44,6 +49,12 @@ import GHC.Internal.Base import GHC.Internal.Ptr import GHC.Internal.IO.Encoding import GHC.Internal.List ( concatMap, reverse ) +import GHC.Internal.Word ( Word32 ) +import GHC.Internal.Show +import GHC.Internal.Read +import GHC.Internal.Enum +import GHC.Internal.Real +import GHC.Internal.Num #define PROFILING #include "Rts.h" @@ -54,6 +65,13 @@ data CostCentreStack -- | A cost-centre from GHC's cost-center profiler. data CostCentre +-- | Cost centre identifier +-- +-- @since 4.20.0.0 +newtype CostCentreId = CostCentreId Word32 + deriving (Show, Read) + deriving newtype (Eq, Ord, Bounded, Enum, Integral, Num, Real) + -- | Returns the current 'CostCentreStack' (value is @nullPtr@ if the current -- program was not compiled with profiling support). Takes a dummy argument -- which can be used to avoid the call to @getCurrentCCS@ being floated out by @@ -83,6 +101,12 @@ ccsCC p = peekByteOff p 4 ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack) ccsParent p = peekByteOff p 8 +-- | Get the 'CostCentreId' of a 'CostCentre'. +-- +-- @since 4.20.0.0 +ccId :: Ptr CostCentre -> IO CostCentreId +ccId p = fmap CostCentreId $ peekByteOff p 0 + ccLabel :: Ptr CostCentre -> IO CString ccLabel p = peekByteOff p 4 @@ -99,6 +123,12 @@ ccsCC p = (# peek CostCentreStack, cc) p ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack) ccsParent p = (# peek CostCentreStack, prevStack) p +-- | Get the 'CostCentreId' of a 'CostCentre'. +-- +-- @since 4.20.0.0 +ccId :: Ptr CostCentre -> IO CostCentreId +ccId p = fmap CostCentreId $ (# peek CostCentre, ccID) p + -- | Get the label of a 'CostCentre'. ccLabel :: Ptr CostCentre -> IO CString ccLabel p = (# peek CostCentre, label) p @@ -125,6 +155,19 @@ ccSrcSpan p = (# peek CostCentre, srcloc) p currentCallStack :: IO [String] currentCallStack = ccsToStrings =<< getCurrentCCS () +-- | Returns a @[CostCentreId]@ representing the current call stack. This +-- can be useful for debugging. +-- +-- The implementation uses the call-stack simulation maintained by the +-- profiler, so it only works if the program was compiled with @-prof@ +-- and contains suitable SCC annotations (e.g. by using @-fprof-late@). +-- Otherwise, the list returned is likely to be empty or +-- uninformative. +-- +-- @since 4.20.0.0 +currentCallStackIds :: IO [CostCentreId] +currentCallStackIds = ccsToIds =<< getCurrentCCS () + -- | Format a 'CostCentreStack' as a list of lines. ccsToStrings :: Ptr CostCentreStack -> IO [String] ccsToStrings ccs0 = go ccs0 [] @@ -141,6 +184,24 @@ ccsToStrings ccs0 = go ccs0 [] then return acc else go parent ((mdl ++ '.':lbl ++ ' ':'(':loc ++ ")") : acc) +-- | Format a 'CostCentreStack' as a list of cost centre IDs. +-- +-- @since 4.20.0.0 +ccsToIds :: Ptr CostCentreStack -> IO [CostCentreId] +ccsToIds ccs0 = go ccs0 [] + where + go ccs acc + | ccs == nullPtr = return acc + | otherwise = do + cc <- ccsCC ccs + cc_id <- ccId cc + lbl <- GHC.peekCString utf8 =<< ccLabel cc + mdl <- GHC.peekCString utf8 =<< ccModule cc + parent <- ccsParent ccs + if (mdl == "MAIN" && lbl == "MAIN") + then return acc + else go parent (cc_id : acc) + -- | Get the stack trace attached to an object. -- -- @since base-4.5.0.0 ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -11601,6 +11601,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -11676,6 +11677,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ @@ -12060,6 +12062,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -12171,6 +12174,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12244,6 +12248,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -12290,6 +12295,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -12468,6 +12474,7 @@ instance GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.Event.Interna instance GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.Event.Manager.FdKey -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.Event.Manager.State -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Event.TimerManager’ +instance GHC.Internal.Show.Show GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Show.Show GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance GHC.Internal.Show.Show GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Show.Show GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ @@ -12681,6 +12688,7 @@ instance GHC.Classes.Eq GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘G instance GHC.Classes.Eq ghc-internal-9.1001.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Event.TimerManager’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12846,6 +12854,7 @@ instance forall a. GHC.Classes.Ord (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) instance forall i e. (GHC.Internal.Ix.Ix i, GHC.Classes.Ord e) => GHC.Classes.Ord (GHC.Internal.Arr.Array i e) -- Defined in ‘GHC.Internal.Arr’ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -234,7 +234,7 @@ module Control.Exception where type ErrorCall :: * data ErrorCall = ErrorCallWithLocation GHC.Internal.Base.String GHC.Internal.Base.String type Exception :: * -> Constraint - class (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where + class (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where toException :: e -> SomeException fromException :: SomeException -> GHC.Internal.Maybe.Maybe e displayException :: e -> GHC.Internal.Base.String @@ -303,7 +303,7 @@ module Control.Exception where module Control.Exception.Annotation where -- Safety: None type ExceptionAnnotation :: * -> Constraint - class ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a => ExceptionAnnotation a where + class ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a => ExceptionAnnotation a where displayExceptionAnnotation :: a -> GHC.Internal.Base.String default displayExceptionAnnotation :: GHC.Internal.Show.Show a => a -> GHC.Internal.Base.String {-# MINIMAL #-} @@ -345,7 +345,7 @@ module Control.Exception.Base where type ErrorCall :: * data ErrorCall = ErrorCallWithLocation GHC.Internal.Base.String GHC.Internal.Base.String type Exception :: * -> Constraint - class (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where + class (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where toException :: e -> SomeException fromException :: SomeException -> GHC.Internal.Maybe.Maybe e displayException :: e -> GHC.Internal.Base.String @@ -848,11 +848,11 @@ module Data.Data where type TyCon :: * data TyCon = ... type TypeRep :: * - type TypeRep = ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep + type TypeRep = ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep type Typeable :: forall k. k -> Constraint class Typeable a where ... - {-# MINIMAL ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} + {-# MINIMAL ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} cast :: forall a b. (Typeable a, Typeable b) => a -> GHC.Internal.Maybe.Maybe b constrFields :: Constr -> [GHC.Internal.Base.String] constrFixity :: Constr -> Fixity @@ -895,7 +895,7 @@ module Data.Data where showConstr :: Constr -> GHC.Internal.Base.String showsTypeRep :: TypeRep -> GHC.Internal.Show.ShowS splitTyConApp :: TypeRep -> (TyCon, [TypeRep]) - trLiftedRep :: ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.TypeRep GHC.Types.LiftedRep + trLiftedRep :: ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.TypeRep GHC.Types.LiftedRep tyConFingerprint :: TyCon -> GHC.Internal.Fingerprint.Type.Fingerprint tyConModule :: TyCon -> GHC.Internal.Base.String tyConName :: TyCon -> GHC.Internal.Base.String @@ -919,14 +919,14 @@ module Data.Dynamic where -- Safety: Safe type Dynamic :: * data Dynamic where - Dynamic :: forall a. ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.TypeRep a -> a -> Dynamic + Dynamic :: forall a. ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.TypeRep a -> a -> Dynamic type Typeable :: forall k. k -> Constraint class Typeable a where ... - {-# MINIMAL ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} + {-# MINIMAL ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} dynApp :: Dynamic -> Dynamic -> Dynamic dynApply :: Dynamic -> Dynamic -> GHC.Internal.Maybe.Maybe Dynamic - dynTypeRep :: Dynamic -> ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep + dynTypeRep :: Dynamic -> ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep fromDyn :: forall a. Typeable a => Dynamic -> a -> a fromDynamic :: forall a. Typeable a => Dynamic -> GHC.Internal.Maybe.Maybe a toDyn :: forall a. Typeable a => a -> Dynamic @@ -1809,11 +1809,11 @@ module Data.Typeable where type TyCon :: * data TyCon = ... type TypeRep :: * - type TypeRep = ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep + type TypeRep = ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep type Typeable :: forall k. k -> Constraint class Typeable a where ... - {-# MINIMAL ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} + {-# MINIMAL ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} cast :: forall a b. (Typeable a, Typeable b) => a -> GHC.Internal.Maybe.Maybe b decT :: forall {k} (a :: k) (b :: k). (Typeable a, Typeable b) => GHC.Internal.Data.Either.Either ((a :~: b) -> GHC.Internal.Base.Void) (a :~: b) eqT :: forall {k} (a :: k) (b :: k). (Typeable a, Typeable b) => GHC.Internal.Maybe.Maybe (a :~: b) @@ -1828,7 +1828,7 @@ module Data.Typeable where rnfTypeRep :: TypeRep -> () showsTypeRep :: TypeRep -> GHC.Internal.Show.ShowS splitTyConApp :: TypeRep -> (TyCon, [TypeRep]) - trLiftedRep :: ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.TypeRep GHC.Types.LiftedRep + trLiftedRep :: ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.TypeRep GHC.Types.LiftedRep tyConFingerprint :: TyCon -> GHC.Internal.Fingerprint.Type.Fingerprint tyConModule :: TyCon -> GHC.Internal.Base.String tyConName :: TyCon -> GHC.Internal.Base.String @@ -5251,9 +5251,9 @@ module GHC.Event.TimeOut where type TimeoutEdit :: * type TimeoutEdit = TimeoutQueue -> TimeoutQueue type TimeoutKey :: * - newtype TimeoutKey = TK ghc-internal-0.1.0.0:GHC.Internal.Event.Unique.Unique + newtype TimeoutKey = TK ghc-internal-9.1001.0:GHC.Internal.Event.Unique.Unique type TimeoutQueue :: * - type TimeoutQueue = ghc-internal-0.1.0.0:GHC.Internal.Event.PSQ.PSQ TimeoutCallback + type TimeoutQueue = ghc-internal-9.1001.0:GHC.Internal.Event.PSQ.PSQ TimeoutCallback module GHC.Exception where -- Safety: Safe @@ -5265,7 +5265,7 @@ module GHC.Exception where type ErrorCall :: * data ErrorCall = ErrorCallWithLocation GHC.Internal.Base.String GHC.Internal.Base.String type Exception :: * -> Constraint - class (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where + class (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where toException :: e -> SomeException fromException :: SomeException -> GHC.Internal.Maybe.Maybe e displayException :: e -> GHC.Internal.Base.String @@ -5294,7 +5294,7 @@ module GHC.Exception.Type where type ArithException :: * data ArithException = Overflow | Underflow | LossOfPrecision | DivideByZero | Denormal | RatioZeroDenominator type Exception :: * -> Constraint - class (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where + class (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where toException :: e -> SomeException fromException :: SomeException -> GHC.Internal.Maybe.Maybe e displayException :: e -> GHC.Internal.Base.String @@ -7847,8 +7847,8 @@ module GHC.IO.Handle where hTryLock :: Handle -> LockMode -> GHC.Types.IO GHC.Types.Bool hWaitForInput :: Handle -> GHC.Types.Int -> GHC.Types.IO GHC.Types.Bool isEOF :: GHC.Types.IO GHC.Types.Bool - mkDuplexHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> NewlineMode -> GHC.Types.IO Handle - mkFileHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> NewlineMode -> GHC.Types.IO Handle + mkDuplexHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> NewlineMode -> GHC.Types.IO Handle + mkFileHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> NewlineMode -> GHC.Types.IO Handle nativeNewline :: Newline nativeNewlineMode :: NewlineMode noNewlineTranslation :: NewlineMode @@ -7898,11 +7898,11 @@ module GHC.IO.Handle.Internals where ioe_notReadable :: forall a. GHC.Types.IO a ioe_notWritable :: forall a. GHC.Types.IO a ioe_semiclosedHandle :: forall a. GHC.Types.IO a - mkDuplexHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle - mkDuplexHandleNoFinalizer :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle - mkFileHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle - mkFileHandleNoFinalizer :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle - mkHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.Handle.Types.HandleType -> GHC.Types.Bool -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Internal.Maybe.Maybe HandleFinalizer -> GHC.Internal.Maybe.Maybe (GHC.Internal.MVar.MVar GHC.Internal.IO.Handle.Types.Handle__) -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle + mkDuplexHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle + mkDuplexHandleNoFinalizer :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle + mkFileHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle + mkFileHandleNoFinalizer :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle + mkHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.Handle.Types.HandleType -> GHC.Types.Bool -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Internal.Maybe.Maybe HandleFinalizer -> GHC.Internal.Maybe.Maybe (GHC.Internal.MVar.MVar GHC.Internal.IO.Handle.Types.Handle__) -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle openTextEncoding :: forall a. GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.HandleType -> (forall es ds. GHC.Internal.Maybe.Maybe (GHC.Internal.IO.Encoding.Types.TextEncoder es) -> GHC.Internal.Maybe.Maybe (GHC.Internal.IO.Encoding.Types.TextDecoder ds) -> GHC.Types.IO a) -> GHC.Types.IO a readTextDevice :: GHC.Internal.IO.Handle.Types.Handle__ -> GHC.Internal.IO.Buffer.CharBuffer -> GHC.Types.IO GHC.Internal.IO.Buffer.CharBuffer readTextDeviceNonBlocking :: GHC.Internal.IO.Handle.Types.Handle__ -> GHC.Internal.IO.Buffer.CharBuffer -> GHC.Types.IO GHC.Internal.IO.Buffer.CharBuffer @@ -7966,7 +7966,7 @@ module GHC.IO.Handle.Types where type Handle__ :: * data Handle__ = forall dev enc_state dec_state. - (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => + (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => Handle__ {haDevice :: !dev, haType :: HandleType, haByteBuffer :: ! {-# UNPACK #-}(GHC.Internal.IORef.N:IORef[0] _N)(GHC.Internal.IORef.IORef (GHC.Internal.IO.Buffer.Buffer GHC.Internal.Word.Word8)), @@ -12462,7 +12462,7 @@ module GHC.StaticPtr where -- Safety: None type IsStatic :: (* -> *) -> Constraint class IsStatic p where - fromStaticPtr :: forall a. ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a => StaticPtr a -> p a + fromStaticPtr :: forall a. ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a => StaticPtr a -> p a {-# MINIMAL fromStaticPtr #-} type StaticKey :: * type StaticKey = GHC.Internal.Fingerprint.Type.Fingerprint @@ -13857,8 +13857,8 @@ module Type.Reflection where data (:~~:) a b where HRefl :: forall {k1} (a :: k1). (:~~:) a a pattern App :: forall k2 (t :: k2). () => forall k1 (a :: k1 -> k2) (b :: k1). (t ~ a b) => TypeRep a -> TypeRep b -> TypeRep t - pattern Con :: forall k (a :: k). () => ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.NotApplication a => TyCon -> TypeRep a - pattern Con' :: forall k (a :: k). () => ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.NotApplication a => TyCon -> [SomeTypeRep] -> TypeRep a + pattern Con :: forall k (a :: k). () => ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.NotApplication a => TyCon -> TypeRep a + pattern Con' :: forall k (a :: k). () => ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.NotApplication a => TyCon -> [SomeTypeRep] -> TypeRep a pattern Fun :: forall k (fun :: k). () => forall (r1 :: GHC.Types.RuntimeRep) (r2 :: GHC.Types.RuntimeRep) (arg :: TYPE r1) (res :: TYPE r2). (k ~ *, fun ~~ (arg -> res)) => TypeRep arg -> TypeRep res -> TypeRep fun type Module :: * data Module = ... @@ -13875,7 +13875,7 @@ module Type.Reflection where type Typeable :: forall k. k -> Constraint class Typeable a where ... - {-# MINIMAL ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} + {-# MINIMAL ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} decTypeRep :: forall k1 k2 (a :: k1) (b :: k2). TypeRep a -> TypeRep b -> GHC.Internal.Data.Either.Either ((a :~~: b) -> GHC.Internal.Base.Void) (a :~~: b) eqTypeRep :: forall k1 k2 (a :: k1) (b :: k2). TypeRep a -> TypeRep b -> GHC.Internal.Maybe.Maybe (a :~~: b) moduleName :: Module -> GHC.Internal.Base.String @@ -13910,9 +13910,9 @@ module Type.Reflection.Unsafe where data TypeRep a where ... mkTrApp :: forall k1 k2 (a :: k1 -> k2) (b :: k1). TypeRep a -> TypeRep b -> TypeRep (a b) - mkTrCon :: forall k (a :: k). TyCon -> [ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep] -> TypeRep a + mkTrCon :: forall k (a :: k). TyCon -> [ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep] -> TypeRep a mkTyCon :: GHC.Internal.Base.String -> GHC.Internal.Base.String -> GHC.Internal.Base.String -> GHC.Types.Int -> KindRep -> TyCon - someTypeRepFingerprint :: ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -> GHC.Internal.Fingerprint.Type.Fingerprint + someTypeRepFingerprint :: ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -> GHC.Internal.Fingerprint.Type.Fingerprint tyConFingerprint :: TyCon -> GHC.Internal.Fingerprint.Type.Fingerprint tyConKindArgs :: TyCon -> GHC.Types.Int tyConKindRep :: TyCon -> KindRep @@ -14426,20 +14426,20 @@ instance GHC.Internal.Control.Monad.Fix.MonadFix Data.Semigroup.First -- Defined instance GHC.Internal.Control.Monad.Fix.MonadFix Data.Semigroup.Last -- Defined in ‘Data.Semigroup’ instance GHC.Internal.Control.Monad.Fix.MonadFix Data.Semigroup.Max -- Defined in ‘Data.Semigroup’ instance GHC.Internal.Control.Monad.Fix.MonadFix Data.Semigroup.Min -- Defined in ‘Data.Semigroup’ -instance forall (a :: * -> * -> *) b c. (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable b, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable c, GHC.Internal.Data.Data.Data (a b c)) => GHC.Internal.Data.Data.Data (Control.Applicative.WrappedArrow a b c) -- Defined in ‘Control.Applicative’ -instance forall (m :: * -> *) a. (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable m, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a, GHC.Internal.Data.Data.Data (m a)) => GHC.Internal.Data.Data.Data (Control.Applicative.WrappedMonad m a) -- Defined in ‘Control.Applicative’ +instance forall (a :: * -> * -> *) b c. (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable b, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable c, GHC.Internal.Data.Data.Data (a b c)) => GHC.Internal.Data.Data.Data (Control.Applicative.WrappedArrow a b c) -- Defined in ‘Control.Applicative’ +instance forall (m :: * -> *) a. (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable m, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a, GHC.Internal.Data.Data.Data (m a)) => GHC.Internal.Data.Data.Data (Control.Applicative.WrappedMonad m a) -- Defined in ‘Control.Applicative’ instance forall a. GHC.Internal.Data.Data.Data a => GHC.Internal.Data.Data.Data (GHC.Internal.Functor.ZipList.ZipList a) -- Defined in ‘GHC.Internal.Functor.ZipList’ instance GHC.Internal.Data.Data.Data Data.Array.Byte.ByteArray -- Defined in ‘Data.Array.Byte’ -instance forall s. ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable s => GHC.Internal.Data.Data.Data (Data.Array.Byte.MutableByteArray s) -- Defined in ‘Data.Array.Byte’ +instance forall s. ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable s => GHC.Internal.Data.Data.Data (Data.Array.Byte.MutableByteArray s) -- Defined in ‘Data.Array.Byte’ instance forall a. GHC.Internal.Data.Data.Data a => GHC.Internal.Data.Data.Data (Data.Complex.Complex a) -- Defined in ‘Data.Complex’ -instance forall i j (a :: i) (b :: j). (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable i, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable j, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable b, a ~~ b) => GHC.Internal.Data.Data.Data (a GHC.Internal.Data.Type.Equality.:~~: b) -- Defined in ‘GHC.Internal.Data.Data’ +instance forall i j (a :: i) (b :: j). (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable i, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable j, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable b, a ~~ b) => GHC.Internal.Data.Data.Data (a GHC.Internal.Data.Type.Equality.:~~: b) -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Internal.Data.Semigroup.Internal.All -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Internal.Data.Semigroup.Internal.Any -- Defined in ‘GHC.Internal.Data.Data’ instance forall a b. (GHC.Internal.Data.Data.Data a, GHC.Internal.Data.Data.Data b, GHC.Internal.Ix.Ix a) => GHC.Internal.Data.Data.Data (GHC.Internal.Arr.Array a b) -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Types.Bool -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Types.Char -- Defined in ‘GHC.Internal.Data.Data’ -instance forall k a (b :: k). (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable k, GHC.Internal.Data.Data.Data a, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable b) => GHC.Internal.Data.Data.Data (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Data’ +instance forall k a (b :: k). (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable k, GHC.Internal.Data.Data.Data a, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable b) => GHC.Internal.Data.Data.Data (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Data’ instance forall a. GHC.Internal.Data.Data.Data a => GHC.Internal.Data.Data.Data (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Types.Double -- Defined in ‘GHC.Internal.Data.Data’ @@ -14487,10 +14487,10 @@ instance GHC.Internal.Data.Data.Data GHC.Internal.Word.Word32 -- Defined in ‘G instance GHC.Internal.Data.Data.Data GHC.Internal.Word.Word64 -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Internal.Word.Word8 -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Internal.Foreign.Ptr.WordPtr -- Defined in ‘GHC.Internal.Data.Data’ -instance forall k (a :: k). (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable k, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a) => GHC.Internal.Data.Data.Data (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ -instance forall k1 (f :: k1 -> *) k2 (g :: k2 -> k1) (a :: k2). (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable f, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable g, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable k1, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable k2, GHC.Internal.Data.Data.Data (f (g a))) => GHC.Internal.Data.Data.Data (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ -instance [safe] forall k (f :: k -> *) (g :: k -> *) (a :: k). (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable f, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable g, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable k, GHC.Internal.Data.Data.Data (f a), GHC.Internal.Data.Data.Data (g a)) => GHC.Internal.Data.Data.Data (Data.Functor.Product.Product f g a) -- Defined in ‘Data.Functor.Product’ -instance [safe] forall k (f :: k -> *) (g :: k -> *) (a :: k). (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable f, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable g, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable k, GHC.Internal.Data.Data.Data (f a), GHC.Internal.Data.Data.Data (g a)) => GHC.Internal.Data.Data.Data (Data.Functor.Sum.Sum f g a) -- Defined in ‘Data.Functor.Sum’ +instance forall k (a :: k). (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable k, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a) => GHC.Internal.Data.Data.Data (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ +instance forall k1 (f :: k1 -> *) k2 (g :: k2 -> k1) (a :: k2). (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable f, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable g, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable k1, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable k2, GHC.Internal.Data.Data.Data (f (g a))) => GHC.Internal.Data.Data.Data (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ +instance [safe] forall k (f :: k -> *) (g :: k -> *) (a :: k). (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable f, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable g, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable k, GHC.Internal.Data.Data.Data (f a), GHC.Internal.Data.Data.Data (g a)) => GHC.Internal.Data.Data.Data (Data.Functor.Product.Product f g a) -- Defined in ‘Data.Functor.Product’ +instance [safe] forall k (f :: k -> *) (g :: k -> *) (a :: k). (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable f, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable g, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable k, GHC.Internal.Data.Data.Data (f a), GHC.Internal.Data.Data.Data (g a)) => GHC.Internal.Data.Data.Data (Data.Functor.Sum.Sum f g a) -- Defined in ‘Data.Functor.Sum’ instance forall a b. (GHC.Internal.Data.Data.Data a, GHC.Internal.Data.Data.Data b) => GHC.Internal.Data.Data.Data (Data.Semigroup.Arg a b) -- Defined in ‘Data.Semigroup’ instance forall a. GHC.Internal.Data.Data.Data a => GHC.Internal.Data.Data.Data (Data.Semigroup.First a) -- Defined in ‘Data.Semigroup’ instance forall a. GHC.Internal.Data.Data.Data a => GHC.Internal.Data.Data.Data (Data.Semigroup.Last a) -- Defined in ‘Data.Semigroup’ @@ -14556,7 +14556,7 @@ instance GHC.Internal.Data.Type.Equality.TestEquality GHC.Internal.TypeLits.SCha instance GHC.Internal.Data.Type.Equality.TestEquality GHC.Internal.TypeLits.SSymbol -- Defined in ‘GHC.Internal.TypeLits’ instance forall k (a :: k). GHC.Internal.Data.Type.Equality.TestEquality ((GHC.Internal.Data.Type.Equality.:~:) a) -- Defined in ‘GHC.Internal.Data.Type.Equality’ instance forall k1 k (a :: k1). GHC.Internal.Data.Type.Equality.TestEquality ((GHC.Internal.Data.Type.Equality.:~~:) a) -- Defined in ‘GHC.Internal.Data.Type.Equality’ -instance forall k. GHC.Internal.Data.Type.Equality.TestEquality ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.TypeRep -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal’ +instance forall k. GHC.Internal.Data.Type.Equality.TestEquality ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.TypeRep -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1). GHC.Internal.Data.Type.Equality.TestEquality f => GHC.Internal.Data.Type.Equality.TestEquality (Data.Functor.Compose.Compose f g) -- Defined in ‘Data.Functor.Compose’ instance forall a k (b :: k). GHC.Internal.Enum.Bounded a => GHC.Internal.Enum.Bounded (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall a. GHC.Internal.Enum.Bounded a => GHC.Internal.Enum.Bounded (GHC.Internal.Data.Bits.And a) -- Defined in ‘GHC.Internal.Data.Bits’ @@ -14636,6 +14636,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -14711,6 +14712,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ @@ -14753,7 +14755,7 @@ instance GHC.Internal.Exception.Type.Exception GHC.Internal.Control.Exception.Ba instance GHC.Internal.Exception.Type.Exception GHC.Internal.Control.Exception.Base.RecUpdError -- Defined in ‘GHC.Internal.Control.Exception.Base’ instance GHC.Internal.Exception.Type.Exception GHC.Internal.Control.Exception.Base.TypeError -- Defined in ‘GHC.Internal.Control.Exception.Base’ instance GHC.Internal.Exception.Type.Exception GHC.Internal.Data.Dynamic.Dynamic -- Defined in ‘GHC.Internal.Data.Dynamic’ -instance [safe] GHC.Internal.Exception.Type.Exception ghc-internal-0.1.0.0:GHC.Internal.IO.Handle.Lock.Common.FileLockingNotSupported -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.IO.Handle.Lock.Common’ +instance [safe] GHC.Internal.Exception.Type.Exception ghc-internal-9.1001.0:GHC.Internal.IO.Handle.Lock.Common.FileLockingNotSupported -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.IO.Handle.Lock.Common’ instance GHC.Internal.Exception.Type.Exception GHC.Internal.IOPort.IOPortException -- Defined in ‘GHC.Internal.IOPort’ instance GHC.Internal.Exception.Type.Exception GHC.Internal.JS.Prim.JSException -- Defined in ‘GHC.Internal.JS.Prim’ instance GHC.Internal.Exception.Type.Exception GHC.Internal.JS.Prim.WouldBlockException -- Defined in ‘GHC.Internal.JS.Prim’ @@ -15097,6 +15099,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -15208,6 +15211,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -15281,6 +15285,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -15327,6 +15332,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -15426,8 +15432,8 @@ instance GHC.Internal.Show.Show GHC.Internal.Data.Data.DataRep -- Defined in ‘ instance GHC.Internal.Show.Show GHC.Internal.Data.Data.DataType -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Show.Show GHC.Internal.Data.Data.Fixity -- Defined in ‘GHC.Internal.Data.Data’ instance forall k (s :: k). GHC.Internal.Show.Show (GHC.Internal.Data.Proxy.Proxy s) -- Defined in ‘GHC.Internal.Data.Proxy’ -instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal’ -instance forall k (a :: k). GHC.Internal.Show.Show (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.TypeRep a) -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal’ +instance GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal’ +instance forall k (a :: k). GHC.Internal.Show.Show (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.TypeRep a) -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal’ instance GHC.Internal.Show.Show GHC.Internal.Data.Dynamic.Dynamic -- Defined in ‘GHC.Internal.Data.Dynamic’ instance forall a b. (GHC.Internal.Show.Show a, GHC.Internal.Show.Show b) => GHC.Internal.Show.Show (GHC.Internal.Data.Either.Either a b) -- Defined in ‘GHC.Internal.Data.Either’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Show.Show (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ @@ -15498,6 +15504,7 @@ instance GHC.Internal.Show.Show GHC.Internal.Foreign.C.Types.CWchar -- Defined i instance forall a. GHC.Internal.Show.Show (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) -- Defined in ‘GHC.Internal.Foreign.C.ConstPtr’ instance forall a b. (GHC.Internal.Ix.Ix a, GHC.Internal.Show.Show a, GHC.Internal.Show.Show b) => GHC.Internal.Show.Show (GHC.Internal.Arr.Array a b) -- Defined in ‘GHC.Internal.Arr’ instance GHC.Internal.Show.Show GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Show.Show GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Show.Show GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance GHC.Internal.Show.Show GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Show.Show GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ @@ -15530,7 +15537,7 @@ instance GHC.Internal.Show.Show GHC.Internal.IO.Handle.Types.Handle -- Defined i instance GHC.Internal.Show.Show GHC.Internal.IO.Handle.Types.HandleType -- Defined in ‘GHC.Internal.IO.Handle.Types’ instance GHC.Internal.Show.Show GHC.Internal.IO.Handle.Types.Newline -- Defined in ‘GHC.Internal.IO.Handle.Types’ instance GHC.Internal.Show.Show GHC.Internal.IO.Handle.Types.NewlineMode -- Defined in ‘GHC.Internal.IO.Handle.Types’ -instance [safe] GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.IO.Handle.Lock.Common.FileLockingNotSupported -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.IO.Handle.Lock.Common’ +instance [safe] GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.IO.Handle.Lock.Common.FileLockingNotSupported -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.IO.Handle.Lock.Common’ instance GHC.Internal.Show.Show GHC.Internal.IO.Handle.HandlePosn -- Defined in ‘GHC.Internal.IO.Handle’ instance GHC.Internal.Show.Show GHC.Internal.IO.IOMode.IOMode -- Defined in ‘GHC.Internal.IO.IOMode’ instance GHC.Internal.Show.Show GHC.Internal.IOPort.IOPortException -- Defined in ‘GHC.Internal.IOPort’ @@ -15627,8 +15634,8 @@ instance GHC.Classes.Eq GHC.Internal.Data.Data.ConstrRep -- Defined in ‘GHC.In instance GHC.Classes.Eq GHC.Internal.Data.Data.DataRep -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Classes.Eq GHC.Internal.Data.Data.Fixity -- Defined in ‘GHC.Internal.Data.Data’ instance forall k (s :: k). GHC.Classes.Eq (GHC.Internal.Data.Proxy.Proxy s) -- Defined in ‘GHC.Internal.Data.Proxy’ -instance GHC.Classes.Eq ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal’ -instance forall k (a :: k). GHC.Classes.Eq (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.TypeRep a) -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal’ +instance GHC.Classes.Eq ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal’ +instance forall k (a :: k). GHC.Classes.Eq (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.TypeRep a) -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal’ instance forall a b. (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (GHC.Internal.Data.Either.Either a b) -- Defined in ‘GHC.Internal.Data.Either’ instance forall k (a :: k). GHC.Classes.Eq (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Classes.Eq (f (g a)) => GHC.Classes.Eq (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -15707,6 +15714,7 @@ instance GHC.Classes.Eq GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.In instance GHC.Classes.Eq GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -15801,8 +15809,8 @@ instance GHC.Classes.Ord GHC.Internal.Unicode.GeneralCategory -- Defined in ‘G instance forall k (a :: k) (b :: k). GHC.Classes.Ord (a GHC.Internal.Data.Type.Equality.:~: b) -- Defined in ‘GHC.Internal.Data.Type.Equality’ instance forall k1 k2 (a :: k1) (b :: k2). GHC.Classes.Ord (a GHC.Internal.Data.Type.Equality.:~~: b) -- Defined in ‘GHC.Internal.Data.Type.Equality’ instance forall k (s :: k). GHC.Classes.Ord (GHC.Internal.Data.Proxy.Proxy s) -- Defined in ‘GHC.Internal.Data.Proxy’ -instance GHC.Classes.Ord ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal’ -instance forall k (a :: k). GHC.Classes.Ord (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.TypeRep a) -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal’ +instance GHC.Classes.Ord ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal’ +instance forall k (a :: k). GHC.Classes.Ord (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.TypeRep a) -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal’ instance forall a b. (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (GHC.Internal.Data.Either.Either a b) -- Defined in ‘GHC.Internal.Data.Either’ instance forall k (a :: k). GHC.Classes.Ord (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Classes.Ord (f (g a)) => GHC.Classes.Ord (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -15873,6 +15881,7 @@ instance forall a. GHC.Classes.Ord (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) instance forall i e. (GHC.Internal.Ix.Ix i, GHC.Classes.Ord e) => GHC.Classes.Ord (GHC.Internal.Arr.Array i e) -- Defined in ‘GHC.Internal.Arr’ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -11865,6 +11865,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -11940,6 +11941,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Internal.Event.Windows.ConsoleEvent.ConsoleEvent -- Defined in ‘GHC.Internal.Event.Windows.ConsoleEvent’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ @@ -12337,6 +12339,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -12448,6 +12451,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Read.Read GHC.Internal.Event.Windows.ConsoleEvent.ConsoleEvent -- Defined in ‘GHC.Internal.Event.Windows.ConsoleEvent’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12522,6 +12526,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -12568,6 +12573,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -12746,6 +12752,7 @@ instance GHC.Internal.Show.Show GHC.Internal.Event.Windows.FFI.IOCP -- Defined i instance GHC.Internal.Show.Show GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance GHC.Internal.Show.Show GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Show.Show GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ +instance GHC.Internal.Show.Show GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Show.Show (f p), GHC.Internal.Show.Show (g p)) => GHC.Internal.Show.Show ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Show.Show (f p), GHC.Internal.Show.Show (g p)) => GHC.Internal.Show.Show ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Show.Show (f (g p)) => GHC.Internal.Show.Show ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12956,6 +12963,7 @@ instance GHC.Classes.Eq GHC.Internal.Event.Windows.HandleKey -- Defined in ‘GH instance GHC.Classes.Eq GHC.Internal.Event.Windows.FFI.IOCP -- Defined in ‘GHC.Internal.Event.Windows.FFI’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -13121,6 +13129,7 @@ instance GHC.Classes.Ord GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GH instance forall a. GHC.Classes.Ord (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) -- Defined in ‘GHC.Internal.Foreign.C.ConstPtr’ instance forall i e. (GHC.Internal.Ix.Ix i, GHC.Classes.Ord e) => GHC.Classes.Ord (GHC.Internal.Arr.Array i e) -- Defined in ‘GHC.Internal.Arr’ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Event.Windows.ConsoleEvent.ConsoleEvent -- Defined in ‘GHC.Internal.Event.Windows.ConsoleEvent’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ instance GHC.Classes.Ord GHC.Internal.Event.Windows.FFI.IOCP -- Defined in ‘GHC.Internal.Event.Windows.FFI’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -11601,6 +11601,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -11676,6 +11677,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ @@ -12060,6 +12062,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -12171,6 +12174,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12244,6 +12248,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -12290,6 +12295,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -12468,6 +12474,7 @@ instance GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.Event.Interna instance GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.Event.Manager.FdKey -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.Event.Manager.State -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Event.TimerManager’ +instance GHC.Internal.Show.Show GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Show.Show GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance GHC.Internal.Show.Show GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Show.Show GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ @@ -12681,6 +12688,7 @@ instance GHC.Classes.Eq GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘G instance GHC.Classes.Eq ghc-internal-9.1001.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Event.TimerManager’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12846,6 +12854,7 @@ instance forall a. GHC.Classes.Ord (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) instance forall i e. (GHC.Internal.Ix.Ix i, GHC.Classes.Ord e) => GHC.Classes.Ord (GHC.Internal.Arr.Array i e) -- Defined in ‘GHC.Internal.Arr’ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1ff65c756ef614aee2511b6ef64ec0c281d8484a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1ff65c756ef614aee2511b6ef64ec0c281d8484a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 20:35:39 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Fri, 03 May 2024 16:35:39 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/profile_safe_ffi Message-ID: <66354a9b64568_36c4de248fc547437d@gitlab.mail> Andreas Klebinger pushed new branch wip/andreask/profile_safe_ffi at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/profile_safe_ffi You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 21:36:30 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 03 May 2024 17:36:30 -0400 Subject: [Git][ghc/ghc][wip/T24676] More comments in response to Richard Message-ID: <663558de40014_36c4de2b41ee4784bd@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24676 at Glasgow Haskell Compiler / GHC Commits: a17deb8a by Simon Peyton Jones at 2024-05-03T22:35:31+01:00 More comments in response to Richard - - - - - 3 changed files: - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Utils/TcMType.hs Changes: ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -534,7 +534,7 @@ tcValArg do_ql (EValArgQL { eaql_status = ql_status = return () resume_ql_arg (QLIndependent delta wc) arg_rho = -- A tricky function! - -- See Note [Quick Look at value arguments] wrinkle (QLA4) + -- See Note [Quick Look at value arguments] wrinkle (QLA5) do { unless (isEmptyVarSet delta) $ -- Optimisation only do { demoteQLDelta delta ; qlUnify delta arg_rho res_rho } @@ -1565,18 +1565,19 @@ This turned out to be more subtle than I expected. Wrinkles: - Calling `tcInstFun` on the argument may have emitted some constraints, which we carefully captured in `quickLookArg` and stored in the EValArgQL. We must - now emit them with `emitConstraints`. (In the `QLIndependent` case this was + now emit them with `emitConstraints`. (In the `QLUnified` case this was done in `quickLookArg`.) - Consider (f (g (h x))).`tcApp` instantiates the call to `f`, and in doing so quick-looks at the argument(s), in this case (g (h x)). But `quickLookArg` - on (g (h x)) in turn instantiates `g` and quick-looks at /its/ argument (s), - in this case (h ). And so on recursively. Key point: all these + on (g (h x)) in turn instantiates `g` and quick-looks at /its/ argument(s), + in this case (h x). And so on recursively. Key point: all these instantiations make instantiation variables whose level number is that of the /original/ `tcApp`. - When we resume typechecking the argument, we may now know that the arg is - a polytype. E.g. suppose f :: a -> [a], and we are checking that +(QLA5) When we resume typechecking the argument (in the `EValArgQL` case of + `tcValArg`), we may now know that the arg is a polytype. + E.g. suppose f :: a -> [a], and we are checking that f (g (h x)) :: [forall b. b->b] We will end up instantiating `f` at (forall b. b->b), and hence we need to check (g (h x)) :: forall b. b -> b @@ -1587,9 +1588,33 @@ This turned out to be more subtle than I expected. Wrinkles: so we must instantiate g with type variables whose level numbers are inside the skolemise. - We call `demoteQLDelta` to do this. The demotion seems right but is not very - beautiful; e.g. `demoteDeltaTyVarTo` deliberately disobeys a sanity check - otherwise enforced by writeMetaTyVar. + We call `demoteQLDelta` to do this. Demotion seems like an unusual thing to + do, and indeed we need to carefully avoid calling `writeMetaTyVar` in order + to skip the check that we never unify with a type at a deeper level. But + the key insight is this: + + We should think of instantiation variables + as not having a level number at all. + + They don't need a level number (see next para), and in fact only have one + because we use normal unification variables as instantiation variables for + convenience. So `demoteQLDelta` should really be seen as creating fresh + unification variables (at the current, correct level), and then + substituting the instantiation variables to these fresh unification + variables. So it's not really a demotion at all, but rather a substitution + from unleveled instantiation variables to fresh, leveled, unification + variables. + +(QLA6) Why do instantiation variables not need a level? Because their lifetime is + short; see Note [Instantiation variables are short lived]. They must /all/ + be substituted by types (possibly with regular unification variables) before + we are done. Now, it happens that a very common case is that we want to substitute + an instantiate variable with a fresh unification variable at the same level as + the original `tcApp` call. + + By using a (levelled) unification variable as the implementation for an + (unlevelled) instantiation variable, we can make this common case into a + no-op; see the `when` short-cut in `demoteQLDelta`. -} quickLookArg :: Delta @@ -1700,7 +1725,7 @@ quickLookArg1 guarded delta ctxt larg@(L _ arg) sc_arg_ty@(Scaled _ arg_ty) ; qlUnify delta' arg_ty app_res_rho ; emitConstraints wanted ; traceTc "quickLookArg unify" (ppr rn_fun <+> ppr delta') - ; return (delta', mk_ql_arg QLUnified) } + ; return (delta', mk_ql_arg QLUnified) }o else -- Argument does not influence the enclosing call. -- So we treat this argument entirely independently: @@ -1770,7 +1795,8 @@ which has no free instantiation variables, so we can QL-unify --------------------- qlUnify :: Delta -> TcType -> TcType -> TcM () --- Unify ty1 with ty2, unifying only variables in delta +-- Unify ty1 with ty2, unifying only instantiation variables in delta +-- (it never unifies ordinary unification variables) -- It never produces errors, even for mis-matched types qlUnify delta ty1 ty2 = assertPpr (not (isEmptyVarSet delta)) (ppr delta $$ ppr ty1 $$ ppr ty2) $ ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -113,9 +113,8 @@ is a very local type, used only within this module and GHC.Tc.Gen.App The result of splitHsApps, which decomposes a HsExpr GhcRn - HsExprArg TcpInst: - The result of tcInstFun, which instantiates the function type - Adds EWrap nodes, the argument type in EValArg, - and the kind-checked type in ETypeArg + The result of tcInstFun, which instantiates the function type, + perhaps taking a quick look at arguments. - HsExprArg TcpTc: The result of tcArg, which typechecks the value args @@ -124,19 +123,6 @@ is a very local type, used only within this module and GHC.Tc.Gen.App * rebuildPrefixApps is dual to splitHsApps, and zips an application back into a HsExpr -Note [EValArg] -~~~~~~~~~~~~~~ -The data type EValArg is the payload of the EValArg constructor of -HsExprArg; i.e. a value argument of the application. EValArg has two -forms: - -* ValArg: payload is just the expression itself. Simple. - -* ValArgQL: captures the results of applying quickLookArg to the - argument in a ValArg. When we later want to typecheck that argument - we can just carry on from where quick-look left off. The fields of - ValArgQL exactly capture what is needed to complete the job. - Invariants: 1. With QL switched off, all arguments are ValArg; no ValArgQL @@ -145,6 +131,17 @@ Invariants: under the conditions when quick-look should happen (eg the argument type is guarded) -- see quickLookArg +Note [EValArgQL] +~~~~~~~~~~~~~~~~ +Data constructor EValArgQL represents an argument that has been +partly-type-checked by Quick Look: the first part of `tcApp` has been +done, but not the second, `finishApp` part. + +The constuctor captures all the bits and pieces needed to complete +typechecking. (An alternative would to to store a function closure, +but that's less concrete.) See Note [Quick Look at value arguments] +in GHC.Tc.Gen.App + Note [splitHsApps] ~~~~~~~~~~~~~~~~~~ The key function @@ -176,17 +173,14 @@ type Delta = TcTyVarSet -- Set of instantiation variables, data HsExprArg (p :: TcPass) where -- See Note [HsExprArg] - -- See Note [EValArg] + -- Data constructor EValArg represents a value argument EValArg :: { ea_ctxt :: AppCtxt , ea_arg_ty :: !(XEVAType p) , ea_arg :: LHsExpr (GhcPass (XPass p)) } -> HsExprArg p - -- This data constructor reprsents an argument that has been partly-type-checked; - -- The first part of `tcApp` has been done, but not the second, `finishApp` part. - -- The constuctor captures all the bits and pieces needed to complete typechecking. - -- (An alternative would to to store a function closure, but that's less concrete.) - -- See Note [Quick Look at value arguments] in GHC.Tc.Gen.App + -- Data constructor EValArgQL represents an argument that has been + -- partly-type-checked by Quick Look; see Note [EValArgQL] EValArgQL :: { eaql_status :: QLArgStatus , eaql_ctxt :: AppCtxt , eaql_arg_ty :: Scaled TcSigmaType -- Argument type expected by function ===================================== compiler/GHC/Tc/Utils/TcMType.hs ===================================== @@ -2464,7 +2464,7 @@ demoteDeltaTyVarTo new_lvl tv = pprPanic "demoteDeltaTyVarTo" (ppr tv) demoteQLDelta :: TcTyVarSet -> TcM () --- See Note [Quick Look at value arguments] wrinkle (QLA4) +-- See Note [Quick Look at value arguments] wrinkle (QLA5) -- in GHC.Tc.Gen.App demoteQLDelta delta = case tvs of @@ -2472,6 +2472,9 @@ demoteQLDelta delta (tv1:_) -> do { tclvl <- getTcLevel ; assertPpr (isMetaTyVar tv1) (ppr delta) $ when (tclvl `strictlyDeeperThan` tcTyVarLevel tv1) $ + -- This 'when' is just an optimisation + -- See (QLA6) in Note [Quick Look at value arguments] + -- in GHC.Tc.Gen.App. mapM_ (demoteDeltaTyVarTo tclvl) tvs } where tvs = nonDetEltsUniqSet delta View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a17deb8a491f23ff538e3b801429f81a8f2c7417 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a17deb8a491f23ff538e3b801429f81a8f2c7417 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri May 3 22:36:57 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 03 May 2024 18:36:57 -0400 Subject: [Git][ghc/ghc][wip/T24676] Typo Message-ID: <663567097712b_36c4de337492c88937@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24676 at Glasgow Haskell Compiler / GHC Commits: 729a5f48 by Simon Peyton Jones at 2024-05-03T23:36:32+01:00 Typo - - - - - 1 changed file: - compiler/GHC/Tc/Gen/App.hs Changes: ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -1725,7 +1725,7 @@ quickLookArg1 guarded delta ctxt larg@(L _ arg) sc_arg_ty@(Scaled _ arg_ty) ; qlUnify delta' arg_ty app_res_rho ; emitConstraints wanted ; traceTc "quickLookArg unify" (ppr rn_fun <+> ppr delta') - ; return (delta', mk_ql_arg QLUnified) }o + ; return (delta', mk_ql_arg QLUnified) } else -- Argument does not influence the enclosing call. -- So we treat this argument entirely independently: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/729a5f48c5386f246a07bbe612aae1a4bb85ec0d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/729a5f48c5386f246a07bbe612aae1a4bb85ec0d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 00:46:13 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 03 May 2024 20:46:13 -0400 Subject: [Git][ghc/ghc][master] Expose constructors of SNat, SChar and SSymbol in ghc-internal Message-ID: <66358555cc607_36c4de449f954988b6@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - 2 changed files: - libraries/ghc-internal/src/GHC/Internal/TypeLits.hs - libraries/ghc-internal/src/GHC/Internal/TypeNats.hs Changes: ===================================== libraries/ghc-internal/src/GHC/Internal/TypeLits.hs ===================================== @@ -49,7 +49,7 @@ module GHC.Internal.TypeLits , OrderingI(..) , N.cmpNat, cmpSymbol, cmpChar -- ** Singleton values - , N.SNat, SSymbol, SChar + , N.SNat (..), SSymbol (..), SChar (..) , pattern N.SNat, pattern SSymbol, pattern SChar , fromSNat, fromSSymbol, fromSChar , withSomeSNat, withSomeSSymbol, withSomeSChar ===================================== libraries/ghc-internal/src/GHC/Internal/TypeNats.hs ===================================== @@ -36,7 +36,7 @@ module GHC.Internal.TypeNats , sameNat , decideNat -- ** Singleton values - , SNat + , SNat (..) , pattern SNat , fromSNat , withSomeSNat View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/649c24b96c688f64ebbccea5837380a283f4b09a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/649c24b96c688f64ebbccea5837380a283f4b09a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 00:47:10 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 03 May 2024 20:47:10 -0400 Subject: [Git][ghc/ghc][master] Add DCoVarSet to PluginProv (!12037) Message-ID: <6635858e1cfc1_36c4de46658c41032a8@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - 28 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Tc/TyCl/Utils.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/RepType.hs - compiler/GHC/Types/TyThing/Ppr.hs - compiler/GHC/Types/Unique/DSet.hs - compiler/GHC/Types/Var/Set.hs - compiler/GHC/Utils/FV.hs - docs/users_guide/9.12.1-notes.rst - docs/users_guide/extending_ghc.rst - testsuite/tests/pmcheck/should_compile/T11195.hs - testsuite/tests/tcplugins/CtIdPlugin.hs - testsuite/tests/tcplugins/RewritePlugin.hs - testsuite/tests/tcplugins/TyFamPlugin.hs Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -97,7 +97,7 @@ module GHC.Core.Coercion ( emptyLiftingContext, extendLiftingContext, extendLiftingContextAndInScope, liftCoSubstVarBndrUsing, isMappedByLC, extendLiftingContextCvSubst, - mkSubstLiftingContext, zapLiftingContext, + mkSubstLiftingContext, liftingContextSubst, zapLiftingContext, substForAllCoBndrUsingLC, lcLookupCoVar, lcInScopeSet, LiftCoEnv, LiftingContext(..), liftEnvSubstLeft, liftEnvSubstRight, @@ -1456,9 +1456,9 @@ setNominalRole_maybe r co setNominalRole_maybe_helper (InstCo co arg) = InstCo <$> setNominalRole_maybe_helper co <*> pure arg setNominalRole_maybe_helper (UnivCo prov _ co1 co2) - | case prov of PhantomProv _ -> False -- should always be phantom - ProofIrrelProv _ -> True -- it's always safe - PluginProv _ -> False -- who knows? This choice is conservative. + | case prov of PhantomProv {} -> False -- should always be phantom + ProofIrrelProv {} -> True -- it's always safe + PluginProv {} -> False -- who knows? This choice is conservative. = Just $ UnivCo prov Nominal co1 co2 setNominalRole_maybe_helper _ = Nothing @@ -1583,7 +1583,7 @@ promoteCoercion co = case co of UnivCo (PhantomProv kco) _ _ _ -> kco UnivCo (ProofIrrelProv kco) _ _ _ -> kco - UnivCo (PluginProv _) _ _ _ -> mkKindCo co + UnivCo (PluginProv _ _) _ _ _ -> mkKindCo co SymCo g -> mkSymCo (promoteCoercion g) @@ -2040,6 +2040,9 @@ mkLiftingContext pairs mkSubstLiftingContext :: Subst -> LiftingContext mkSubstLiftingContext subst = LC subst emptyVarEnv +liftingContextSubst :: LiftingContext -> Subst +liftingContextSubst (LC subst _) = subst + -- | Extend a lifting context with a new mapping. extendLiftingContext :: LiftingContext -- ^ original LC -> TyCoVar -- ^ new variable to map... @@ -2415,7 +2418,7 @@ seqCo (AxiomRuleCo _ cs) = seqCos cs seqProv :: UnivCoProvenance -> () seqProv (PhantomProv co) = seqCo co seqProv (ProofIrrelProv co) = seqCo co -seqProv (PluginProv _) = () +seqProv (PluginProv _ cvs) = seqDVarSet cvs seqCos :: [Coercion] -> () seqCos [] = () ===================================== compiler/GHC/Core/Coercion/Opt.hs ===================================== @@ -636,7 +636,7 @@ opt_univ env sym prov role oty1 oty2 where prov' = case prov of ProofIrrelProv kco -> ProofIrrelProv $ opt_co4_wrap env sym False Nominal kco - PluginProv _ -> prov + PluginProv s cvs -> PluginProv s $ substDCoVarSet (liftingContextSubst env) cvs ------------- opt_transList :: HasDebugCallStack => InScopeSet -> [NormalCo] -> [NormalCo] -> [NormalCo] @@ -734,7 +734,8 @@ opt_trans_rule is in_co1@(UnivCo p1 r1 tyl1 _tyr1) = Just $ PhantomProv $ opt_trans is kco1 kco2 opt_trans_prov (ProofIrrelProv kco1) (ProofIrrelProv kco2) = Just $ ProofIrrelProv $ opt_trans is kco1 kco2 - opt_trans_prov (PluginProv str1) (PluginProv str2) | str1 == str2 = Just p1 + opt_trans_prov (PluginProv str1 cvs1) (PluginProv str2 cvs2) + | str1 == str2 = Just (PluginProv str1 (cvs1 `unionDVarSet` cvs2)) opt_trans_prov _ _ = Nothing -- Push transitivity down through matching top-level constructors. ===================================== compiler/GHC/Core/FVs.hs ===================================== @@ -410,7 +410,7 @@ orphNamesOfCo (HoleCo _) = emptyNameSet orphNamesOfProv :: UnivCoProvenance -> NameSet orphNamesOfProv (PhantomProv co) = orphNamesOfCo co orphNamesOfProv (ProofIrrelProv co) = orphNamesOfCo co -orphNamesOfProv (PluginProv _) = emptyNameSet +orphNamesOfProv (PluginProv _ _) = emptyNameSet orphNamesOfCos :: [Coercion] -> NameSet orphNamesOfCos = orphNamesOfThings orphNamesOfCo ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -1931,6 +1931,13 @@ checkTyCon :: TyCon -> LintM () checkTyCon tc = checkL (not (isTcTyCon tc)) (text "Found TcTyCon:" <+> ppr tc) +------------------- +checkTyCoVarInScope :: Subst -> TyCoVar -> LintM () +checkTyCoVarInScope subst tcv + = checkL (tcv `isInScope` subst) $ + hang (text "The type or coercion variable" <+> pprBndr LetBind tcv) + 2 (text "is out of scope") + ------------------- lintType :: Type -> LintM LintedType @@ -1948,12 +1955,8 @@ lintType (TyVarTy tv) -- In GHCi we may lint an expression with a free -- type variable. Then it won't be in the -- substitution, but it should be in scope - Nothing | tv `isInScope` subst - -> return (TyVarTy tv) - | otherwise - -> failWithL $ - hang (text "The type variable" <+> pprBndr LetBind tv) - 2 (text "is out of scope") + Nothing -> do { checkTyCoVarInScope subst tv + ; return (TyVarTy tv) } } lintType ty@(AppTy t1 t2) @@ -2325,15 +2328,8 @@ lintCoercion (CoVarCo cv) = do { subst <- getSubst ; case lookupCoVar subst cv of Just linted_co -> return linted_co ; - Nothing - | cv `isInScope` subst - -> return (CoVarCo cv) - | otherwise - -> - -- lintCoBndr always extends the substitution - failWithL $ - hang (text "The coercion variable" <+> pprBndr LetBind cv) - 2 (text "is out of scope") + Nothing -> do { checkTyCoVarInScope subst cv + ; return (CoVarCo cv) } } @@ -2532,7 +2528,12 @@ lintCoercion co@(UnivCo prov r ty1 ty2) ; check_kinds kco k1 k2 ; return (ProofIrrelProv kco') } - lint_prov _ _ prov@(PluginProv _) = return prov + lint_prov _ _ (PluginProv s cvs) + = do { subst <- getSubst + ; mapM_ (checkTyCoVarInScope subst) (dVarSetElems cvs) + -- Don't bother to return substituted fvs; + -- they don't matter to Lint + ; return (PluginProv s cvs) } check_kinds kco k1 k2 = do { let Pair k1' k2' = coercionKind kco ===================================== compiler/GHC/Core/TyCo/FVs.hs ===================================== @@ -19,6 +19,7 @@ module GHC.Core.TyCo.FVs tyCoVarsOfCoDSet, tyCoFVsOfCo, tyCoFVsOfCos, tyCoVarsOfCoList, + coVarsOfCosDSet, almostDevoidCoVarOfCo, @@ -446,6 +447,13 @@ deepCoVarFolder = TyCoFolder { tcf_view = noView -- See Note [CoercionHoles and coercion free variables] -- in GHC.Core.TyCo.Rep +------- Same again, but for DCoVarSet ---------- +-- But this time the free vars are shallow + +coVarsOfCosDSet :: [Coercion] -> DCoVarSet +coVarsOfCosDSet cos = fvDVarSetSome isCoVar (tyCoFVsOfCos cos) + + {- ********************************************************************* * * Closing over kinds @@ -660,7 +668,8 @@ tyCoFVsOfCoVar v fv_cand in_scope acc tyCoFVsOfProv :: UnivCoProvenance -> FV tyCoFVsOfProv (PhantomProv co) fv_cand in_scope acc = tyCoFVsOfCo co fv_cand in_scope acc tyCoFVsOfProv (ProofIrrelProv co) fv_cand in_scope acc = tyCoFVsOfCo co fv_cand in_scope acc -tyCoFVsOfProv (PluginProv _) fv_cand in_scope acc = emptyFV fv_cand in_scope acc +tyCoFVsOfProv (PluginProv _ cvs) _ _ (have, haveSet) = + (dVarSetElems cvs ++ have, dVarSetToVarSet cvs `unionVarSet` haveSet) tyCoFVsOfCos :: [Coercion] -> FV tyCoFVsOfCos [] fv_cand in_scope acc = emptyFV fv_cand in_scope acc @@ -730,7 +739,7 @@ almost_devoid_co_var_of_prov (PhantomProv co) cv = almost_devoid_co_var_of_co co cv almost_devoid_co_var_of_prov (ProofIrrelProv co) cv = almost_devoid_co_var_of_co co cv -almost_devoid_co_var_of_prov (PluginProv _) _ = True +almost_devoid_co_var_of_prov (PluginProv _ cvs) cv = not (cv `elemDVarSet` cvs) almost_devoid_co_var_of_type :: Type -> CoVar -> Bool almost_devoid_co_var_of_type (TyVarTy _) _ = True @@ -1129,7 +1138,7 @@ tyConsOfType ty go_prov (PhantomProv co) = go_co co go_prov (ProofIrrelProv co) = go_co co - go_prov (PluginProv _) = emptyUniqSet + go_prov (PluginProv _ _) = emptyUniqSet go_cos cos = foldr (unionUniqSets . go_co) emptyUniqSet cos @@ -1340,4 +1349,4 @@ occCheckExpand vs_to_avoid ty ------------------ go_prov cxt (PhantomProv co) = PhantomProv <$> go_co cxt co go_prov cxt (ProofIrrelProv co) = ProofIrrelProv <$> go_co cxt co - go_prov _ p@(PluginProv _) = return p + go_prov _ p@(PluginProv _ _) = return p ===================================== compiler/GHC/Core/TyCo/Rep.hs ===================================== @@ -1,4 +1,3 @@ - {-# LANGUAGE DeriveDataTypeable #-} {-# OPTIONS_HADDOCK not-home #-} @@ -78,7 +77,7 @@ import {-# SOURCE #-} GHC.Core.Type( chooseFunTyFlag, typeKind, typeTypeOrConstr -- friends: import GHC.Types.Var -import GHC.Types.Var.Set( elemVarSet ) +import GHC.Types.Var.Set( DCoVarSet, dVarSetElems, elemVarSet ) import GHC.Core.TyCon import GHC.Core.Coercion.Axiom @@ -886,7 +885,7 @@ data Coercion | FunCo -- FunCo :: "e" -> N/P -> e -> e -> e -- See Note [FunCo] for fco_afl, fco_afr - { fco_role :: Role + { fco_role :: Role , fco_afl :: FunTyFlag -- Arrow for coercionLKind , fco_afr :: FunTyFlag -- Arrow for coercionRKind , fco_mult :: CoercionN @@ -1533,15 +1532,19 @@ data UnivCoProvenance -- considered equivalent. See Note [ProofIrrelProv]. -- Can be used in Nominal or Representational coercions - | PluginProv String -- ^ From a plugin, which asserts that this coercion - -- is sound. The string is for the use of the plugin. + | PluginProv String !DCoVarSet + -- ^ From a plugin, which asserts that this coercion is sound. + -- The string and the variable set are for the use by the plugin. + -- The set must contain all the in-scope coercion variables + -- that the the proof represented by the coercion makes use of. + -- See Note [The importance of tracking free coercion variables]. deriving Data.Data instance Outputable UnivCoProvenance where - ppr (PhantomProv _) = text "(phantom)" - ppr (ProofIrrelProv _) = text "(proof irrel.)" - ppr (PluginProv str) = parens (text "plugin" <+> brackets (text str)) + ppr (PhantomProv _) = text "(phantom)" + ppr (ProofIrrelProv _) = text "(proof irrel.)" + ppr (PluginProv str cvs) = parens (text "plugin" <+> brackets (text str) <+> ppr cvs) -- | A coercion to be filled in by the type-checker. See Note [Coercion holes] data CoercionHole @@ -1696,6 +1699,50 @@ Here, where co5 :: (a1 ~ Bool) ~ (a2 ~ Bool) co5 = TyConAppCo Nominal (~#) [<*>, <*>, co4, ] + + +Note [The importance of tracking free coercion variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It is vital that `UnivCo` (a coercion that lacks a proper proof) +tracks its free coercion variables. To see why, consider this program: + + type S :: Nat -> Nat + + data T (a::Nat) where + T1 :: T 0 + T2 :: ... + + f :: T a -> S (a+1) -> S 1 + f = /\a (x:T a) (y:a). + case x of + T1 (gco : a ~# 0) -> y |> wco + +For this to typecheck we need `wco :: S (a+1) ~# S 1`, given that `gco : a ~# 0`. +To prove that we need to know that `a+1 = 1` if `a=0`, which a plugin might know. +So it solves `wco` by providing a `UnivCo (PluginProv "my-plugin" gcvs) (a+1) 1`. + + But the `gcvs` in `PluginProv` must mention `gco`. + +Why? Otherwise we might float the entire expression (y |> wco) out of the +the case alternative for `T1` which brings `gco` into scope. If this +happens then we aren't far from a segmentation fault or much worse. +See #23923 for a real-world example of this happening. + +So it is /crucial/ for the `PluginProv` to mention, in `gcvs`, the coercion +variables used by the plugin to justify the `UnivCo` that it builds. + +Note that we don't need to track +* the coercion's free *type* variables +* coercion variables free in kinds (we only need the "shallow" free covars) + +This means that we may float past type variables which the original +proof had as free variables. While surprising, this doesn't jeopardise +the validity of the coercion, which only depends upon the scoping +relative to the free coercion variables. + +(The free coercion variables are kept as a DCoVarSet in UnivCo, +since these sets are included in interface files.) + -} @@ -1755,7 +1802,6 @@ In particular, given | tv `elemVarSet` acc = acc | otherwise = acc `extendVarSet` tv - we want to end up with fvs ty = go emptyVarSet ty emptyVarSet where @@ -1785,6 +1831,38 @@ Here deep_fvs and deep_tcf are mutually recursive, unlike fvs and tcf. But, amazingly, we get good code here too. GHC is careful not to mark TyCoFolder data constructor for deep_tcf as a loop breaker, so the record selections still cancel. And eta expansion still happens too. + +Note [Use explicit recursion in foldTyCo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In foldTyCo you'll see things like: + go_tys _ [] = mempty + go_tys env (t:ts) = go_ty env t `mappend` go_tys env ts +where we use /explicit recursion/. You might wonder about using foldl instead: + go_tys env = foldl (\t acc -> go_ty env t `mappend` acc) mempty +Or maybe foldl', or foldr. + +But don't do that for two reasons (see #24591) + +* We sometimes instantiate `a` to (Endo VarSet). Remembering + newtype Endo a = Endo (a->a) + after inlining `foldTyCo` bodily, the explicit recursion looks like + go_tys _ [] = \acc -> acc + go_tys env (t:ts) = \acc -> go_ty env t (go_tys env ts acc) + The strictness analyser has no problem spotting that this function is + strict in `acc`, provided `go_ty` is. + + But in the foldl form that is /much/ less obvious, and the strictness + analyser fails utterly. Result: lots and lots of thunks get built. In + !12037, Mikolaj found that GHC allocated /six times/ as much heap + on test perf/compiler/T9198 as a result of this single problem! + +* Second, while I think that using `foldr` would be fine (simple experiments in + #24591 suggest as much), it builds a local loop (with env free) and I'm not 100% + confident it'll be lambda lifted in the end. It seems more direct just to write + the code we want. + + On the other hand in `go_cvs` we might hope that the `foldr` will fuse with the + `dVarSetElems` so I have used `foldr`. -} data TyCoFolder env a @@ -1823,12 +1901,11 @@ foldTyCo (TyCoFolder { tcf_view = view = let !env' = tycobinder env tv vis -- Avoid building a thunk here in go_ty env (varType tv) `mappend` go_ty env' inner - -- Explicit recursion because using foldr builds a local - -- loop (with env free) and I'm not confident it'll be - -- lambda lifted in the end + -- See Note [Use explicit recursion in foldTyCo] go_tys _ [] = mempty go_tys env (t:ts) = go_ty env t `mappend` go_tys env ts + -- See Note [Use explicit recursion in foldTyCo] go_cos _ [] = mempty go_cos env (c:cs) = go_co env c `mappend` go_cos env cs @@ -1862,7 +1939,11 @@ foldTyCo (TyCoFolder { tcf_view = view go_prov env (PhantomProv co) = go_co env co go_prov env (ProofIrrelProv co) = go_co env co - go_prov _ (PluginProv _) = mempty + go_prov _ (PluginProv _ cvs) = go_cvs env cvs + + -- See Note [Use explicit recursion in foldTyCo] + go_cvs env cvs = foldr (add_one env) mempty (dVarSetElems cvs) + add_one env cv acc = covar env cv `mappend` acc -- | A view function that looks through nothing. noView :: Type -> Maybe Type @@ -1928,7 +2009,7 @@ coercionSize (AxiomRuleCo _ cs) = 1 + sum (map coercionSize cs) provSize :: UnivCoProvenance -> Int provSize (PhantomProv co) = 1 + coercionSize co provSize (ProofIrrelProv co) = 1 + coercionSize co -provSize (PluginProv _) = 1 +provSize (PluginProv _ _) = 1 {- ************************************************************************ ===================================== compiler/GHC/Core/TyCo/Subst.hs ===================================== @@ -41,7 +41,7 @@ module GHC.Core.TyCo.Subst cloneTyVarBndr, cloneTyVarBndrs, substVarBndr, substVarBndrs, substTyVarBndr, substTyVarBndrs, - substCoVarBndr, + substCoVarBndr, substDCoVarSet, substTyVar, substTyVars, substTyVarToTyVar, substTyCoVars, substTyCoBndr, substForAllCoBndr, @@ -903,12 +903,18 @@ subst_co subst co go_prov (PhantomProv kco) = PhantomProv (go kco) go_prov (ProofIrrelProv kco) = ProofIrrelProv (go kco) - go_prov p@(PluginProv _) = p + go_prov (PluginProv s cvs) = PluginProv s $ substDCoVarSet subst cvs -- See Note [Substituting in a coercion hole] go_hole h@(CoercionHole { ch_co_var = cv }) = h { ch_co_var = updateVarType go_ty cv } +-- | Perform a substitution within a 'DVarSet' of free variables, +-- returning the shallow free coercion variables. +substDCoVarSet :: Subst -> DCoVarSet -> DCoVarSet +substDCoVarSet subst cvs = coVarsOfCosDSet $ map (substCoVar subst) $ + dVarSetElems cvs + substForAllCoBndr :: Subst -> TyCoVar -> KindCoercion -> (Subst, TyCoVar, Coercion) substForAllCoBndr subst ===================================== compiler/GHC/Core/TyCo/Tidy.hs ===================================== @@ -20,9 +20,11 @@ import GHC.Data.FastString import GHC.Core.TyCo.Rep import GHC.Core.TyCo.FVs (tyCoVarsOfTypesWellScoped, tyCoVarsOfTypeList) +import GHC.Data.Maybe (orElse) import GHC.Types.Name hiding (varName) import GHC.Types.Var import GHC.Types.Var.Env +import GHC.Types.Var.Set import GHC.Utils.Misc (strictMap) import Data.List (mapAccumL) @@ -233,9 +235,7 @@ tidyCo env@(_, subst) co -- the case above duplicates a bit of work in tidying h and the kind -- of tv. But the alternative is to use coercionKind, which seems worse. go (FunCo r afl afr w co1 co2) = ((FunCo r afl afr $! go w) $! go co1) $! go co2 - go (CoVarCo cv) = case lookupVarEnv subst cv of - Nothing -> CoVarCo cv - Just cv' -> CoVarCo cv' + go (CoVarCo cv) = CoVarCo $! go_cv cv go (HoleCo h) = HoleCo h go (AxiomInstCo con ind cos) = AxiomInstCo con ind $! strictMap go cos go (UnivCo p r t1 t2) = (((UnivCo $! (go_prov p)) $! r) $! @@ -249,9 +249,11 @@ tidyCo env@(_, subst) co go (SubCo co) = SubCo $! go co go (AxiomRuleCo ax cos) = AxiomRuleCo ax $ strictMap go cos + go_cv cv = lookupVarEnv subst cv `orElse` cv + go_prov (PhantomProv co) = PhantomProv $! go co go_prov (ProofIrrelProv co) = ProofIrrelProv $! go co - go_prov p@(PluginProv _) = p + go_prov (PluginProv s cvs) = PluginProv s $ mapDVarSet go_cv cvs tidyCos :: TidyEnv -> [Coercion] -> [Coercion] tidyCos env = strictMap (tidyCo env) ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -579,7 +579,7 @@ expandTypeSynonyms ty go_prov subst (PhantomProv co) = PhantomProv (go_co subst co) go_prov subst (ProofIrrelProv co) = ProofIrrelProv (go_co subst co) - go_prov _ p@(PluginProv _) = p + go_prov _ p@(PluginProv _ _) = p -- the "False" and "const" are to accommodate the type of -- substForAllCoBndrUsing, which is general enough to @@ -911,7 +911,8 @@ mapTyCo mapper -> (go_ty (), go_tys (), go_co (), go_cos ()) {-# INLINE mapTyCoX #-} -- See Note [Specialising mappers] -mapTyCoX :: Monad m => TyCoMapper env m +mapTyCoX :: forall m env. Monad m + => TyCoMapper env m -> ( env -> Type -> m Type , env -> [Type] -> m [Type] , env -> Coercion -> m Coercion @@ -923,6 +924,7 @@ mapTyCoX (TyCoMapper { tcm_tyvar = tyvar , tcm_hole = cohole }) = (go_ty, go_tys, go_co, go_cos) where + -- See Note [Use explicit recursion in mapTyCo] go_tys !_ [] = return [] go_tys !env (ty:tys) = (:) <$> go_ty env ty <*> go_tys env tys @@ -953,12 +955,14 @@ mapTyCoX (TyCoMapper { tcm_tyvar = tyvar ; inner' <- go_ty env' inner ; return $ ForAllTy (Bndr tv' vis) inner' } + -- See Note [Use explicit recursion in mapTyCo] go_cos !_ [] = return [] go_cos !env (co:cos) = (:) <$> go_co env co <*> go_cos env cos go_mco !_ MRefl = return MRefl go_mco !env (MCo co) = MCo <$> (go_co env co) + go_co :: env -> Coercion -> m Coercion go_co !env (Refl ty) = Refl <$> go_ty env ty go_co !env (GRefl r ty mco) = mkGReflCo r <$> go_ty env ty <*> go_mco env mco go_co !env (AppCo c1 c2) = mkAppCo <$> go_co env c1 <*> go_co env c2 @@ -998,8 +1002,28 @@ mapTyCoX (TyCoMapper { tcm_tyvar = tyvar go_prov !env (PhantomProv co) = PhantomProv <$> go_co env co go_prov !env (ProofIrrelProv co) = ProofIrrelProv <$> go_co env co - go_prov !_ p@(PluginProv _) = return p - + go_prov !env (PluginProv s cvs) = PluginProv s <$> go_fcvs env (dVarSetElems cvs) + + -- See Note [Use explicit recursion in mapTyCo] + go_fcvs :: env -> [CoVar] -> m DTyCoVarSet + go_fcvs _ [] = return emptyDVarSet + go_fcvs env (cv:cvs) = do { co <- covar env cv + ; cvs' <- go_fcvs env cvs + ; return (tyCoVarsOfCoDSet co `unionDVarSet` cvs') } + +{- Note [Use explicit recursion in mapTyCo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We use explicit recursion in `mapTyCo`, rather than calling, say, `strictFoldDVarSet`, +for exactly the same reason as in Note [Use explicit recursion in foldTyCo] in +GHC.Core.TyCo.Rep. We are in a monadic context, and using too-clever higher order +functions makes the strictness analyser produce worse results. + +We could probably use `foldr`, since it is inlined bodily, fairly early; but +I'm doing the simple thing and inlining it by hand. + +See !12037 for performance glitches caused by using `strictFoldDVarSet` (which is +definitely not inlined bodily). +-} {- ********************************************************************* * * ===================================== compiler/GHC/CoreToIface.hs ===================================== @@ -88,6 +88,7 @@ import GHC.Utils.Panic import GHC.Utils.Misc import Data.Maybe ( isNothing, catMaybes ) +import Data.List ( partition ) {- Note [Avoiding space leaks in toIface*] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -176,7 +177,7 @@ toIfaceTypeX :: VarSet -> Type -> IfaceType -- translates the tyvars in 'free' as IfaceFreeTyVars -- -- Synonyms are retained in the interface type -toIfaceTypeX fr (TyVarTy tv) -- See Note [Free tyvars in IfaceType] in GHC.Iface.Type +toIfaceTypeX fr (TyVarTy tv) -- See Note [Free TyVars and CoVars in IfaceType] in GHC.Iface.Type | tv `elemVarSet` fr = IfaceFreeTyVar tv | otherwise = IfaceTyVar (toIfaceTyVar tv) toIfaceTypeX fr ty@(AppTy {}) = @@ -283,7 +284,7 @@ toIfaceCoercionX fr co go (Refl ty) = IfaceReflCo (toIfaceTypeX fr ty) go (GRefl r ty mco) = IfaceGReflCo r (toIfaceTypeX fr ty) (go_mco mco) go (CoVarCo cv) - -- See Note [Free tyvars in IfaceType] in GHC.Iface.Type + -- See Note [Free TyVars and CoVars in IfaceType] in GHC.Iface.Type | cv `elemVarSet` fr = IfaceFreeCoVar cv | otherwise = IfaceCoVarCo (toIfaceCoVar cv) go (HoleCo h) = IfaceHoleCo (coHoleCoVar h) @@ -318,9 +319,11 @@ toIfaceCoercionX fr co fr' = fr `delVarSet` tv go_prov :: UnivCoProvenance -> IfaceUnivCoProv - go_prov (PhantomProv co) = IfacePhantomProv (go co) - go_prov (ProofIrrelProv co) = IfaceProofIrrelProv (go co) - go_prov (PluginProv str) = IfacePluginProv str + go_prov (PhantomProv co) = IfacePhantomProv (go co) + go_prov (ProofIrrelProv co) = IfaceProofIrrelProv (go co) + go_prov (PluginProv str cvs) = IfacePluginProv str (map toIfaceCoVar bound_cvs) free_cvs + where + (free_cvs, bound_cvs) = partition (`elemVarSet` fr) (dVarSetElems cvs) toIfaceTcArgs :: TyCon -> [Type] -> IfaceAppArgs toIfaceTcArgs = toIfaceTcArgsX emptyVarSet ===================================== compiler/GHC/Iface/Rename.hs ===================================== @@ -678,6 +678,8 @@ rnIfaceCo (IfaceAxiomInstCo n i cs) = IfaceAxiomInstCo <$> rnIfaceGlobal n <*> pure i <*> mapM rnIfaceCo cs rnIfaceCo (IfaceUnivCo s r t1 t2) = IfaceUnivCo s r <$> rnIfaceType t1 <*> rnIfaceType t2 + -- Renaming affects only type constructors, not coercion variables, + -- so no need to recurse into the provenance. rnIfaceCo (IfaceSymCo c) = IfaceSymCo <$> rnIfaceCo c rnIfaceCo (IfaceTransCo c1 c2) ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -1796,7 +1796,7 @@ freeNamesIfCoercion (IfaceAxiomRuleCo _ax cos) freeNamesIfProv :: IfaceUnivCoProv -> NameSet freeNamesIfProv (IfacePhantomProv co) = freeNamesIfCoercion co freeNamesIfProv (IfaceProofIrrelProv co) = freeNamesIfCoercion co -freeNamesIfProv (IfacePluginProv _) = emptyNameSet +freeNamesIfProv (IfacePluginProv _ _ _) = emptyNameSet freeNamesIfVarBndr :: VarBndr IfaceBndr vis -> NameSet freeNamesIfVarBndr (Bndr bndr _) = freeNamesIfBndr bndr ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -154,7 +154,7 @@ type IfaceKind = IfaceType -- Any time a 'Type' is pretty-printed, it is first converted to an 'IfaceType' -- before being printed. See Note [Pretty printing via Iface syntax] in "GHC.Types.TyThing.Ppr" data IfaceType - = IfaceFreeTyVar TyVar -- See Note [Free tyvars in IfaceType] + = IfaceFreeTyVar TyVar -- See Note [Free TyVars and CoVars in IfaceType] | IfaceTyVar IfLclName -- Type/coercion variable only, not tycon | IfaceLitTy IfaceTyLit | IfaceAppTy IfaceType IfaceAppArgs @@ -284,7 +284,7 @@ instance Outputable IfaceTyConSort where ppr (IfaceSumTyCon n) = text "sum:" <> ppr n ppr IfaceEqualityTyCon = text "equality" -{- Note [Free tyvars in IfaceType] +{- Note [Free TyVars and CoVars in IfaceType] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Nowadays (since Nov 16, 2016) we pretty-print a Type by converting to an IfaceType and pretty printing that. This eliminates a lot of @@ -432,7 +432,7 @@ data IfaceCoercion | IfaceCoVarCo IfLclName | IfaceAxiomInstCo IfExtName BranchIndex [IfaceCoercion] | IfaceAxiomRuleCo IfLclName [IfaceCoercion] - -- There are only a fixed number of CoAxiomRules, so it suffices + -- ^ There are only a fixed number of CoAxiomRules, so it suffices -- to use an IfaceLclName to distinguish them. -- See Note [Adding built-in type families] in GHC.Builtin.Types.Literals | IfaceUnivCo IfaceUnivCoProv Role IfaceType IfaceType @@ -443,13 +443,16 @@ data IfaceCoercion | IfaceInstCo IfaceCoercion IfaceCoercion | IfaceKindCo IfaceCoercion | IfaceSubCo IfaceCoercion - | IfaceFreeCoVar CoVar -- See Note [Free tyvars in IfaceType] + | IfaceFreeCoVar CoVar -- ^ See Note [Free TyVars and CoVars in IfaceType] | IfaceHoleCo CoVar -- ^ See Note [Holes in IfaceCoercion] data IfaceUnivCoProv = IfacePhantomProv IfaceCoercion | IfaceProofIrrelProv IfaceCoercion - | IfacePluginProv String + | IfacePluginProv String [IfLclName] [Var] + -- ^ Local covars and open (free) covars resp + -- See Note [Free TyVars and CoVars in IfaceType] + {- Note [Holes in IfaceCoercion] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -670,7 +673,7 @@ substIfaceType env ty go_prov (IfacePhantomProv co) = IfacePhantomProv (go_co co) go_prov (IfaceProofIrrelProv co) = IfaceProofIrrelProv (go_co co) - go_prov co@(IfacePluginProv _) = co + go_prov co@(IfacePluginProv _ _ _) = co substIfaceAppArgs :: IfaceTySubst -> IfaceAppArgs -> IfaceAppArgs substIfaceAppArgs env args @@ -1023,7 +1026,7 @@ ppr_ty ctxt_prec ty | not (isIfaceRhoType ty) = ppr_sigma ShowForAllMust ctxt_prec ty ppr_ty _ (IfaceForAllTy {}) = panic "ppr_ty" -- Covered by not.isIfaceRhoType ppr_ty _ (IfaceFreeTyVar tyvar) = ppr tyvar -- This is the main reason for IfaceFreeTyVar! -ppr_ty _ (IfaceTyVar tyvar) = ppr tyvar -- See Note [Free tyvars in IfaceType] +ppr_ty _ (IfaceTyVar tyvar) = ppr tyvar -- See Note [Free TyVars and CoVars in IfaceType] ppr_ty ctxt_prec (IfaceTyConApp tc tys) = pprTyTcApp ctxt_prec tc tys ppr_ty ctxt_prec (IfaceTupleTy i p tys) = ppr_tuple ctxt_prec i p tys -- always fully saturated ppr_ty _ (IfaceLitTy n) = pprIfaceTyLit n @@ -1955,7 +1958,7 @@ ppr_co ctxt_prec co@(IfaceForAllCo {}) = let (tvs, co'') = split_co co' in ((name,kind_co,visL,visR):tvs,co'') split_co co' = ([], co') --- Why these three? See Note [Free tyvars in IfaceType] +-- Why these three? See Note [Free TyVars and CoVars in IfaceType] ppr_co _ (IfaceFreeCoVar covar) = ppr covar ppr_co _ (IfaceCoVarCo covar) = ppr covar ppr_co _ (IfaceHoleCo covar) = braces (ppr covar) @@ -2010,8 +2013,8 @@ pprIfaceUnivCoProv (IfacePhantomProv co) = text "phantom" <+> pprParendIfaceCoercion co pprIfaceUnivCoProv (IfaceProofIrrelProv co) = text "irrel" <+> pprParendIfaceCoercion co -pprIfaceUnivCoProv (IfacePluginProv s) - = text "plugin" <+> doubleQuotes (text s) +pprIfaceUnivCoProv (IfacePluginProv s cvs fcvs) + = hang (text "plugin") 2 (sep [doubleQuotes (text s), ppr cvs, ppr fcvs]) ------------------- instance Outputable IfaceTyCon where @@ -2173,6 +2176,7 @@ ppr_parend_preds preds = parens (fsep (punctuate comma (map ppr preds))) instance Binary IfaceType where put_ _ (IfaceFreeTyVar tv) = pprPanic "Can't serialise IfaceFreeTyVar" (ppr tv) + -- See Note [Free TyVars and CoVars in IfaceType] put_ bh (IfaceForAllTy aa ab) = do putByte bh 0 @@ -2321,9 +2325,10 @@ instance Binary IfaceCoercion where put_ bh b put_ _ (IfaceFreeCoVar cv) = pprPanic "Can't serialise IfaceFreeCoVar" (ppr cv) + -- See Note [Free TyVars and CoVars in IfaceType] put_ _ (IfaceHoleCo cv) = pprPanic "Can't serialise IfaceHoleCo" (ppr cv) - -- See Note [Holes in IfaceCoercion] + -- See Note [Holes in IfaceCoercion] get bh = do tag <- getByte bh @@ -2393,9 +2398,12 @@ instance Binary IfaceUnivCoProv where put_ bh (IfaceProofIrrelProv a) = do putByte bh 2 put_ bh a - put_ bh (IfacePluginProv a) = do + put_ bh (IfacePluginProv a cvs fcvs) = do putByte bh 3 put_ bh a + -- See Note [Free TyVars and CoVars in IfaceType] + assertPpr (null fcvs) (ppr cvs $$ ppr fcvs) $ + put_ bh cvs get bh = do tag <- getByte bh @@ -2405,7 +2413,8 @@ instance Binary IfaceUnivCoProv where 2 -> do a <- get bh return $ IfaceProofIrrelProv a 3 -> do a <- get bh - return $ IfacePluginProv a + cvs <- get bh + return $ IfacePluginProv a cvs [] _ -> panic ("get IfaceUnivCoProv " ++ show tag) ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -1493,7 +1493,10 @@ tcIfaceCo = go tcIfaceUnivCoProv :: IfaceUnivCoProv -> IfL UnivCoProvenance tcIfaceUnivCoProv (IfacePhantomProv kco) = PhantomProv <$> tcIfaceCo kco tcIfaceUnivCoProv (IfaceProofIrrelProv kco) = ProofIrrelProv <$> tcIfaceCo kco -tcIfaceUnivCoProv (IfacePluginProv str) = return $ PluginProv str +tcIfaceUnivCoProv (IfacePluginProv str cvs fcvs) = + assertPpr (null fcvs) (ppr fcvs) $ do + cvs' <- mapM tcIfaceLclId cvs + return $ PluginProv str $ mkDVarSet cvs' {- ************************************************************************ ===================================== compiler/GHC/Tc/TyCl/Utils.hs ===================================== @@ -156,7 +156,7 @@ synonymTyConsOfType ty go_prov (PhantomProv co) = go_co co go_prov (ProofIrrelProv co) = go_co co - go_prov (PluginProv _) = emptyNameEnv + go_prov (PluginProv _ _) = emptyNameEnv go_tc tc | isTypeSynonymTyCon tc = unitNameEnv (tyConName tc) tc | otherwise = emptyNameEnv ===================================== compiler/GHC/Tc/Utils/TcMType.hs ===================================== @@ -1592,7 +1592,10 @@ collect_cand_qtvs_co orig_ty cur_lvl bound = go_co go_prov dv (PhantomProv co) = go_co dv co go_prov dv (ProofIrrelProv co) = go_co dv co - go_prov dv (PluginProv _) = return dv + go_prov dv (PluginProv _ cvs) = strictFoldDVarSet zt_cv (return dv) cvs + + zt_cv :: CoVar -> TcM CandidatesQTvs -> TcM CandidatesQTvs + zt_cv cv mdvs = do { dvs <- mdvs; go_cv dvs cv } go_cv :: CandidatesQTvs -> CoVar -> TcM CandidatesQTvs go_cv dv@(DV { dv_cvs = cvs }) cv ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -1120,7 +1120,7 @@ To achieve this, we use a variant of the 'typed' lens from 'generic-lens' first, and decide whether to recur into it using the HasTypeQ type family. - The two different behaviours are controlled by two main instances (*) and (**). - - (*) recurs into a subtype, when we have a type family equation such as: + - (*) recurses into a subtype, when we have a type family equation such as: ConRecursInto "TcRnCannotDeriveInstance" = 'Just DeriveInstanceErrReason ===================================== compiler/GHC/Types/RepType.hs ===================================== @@ -535,7 +535,7 @@ and returns the PrimRep IntRep. (See the definition of runtimeRepSimpleDataCons GHC.Builtin.Types and its helper function mk_runtime_rep_dc.) Example 2 passes the promoted list as the one argument to the extracted function. The extracted function is defined as prim_rep_fun within tupleRepDataCon in GHC.Builtin.Types. It takes one argument, decomposes -the promoted list (with extractPromotedList), and then recurs back to runtimeRepPrimRep +the promoted list (with extractPromotedList), and then recurses back to runtimeRepPrimRep to process the LiftedRep and WordRep, concatenating the results. -} ===================================== compiler/GHC/Types/TyThing/Ppr.hs ===================================== @@ -98,7 +98,7 @@ Consequences: (in GHC.IfaceToCore). For example, IfaceClosedSynFamilyTyCon stores a [IfaceAxBranch] that is used only for pretty-printing. -- See Note [Free tyvars in IfaceType] in GHC.Iface.Type +- See Note [Free TyVars and CoVars in IfaceType] in GHC.Iface.Type See #7730, #8776 for details -} ===================================== compiler/GHC/Types/Unique/DSet.hs ===================================== @@ -33,7 +33,7 @@ module GHC.Types.Unique.DSet ( lookupUniqDSet, uniqDSetToList, partitionUniqDSet, - mapUniqDSet + mapUniqDSet, strictFoldUniqDSet ) where import GHC.Prelude @@ -125,7 +125,15 @@ partitionUniqDSet p = coerce . partitionUDFM p . getUniqDSet -- See Note [UniqSet invariant] in GHC.Types.Unique.Set mapUniqDSet :: Uniquable b => (a -> b) -> UniqDSet a -> UniqDSet b -mapUniqDSet f = mkUniqDSet . map f . uniqDSetToList +mapUniqDSet f (UniqDSet m) = UniqDSet $ unsafeCastUDFMKey $ mapUDFM f m + -- Simply apply `f` to each element, retaining all the structure unchanged. + -- The identification of keys and elements prevents a derived Functor + -- instance, but `unsafeCastUDFMKey` makes it possible to apply the strict + -- mapping from DFM. + +strictFoldUniqDSet :: (a -> r -> r) -> r -> UniqDSet a -> r +strictFoldUniqDSet k r s = foldl' (\ !r e -> k e r) r $ + uniqDSetToList s -- Two 'UniqDSet's are considered equal if they contain the same -- uniques. ===================================== compiler/GHC/Types/Var/Set.hs ===================================== @@ -26,7 +26,7 @@ module GHC.Types.Var.Set ( nonDetStrictFoldVarSet, -- * Deterministic Var set types - DVarSet, DIdSet, DTyVarSet, DTyCoVarSet, + DVarSet, DIdSet, DTyVarSet, DCoVarSet, DTyCoVarSet, -- ** Manipulating these sets emptyDVarSet, unitDVarSet, mkDVarSet, @@ -38,7 +38,7 @@ module GHC.Types.Var.Set ( isEmptyDVarSet, delDVarSet, delDVarSetList, minusDVarSet, nonDetStrictFoldDVarSet, - filterDVarSet, mapDVarSet, + filterDVarSet, mapDVarSet, strictFoldDVarSet, dVarSetMinusVarSet, anyDVarSet, allDVarSet, transCloDVarSet, sizeDVarSet, seqDVarSet, @@ -232,6 +232,9 @@ type DIdSet = UniqDSet Id -- | Deterministic Type Variable Set type DTyVarSet = UniqDSet TyVar +-- | Deterministic Coercion Variable Set +type DCoVarSet = UniqDSet CoVar + -- | Deterministic Type or Coercion Variable Set type DTyCoVarSet = UniqDSet TyCoVar @@ -308,6 +311,9 @@ allDVarSet p = allUDFM p . getUniqDSet mapDVarSet :: Uniquable b => (a -> b) -> UniqDSet a -> UniqDSet b mapDVarSet = mapUniqDSet +strictFoldDVarSet :: (a -> r -> r) -> r -> UniqDSet a -> r +strictFoldDVarSet = strictFoldUniqDSet + filterDVarSet :: (Var -> Bool) -> DVarSet -> DVarSet filterDVarSet = filterUniqDSet ===================================== compiler/GHC/Utils/FV.hs ===================================== @@ -21,6 +21,7 @@ module GHC.Utils.FV ( delFVs, filterFV, mapUnionFV, + fvDVarSetSome, ) where import GHC.Prelude @@ -195,3 +196,7 @@ mkFVs :: [Var] -> FV mkFVs vars fv_cand in_scope acc = mapUnionFV unitFV vars fv_cand in_scope acc {-# INLINE mkFVs #-} + +fvDVarSetSome :: InterestingVarFun -> FV -> DVarSet +fvDVarSetSome interesting_var fv = + mkDVarSet $ fst $ fv interesting_var emptyVarSet ([], emptyVarSet) ===================================== docs/users_guide/9.12.1-notes.rst ===================================== @@ -26,6 +26,14 @@ Language Compiler ~~~~~~~~ +- Constructor ``PluginProv`` of type ``UnivCoProvenance``, relevant +for typing plugins, gets an extra ``DCoVarSet`` argument. +The argument is intended to contain the in-scope coercion variables +that the the proof represented by the coercion makes use of. +See ``Note [The importance of tracking free coercion variables]`` +in ``GHC.Core.TyCo.Rep``, :ref:`constraint-solving-with-plugins` +and the migration guide. + GHCi ~~~~ ===================================== docs/users_guide/extending_ghc.rst ===================================== @@ -760,10 +760,33 @@ This evidence is ignored for Given constraints, which GHC "solves" simply by discarding them; typically this is used when they are uninformative (e.g. reflexive equations). For Wanted constraints, the evidence will form part of the Core term that is generated after -typechecking, and can be checked by ``-dcore-lint``. It is possible for -the plugin to create equality axioms for use in evidence terms, but GHC -does not check their consistency, and inconsistent axiom sets may lead -to segfaults or other runtime misbehaviour. +typechecking, and can be checked by ``-dcore-lint``. + +When solving a Wanted equality constraint (of type ``t1 ~N# t2`` +or ``t1 ~R# t2`` for nominal and representation equalities respectively), +the evidence (of type ``EvTerm``) will take the form ``EvExpr (Coercion co)``, +where the coercion ``co`` has type ``co :: t1 ~N# t2`` or ``co :: t1 ~R# t2`` +respectively. + +It is up to the plugin to construct a suitable coercion ``co``. +However, one possibility is to construct one of form :: + + UnivCo (PluginProv "my-plugin" gcvs) role t1 t2 + +A ``UnivCo`` of this form says "trust me: my-plugin has solved this Wanted +using (only) ``gcvs``". + +Here + +* The ``role`` should be the role of the original equality constraint + (nominal or representational). +* The ``gcvs`` is a set of "given coercion variables"; these are the coercion + variable bound by enclosing Given constraints, which the plugin has used + to justify solving the Wanted. + +For soundness, it is very important to include the ``gcvs``; otherwise +GHC may transform the program into a form that seg-faults. +See #23923 for a long dicussion. Evidence is required also when creating new Given constraints, which are usually implied by old ones. It is not uncommon that the evidence of a new ===================================== testsuite/tests/pmcheck/should_compile/T11195.hs ===================================== @@ -84,7 +84,7 @@ opt_trans_rule is in_co1@(UnivCo p1 r1 tyl1 _tyr1) = Just $ PhantomProv $ opt_trans is kco1 kco2 opt_trans_prov (ProofIrrelProv kco1) (ProofIrrelProv kco2) = Just $ ProofIrrelProv $ opt_trans is kco1 kco2 - opt_trans_prov (PluginProv str1) (PluginProv str2) + opt_trans_prov (PluginProv str1 _) (PluginProv str2 _) | str1 == str2 = Just p1 opt_trans_prov _ _ = Nothing ===================================== testsuite/tests/tcplugins/CtIdPlugin.hs ===================================== @@ -21,6 +21,7 @@ import GHC.Tc.Plugin import GHC.Tc.Types import GHC.Tc.Types.Constraint import GHC.Tc.Types.Evidence +import GHC.Types.Unique.DSet -- common import Common @@ -41,7 +42,7 @@ solver :: [String] -> PluginDefs -> EvBindsVar -> [Ct] -> [Ct] -> TcPluginM TcPluginSolveResult solver _args defs ev givens wanteds = do - let pluginCo = mkUnivCo (PluginProv "CtIdPlugin") Representational + let pluginCo = mkUnivCo (PluginProv "CtIdPlugin" emptyUniqDSet) Representational -- Empty is fine. This plugin does not use "givens". let substEvidence ct ct' = evCast (ctEvExpr $ ctEvidence ct') $ pluginCo (ctPred ct') (ctPred ct) ===================================== testsuite/tests/tcplugins/RewritePlugin.hs ===================================== @@ -45,6 +45,8 @@ import GHC.Tc.Types.Constraint ) import GHC.Tc.Types.Evidence ( EvTerm(EvExpr), Role(Nominal) ) +import GHC.Types.Unique.DSet + ( emptyUniqDSet ) import GHC.Types.Unique.FM ( UniqFM, listToUFM ) @@ -85,5 +87,5 @@ mkTyFamReduction :: TyCon -> [ Type ] -> Type -> Reduction mkTyFamReduction tyCon args res = Reduction co res where co :: Coercion - co = mkUnivCo ( PluginProv "RewritePlugin" ) Nominal + co = mkUnivCo ( PluginProv "RewritePlugin" emptyUniqDSet) Nominal -- Empty is fine. This plugin does not use "givens". ( mkTyConApp tyCon args ) res ===================================== testsuite/tests/tcplugins/TyFamPlugin.hs ===================================== @@ -39,6 +39,8 @@ import GHC.Tc.Types.Constraint ) import GHC.Tc.Types.Evidence ( EvBindsVar, EvTerm(EvExpr), Role(Nominal) ) +import GHC.Types.Unique.DSet + ( emptyUniqDSet ) -- common import Common @@ -78,6 +80,6 @@ solveCt ( PluginDefs {..} ) ct@( classifyPredType . ctPred -> EqPred NomEq lhs r , let evTerm :: EvTerm evTerm = EvExpr . Coercion - $ mkUnivCo ( PluginProv "TyFamPlugin" ) Nominal lhs rhs + $ mkUnivCo ( PluginProv "TyFamPlugin" emptyUniqDSet) Nominal lhs rhs -- Empty is fine. This plugin does not use "givens". = pure $ Just ( evTerm, ct ) solveCt _ ct = pure Nothing View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d603f1995f92eb14e533815f5e20e33e27a8ed6a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d603f1995f92eb14e533815f5e20e33e27a8ed6a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 00:48:21 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 03 May 2024 20:48:21 -0400 Subject: [Git][ghc/ghc][master] JS: Enable more efficient packing of string data (fixes #24706) Message-ID: <663585d54c4c_36c4de4901f7411009d@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - 2 changed files: - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/StgToJS/Linker/Utils.hs Changes: ===================================== compiler/GHC/StgToJS/Linker/Linker.hs ===================================== @@ -1284,7 +1284,16 @@ staticDeclStat (StaticInfo global_name static_value _) = jStgStatToJS decl StaticUnboxedBool b -> app "h$p" [toJExpr b] StaticUnboxedInt i -> app "h$p" [toJExpr i] StaticUnboxedDouble d -> app "h$p" [toJExpr (unSaneDouble d)] - StaticUnboxedString str -> app "h$rawStringData" [ValExpr (to_byte_list str)] + -- GHCJS used a function wrapper for this: + -- StaticUnboxedString str -> ApplExpr (initStr str) [] + -- But we are defining it statically for now. + StaticUnboxedString str -> initStr str StaticUnboxedStringOffset {} -> 0 to_byte_list = JList . map (Int . fromIntegral) . BS.unpack + + initStr :: BS.ByteString -> JStgExpr + initStr str = + case decodeModifiedUTF8 str of + Just t -> app "h$encodeModifiedUtf8" [ValExpr (JStr t)] + Nothing -> app "h$rawStringData" [ValExpr $ to_byte_list str] ===================================== compiler/GHC/StgToJS/Linker/Utils.hs ===================================== @@ -21,6 +21,7 @@ module GHC.StgToJS.Linker.Utils , getInstalledPackageLibDirs , getInstalledPackageHsLibs , commonCppDefs + , decodeModifiedUTF8 ) where @@ -283,3 +284,15 @@ jsExeFileName dflags dropPrefix prefix xs | prefix `isPrefixOf` xs = drop (length prefix) xs | otherwise = xs + +-- GHC produces string literals in ByteString. +-- When ByteString has all bytes UTF-8 compatbile we make attempt to +-- represent it as FastString. +-- Otherwise (for example when string literal encodes long integers or zero bytes) we +-- leave it as is. +-- Having zero bytes points that this literal never was assumed to be a Modified UTF8 compatible. +decodeModifiedUTF8 :: B.ByteString -> Maybe FastString +decodeModifiedUTF8 bs + | B.any (==0) bs = Nothing + | not $ B.isValidUtf8 bs = Nothing + | otherwise = Just . mkFastStringByteString $ bs View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ba480026903aa735e63818a64228ab13639ecdc9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ba480026903aa735e63818a64228ab13639ecdc9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 00:49:26 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 03 May 2024 20:49:26 -0400 Subject: [Git][ghc/ghc][master] 4 commits: Track in-scope variables in ruleCheckProgram Message-ID: <66358615e1822_36c4de49aa8cc1157df@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 21 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Stg/Subst.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Utils.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/Tc/Types/Origin.hs-boot - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/TcType.hs-boot - compiler/GHC/Utils/Misc.hs - compiler/GHC/Utils/Word64.hs - + testsuite/tests/simplCore/should_compile/T24726.hs - + testsuite/tests/simplCore/should_compile/T24726.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -483,7 +483,7 @@ isOffsetImm off w -- TODO OPT: we might be able give getRegister -- a hint, what kind of register we want. -getFloatReg :: HasCallStack => CmmExpr -> NatM (Reg, Format, InstrBlock) +getFloatReg :: HasDebugCallStack => CmmExpr -> NatM (Reg, Format, InstrBlock) getFloatReg expr = do r <- getRegister expr case r of ===================================== compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs ===================================== @@ -8,11 +8,11 @@ import GHC.Platform.Reg import GHC.Utils.Outputable import GHC.Utils.Panic +import GHC.Utils.Misc( HasDebugCallStack ) import GHC.Platform import Data.Word -import GHC.Stack -- AArch64 has 32 64bit general purpose register r0..r30, and zr/sp -- AArch64 has 32 128bit floating point registers v0..v31 as part of the NEON -- extension in Armv8-A. @@ -65,7 +65,7 @@ showBits :: Word32 -> String showBits w = map (\i -> if testBit w i then '1' else '0') [0..31] -- FR instance implementation (See Linear.FreeRegs) -allocateReg :: HasCallStack => RealReg -> FreeRegs -> FreeRegs +allocateReg :: HasDebugCallStack => RealReg -> FreeRegs -> FreeRegs allocateReg (RealRegSingle r) (FreeRegs g f) | r > 31 && testBit f (r - 32) = FreeRegs g (clearBit f (r - 32)) | r < 32 && testBit g r = FreeRegs (clearBit g r) f @@ -127,7 +127,7 @@ getFreeRegs cls (FreeRegs g f) initFreeRegs :: Platform -> FreeRegs initFreeRegs platform = foldl' (flip releaseReg) noFreeRegs (allocatableRegs platform) -releaseReg :: HasCallStack => RealReg -> FreeRegs -> FreeRegs +releaseReg :: HasDebugCallStack => RealReg -> FreeRegs -> FreeRegs releaseReg (RealRegSingle r) (FreeRegs g f) | r > 31 && testBit f (r - 32) = pprPanic "Linear.AArch64.releaseReg" (text "can't release non-allocated reg v" <> int (r - 32)) | r < 32 && testBit g r = pprPanic "Linear.AArch64.releaseReg" (text "can't release non-allocated reg x" <> int r) ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -2360,7 +2360,7 @@ addWeakFVs dmd_ty weak_fvs -- L demand doesn't get both'd with the Bot coming up from the inner -- call to f. So we just get an L demand for x for g. -setBndrsDemandInfo :: HasCallStack => [Var] -> [Demand] -> [Var] +setBndrsDemandInfo :: HasDebugCallStack => [Var] -> [Demand] -> [Var] setBndrsDemandInfo (b:bs) ds | isTyVar b = b : setBndrsDemandInfo bs ds setBndrsDemandInfo (b:bs) (d:ds) = ===================================== compiler/GHC/Core/Rules.hs ===================================== @@ -47,7 +47,7 @@ import GHC.Driver.Ppr( showSDoc ) import GHC.Core -- All of it import GHC.Core.Subst import GHC.Core.SimpleOpt ( exprIsLambda_maybe ) -import GHC.Core.FVs ( exprFreeVars, exprsFreeVars, bindFreeVars +import GHC.Core.FVs ( exprFreeVars, bindFreeVars , rulesFreeVarsDSet, exprsOrphNames ) import GHC.Core.Utils ( exprType, mkTick, mkTicks , stripTicksTopT, stripTicksTopE @@ -1887,41 +1887,59 @@ ruleCheckProgram ropts phase rule_pat rules binds vcat [ p $$ line | p <- bagToList results ] ] where + line = text (replicate 20 '-') env = RuleCheckEnv { rc_is_active = isActive phase , rc_id_unf = idUnfolding -- Not quite right -- Should use activeUnfolding , rc_pattern = rule_pat , rc_rules = rules , rc_ropts = ropts - } - results = unionManyBags (map (ruleCheckBind env) binds) - line = text (replicate 20 '-') + , rc_in_scope = emptyInScopeSet } + + results = go env binds + + go _ [] = emptyBag + go env (bind:binds) = let (env', ds) = ruleCheckBind env bind + in ds `unionBags` go env' binds + +data RuleCheckEnv = RuleCheckEnv + { rc_is_active :: Activation -> Bool + , rc_id_unf :: IdUnfoldingFun + , rc_pattern :: String + , rc_rules :: Id -> [CoreRule] + , rc_ropts :: RuleOpts + , rc_in_scope :: InScopeSet } + +extendInScopeRC :: RuleCheckEnv -> Var -> RuleCheckEnv +extendInScopeRC env@(RuleCheckEnv { rc_in_scope = in_scope }) v + = env { rc_in_scope = in_scope `extendInScopeSet` v } -data RuleCheckEnv = RuleCheckEnv { - rc_is_active :: Activation -> Bool, - rc_id_unf :: IdUnfoldingFun, - rc_pattern :: String, - rc_rules :: Id -> [CoreRule], - rc_ropts :: RuleOpts -} +extendInScopeListRC :: RuleCheckEnv -> [Var] -> RuleCheckEnv +extendInScopeListRC env@(RuleCheckEnv { rc_in_scope = in_scope }) vs + = env { rc_in_scope = in_scope `extendInScopeSetList` vs } -ruleCheckBind :: RuleCheckEnv -> CoreBind -> Bag SDoc +ruleCheckBind :: RuleCheckEnv -> CoreBind -> (RuleCheckEnv, Bag SDoc) -- The Bag returned has one SDoc for each call site found -ruleCheckBind env (NonRec _ r) = ruleCheck env r -ruleCheckBind env (Rec prs) = unionManyBags [ruleCheck env r | (_,r) <- prs] +ruleCheckBind env (NonRec b r) = (env `extendInScopeRC` b, ruleCheck env r) +ruleCheckBind env (Rec prs) = (env', unionManyBags (map (ruleCheck env') rhss)) + where + (bs, rhss) = unzip prs + env' = env `extendInScopeListRC` bs ruleCheck :: RuleCheckEnv -> CoreExpr -> Bag SDoc -ruleCheck _ (Var _) = emptyBag -ruleCheck _ (Lit _) = emptyBag -ruleCheck _ (Type _) = emptyBag -ruleCheck _ (Coercion _) = emptyBag -ruleCheck env (App f a) = ruleCheckApp env (App f a) [] -ruleCheck env (Tick _ e) = ruleCheck env e -ruleCheck env (Cast e _) = ruleCheck env e -ruleCheck env (Let bd e) = ruleCheckBind env bd `unionBags` ruleCheck env e -ruleCheck env (Lam _ e) = ruleCheck env e -ruleCheck env (Case e _ _ as) = ruleCheck env e `unionBags` - unionManyBags [ruleCheck env r | Alt _ _ r <- as] +ruleCheck _ (Var _) = emptyBag +ruleCheck _ (Lit _) = emptyBag +ruleCheck _ (Type _) = emptyBag +ruleCheck _ (Coercion _) = emptyBag +ruleCheck env (App f a) = ruleCheckApp env (App f a) [] +ruleCheck env (Tick _ e) = ruleCheck env e +ruleCheck env (Cast e _) = ruleCheck env e +ruleCheck env (Let bd e) = let (env', ds) = ruleCheckBind env bd + in ds `unionBags` ruleCheck env' e +ruleCheck env (Lam b e) = ruleCheck (env `extendInScopeRC` b) e +ruleCheck env (Case e b _ as) = ruleCheck env e `unionBags` + unionManyBags [ruleCheck (env `extendInScopeListRC` (b:bs)) r + | Alt _ bs r <- as] ruleCheckApp :: RuleCheckEnv -> Expr CoreBndr -> [Arg CoreBndr] -> Bag SDoc ruleCheckApp env (App f a) as = ruleCheck env a `unionBags` ruleCheckApp env f (a:as) @@ -1945,8 +1963,9 @@ ruleAppCheck_help env fn args rules vcat [text "Expression:" <+> ppr (mkApps (Var fn) args), vcat (map check_rule rules)] where - n_args = length args - i_args = args `zip` [1::Int ..] + in_scope = rc_in_scope env + n_args = length args + i_args = args `zip` [1::Int ..] rough_args = map roughTopName args check_rule rule = rule_herald rule <> colon <+> rule_info (rc_ropts env) rule @@ -1976,10 +1995,8 @@ ruleAppCheck_help env fn args rules mismatches = [i | (rule_arg, (arg,i)) <- rule_args `zip` i_args, not (isJust (match_fn rule_arg arg))] - lhs_fvs = exprsFreeVars rule_args -- Includes template tyvars match_fn rule_arg arg = match renv emptyRuleSubst rule_arg arg MRefl where - in_scope = mkInScopeSet (lhs_fvs `unionVarSet` exprFreeVars arg) renv = RV { rv_lcl = mkRnEnv2 in_scope , rv_tmpls = mkVarSet rule_bndrs , rv_fltR = mkEmptySubst in_scope ===================================== compiler/GHC/Core/SimpleOpt.hs ===================================== @@ -228,13 +228,14 @@ enterRecGroupRHSs env bndrs k (env', r) = k env{soe_rec_ids = extendUnVarSetList bndrs (soe_rec_ids env)} --------------- -simple_opt_clo :: InScopeSet +simple_opt_clo :: HasCallStack + => InScopeSet -> SimpleClo -> OutExpr simple_opt_clo in_scope (e_env, e) = simple_opt_expr (soeSetInScope in_scope e_env) e -simple_opt_expr :: HasCallStack => SimpleOptEnv -> InExpr -> OutExpr +simple_opt_expr :: HasDebugCallStack => SimpleOptEnv -> InExpr -> OutExpr simple_opt_expr env expr = go expr where @@ -397,7 +398,8 @@ simple_app env (Let bind body) args simple_app env e as = finish_app env (simple_opt_expr env e) as -finish_app :: SimpleOptEnv -> OutExpr -> [SimpleClo] -> OutExpr +finish_app :: HasCallStack + => SimpleOptEnv -> OutExpr -> [SimpleClo] -> OutExpr -- See Note [Eliminate casts in function position] finish_app env (Cast (Lam x e) co) as@(_:_) | not (isTyVar x) && not (isCoVar x) ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -1636,7 +1636,7 @@ tyConAppArgs_maybe ty = case splitTyConApp_maybe ty of Just (_, tys) -> Just tys Nothing -> Nothing -tyConAppArgs :: HasCallStack => Type -> [Type] +tyConAppArgs :: HasDebugCallStack => Type -> [Type] tyConAppArgs ty = tyConAppArgs_maybe ty `orElse` pprPanic "tyConAppArgs" (ppr ty) -- | Attempts to tease a type apart into a type constructor and the application @@ -1676,7 +1676,7 @@ splitTyConAppNoView_maybe ty -- -- Consequently, you may need to zonk your type before -- using this function. -tcSplitTyConApp_maybe :: HasCallStack => Type -> Maybe (TyCon, [Type]) +tcSplitTyConApp_maybe :: HasDebugCallStack => Type -> Maybe (TyCon, [Type]) -- Defined here to avoid module loops between Unify and TcType. tcSplitTyConApp_maybe ty = case coreFullView ty of ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -2354,45 +2354,49 @@ we are optimizing away 'lazy' (see Note [lazyId magic], and also 'cpeRhsE'.) Then, we could have started with: let x :: () - x = lazy @ () y + x = lazy @() y -which is a perfectly fine, non-trivial thunk, but then CorePrep will -drop 'lazy', giving us 'x = y' which is trivial and impermissible. -The solution is CorePrep to have a miniature inlining pass which deals -with cases like this. We can then drop the let-binding altogether. +which is a perfectly fine, non-trivial thunk, but then CorePrep will drop +'lazy', giving us 'x = y' which is trivial and impermissible. The solution is +CorePrep to have a miniature inlining pass which deals with cases like this. +We can then drop the let-binding altogether. -Why does the removal of 'lazy' have to occur in CorePrep? -The gory details are in Note [lazyId magic] in GHC.Types.Id.Make, but the -main reason is that lazy must appear in unfoldings (optimizer -output) and it must prevent call-by-value for catch# (which -is implemented by CorePrep.) +Why does the removal of 'lazy' have to occur in CorePrep? The gory details +are in Note [lazyId magic] in GHC.Types.Id.Make, but the main reason is that +lazy must appear in unfoldings (optimizer output) and it must prevent +call-by-value for catch# (which is implemented by CorePrep.) -An alternate strategy for solving this problem is to have the -inliner treat 'lazy e' as a trivial expression if 'e' is trivial. -We decided not to adopt this solution to keep the definition -of 'exprIsTrivial' simple. +An alternate strategy for solving this problem is to have the inliner treat +'lazy e' as a trivial expression if 'e' is trivial. We decided not to adopt +this solution to keep the definition of 'exprIsTrivial' simple. There is ONE caveat however: for top-level bindings we have to preserve the binding so that we float the (hacky) non-recursive binding for data constructors; see Note [Data constructor workers]. -Note [CorePrep inlines trivial CoreExpr not Id] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -TODO -Why does cpe_env need to be an IdEnv CoreExpr, as opposed to an -IdEnv Id? Naively, we might conjecture that trivial updatable thunks -as per Note [Inlining in CorePrep] always have the form -'lazy @ SomeType gbl_id'. But this is not true: the following is -perfectly reasonable Core: +Note [CorePrepEnv: cpe_subst] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +CorePrepEnv carries a substitution `Subst` in the `cpe_subst1 field, +for these reasons: - let x :: () - x = lazy @ (forall a. a) y @ Bool +1. To support cloning of local Ids so that they are + all unique (see Note [Cloning in CorePrep]) + +2. To support beta-reduction of runRW, see Note [runRW magic] and + Note [runRW arg]. + +3. To let us inline trivial RHSs of non top-level let-bindings, + see Note [lazyId magic], Note [Inlining in CorePrep] (#12076) -When we inline 'x' after eliminating 'lazy', we need to replace -occurrences of 'x' with 'y @ bool', not just 'y'. Situations like -this can easily arise with higher-rank types; thus, cpe_env must -map to CoreExprs, not Ids. + Note that, if (y::forall a. a->a), we could get + x = lazy @(forall a.a) y @Bool + so after eliminating `lazy`, we need to replace occurrences of `x` with + `y @Bool`, not just `y`. Situations like this can easily arise with + higher-rank types; thus, `cpe_subst` must map to CoreExprs, not Ids, which + oc course it does +4. The TyCoVar part of the substitution is used only for + Note [Cloning CoVars and TyVars] -} data CorePrepConfig = CorePrepConfig @@ -2418,23 +2422,9 @@ data CorePrepEnv -- the case where a function we think should bottom -- unexpectedly returns. - , cpe_subst :: Subst - -- ^ The IdEnv part of the substitution is used for three operations: - -- - -- 1. To support cloning of local Ids so that they are - -- all unique (see Note [Cloning in CorePrep]) - -- - -- 2. To support beta-reduction of runRW, see - -- Note [runRW magic] and Note [runRW arg]. - -- - -- 3. To let us inline trivial RHSs of non top-level let-bindings, - -- see Note [lazyId magic], Note [Inlining in CorePrep] - -- and Note [CorePrep inlines trivial CoreExpr not Id] (#12076) - -- - -- The TyCoVar part of the substitution is used only for - -- Note [Cloning CoVars and TyVars] + , cpe_subst :: Subst -- ^ See Note [CorePrepEnv: cpe_subst] - , cpe_rec_ids :: UnVarSet -- Faster OutIdSet; See Note [Speculative evaluation] + , cpe_rec_ids :: UnVarSet -- Faster OutIdSet; See Note [Speculative evaluation] } mkInitialCorePrepEnv :: CorePrepConfig -> CorePrepEnv ===================================== compiler/GHC/Data/Maybe.hs ===================================== @@ -33,7 +33,7 @@ import Control.Monad.Trans.Maybe import Control.Exception (SomeException(..)) import Data.Maybe import Data.Foldable ( foldlM, for_ ) -import GHC.Utils.Misc (HasCallStack) +import GHC.Utils.Misc (HasDebugCallStack) import Data.List.NonEmpty ( NonEmpty ) import Control.Applicative( Alternative( (<|>) ) ) @@ -66,7 +66,7 @@ firstJustsM = foldlM go Nothing where go Nothing action = action go result@(Just _) _action = return result -expectJust :: HasCallStack => String -> Maybe a -> a +expectJust :: HasDebugCallStack => String -> Maybe a -> a {-# INLINE expectJust #-} expectJust _ (Just x) = x expectJust err Nothing = error ("expectJust " ++ err) ===================================== compiler/GHC/Stg/Subst.hs ===================================== @@ -55,7 +55,7 @@ substBndrs = runState . traverse (state . substBndr) -- | Substitutes an occurrence of an identifier for its counterpart recorded -- in the 'Subst'. -lookupIdSubst :: HasCallStack => Id -> Subst -> Id +lookupIdSubst :: HasDebugCallStack => Id -> Subst -> Id lookupIdSubst id (Subst in_scope env) | not (isLocalId id) = id | Just id' <- lookupVarEnv env id = id' @@ -65,7 +65,7 @@ lookupIdSubst id (Subst in_scope env) -- | Substitutes an occurrence of an identifier for its counterpart recorded -- in the 'Subst'. Does not generate a debug warning if the identifier to -- to substitute wasn't in scope. -noWarnLookupIdSubst :: HasCallStack => Id -> Subst -> Id +noWarnLookupIdSubst :: HasDebugCallStack => Id -> Subst -> Id noWarnLookupIdSubst id (Subst in_scope env) | not (isLocalId id) = id | Just id' <- lookupVarEnv env id = id' ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -2445,7 +2445,7 @@ postfixModTbl ] -- | Lookup `Type` in an association list. -assoc_ty_id :: HasCallStack => String -- The class involved +assoc_ty_id :: HasDebugCallStack => String -- The class involved -> [(Type,a)] -- The table -> Type -- The type -> a -- The result of the lookup ===================================== compiler/GHC/Tc/Deriv/Utils.hs ===================================== @@ -649,7 +649,7 @@ mkDirectThetaSpec origin t_or_k = , sps_type_or_kind = t_or_k }) -substPredSpec :: HasCallStack => Subst -> PredSpec -> PredSpec +substPredSpec :: HasDebugCallStack => Subst -> PredSpec -> PredSpec substPredSpec subst ps = case ps of SimplePredSpec { sps_pred = pred ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -3589,7 +3589,7 @@ data SkolemModeDetails | SMDSkolemTv SkolemInfo -smVanilla :: HasCallStack => SkolemMode +smVanilla :: HasDebugCallStack => SkolemMode smVanilla = SM { sm_clone = panic "sm_clone" -- We always override this , sm_parent = False , sm_tvtv = pprPanic "sm_tvtv" callStackDoc -- We always override this ===================================== compiler/GHC/Tc/Types/Origin.hs ===================================== @@ -77,6 +77,7 @@ import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Stack import GHC.Utils.Monad +import GHC.Utils.Misc( HasDebugCallStack ) import GHC.Types.Unique import GHC.Types.Unique.Supply @@ -327,10 +328,10 @@ data SkolemInfoAnon -- -- We're hoping to be able to get rid of this entirely, but for the moment -- it's still needed. -unkSkol :: HasCallStack => SkolemInfo +unkSkol :: HasDebugCallStack => SkolemInfo unkSkol = SkolemInfo (mkUniqueGrimily 0) unkSkolAnon -unkSkolAnon :: HasCallStack => SkolemInfoAnon +unkSkolAnon :: HasDebugCallStack => SkolemInfoAnon unkSkolAnon = UnkSkol callStack -- | Wrap up the origin of a skolem type variable with a new 'Unique', @@ -895,7 +896,7 @@ pprCtOrigin simple_origin = ctoHerald <+> pprCtO simple_origin -- | Short one-liners -pprCtO :: HasCallStack => CtOrigin -> SDoc +pprCtO :: HasDebugCallStack => CtOrigin -> SDoc pprCtO (OccurrenceOf name) = hsep [text "a use of", quotes (ppr name)] pprCtO (OccurrenceOfRecSel name) = hsep [text "a use of", quotes (ppr name)] pprCtO AppOrigin = text "an application" @@ -960,7 +961,7 @@ pprCtO (AmbiguityCheckOrigin {}) = text "a type ambiguity check" pprCtO (ImpedanceMatching {}) = text "combining required constraints" pprCtO (NonLinearPatternOrigin _ pat) = hsep [text "a non-linear pattern" <+> quotes (ppr pat)] -pprNonLinearPatternReason :: HasCallStack => NonLinearPatternReason -> SDoc +pprNonLinearPatternReason :: HasDebugCallStack => NonLinearPatternReason -> SDoc pprNonLinearPatternReason LazyPatternReason = parens (text "non-variable lazy pattern aren't linear") pprNonLinearPatternReason GeneralisedPatternReason = parens (text "non-variable pattern bindings that have been generalised aren't linear") pprNonLinearPatternReason PatternSynonymReason = parens (text "pattern synonyms aren't linear") ===================================== compiler/GHC/Tc/Types/Origin.hs-boot ===================================== @@ -1,7 +1,7 @@ module GHC.Tc.Types.Origin where import GHC.Prelude.Basic ( Int, Maybe ) -import GHC.Stack ( HasCallStack ) +import GHC.Utils.Misc ( HasDebugCallStack ) import {-# SOURCE #-} GHC.Core.TyCo.Rep ( Type ) data SkolemInfoAnon @@ -16,4 +16,4 @@ data FixedRuntimeRepOrigin mkFRRUnboxedTuple :: Int -> FixedRuntimeRepContext mkFRRUnboxedSum :: Maybe Int -> FixedRuntimeRepContext -unkSkol :: HasCallStack => SkolemInfo +unkSkol :: HasDebugCallStack => SkolemInfo ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -609,7 +609,7 @@ data TcTyVarDetails , mtv_ref :: IORef MetaDetails , mtv_tclvl :: TcLevel } -- See Note [TcLevel invariants] -vanillaSkolemTvUnk :: HasCallStack => TcTyVarDetails +vanillaSkolemTvUnk :: HasDebugCallStack => TcTyVarDetails vanillaSkolemTvUnk = SkolemTv unkSkol topTcLevel False instance Outputable TcTyVarDetails where ===================================== compiler/GHC/Tc/Utils/TcType.hs-boot ===================================== @@ -1,16 +1,16 @@ module GHC.Tc.Utils.TcType where import GHC.Utils.Outputable( SDoc ) +import GHC.Utils.Misc( HasDebugCallStack ) import GHC.Prelude ( Bool ) import {-# SOURCE #-} GHC.Types.Var ( TcTyVar ) import {-# SOURCE #-} GHC.Tc.Types.Origin ( FixedRuntimeRepOrigin ) import GHC.Types.Name.Env ( NameEnv ) -import GHC.Stack data MetaDetails data TcTyVarDetails pprTcTyVarDetails :: TcTyVarDetails -> SDoc -vanillaSkolemTvUnk :: HasCallStack => TcTyVarDetails +vanillaSkolemTvUnk :: HasDebugCallStack => TcTyVarDetails isMetaTyVar :: TcTyVar -> Bool isTyConableTyVar :: TcTyVar -> Bool ===================================== compiler/GHC/Utils/Misc.hs ===================================== @@ -488,7 +488,7 @@ only _ = panic "Util: only" -- | Extract the single element of a list and panic with the given message if -- there are more elements or the list was empty. -- Like 'expectJust', but for lists. -expectOnly :: HasCallStack => String -> [a] -> a +expectOnly :: HasDebugCallStack => String -> [a] -> a {-# INLINE expectOnly #-} #if defined(DEBUG) expectOnly _ [a] = a @@ -511,7 +511,7 @@ changeLast [_] x = [x] changeLast (x:xs) x' = x : changeLast xs x' -- | Like @expectJust msg . nonEmpty@; a better alternative to 'NE.fromList'. -expectNonEmpty :: HasCallStack => String -> [a] -> NonEmpty a +expectNonEmpty :: HasDebugCallStack => String -> [a] -> NonEmpty a {-# INLINE expectNonEmpty #-} expectNonEmpty _ (x:xs) = x:|xs expectNonEmpty msg [] = expectNonEmptyPanic msg ===================================== compiler/GHC/Utils/Word64.hs ===================================== @@ -6,15 +6,15 @@ module GHC.Utils.Word64 ( import GHC.Prelude import GHC.Utils.Panic.Plain (assert) +import GHC.Utils.Misc (HasDebugCallStack) import Data.Word -import GHC.Stack -intToWord64 :: HasCallStack => Int -> Word64 +intToWord64 :: HasDebugCallStack => Int -> Word64 intToWord64 x = assert (0 <= x) (fromIntegral x) -word64ToInt :: HasCallStack => Word64 -> Int +word64ToInt :: HasDebugCallStack => Word64 -> Int word64ToInt x = assert (x <= fromIntegral (maxBound :: Int)) (fromIntegral x) truncateWord64ToWord32 :: Word64 -> Word32 -truncateWord64ToWord32 = fromIntegral \ No newline at end of file +truncateWord64ToWord32 = fromIntegral ===================================== testsuite/tests/simplCore/should_compile/T24726.hs ===================================== @@ -0,0 +1,26 @@ +{-# OPTIONS_GHC -drule-check concatMap #-} + -- This rule-check thing crashed #24726 + +module T24726 where + +data Stream a = forall s. Stream (s -> ()) s + +concatMapS :: (a -> Stream b) -> Stream a -> Stream b +concatMapS f (Stream next0 s0) = Stream undefined undefined +{-# INLINE [1] concatMapS #-} + +concatMapS' :: (s -> ()) -> (a -> s) -> Stream a -> Stream b +concatMapS' = undefined + +{-# RULES "concatMap" forall step f. concatMapS (\x -> Stream step (f x)) = concatMapS' step f #-} + +replicateStep :: a -> b +replicateStep _ = undefined +{-# INLINE replicateStep #-} + +replicateS :: Int -> a -> Stream a +replicateS n x0 = Stream replicateStep undefined +{-# INLINE replicateS #-} + +foo1 :: Stream Int -> Stream Int +foo1 = concatMapS (replicateS 2) ===================================== testsuite/tests/simplCore/should_compile/T24726.stderr ===================================== @@ -0,0 +1,36 @@ + +==================== Rule check ==================== +Rule check results: +-------------------- +Expression: concatMapS @(*) @Int @Int foo1 +Rule "concatMap": all arguments match (considered individually), but rule as a whole does not +-------------------- + + + +==================== Rule check ==================== +Rule check results: +-------------------- +Expression: concatMapS @(*) @Int @Int foo1 +Rule "concatMap": all arguments match (considered individually), but rule as a whole does not +-------------------- + + + +==================== Rule check ==================== +Rule check results: +-------------------- +Expression: concatMapS @(*) @Int @Int foo1 +Rule "concatMap": all arguments match (considered individually), but rule as a whole does not +-------------------- + + + +==================== Rule check ==================== +Rule check results: +-------------------- +Expression: concatMapS @(*) @Int @Int foo1 +Rule "concatMap": all arguments match (considered individually), but rule as a whole does not +-------------------- + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -514,3 +514,4 @@ test('T24229a', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typea test('T24229b', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques -dppr-cols=99999']) test('T24370', normal, compile, ['-O']) test('T24551', normal, compile, ['-O -dcore-lint']) +test('T24726', normal, compile, ['-dcore-lint -dsuppress-uniques']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ba480026903aa735e63818a64228ab13639ecdc9...e56871861c8a531feaa1a24e37fb56ba6c8cc690 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ba480026903aa735e63818a64228ab13639ecdc9...e56871861c8a531feaa1a24e37fb56ba6c8cc690 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 00:50:50 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 03 May 2024 20:50:50 -0400 Subject: [Git][ghc/ghc][master] driver: always merge objects when possible Message-ID: <66358669f381e_36c4de4cab3b41248e8@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1 changed file: - compiler/GHC/Driver/Pipeline/Execute.hs Changes: ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -1045,17 +1045,12 @@ However, `ld -r` is broken in some cases: * The LLD linker that we use on Windows does not support the `-r` flag needed to support object merging (see #21068). For this reason on Windows we do not support GHCi objects. - * `wasm-ld -r` is prohibitively slow, especially when handling large - input objects (e.g. profiled objects). In these cases, we bundle a module's own object file with its foreign stub's object file, instead of merging them. Consequently, we can end up producing `.o` files which are in fact static archives. This can only work if `ar -L` is supported, so the archive `.o` files can be -properly added to the final static library. We must also take care not -to produce archive `.dyn_o` when building dynamic objects, otherwise -we end up with broken `.so` files when GHC is built with `llvm-ar` -(#22210). +properly added to the final static library. Note that this has somewhat non-obvious consequences when producing initializers and finalizers. See Note [Initializers and finalizers in Cmm] @@ -1081,7 +1076,7 @@ via gcc. -- | See Note [Object merging]. joinObjectFiles :: HscEnv -> [FilePath] -> FilePath -> IO () joinObjectFiles hsc_env o_files output_fn - | can_merge_objs && (not dashLSupported || is_dyn) = do + | can_merge_objs = do let toolSettings' = toolSettings dflags ldIsGnuLd = toolSettings_ldIsGnuLd toolSettings' ld_r args = GHC.SysTools.runMergeObjects (hsc_logger hsc_env) (hsc_tmpfs hsc_env) (hsc_dflags hsc_env) ( @@ -1109,7 +1104,6 @@ joinObjectFiles hsc_env o_files output_fn withAtomicRename output_fn $ \tmp_ar -> liftIO $ runAr logger dflags Nothing $ map Option $ ["qc" ++ dashL, tmp_ar] ++ o_files where - is_dyn = ways dflags `hasWay` WayDyn dashLSupported = sArSupportsDashL (settings dflags) dashL = if dashLSupported then "L" else "" can_merge_objs = isJust (pgm_lm (hsc_dflags hsc_env)) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/631cefec222e2db951c58db0b15a8d80ef5549cb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/631cefec222e2db951c58db0b15a8d80ef5549cb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 00:52:13 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 03 May 2024 20:52:13 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Bump time submodule to 1.14 Message-ID: <663586bde6e_36c4de4e0ba74130914@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 7 changed files: - compiler/ghc.cabal.in - ghc/ghc-bin.cabal.in - libraries/Cabal - libraries/directory - libraries/hpc - libraries/terminfo - libraries/time Changes: ===================================== compiler/ghc.cabal.in ===================================== @@ -120,7 +120,7 @@ Library process >= 1 && < 1.7, bytestring >= 0.11 && < 0.13, binary == 0.8.*, - time >= 1.4 && < 1.13, + time >= 1.4 && < 1.15, containers >= 0.6.2.1 && < 0.8, array >= 0.1 && < 0.6, filepath >= 1 && < 1.6, ===================================== ghc/ghc-bin.cabal.in ===================================== @@ -61,7 +61,7 @@ Executable ghc ghci == @ProjectVersionMunged@, haskeline == 0.8.*, exceptions == 0.10.*, - time >= 1.8 && < 1.13 + time >= 1.8 && < 1.15 CPP-Options: -DHAVE_INTERNAL_INTERPRETER Other-Modules: GHCi.Leak ===================================== libraries/Cabal ===================================== @@ -1 +1 @@ -Subproject commit fb3f4d47d261f7401e4ea717ffab31af5d5470fb +Subproject commit 56fb1dc9baa20b079eb0fa84ccafb284a6e91d41 ===================================== libraries/directory ===================================== @@ -1 +1 @@ -Subproject commit 4b7c231d187cf253c5f446c4aed2fea26b81d5f9 +Subproject commit a97a8a8f30d652f972192122fd5f459a147c13e5 ===================================== libraries/hpc ===================================== @@ -1 +1 @@ -Subproject commit 8bf6f8b08b0d72cb9231775b66ca572acc1d3197 +Subproject commit 4989c41b96c7c9ca09a6687da638ac28f3d3688b ===================================== libraries/terminfo ===================================== @@ -1 +1 @@ -Subproject commit 500399a1497dfe1786ba67d6d2bfced4832f3fed +Subproject commit 5b43c14f6843973d8704fb60486e6c458fc0ac8c ===================================== libraries/time ===================================== @@ -1 +1 @@ -Subproject commit baab563ee2ce547f7b7f7e7069ed09db2d406941 +Subproject commit e5c5d1987011efe88a21ab6ded45aaa33a16274f View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/631cefec222e2db951c58db0b15a8d80ef5549cb...4941b90e530b11053dd34c3e139ca86bbb1b91ee -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/631cefec222e2db951c58db0b15a8d80ef5549cb...4941b90e530b11053dd34c3e139ca86bbb1b91ee You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 00:53:07 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 03 May 2024 20:53:07 -0400 Subject: [Git][ghc/ghc][master] wasm: use scheduler.postTask() for context switch when available Message-ID: <663586f385019_36c4de4fab50013464@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 1 changed file: - utils/jsffi/prelude.js Changes: ===================================== utils/jsffi/prelude.js ===================================== @@ -75,17 +75,21 @@ class SetImmediate { // The actual setImmediate() to be used. This is a ESM module top // level binding and doesn't pollute the globalThis namespace. -let setImmediate; -if (globalThis.setImmediate) { - // node.js, bun - setImmediate = globalThis.setImmediate; -} else { +const setImmediate = await (async () => { + // https://developer.mozilla.org/en-US/docs/Web/API/Scheduler + if (globalThis.scheduler) { + return (cb, ...args) => scheduler.postTask(() => cb(...args)); + } + // node, bun, or other scripts might have set this up in the browser + if (globalThis.setImmediate) { + return globalThis.setImmediate; + } try { // deno - setImmediate = (await import("node:timers")).setImmediate; + return (await import("node:timers")).setImmediate; } catch { // browsers const sm = new SetImmediate(); - setImmediate = (cb, ...args) => sm.setImmediate(cb, ...args); + return (cb, ...args) => sm.setImmediate(cb, ...args); } -} +})(); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/43d48b449a46e805e3baeafbafa62b6cd6f761c9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/43d48b449a46e805e3baeafbafa62b6cd6f761c9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 00:53:45 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 03 May 2024 20:53:45 -0400 Subject: [Git][ghc/ghc][master] testsuite: give pre_cmd for mhu-perf 5x time Message-ID: <66358719285b_36c4de5293704134850@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - 1 changed file: - testsuite/tests/driver/multipleHomeUnits/mhu-perf/all.T Changes: ===================================== testsuite/tests/driver/multipleHomeUnits/mhu-perf/all.T ===================================== @@ -4,7 +4,7 @@ test('mhu-perf', pre_cmd('$MAKE -s --no-print-directory mhu-perf'), js_broken(22349), when(arch('wasm32'), skip), # wasm32 doesn't like running Setup/Makefile tests - pre_cmd_timeout_multiplier(2), + pre_cmd_timeout_multiplier(5), compile_timeout_multiplier(5), ], multiunit_compile, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0820750140af2972ca254a42c0fdc537f3b7c447 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0820750140af2972ca254a42c0fdc537f3b7c447 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 00:54:01 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 03 May 2024 20:54:01 -0400 Subject: [Git][ghc/ghc][master] EPA: Preserve comments for pattern synonym sig Message-ID: <663587295b93b_36c4de52bd478135014@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - 4 changed files: - compiler/GHC/Parser.y - testsuite/tests/printer/Makefile - + testsuite/tests/printer/Test24749.hs - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -2653,7 +2653,7 @@ sigdecl :: { LHsDecl GhcPs } (Fixity fixText fixPrec (unLoc $1))))) }} - | pattern_synonym_sig { sL1a $1 . SigD noExtField . unLoc $ $1 } + | pattern_synonym_sig { L (getLoc $1) . SigD noExtField . unLoc $ $1 } | '{-# COMPLETE' qcon_list opt_tyconsig '#-}' {% let (dcolon, tc) = $3 ===================================== testsuite/tests/printer/Makefile ===================================== @@ -846,3 +846,8 @@ Test24748: DataDeclShort: $(CHECK_PPR) $(LIBDIR) DataDeclShort.hs $(CHECK_EXACT) $(LIBDIR) DataDeclShort.hs + +.PHONY: Test24749 +Test24749: + $(CHECK_PPR) $(LIBDIR) Test24749.hs + $(CHECK_EXACT) $(LIBDIR) Test24749.hs ===================================== testsuite/tests/printer/Test24749.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE PatternSynonyms #-} +module Test24749 where + +-- c0 +pattern (:|) :: + -- c1 + a -> + -- c2 + a -> + -- c3 + Domino a ===================================== testsuite/tests/printer/all.T ===================================== @@ -202,3 +202,4 @@ test('CaseAltComments', [ignore_stderr, req_ppr_deps], makefile_test, ['CaseAltC test('MatchPatComments', [ignore_stderr, req_ppr_deps], makefile_test, ['MatchPatComments']) test('Test24748', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24748']) test('DataDeclShort', [ignore_stderr, req_ppr_deps], makefile_test, ['DataDeclShort']) +test('Test24749', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24749']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bf3d4db0894233ec72f092a4a34bce9ed4ff4e21 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bf3d4db0894233ec72f092a4a34bce9ed4ff4e21 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 00:54:34 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 03 May 2024 20:54:34 -0400 Subject: [Git][ghc/ghc][wip/T24504] IPE: Eliminate dependency on Read Message-ID: <6635874a2dd5_36c4de54419d413697e@gitlab.mail> Ben Gamari pushed to branch wip/T24504 at Glasgow Haskell Compiler / GHC Commits: 80c85fe5 by Ben Gamari at 2024-05-03T20:53:07-04:00 IPE: Eliminate dependency on Read Instead of encoding the closure type as decimal string we now simply represent it as an integer, eliminating the need for `Read` in `GHC.Internal.InfoProv.Types.peekInfoProv`. Closes #24504. - - - - - 5 changed files: - compiler/GHC/StgToCmm/InfoTableProv.hs - libraries/ghc-internal/src/GHC/Internal/InfoProv/Types.hsc - rts/IPE.c - rts/Trace.c - rts/include/rts/IPE.h Changes: ===================================== compiler/GHC/StgToCmm/InfoTableProv.hs ===================================== @@ -178,7 +178,7 @@ toIpeBufferEntries byte_order cg_ipes = to_ipe_buf_ent :: CgInfoProvEnt -> [Word32] to_ipe_buf_ent cg_ipe = [ ipeTableName cg_ipe - , ipeClosureDesc cg_ipe + , fromIntegral $ ipeClosureDesc cg_ipe , ipeTypeDesc cg_ipe , ipeLabel cg_ipe , ipeSrcFile cg_ipe @@ -193,7 +193,6 @@ toIpeBufferEntries byte_order cg_ipes = toCgIPE :: Platform -> SDocContext -> InfoProvEnt -> State StringTable CgInfoProvEnt toCgIPE platform ctx ipe = do table_name <- lookupStringTable $ ST.pack $ renderWithContext ctx (pprCLabel platform (infoTablePtr ipe)) - closure_desc <- lookupStringTable $ ST.pack $ show (infoProvEntClosureType ipe) type_desc <- lookupStringTable $ ST.pack $ infoTableType ipe let label_str = maybe "" ((\(LexicalFastString s) -> unpackFS s) . snd) (infoTableProv ipe) let (src_loc_file, src_loc_span) = @@ -208,7 +207,7 @@ toCgIPE platform ctx ipe = do src_span <- lookupStringTable $ ST.pack src_loc_span return $ CgInfoProvEnt { ipeInfoTablePtr = infoTablePtr ipe , ipeTableName = table_name - , ipeClosureDesc = closure_desc + , ipeClosureDesc = fromIntegral (infoProvEntClosureType ipe) , ipeTypeDesc = type_desc , ipeLabel = label , ipeSrcFile = src_file @@ -218,7 +217,7 @@ toCgIPE platform ctx ipe = do data CgInfoProvEnt = CgInfoProvEnt { ipeInfoTablePtr :: !CLabel , ipeTableName :: !StrTabOffset - , ipeClosureDesc :: !StrTabOffset + , ipeClosureDesc :: !Word32 , ipeTypeDesc :: !StrTabOffset , ipeLabel :: !StrTabOffset , ipeSrcFile :: !StrTabOffset ===================================== libraries/ghc-internal/src/GHC/Internal/InfoProv/Types.hsc ===================================== @@ -18,8 +18,9 @@ module GHC.Internal.InfoProv.Types ) where import GHC.Internal.Base -import GHC.Internal.Data.Maybe import GHC.Internal.Enum +import GHC.Internal.Real (fromIntegral) +import GHC.Internal.Word (Word32) import GHC.Internal.Show (Show) import GHC.Internal.Ptr (Ptr(..), plusPtr) import GHC.Internal.Foreign.C.String.Encoding (CString, peekCString) @@ -28,7 +29,6 @@ import GHC.Internal.Foreign.Marshal.Alloc (allocaBytes) import GHC.Internal.IO.Encoding (utf8) import GHC.Internal.Foreign.Storable (peekByteOff) import GHC.Internal.ClosureTypes -import GHC.Internal.Text.Read import GHC.Prim (whereFrom##) data InfoProv = InfoProv { @@ -70,9 +70,11 @@ getIPE obj fail k = allocaBytes (#size InfoProvEnt) $ \p -> IO $ \s -> ipeProv :: Ptr InfoProvEnt -> Ptr InfoProv ipeProv p = (#ptr InfoProvEnt, prov) p -peekIpName, peekIpDesc, peekIpLabel, peekIpUnitId, peekIpModule, peekIpSrcFile, peekIpSrcSpan, peekIpTyDesc :: Ptr InfoProv -> IO CString -peekIpName p = (# peek InfoProv, table_name) p +peekIpDesc :: Ptr InfoProv -> IO Word32 peekIpDesc p = (# peek InfoProv, closure_desc) p + +peekIpName, peekIpLabel, peekIpUnitId, peekIpModule, peekIpSrcFile, peekIpSrcSpan, peekIpTyDesc :: Ptr InfoProv -> IO CString +peekIpName p = (# peek InfoProv, table_name) p peekIpLabel p = (# peek InfoProv, label) p peekIpUnitId p = (# peek InfoProv, unit_id) p peekIpModule p = (# peek InfoProv, module) p @@ -83,7 +85,7 @@ peekIpTyDesc p = (# peek InfoProv, ty_desc) p peekInfoProv :: Ptr InfoProv -> IO InfoProv peekInfoProv infop = do name <- peekCString utf8 =<< peekIpName infop - desc <- peekCString utf8 =<< peekIpDesc infop + desc <- peekIpDesc infop tyDesc <- peekCString utf8 =<< peekIpTyDesc infop label <- peekCString utf8 =<< peekIpLabel infop unit_id <- peekCString utf8 =<< peekIpUnitId infop @@ -94,7 +96,7 @@ peekInfoProv infop = do ipName = name, -- The INVALID_OBJECT case should be impossible as we -- control the C code generating these values. - ipDesc = maybe INVALID_OBJECT toEnum . readMaybe @Int $ desc, + ipDesc = toEnum $ fromIntegral desc, ipTyDesc = tyDesc, ipLabel = label, ipUnitId = unit_id, ===================================== rts/IPE.c ===================================== @@ -105,7 +105,7 @@ static InfoProvEnt ipeBufferEntryToIpe(const IpeBufferListNode *node, uint32_t i .info = node->tables[idx], .prov = { .table_name = &strings[ent->table_name], - .closure_desc = &strings[ent->closure_desc], + .closure_desc = ent->closure_desc, .ty_desc = &strings[ent->ty_desc], .label = &strings[ent->label], .unit_id = &strings[node->unit_id], ===================================== rts/Trace.c ===================================== @@ -689,7 +689,7 @@ void traceIPE(const InfoProvEnt *ipe) ACQUIRE_LOCK(&trace_utx); tracePreface(); - debugBelch("IPE: table_name %s, closure_desc %s, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", + debugBelch("IPE: table_name %s, closure_desc %d, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", ipe->prov.table_name, ipe->prov.closure_desc, ipe->prov.ty_desc, ipe->prov.label, ipe->prov.unit_id, ipe->prov.module, ipe->prov.src_file, ipe->prov.src_span); ===================================== rts/include/rts/IPE.h ===================================== @@ -15,7 +15,7 @@ typedef struct InfoProv_ { const char *table_name; - const char *closure_desc; + uint32_t closure_desc; // closure type const char *ty_desc; const char *label; const char *unit_id; @@ -54,7 +54,7 @@ typedef uint32_t StringIdx; // to ensure correct packing. typedef struct { StringIdx table_name; - StringIdx closure_desc; + uint32_t closure_desc; // closure type StringIdx ty_desc; StringIdx label; StringIdx src_file; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/80c85fe57531a20dc8ea17d79d4b72ef51abd842 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/80c85fe57531a20dc8ea17d79d4b72ef51abd842 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 03:52:57 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 03 May 2024 23:52:57 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 16 commits: Expose constructors of SNat, SChar and SSymbol in ghc-internal Message-ID: <6635b11947077_95755128174c104e@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - 395bfe31 by Matthew Pickering at 2024-05-03T23:52:47-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 66563da8 by Matthew Pickering at 2024-05-03T23:52:47-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - 7c3dd23a by Ryan Scott at 2024-05-03T23:52:47-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 30 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Stg/Subst.hs - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/StgToJS/Linker/Utils.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Utils.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e242c503c45f46043807a9924fa5b7ca71b7c7bc...7c3dd23ae4a80dea03d7985fbcf3d9e3b8aa9656 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e242c503c45f46043807a9924fa5b7ca71b7c7bc...7c3dd23ae4a80dea03d7985fbcf3d9e3b8aa9656 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 08:43:25 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sat, 04 May 2024 04:43:25 -0400 Subject: [Git][ghc/ghc][wip/az/T24754-epa-stmtlist-semi-span] 16 commits: testsuite: expand size testing infrastructure Message-ID: <6635f52d8d8cf_14588626f64c5543b@gitlab.mail> Alan Zimmerman pushed to branch wip/az/T24754-epa-stmtlist-semi-span at Glasgow Haskell Compiler / GHC Commits: 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - 41d1ee18 by Alan Zimmerman at 2024-05-04T09:42:22+01:00 EPA: Widen stmtslist to include last semicolon Closes #24754 - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Eval/Types.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/Stg/Subst.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f38ebf3e08ff63d49199b002bef2a0b2940d956e...41d1ee1824f84f520764ed80901a18b45bc01809 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f38ebf3e08ff63d49199b002bef2a0b2940d956e...41d1ee1824f84f520764ed80901a18b45bc01809 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 09:05:25 2024 From: gitlab at gitlab.haskell.org (Artin Ghasivand (@Ei30metry)) Date: Sat, 04 May 2024 05:05:25 -0400 Subject: [Git][ghc/ghc][wip/T24467] Add TypeAnnDataDecl and a draft Outputable instance for it Message-ID: <6635fa55860ef_1458865f65e065574@gitlab.mail> Artin Ghasivand pushed to branch wip/T24467 at Glasgow Haskell Compiler / GHC Commits: f8aa6a14 by Artin Ghasivand at 2024-05-04T12:34:41+03:30 Add TypeAnnDataDecl and a draft Outputable instance for it - - - - - 3 changed files: - compiler/GHC/Iface/Decl.hs - compiler/GHC/Iface/Syntax.hs - ghc/GHCi/UI.hs Changes: ===================================== compiler/GHC/Iface/Decl.hs ===================================== @@ -14,6 +14,7 @@ module GHC.Iface.Decl ( coAxiomToIfaceDecl , tyThingToIfaceDecl -- Converting things to their Iface equivalents , toIfaceBooleanFormula + , tyConToIfaceDecl ) where ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -44,6 +44,7 @@ module GHC.Iface.Syntax ( -- Pretty printing pprIfaceExpr, pprIfaceDecl, + pprIfaceConDecl, AltPpr(..), ShowSub(..), ShowHowMuch(..), showToIface, showToHeader ) where @@ -909,7 +910,7 @@ pprIfaceDecl ss (IfaceData { ifName = tycon, ifCType = ctype, | gadt = vcat [ pp_roles , pp_ki_sig - , pp_nd <+> pp_lhs <+> pp_kind <+> pp_where + , pp_nd <+> pp_lhs <+> pp_kind <+> text "where" , nest 2 (vcat pp_cons) , nest 2 $ ppShowIface ss pp_extra ] | otherwise = vcat [ pp_roles @@ -926,7 +927,6 @@ pprIfaceDecl ss (IfaceData { ifName = tycon, ifCType = ctype, forall_bndrs = [Bndr (binderVar tc_bndr) Specified | tc_bndr <- binders] cons = visibleIfConDecls condecls - pp_where = ppWhen (gadt && not (null cons)) $ text "where" pp_cons = ppr_trim (map show_con cons) :: [SDoc] pp_kind = ppUnless (ki_sig_printable || isIfaceLiftedTypeKind kind) (dcolon <+> ppr kind) ===================================== ghc/GHCi/UI.hs ===================================== @@ -44,10 +44,12 @@ import GHCi.BreakArray( breakOn, breakOff ) import GHC.ByteCode.Types import GHC.Core.DataCon import GHC.Core.ConLike +import GHC.Core.TyCon import GHC.Core.PatSyn import GHC.Driver.Flags import GHC.Driver.Errors import GHC.Driver.Errors.Types +import GHC.Types.Var.Env import GHC.Driver.Phases import GHC.Driver.Session as DynFlags import GHC.Driver.Ppr hiding (printForUser) @@ -73,7 +75,15 @@ import GHC.Types.SafeHaskell ( getSafeMode ) import GHC.Types.SourceError ( SourceError ) import GHC.Types.Name import GHC.Types.Var ( varType ) -import GHC.Iface.Syntax ( showToHeader ) +import GHC.Iface.Type +import GHC.Iface.Syntax ( IfaceConDecls(..) + , IfaceDecl(..) + , IfaceFamTyConFlav(..) + , IfaceTyConParent(..) + , showToHeader + , pprIfaceConDecl + ) +import GHC.Iface.Decl ( tyConToIfaceDecl ) import GHC.Builtin.Names import GHC.Builtin.Types( stringTyCon_RDR ) import GHC.Types.Name.Reader as RdrName ( getGRE_NameQualifier_maybes, getRdrName ) @@ -1625,41 +1635,93 @@ pprInfo (thing, fixity, cls_insts, fam_insts, docs) ----------------------------------------------------------------------------- -- :normalize -normalize :: String -> m () -normalize = undefined +normalize :: GHC.GhcMonad m => String -> m () +normalize "" = throwGhcException (CmdLineError "normalize needs arguments to work on!") +normalize s = do + forM_ (words s) $ \str -> do + -- stuff <- mapM (GHC.getInfo False) name + rendered <- showSDocForUser' (ppr @FastString "blah") + liftIO (putStrLn rendered) + where + isInParenthesis ("(":xs) = True + isInParenthesis _ = False + +normalizeDecl :: GHC.GhcMonad m => IfaceDecl -> [Name] -> m IfaceDecl +normalizeDecl decl@(IfaceData {..}) args + | null args = pure decl + | otherwise = do + let dummyIfName = ppr ifName <+> hsep (map ppr args) + return undefined +normalizeDecl _ _ = throwGhcException (CmdLineError "blah") --- NOTE use namesAreInParenthesis in this -normalizeType :: String -> m () -normalizeType str = do - names <- GHC.parseName str - mb_stuff <- mapM (GHC.getInfo False) names - case mb_stuff of - Nothing -> undefined - Just x -> undefined -pprDummyDataDeclaration :: TyThing -> SDoc -pprDummyDataDeclaration = undefined +pprNormalizedDeclaration :: GHC.GhcMonad m => TyCon -> String -> m SDoc +pprNormalizedDeclaration con str = undefined . snd $ tyConToIfaceDecl emptyTidyEnv con + where + replaceUniversals = undefined {- Note [Arguments of the normalize command] :normalize, like :info, can take multiple arguments; Which is why the arguments -should always be inside parenthesis. Even if they are type constructors of kind *. +should always be inside parenthesis. Even if they are type constructors of kind Type. Here is an example: Assume type family RetInt a where RetInt a = Int -:normalize (Bool) (Either String (RetInt Bool)) +:normalize (Bool) (Either String (RetInt Bool)) -- GOOD results in: -data Bool = True | False +Bool = True | False -data Either String (RetInt Bool) = Left String | Right Int +Either String (RetInt Bool) = Left String | Right Int -:normalize Bool +:normalize Bool -- BAD -} -namesAreInParenthesis = undefined +data TypeAnnDataDecl -- This could probably use a better name + = + MkTadd + { tadTypeCons :: FastString + , tadArguments :: [IfaceType] + , tadCons :: IfaceConDecls + , tadBinders :: [IfaceTyConBinder] + , tadCtx :: IfaceContext + , tadParent :: IfaceTyConParent + , tadGADTSyntax :: Bool + } + + +--data TypeAnnConDecl = MkTacd + +instance Outputable TypeAnnDataDecl where + ppr = pprTypeAnnDataDecl + + +pprTypeAnnDataDecl :: TypeAnnDataDecl -> SDoc +pprTypeAnnDataDecl (MkTadd {tadTypeCons = tycon, + tadArguments = args, + tadCons = conss, + tadBinders = binders, + tadParent = parent, + tadCtx = ctx, + tadGADTSyntax = gadt}) + + | gadt = vcat [pp_tycon_applied <+> pp_where + ,nest 2 (vcat pp_conss)] + | otherwise = hang pp_tycon_applied 2 (add_bars pp_conss) + where + pp_tycon_applied = ppr tycon <+> hsep (map ppr args) + pp_where = text "where" + pp_conss = [text "Blah Cons", text "Cons Blah", text "Foo Bar"] -- map show_con conss + + show_con = undefined --pprIfaceConDecl showToHeader gadt tycon binders parent + + add_bars [] = empty + add_bars (c:cs) = sep ((equals <+> c) : map (vbar <+>) cs) + +ifaceDeclToTypeAnnDataDecl :: IfaceDecl -> Maybe TypeAnnDataDecl +ifaceDeclToTypeAnnDataDecl = undefined ----------------------------------------------------------------------------- -- :main View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f8aa6a145748602b4b68c836518bd8f8c426862b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f8aa6a145748602b4b68c836518bd8f8c426862b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 10:03:34 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 04 May 2024 06:03:34 -0400 Subject: [Git][ghc/ghc][master] 2 commits: tests: Widen acceptance window for dir and so size tests Message-ID: <663607f6993fc_145886c8da0c7842c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - 1 changed file: - testsuite/tests/perf/size/all.T Changes: ===================================== testsuite/tests/perf/size/all.T ===================================== @@ -3,77 +3,80 @@ test('size_hello_obj', [collect_size(5, 'size_hello_obj.o')], compile, ['']) test('size_hello_artifact', [collect_size(5, 'size_hello_artifact' + exe_extension())], compile_artifact, ['']) -test('array_dir' ,[collect_size_ghc_pkg(5 , 'array')] , static_stats , [] ) -test('base_dir' ,[collect_size_ghc_pkg(5 , 'base')] , static_stats , [] ) -test('binary_dir' ,[collect_size_ghc_pkg(5 , 'binary')] , static_stats , [] ) -test('bytestring_dir' ,[collect_size_ghc_pkg(5 , 'bytestring')] , static_stats , [] ) -test('cabal_dir' ,[collect_size_ghc_pkg(5 , 'Cabal')] , static_stats , [] ) -test('cabal_syntax_dir' ,[collect_size_ghc_pkg(5 , 'Cabal-syntax')] , static_stats , [] ) -test('containers_dir' ,[collect_size_ghc_pkg(5 , 'containers')] , static_stats , [] ) -test('deepseq_dir' ,[collect_size_ghc_pkg(5 , 'deepseq')] , static_stats , [] ) -test('directory_dir' ,[collect_size_ghc_pkg(5 , 'directory')] , static_stats , [] ) -test('exceptions_dir' ,[collect_size_ghc_pkg(5 , 'exceptions')] , static_stats , [] ) -test('ghc_bignum_dir' ,[collect_size_ghc_pkg(5 , 'ghc-bignum')] , static_stats , [] ) -test('ghc_boot_dir' ,[collect_size_ghc_pkg(5 , 'ghc-boot')] , static_stats , [] ) -test('ghc_boot_th_dir' ,[collect_size_ghc_pkg(5 , 'ghc-boot-th')] , static_stats , [] ) -test('ghc_compact_dir' ,[collect_size_ghc_pkg(5 , 'ghc-compact')] , static_stats , [] ) -test('ghc_dir' ,[collect_size_ghc_pkg(5 , 'ghc')] , static_stats , [] ) -test('ghc_experimental_dir',[collect_size_ghc_pkg(5 , 'ghc-experimental')], static_stats , [] ) -test('ghc_heap_dir' ,[collect_size_ghc_pkg(5 , 'ghc-heap')] , static_stats , [] ) -test('ghc_internal_dir' ,[collect_size_ghc_pkg(5 , 'ghc-internal')] , static_stats , [] ) -test('ghc_platform_dir' ,[collect_size_ghc_pkg(5 , 'ghc-platform')] , static_stats , [] ) -test('ghc_prim_dir' ,[collect_size_ghc_pkg(5 , 'ghc-prim')] , static_stats , [] ) -test('ghc_toolchain_dir' ,[collect_size_ghc_pkg(5 , 'ghc-toolchain')] , static_stats , [] ) -test('haskeline_dir' ,[collect_size_ghc_pkg(5 , 'haskeline')] , static_stats , [] ) -test('hpc_dir' ,[collect_size_ghc_pkg(5 , 'hpc')] , static_stats , [] ) -test('integer_gmp_dir' ,[collect_size_ghc_pkg(5 , 'integer-gmp')] , static_stats , [] ) -test('mtl_dir' ,[collect_size_ghc_pkg(5 , 'mtl')] , static_stats , [] ) -test('os_string_dir' ,[collect_size_ghc_pkg(5 , 'os-string')] , static_stats , [] ) -test('parsec_dir' ,[collect_size_ghc_pkg(5 , 'parsec')] , static_stats , [] ) -test('pretty_dir' ,[collect_size_ghc_pkg(5 , 'pretty')] , static_stats , [] ) -test('process_dir' ,[collect_size_ghc_pkg(5 , 'process')] , static_stats , [] ) -test('time_dir' ,[collect_size_ghc_pkg(5 , 'time')] , static_stats , [] ) -test('xhtml_dir' ,[collect_size_ghc_pkg(5 , 'xhtml')] , static_stats , [] ) +size_acceptance_threshold = 100 + +test('array_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'array')] , static_stats , [] ) +test('base_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'base')] , static_stats , [] ) +test('binary_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'binary')] , static_stats , [] ) +test('bytestring_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'bytestring')] , static_stats , [] ) +test('cabal_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'Cabal')] , static_stats , [] ) +test('cabal_syntax_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'Cabal-syntax')] , static_stats , [] ) +test('containers_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'containers')] , static_stats , [] ) +test('deepseq_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'deepseq')] , static_stats , [] ) +test('directory_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'directory')] , static_stats , [] ) +test('exceptions_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'exceptions')] , static_stats , [] ) +test('ghc_bignum_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-bignum')] , static_stats , [] ) +test('ghc_boot_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-boot')] , static_stats , [] ) +test('ghc_boot_th_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-boot-th')] , static_stats , [] ) +test('ghc_compact_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-compact')] , static_stats , [] ) +test('ghc_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc')] , static_stats , [] ) +test('ghc_experimental_dir',[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-experimental')], static_stats , [] ) +test('ghc_heap_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-heap')] , static_stats , [] ) +test('ghc_internal_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-internal')] , static_stats , [] ) +test('ghc_platform_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-platform')] , static_stats , [] ) +test('ghc_prim_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-prim')] , static_stats , [] ) +test('ghc_toolchain_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-toolchain')] , static_stats , [] ) +test('haskeline_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'haskeline')] , static_stats , [] ) +test('hpc_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'hpc')] , static_stats , [] ) +test('integer_gmp_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'integer-gmp')] , static_stats , [] ) +test('mtl_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'mtl')] , static_stats , [] ) +test('os_string_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'os-string')] , static_stats , [] ) +test('parsec_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'parsec')] , static_stats , [] ) +test('pretty_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'pretty')] , static_stats , [] ) +test('process_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'process')] , static_stats , [] ) +test('time_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'time')] , static_stats , [] ) +test('xhtml_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'xhtml')] , static_stats , [] ) # size of the entire libdir test('libdir' ,[collect_size_dir(10, config.libdir)] , static_stats , [] ) # skip these on windows -test('unix_dir' ,[windows_skip, collect_size_ghc_pkg(5, 'unix')] , static_stats, [] ) -test('terminfo_dir' ,[windows_skip, js_skip, collect_size_ghc_pkg(5, 'terminfo')], static_stats, [] ) +test('unix_dir' ,[windows_skip, collect_size_ghc_pkg(size_acceptance_threshold, 'unix')] , static_stats, [] ) +test('terminfo_dir' ,[windows_skip, js_skip, collect_size_ghc_pkg(size_acceptance_threshold, 'terminfo')], static_stats, [] ) # skip the shared object file tests on windows -test('array_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "array")] , static_stats, [] ) -test('base_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "base")] , static_stats, [] ) -test('binary_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "binary")] , static_stats, [] ) -test('bytestring_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "bytestring")] , static_stats, [] ) -test('cabal_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "Cabal")] , static_stats, [] ) -test('cabal_syntax_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "Cabal-syntax")] , static_stats, [] ) -test('containers_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "containers")] , static_stats, [] ) -test('deepseq_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "deepseq")] , static_stats, [] ) -test('directory_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "directory")] , static_stats, [] ) -test('exceptions_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "exceptions")] , static_stats, [] ) -test('filepath_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "filepath")] , static_stats, [] ) -test('ghc_bignum_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-bignum")] , static_stats, [] ) -test('ghc_boot_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-boot")] , static_stats, [] ) -test('ghc_boot_th_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-boot-th")] , static_stats, [] ) -test('ghc_experimental_so',[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-experimental")] , static_stats, [] ) -test('ghc_heap_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-heap")] , static_stats, [] ) -test('ghc_platform_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-platform")] , static_stats, [] ) -test('ghc_prim_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-prim")] , static_stats, [] ) -test('ghc_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc")] , static_stats, [] ) -test('ghc_toolchain_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-toolchain")] , static_stats, [] ) -test('ghci_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghci")] , static_stats, [] ) -test('haskeline_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "haskeline")] , static_stats, [] ) -test('hpc_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "hpc")] , static_stats, [] ) -test('mtl_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "mtl")] , static_stats, [] ) -test('os_string_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "os-string")] , static_stats, [] ) -test('parsec_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "parsec")] , static_stats, [] ) -test('process_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "process")] , static_stats, [] ) -test('rts_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "rts", True)] , static_stats, [] ) -test('template_haskell_so',[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "template-haskell")] , static_stats, [] ) -test('terminfo_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "terminfo")] , static_stats, [] ) -test('text_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "text")] , static_stats, [] ) -test('time_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "time")] , static_stats, [] ) -test('transformers_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "transformers")] , static_stats, [] ) -test('xhtml_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "xhtml")] , static_stats, [] ) +test('array_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "array")] , static_stats, [] ) +test('base_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "base")] , static_stats, [] ) +test('binary_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "binary")] , static_stats, [] ) +test('bytestring_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "bytestring")] , static_stats, [] ) +test('cabal_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "Cabal")] , static_stats, [] ) +test('cabal_syntax_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "Cabal-syntax")] , static_stats, [] ) +test('containers_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "containers")] , static_stats, [] ) +test('deepseq_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "deepseq")] , static_stats, [] ) +test('directory_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "directory")] , static_stats, [] ) +test('exceptions_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "exceptions")] , static_stats, [] ) +test('filepath_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "filepath")] , static_stats, [] ) +test('ghc_bignum_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-bignum")] , static_stats, [] ) +test('ghc_boot_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-boot")] , static_stats, [] ) +test('ghc_boot_th_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-boot-th")] , static_stats, [] ) +test('ghc_experimental_so',[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-experimental")] , static_stats, [] ) +test('ghc_heap_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-heap")] , static_stats, [] ) +test('ghc_platform_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-platform")] , static_stats, [] ) +test('ghc_prim_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-prim")] , static_stats, [] ) +test('ghc_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc")] , static_stats, [] ) +test('ghc_toolchain_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-toolchain")] , static_stats, [] ) +test('ghci_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghci")] , static_stats, [] ) +test('haskeline_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "haskeline")] , static_stats, [] ) +test('hpc_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "hpc")] , static_stats, [] ) +test('mtl_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "mtl")] , static_stats, [] ) +test('os_string_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "os-string")] , static_stats, [] ) +test('parsec_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "parsec")] , static_stats, [] ) +test('process_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "process")] , static_stats, [] ) +# Disabled as extremely unstable +#test('rts_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "rts", True)] , static_stats, [] ) +test('template_haskell_so',[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "template-haskell")] , static_stats, [] ) +test('terminfo_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "terminfo")] , static_stats, [] ) +test('text_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "text")] , static_stats, [] ) +test('time_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "time")] , static_stats, [] ) +test('transformers_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "transformers")] , static_stats, [] ) +test('xhtml_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "xhtml")] , static_stats, [] ) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bf3d4db0894233ec72f092a4a34bce9ed4ff4e21...9562808d02db67838844d874c632f18af904949c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bf3d4db0894233ec72f092a4a34bce9ed4ff4e21...9562808d02db67838844d874c632f18af904949c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 10:04:18 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 04 May 2024 06:04:18 -0400 Subject: [Git][ghc/ghc][master] unboxedSum{Type,Data}Name: Use GHC.Types as the module Message-ID: <66360822ae03e_145886e0f77c83242@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 3 changed files: - libraries/template-haskell/Language/Haskell/TH/Lib/Syntax.hs - + testsuite/tests/quotes/T24750.hs - testsuite/tests/quotes/all.T Changes: ===================================== libraries/template-haskell/Language/Haskell/TH/Lib/Syntax.hs ===================================== @@ -1955,7 +1955,7 @@ unboxedSumDataName alt arity | otherwise = Name (mkOccName sum_occ) - (NameG DataName (mkPkgName "ghc-prim") (mkModName "GHC.Prim")) + (NameG DataName (mkPkgName "ghc-prim") (mkModName "GHC.Types")) where prefix = "unboxedSumDataName: " @@ -1974,11 +1974,11 @@ unboxedSumTypeName arity | otherwise = Name (mkOccName sum_occ) - (NameG TcClsName (mkPkgName "ghc-prim") (mkModName "GHC.Prim")) + (NameG TcClsName (mkPkgName "ghc-prim") (mkModName "GHC.Types")) where -- Synced with the definition of mkSumTyConOcc in GHC.Builtin.Types - sum_occ = '(' : '#' : replicate (arity - 1) '|' ++ "#)" + sum_occ = "Sum" ++ show arity ++ "#" ----------------------------------------------------- -- Locations ===================================== testsuite/tests/quotes/T24750.hs ===================================== @@ -0,0 +1,35 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE TemplateHaskellQuotes #-} +{-# LANGUAGE UnboxedTuples #-} +-- A regression test for #24750. This test ensures that a family of functions +-- from the `template-haskell` library (tupeTypeName, tupleDataName, etc.) +-- returns the same Names as when you manually quote the names using +-- TemplateHaskellQuotes. +module Main (main) where + +import Control.Monad (unless) +import GHC.Tuple (Tuple2) +import GHC.Types (Sum2#, Tuple2#) +import Language.Haskell.TH + +test :: Name -> Name -> IO () +test n1 n2 = + unless (n1 == n2) $ + fail $ unlines + [ "Names are not equal" + , "LHS name: " ++ show n1 + , "RHS name: " ++ show n2 + ] + +main :: IO () +main = do + test (tupleTypeName 2) ''(,) + test (tupleTypeName 2) ''Tuple2 + test (tupleDataName 2) '(,) + test (unboxedTupleTypeName 2) ''(#,#) + test (unboxedTupleTypeName 2) ''Tuple2# + test (unboxedTupleDataName 2) '(#,#) + test (unboxedSumTypeName 2) ''Sum2# + -- There is currently no way to manually quote an unboxed sum data constructor + -- Name, as you cannot write unboxed sum data constructors in prefix form. As + -- such, a test case for `unboxedSumDataName` is omitted. ===================================== testsuite/tests/quotes/all.T ===================================== @@ -42,3 +42,4 @@ test('T20688', normal, compile, ['-Wimplicit-lift -Werror']) test('T20893', normal, compile_and_run, ['']) test('T21619', normal, compile, ['']) test('T20472_quotes', normal, compile, ['']) +test('T24750', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fc24c5cf6c62ca9e3c8d236656e139676df65034 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fc24c5cf6c62ca9e3c8d236656e139676df65034 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 11:13:58 2024 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Sat, 04 May 2024 07:13:58 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24334 Message-ID: <6636187613df2_14588616faea492180@gitlab.mail> Sebastian Graf pushed new branch wip/T24334 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24334 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 12:32:04 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Sat, 04 May 2024 08:32:04 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24767 Message-ID: <66362ac4585c4_1458862036b581017b3@gitlab.mail> Teo Camarasu pushed new branch wip/T24767 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24767 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 15:13:22 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sat, 04 May 2024 11:13:22 -0400 Subject: [Git][ghc/ghc][wip/T24504] 17 commits: Expose constructors of SNat, SChar and SSymbol in ghc-internal Message-ID: <663650921d11d_1b12c0bd4354616b2@gitlab.mail> Ben Gamari pushed to branch wip/T24504 at Glasgow Haskell Compiler / GHC Commits: 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - f83be2b4 by Ben Gamari at 2024-05-04T15:13:16+00:00 IPE: Eliminate dependency on Read Instead of encoding the closure type as decimal string we now simply represent it as an integer, eliminating the need for `Read` in `GHC.Internal.InfoProv.Types.peekInfoProv`. Closes #24504. - - - - - 30 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Stg/Subst.hs - compiler/GHC/StgToCmm/InfoTableProv.hs - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/StgToJS/Linker/Utils.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Utils.hs - compiler/GHC/Tc/Gen/HsType.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/80c85fe57531a20dc8ea17d79d4b72ef51abd842...f83be2b4642170814cd150318034a2cdbafe1f58 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/80c85fe57531a20dc8ea17d79d4b72ef51abd842...f83be2b4642170814cd150318034a2cdbafe1f58 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 15:13:52 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sat, 04 May 2024 11:13:52 -0400 Subject: [Git][ghc/ghc][wip/T24741] 17 commits: Expose constructors of SNat, SChar and SSymbol in ghc-internal Message-ID: <663650b024166_1b12c0cab9446228d@gitlab.mail> Ben Gamari pushed to branch wip/T24741 at Glasgow Haskell Compiler / GHC Commits: 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 928ad9d6 by Ben Gamari at 2024-05-04T15:13:41+00:00 Introduce GHC.Tc.Plugin.lookupTHName As proposed in #24741. - - - - - 30 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Stg/Subst.hs - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/StgToJS/Linker/Utils.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Utils.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Plugin.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/79efdf1e7f21cb3cf04a16539777704f7bca2996...928ad9d6ae6592d772579ae0e36b3b2a35c09025 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/79efdf1e7f21cb3cf04a16539777704f7bca2996...928ad9d6ae6592d772579ae0e36b3b2a35c09025 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 15:15:09 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sat, 04 May 2024 11:15:09 -0400 Subject: [Git][ghc/ghc][wip/az/T24754-epa-stmtlist-semi-span] 4 commits: tests: Widen acceptance window for dir and so size tests Message-ID: <663650fd27ea2_1b12c0d3bd3c62640@gitlab.mail> Alan Zimmerman pushed to branch wip/az/T24754-epa-stmtlist-semi-span at Glasgow Haskell Compiler / GHC Commits: c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 7eab4e01 by Alan Zimmerman at 2024-05-04T16:14:55+01:00 EPA: Widen stmtslist to include last semicolon Closes #24754 - - - - - 9 changed files: - compiler/GHC/Parser.y - libraries/template-haskell/Language/Haskell/TH/Lib/Syntax.hs - testsuite/tests/parser/should_compile/DumpSemis.stderr - testsuite/tests/perf/size/all.T - testsuite/tests/printer/Makefile - + testsuite/tests/printer/Test24754.hs - testsuite/tests/printer/all.T - + testsuite/tests/quotes/T24750.hs - testsuite/tests/quotes/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -3444,7 +3444,7 @@ stmts :: { forall b. DisambECP b => PV (Located (OrdList AddEpAnn,[LStmt GhcPs ( [] -> return (sLZ $1 $> ((fst $ unLoc $1) `snocOL` (mj AnnSemi $2),snd $ unLoc $1)) (h:t) -> do { h' <- addTrailingSemiA h (gl $2) - ; return $ sL1 $1 (fst $ unLoc $1,h':t) }} + ; return $ sLZ $1 $> (fst $ unLoc $1,h':t) }} | stmt { $1 >>= \ $1 -> return $ sL1 $1 (nilOL,[$1]) } | {- empty -} { return $ noLoc (nilOL,[]) } ===================================== libraries/template-haskell/Language/Haskell/TH/Lib/Syntax.hs ===================================== @@ -1955,7 +1955,7 @@ unboxedSumDataName alt arity | otherwise = Name (mkOccName sum_occ) - (NameG DataName (mkPkgName "ghc-prim") (mkModName "GHC.Prim")) + (NameG DataName (mkPkgName "ghc-prim") (mkModName "GHC.Types")) where prefix = "unboxedSumDataName: " @@ -1974,11 +1974,11 @@ unboxedSumTypeName arity | otherwise = Name (mkOccName sum_occ) - (NameG TcClsName (mkPkgName "ghc-prim") (mkModName "GHC.Prim")) + (NameG TcClsName (mkPkgName "ghc-prim") (mkModName "GHC.Types")) where -- Synced with the definition of mkSumTyConOcc in GHC.Builtin.Types - sum_occ = '(' : '#' : replicate (arity - 1) '|' ++ "#)" + sum_occ = "Sum" ++ show arity ++ "#" ----------------------------------------------------- -- Locations ===================================== testsuite/tests/parser/should_compile/DumpSemis.stderr ===================================== @@ -856,7 +856,7 @@ (EpaSpan { DumpSemis.hs:22:10-30 }) (AnnList (Just - (EpaSpan { DumpSemis.hs:22:12-25 })) + (EpaSpan { DumpSemis.hs:22:12-28 })) (Just (AddEpAnn AnnOpenC (EpaSpan { DumpSemis.hs:22:10 }))) (Just ===================================== testsuite/tests/perf/size/all.T ===================================== @@ -3,77 +3,80 @@ test('size_hello_obj', [collect_size(5, 'size_hello_obj.o')], compile, ['']) test('size_hello_artifact', [collect_size(5, 'size_hello_artifact' + exe_extension())], compile_artifact, ['']) -test('array_dir' ,[collect_size_ghc_pkg(5 , 'array')] , static_stats , [] ) -test('base_dir' ,[collect_size_ghc_pkg(5 , 'base')] , static_stats , [] ) -test('binary_dir' ,[collect_size_ghc_pkg(5 , 'binary')] , static_stats , [] ) -test('bytestring_dir' ,[collect_size_ghc_pkg(5 , 'bytestring')] , static_stats , [] ) -test('cabal_dir' ,[collect_size_ghc_pkg(5 , 'Cabal')] , static_stats , [] ) -test('cabal_syntax_dir' ,[collect_size_ghc_pkg(5 , 'Cabal-syntax')] , static_stats , [] ) -test('containers_dir' ,[collect_size_ghc_pkg(5 , 'containers')] , static_stats , [] ) -test('deepseq_dir' ,[collect_size_ghc_pkg(5 , 'deepseq')] , static_stats , [] ) -test('directory_dir' ,[collect_size_ghc_pkg(5 , 'directory')] , static_stats , [] ) -test('exceptions_dir' ,[collect_size_ghc_pkg(5 , 'exceptions')] , static_stats , [] ) -test('ghc_bignum_dir' ,[collect_size_ghc_pkg(5 , 'ghc-bignum')] , static_stats , [] ) -test('ghc_boot_dir' ,[collect_size_ghc_pkg(5 , 'ghc-boot')] , static_stats , [] ) -test('ghc_boot_th_dir' ,[collect_size_ghc_pkg(5 , 'ghc-boot-th')] , static_stats , [] ) -test('ghc_compact_dir' ,[collect_size_ghc_pkg(5 , 'ghc-compact')] , static_stats , [] ) -test('ghc_dir' ,[collect_size_ghc_pkg(5 , 'ghc')] , static_stats , [] ) -test('ghc_experimental_dir',[collect_size_ghc_pkg(5 , 'ghc-experimental')], static_stats , [] ) -test('ghc_heap_dir' ,[collect_size_ghc_pkg(5 , 'ghc-heap')] , static_stats , [] ) -test('ghc_internal_dir' ,[collect_size_ghc_pkg(5 , 'ghc-internal')] , static_stats , [] ) -test('ghc_platform_dir' ,[collect_size_ghc_pkg(5 , 'ghc-platform')] , static_stats , [] ) -test('ghc_prim_dir' ,[collect_size_ghc_pkg(5 , 'ghc-prim')] , static_stats , [] ) -test('ghc_toolchain_dir' ,[collect_size_ghc_pkg(5 , 'ghc-toolchain')] , static_stats , [] ) -test('haskeline_dir' ,[collect_size_ghc_pkg(5 , 'haskeline')] , static_stats , [] ) -test('hpc_dir' ,[collect_size_ghc_pkg(5 , 'hpc')] , static_stats , [] ) -test('integer_gmp_dir' ,[collect_size_ghc_pkg(5 , 'integer-gmp')] , static_stats , [] ) -test('mtl_dir' ,[collect_size_ghc_pkg(5 , 'mtl')] , static_stats , [] ) -test('os_string_dir' ,[collect_size_ghc_pkg(5 , 'os-string')] , static_stats , [] ) -test('parsec_dir' ,[collect_size_ghc_pkg(5 , 'parsec')] , static_stats , [] ) -test('pretty_dir' ,[collect_size_ghc_pkg(5 , 'pretty')] , static_stats , [] ) -test('process_dir' ,[collect_size_ghc_pkg(5 , 'process')] , static_stats , [] ) -test('time_dir' ,[collect_size_ghc_pkg(5 , 'time')] , static_stats , [] ) -test('xhtml_dir' ,[collect_size_ghc_pkg(5 , 'xhtml')] , static_stats , [] ) +size_acceptance_threshold = 100 + +test('array_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'array')] , static_stats , [] ) +test('base_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'base')] , static_stats , [] ) +test('binary_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'binary')] , static_stats , [] ) +test('bytestring_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'bytestring')] , static_stats , [] ) +test('cabal_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'Cabal')] , static_stats , [] ) +test('cabal_syntax_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'Cabal-syntax')] , static_stats , [] ) +test('containers_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'containers')] , static_stats , [] ) +test('deepseq_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'deepseq')] , static_stats , [] ) +test('directory_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'directory')] , static_stats , [] ) +test('exceptions_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'exceptions')] , static_stats , [] ) +test('ghc_bignum_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-bignum')] , static_stats , [] ) +test('ghc_boot_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-boot')] , static_stats , [] ) +test('ghc_boot_th_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-boot-th')] , static_stats , [] ) +test('ghc_compact_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-compact')] , static_stats , [] ) +test('ghc_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc')] , static_stats , [] ) +test('ghc_experimental_dir',[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-experimental')], static_stats , [] ) +test('ghc_heap_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-heap')] , static_stats , [] ) +test('ghc_internal_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-internal')] , static_stats , [] ) +test('ghc_platform_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-platform')] , static_stats , [] ) +test('ghc_prim_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-prim')] , static_stats , [] ) +test('ghc_toolchain_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-toolchain')] , static_stats , [] ) +test('haskeline_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'haskeline')] , static_stats , [] ) +test('hpc_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'hpc')] , static_stats , [] ) +test('integer_gmp_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'integer-gmp')] , static_stats , [] ) +test('mtl_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'mtl')] , static_stats , [] ) +test('os_string_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'os-string')] , static_stats , [] ) +test('parsec_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'parsec')] , static_stats , [] ) +test('pretty_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'pretty')] , static_stats , [] ) +test('process_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'process')] , static_stats , [] ) +test('time_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'time')] , static_stats , [] ) +test('xhtml_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'xhtml')] , static_stats , [] ) # size of the entire libdir test('libdir' ,[collect_size_dir(10, config.libdir)] , static_stats , [] ) # skip these on windows -test('unix_dir' ,[windows_skip, collect_size_ghc_pkg(5, 'unix')] , static_stats, [] ) -test('terminfo_dir' ,[windows_skip, js_skip, collect_size_ghc_pkg(5, 'terminfo')], static_stats, [] ) +test('unix_dir' ,[windows_skip, collect_size_ghc_pkg(size_acceptance_threshold, 'unix')] , static_stats, [] ) +test('terminfo_dir' ,[windows_skip, js_skip, collect_size_ghc_pkg(size_acceptance_threshold, 'terminfo')], static_stats, [] ) # skip the shared object file tests on windows -test('array_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "array")] , static_stats, [] ) -test('base_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "base")] , static_stats, [] ) -test('binary_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "binary")] , static_stats, [] ) -test('bytestring_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "bytestring")] , static_stats, [] ) -test('cabal_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "Cabal")] , static_stats, [] ) -test('cabal_syntax_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "Cabal-syntax")] , static_stats, [] ) -test('containers_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "containers")] , static_stats, [] ) -test('deepseq_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "deepseq")] , static_stats, [] ) -test('directory_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "directory")] , static_stats, [] ) -test('exceptions_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "exceptions")] , static_stats, [] ) -test('filepath_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "filepath")] , static_stats, [] ) -test('ghc_bignum_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-bignum")] , static_stats, [] ) -test('ghc_boot_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-boot")] , static_stats, [] ) -test('ghc_boot_th_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-boot-th")] , static_stats, [] ) -test('ghc_experimental_so',[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-experimental")] , static_stats, [] ) -test('ghc_heap_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-heap")] , static_stats, [] ) -test('ghc_platform_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-platform")] , static_stats, [] ) -test('ghc_prim_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-prim")] , static_stats, [] ) -test('ghc_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc")] , static_stats, [] ) -test('ghc_toolchain_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-toolchain")] , static_stats, [] ) -test('ghci_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghci")] , static_stats, [] ) -test('haskeline_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "haskeline")] , static_stats, [] ) -test('hpc_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "hpc")] , static_stats, [] ) -test('mtl_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "mtl")] , static_stats, [] ) -test('os_string_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "os-string")] , static_stats, [] ) -test('parsec_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "parsec")] , static_stats, [] ) -test('process_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "process")] , static_stats, [] ) -test('rts_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "rts", True)] , static_stats, [] ) -test('template_haskell_so',[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "template-haskell")] , static_stats, [] ) -test('terminfo_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "terminfo")] , static_stats, [] ) -test('text_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "text")] , static_stats, [] ) -test('time_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "time")] , static_stats, [] ) -test('transformers_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "transformers")] , static_stats, [] ) -test('xhtml_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "xhtml")] , static_stats, [] ) +test('array_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "array")] , static_stats, [] ) +test('base_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "base")] , static_stats, [] ) +test('binary_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "binary")] , static_stats, [] ) +test('bytestring_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "bytestring")] , static_stats, [] ) +test('cabal_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "Cabal")] , static_stats, [] ) +test('cabal_syntax_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "Cabal-syntax")] , static_stats, [] ) +test('containers_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "containers")] , static_stats, [] ) +test('deepseq_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "deepseq")] , static_stats, [] ) +test('directory_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "directory")] , static_stats, [] ) +test('exceptions_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "exceptions")] , static_stats, [] ) +test('filepath_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "filepath")] , static_stats, [] ) +test('ghc_bignum_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-bignum")] , static_stats, [] ) +test('ghc_boot_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-boot")] , static_stats, [] ) +test('ghc_boot_th_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-boot-th")] , static_stats, [] ) +test('ghc_experimental_so',[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-experimental")] , static_stats, [] ) +test('ghc_heap_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-heap")] , static_stats, [] ) +test('ghc_platform_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-platform")] , static_stats, [] ) +test('ghc_prim_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-prim")] , static_stats, [] ) +test('ghc_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc")] , static_stats, [] ) +test('ghc_toolchain_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-toolchain")] , static_stats, [] ) +test('ghci_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghci")] , static_stats, [] ) +test('haskeline_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "haskeline")] , static_stats, [] ) +test('hpc_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "hpc")] , static_stats, [] ) +test('mtl_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "mtl")] , static_stats, [] ) +test('os_string_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "os-string")] , static_stats, [] ) +test('parsec_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "parsec")] , static_stats, [] ) +test('process_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "process")] , static_stats, [] ) +# Disabled as extremely unstable +#test('rts_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "rts", True)] , static_stats, [] ) +test('template_haskell_so',[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "template-haskell")] , static_stats, [] ) +test('terminfo_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "terminfo")] , static_stats, [] ) +test('text_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "text")] , static_stats, [] ) +test('time_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "time")] , static_stats, [] ) +test('transformers_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "transformers")] , static_stats, [] ) +test('xhtml_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "xhtml")] , static_stats, [] ) ===================================== testsuite/tests/printer/Makefile ===================================== @@ -851,3 +851,8 @@ DataDeclShort: Test24749: $(CHECK_PPR) $(LIBDIR) Test24749.hs $(CHECK_EXACT) $(LIBDIR) Test24749.hs + +.PHONY: Test24754 +Test24754: + $(CHECK_PPR) $(LIBDIR) Test24754.hs + $(CHECK_EXACT) $(LIBDIR) Test24754.hs ===================================== testsuite/tests/printer/Test24754.hs ===================================== @@ -0,0 +1,4 @@ +module Test24754 where + +eh1 = try (do return r;) <|> (do + return r) ===================================== testsuite/tests/printer/all.T ===================================== @@ -203,3 +203,4 @@ test('MatchPatComments', [ignore_stderr, req_ppr_deps], makefile_test, ['MatchPa test('Test24748', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24748']) test('DataDeclShort', [ignore_stderr, req_ppr_deps], makefile_test, ['DataDeclShort']) test('Test24749', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24749']) +test('Test24754', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24754']) ===================================== testsuite/tests/quotes/T24750.hs ===================================== @@ -0,0 +1,35 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE TemplateHaskellQuotes #-} +{-# LANGUAGE UnboxedTuples #-} +-- A regression test for #24750. This test ensures that a family of functions +-- from the `template-haskell` library (tupeTypeName, tupleDataName, etc.) +-- returns the same Names as when you manually quote the names using +-- TemplateHaskellQuotes. +module Main (main) where + +import Control.Monad (unless) +import GHC.Tuple (Tuple2) +import GHC.Types (Sum2#, Tuple2#) +import Language.Haskell.TH + +test :: Name -> Name -> IO () +test n1 n2 = + unless (n1 == n2) $ + fail $ unlines + [ "Names are not equal" + , "LHS name: " ++ show n1 + , "RHS name: " ++ show n2 + ] + +main :: IO () +main = do + test (tupleTypeName 2) ''(,) + test (tupleTypeName 2) ''Tuple2 + test (tupleDataName 2) '(,) + test (unboxedTupleTypeName 2) ''(#,#) + test (unboxedTupleTypeName 2) ''Tuple2# + test (unboxedTupleDataName 2) '(#,#) + test (unboxedSumTypeName 2) ''Sum2# + -- There is currently no way to manually quote an unboxed sum data constructor + -- Name, as you cannot write unboxed sum data constructors in prefix form. As + -- such, a test case for `unboxedSumDataName` is omitted. ===================================== testsuite/tests/quotes/all.T ===================================== @@ -42,3 +42,4 @@ test('T20688', normal, compile, ['-Wimplicit-lift -Werror']) test('T20893', normal, compile_and_run, ['']) test('T21619', normal, compile, ['']) test('T20472_quotes', normal, compile, ['']) +test('T24750', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/41d1ee1824f84f520764ed80901a18b45bc01809...7eab4e019205cfced90f06242a9afa23dfcaa70b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/41d1ee1824f84f520764ed80901a18b45bc01809...7eab4e019205cfced90f06242a9afa23dfcaa70b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 19:05:41 2024 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Sat, 04 May 2024 15:05:41 -0400 Subject: [Git][ghc/ghc][wip/t24277] ghc-internal: Add CostCentreId, currentCallStackIds, ccsToIds, ccId Message-ID: <663687052b32d_1b12c0278b08474560@gitlab.mail> Finley McIlwaine pushed to branch wip/t24277 at Glasgow Haskell Compiler / GHC Commits: a4c74ecd by Finley McIlwaine at 2024-05-04T12:05:22-07:00 ghc-internal: Add CostCentreId, currentCallStackIds, ccsToIds, ccId Add functions for gettings the IDs of cost centres to the interface of `GHC.Internal.Stack`, `GHC.Internal.Stack.CCS`, and `GHC.Internal.Exts`. Also add an opaque type for cost center ids, `CostCentreId`, with appropriate instances. Resolves #24277 - - - - - 7 changed files: - libraries/ghc-internal/src/GHC/Internal/Exts.hs - libraries/ghc-internal/src/GHC/Internal/Stack.hs - libraries/ghc-internal/src/GHC/Internal/Stack/CCS.hsc - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 Changes: ===================================== libraries/ghc-internal/src/GHC/Internal/Exts.hs ===================================== @@ -103,6 +103,8 @@ module GHC.Internal.Exts -- ** The call stack currentCallStack, + currentCallStackIds, + CostCentreId, -- * Ids with special behaviour inline, noinline, lazy, oneShot, considerAccessible, seq#, ===================================== libraries/ghc-internal/src/GHC/Internal/Stack.hs ===================================== @@ -24,6 +24,7 @@ module GHC.Internal.Stack ( -- * Profiling call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * HasCallStack call stacks @@ -38,14 +39,17 @@ module GHC.Internal.Stack ( -- * Internals CostCentreStack, CostCentre, + CostCentreId, getCurrentCCS, getCCSOf, clearCCS, ccsCC, ccsParent, + ccId, ccLabel, ccModule, ccSrcSpan, + ccsToIds, ccsToStrings, renderStack ) where ===================================== libraries/ghc-internal/src/GHC/Internal/Stack/CCS.hsc ===================================== @@ -16,14 +16,17 @@ ----------------------------------------------------------------------------- {-# LANGUAGE UnboxedTuples, MagicHash, NoImplicitPrelude #-} +{-# LANGUAGE DerivingStrategies, GeneralizedNewtypeDeriving #-} module GHC.Internal.Stack.CCS ( -- * Call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * Internals CostCentreStack, CostCentre, + CostCentreId, getCurrentCCS, getCCSOf, clearCCS, @@ -31,7 +34,9 @@ module GHC.Internal.Stack.CCS ( ccsParent, ccLabel, ccModule, + ccId, ccSrcSpan, + ccsToIds, ccsToStrings, renderStack, ) where @@ -44,6 +49,12 @@ import GHC.Internal.Base import GHC.Internal.Ptr import GHC.Internal.IO.Encoding import GHC.Internal.List ( concatMap, reverse ) +import GHC.Internal.Word ( Word32 ) +import GHC.Internal.Show +import GHC.Internal.Read +import GHC.Internal.Enum +import GHC.Internal.Real +import GHC.Internal.Num #define PROFILING #include "Rts.h" @@ -54,6 +65,13 @@ data CostCentreStack -- | A cost-centre from GHC's cost-center profiler. data CostCentre +-- | Cost centre identifier +-- +-- @since 4.20.0.0 +newtype CostCentreId = CostCentreId Word32 + deriving (Show, Read) + deriving newtype (Eq, Ord, Bounded, Enum, Integral, Num, Real) + -- | Returns the current 'CostCentreStack' (value is @nullPtr@ if the current -- program was not compiled with profiling support). Takes a dummy argument -- which can be used to avoid the call to @getCurrentCCS@ being floated out by @@ -83,6 +101,12 @@ ccsCC p = peekByteOff p 4 ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack) ccsParent p = peekByteOff p 8 +-- | Get the 'CostCentreId' of a 'CostCentre'. +-- +-- @since 4.20.0.0 +ccId :: Ptr CostCentre -> IO CostCentreId +ccId p = fmap CostCentreId $ peekByteOff p 0 + ccLabel :: Ptr CostCentre -> IO CString ccLabel p = peekByteOff p 4 @@ -99,6 +123,12 @@ ccsCC p = (# peek CostCentreStack, cc) p ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack) ccsParent p = (# peek CostCentreStack, prevStack) p +-- | Get the 'CostCentreId' of a 'CostCentre'. +-- +-- @since 4.20.0.0 +ccId :: Ptr CostCentre -> IO CostCentreId +ccId p = fmap CostCentreId $ (# peek CostCentre, ccID) p + -- | Get the label of a 'CostCentre'. ccLabel :: Ptr CostCentre -> IO CString ccLabel p = (# peek CostCentre, label) p @@ -125,6 +155,19 @@ ccSrcSpan p = (# peek CostCentre, srcloc) p currentCallStack :: IO [String] currentCallStack = ccsToStrings =<< getCurrentCCS () +-- | Returns a @[CostCentreId]@ representing the current call stack. This +-- can be useful for debugging. +-- +-- The implementation uses the call-stack simulation maintained by the +-- profiler, so it only works if the program was compiled with @-prof@ +-- and contains suitable SCC annotations (e.g. by using @-fprof-late@). +-- Otherwise, the list returned is likely to be empty or +-- uninformative. +-- +-- @since 4.20.0.0 +currentCallStackIds :: IO [CostCentreId] +currentCallStackIds = ccsToIds =<< getCurrentCCS () + -- | Format a 'CostCentreStack' as a list of lines. ccsToStrings :: Ptr CostCentreStack -> IO [String] ccsToStrings ccs0 = go ccs0 [] @@ -141,6 +184,24 @@ ccsToStrings ccs0 = go ccs0 [] then return acc else go parent ((mdl ++ '.':lbl ++ ' ':'(':loc ++ ")") : acc) +-- | Format a 'CostCentreStack' as a list of cost centre IDs. +-- +-- @since 4.20.0.0 +ccsToIds :: Ptr CostCentreStack -> IO [CostCentreId] +ccsToIds ccs0 = go ccs0 [] + where + go ccs acc + | ccs == nullPtr = return acc + | otherwise = do + cc <- ccsCC ccs + cc_id <- ccId cc + lbl <- GHC.peekCString utf8 =<< ccLabel cc + mdl <- GHC.peekCString utf8 =<< ccModule cc + parent <- ccsParent ccs + if (mdl == "MAIN" && lbl == "MAIN") + then return acc + else go parent (cc_id : acc) + -- | Get the stack trace attached to an object. -- -- @since base-4.5.0.0 ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -11601,6 +11601,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -11676,6 +11677,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ @@ -12060,6 +12062,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -12171,6 +12174,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12244,6 +12248,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -12290,6 +12295,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -12468,6 +12474,7 @@ instance GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.Event.Interna instance GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.Event.Manager.FdKey -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.Event.Manager.State -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Event.TimerManager’ +instance GHC.Internal.Show.Show GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Show.Show GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance GHC.Internal.Show.Show GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Show.Show GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ @@ -12681,6 +12688,7 @@ instance GHC.Classes.Eq GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘G instance GHC.Classes.Eq ghc-internal-9.1001.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Event.TimerManager’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12846,6 +12854,7 @@ instance forall a. GHC.Classes.Ord (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) instance forall i e. (GHC.Internal.Ix.Ix i, GHC.Classes.Ord e) => GHC.Classes.Ord (GHC.Internal.Arr.Array i e) -- Defined in ‘GHC.Internal.Arr’ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -234,7 +234,7 @@ module Control.Exception where type ErrorCall :: * data ErrorCall = ErrorCallWithLocation GHC.Internal.Base.String GHC.Internal.Base.String type Exception :: * -> Constraint - class (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where + class (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where toException :: e -> SomeException fromException :: SomeException -> GHC.Internal.Maybe.Maybe e displayException :: e -> GHC.Internal.Base.String @@ -303,7 +303,7 @@ module Control.Exception where module Control.Exception.Annotation where -- Safety: None type ExceptionAnnotation :: * -> Constraint - class ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a => ExceptionAnnotation a where + class ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a => ExceptionAnnotation a where displayExceptionAnnotation :: a -> GHC.Internal.Base.String default displayExceptionAnnotation :: GHC.Internal.Show.Show a => a -> GHC.Internal.Base.String {-# MINIMAL #-} @@ -345,7 +345,7 @@ module Control.Exception.Base where type ErrorCall :: * data ErrorCall = ErrorCallWithLocation GHC.Internal.Base.String GHC.Internal.Base.String type Exception :: * -> Constraint - class (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where + class (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where toException :: e -> SomeException fromException :: SomeException -> GHC.Internal.Maybe.Maybe e displayException :: e -> GHC.Internal.Base.String @@ -848,11 +848,11 @@ module Data.Data where type TyCon :: * data TyCon = ... type TypeRep :: * - type TypeRep = ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep + type TypeRep = ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep type Typeable :: forall k. k -> Constraint class Typeable a where ... - {-# MINIMAL ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} + {-# MINIMAL ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} cast :: forall a b. (Typeable a, Typeable b) => a -> GHC.Internal.Maybe.Maybe b constrFields :: Constr -> [GHC.Internal.Base.String] constrFixity :: Constr -> Fixity @@ -895,7 +895,7 @@ module Data.Data where showConstr :: Constr -> GHC.Internal.Base.String showsTypeRep :: TypeRep -> GHC.Internal.Show.ShowS splitTyConApp :: TypeRep -> (TyCon, [TypeRep]) - trLiftedRep :: ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.TypeRep GHC.Types.LiftedRep + trLiftedRep :: ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.TypeRep GHC.Types.LiftedRep tyConFingerprint :: TyCon -> GHC.Internal.Fingerprint.Type.Fingerprint tyConModule :: TyCon -> GHC.Internal.Base.String tyConName :: TyCon -> GHC.Internal.Base.String @@ -919,14 +919,14 @@ module Data.Dynamic where -- Safety: Safe type Dynamic :: * data Dynamic where - Dynamic :: forall a. ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.TypeRep a -> a -> Dynamic + Dynamic :: forall a. ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.TypeRep a -> a -> Dynamic type Typeable :: forall k. k -> Constraint class Typeable a where ... - {-# MINIMAL ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} + {-# MINIMAL ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} dynApp :: Dynamic -> Dynamic -> Dynamic dynApply :: Dynamic -> Dynamic -> GHC.Internal.Maybe.Maybe Dynamic - dynTypeRep :: Dynamic -> ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep + dynTypeRep :: Dynamic -> ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep fromDyn :: forall a. Typeable a => Dynamic -> a -> a fromDynamic :: forall a. Typeable a => Dynamic -> GHC.Internal.Maybe.Maybe a toDyn :: forall a. Typeable a => a -> Dynamic @@ -1809,11 +1809,11 @@ module Data.Typeable where type TyCon :: * data TyCon = ... type TypeRep :: * - type TypeRep = ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep + type TypeRep = ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep type Typeable :: forall k. k -> Constraint class Typeable a where ... - {-# MINIMAL ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} + {-# MINIMAL ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} cast :: forall a b. (Typeable a, Typeable b) => a -> GHC.Internal.Maybe.Maybe b decT :: forall {k} (a :: k) (b :: k). (Typeable a, Typeable b) => GHC.Internal.Data.Either.Either ((a :~: b) -> GHC.Internal.Base.Void) (a :~: b) eqT :: forall {k} (a :: k) (b :: k). (Typeable a, Typeable b) => GHC.Internal.Maybe.Maybe (a :~: b) @@ -1828,7 +1828,7 @@ module Data.Typeable where rnfTypeRep :: TypeRep -> () showsTypeRep :: TypeRep -> GHC.Internal.Show.ShowS splitTyConApp :: TypeRep -> (TyCon, [TypeRep]) - trLiftedRep :: ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.TypeRep GHC.Types.LiftedRep + trLiftedRep :: ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.TypeRep GHC.Types.LiftedRep tyConFingerprint :: TyCon -> GHC.Internal.Fingerprint.Type.Fingerprint tyConModule :: TyCon -> GHC.Internal.Base.String tyConName :: TyCon -> GHC.Internal.Base.String @@ -5251,9 +5251,9 @@ module GHC.Event.TimeOut where type TimeoutEdit :: * type TimeoutEdit = TimeoutQueue -> TimeoutQueue type TimeoutKey :: * - newtype TimeoutKey = TK ghc-internal-0.1.0.0:GHC.Internal.Event.Unique.Unique + newtype TimeoutKey = TK ghc-internal-9.1001.0:GHC.Internal.Event.Unique.Unique type TimeoutQueue :: * - type TimeoutQueue = ghc-internal-0.1.0.0:GHC.Internal.Event.PSQ.PSQ TimeoutCallback + type TimeoutQueue = ghc-internal-9.1001.0:GHC.Internal.Event.PSQ.PSQ TimeoutCallback module GHC.Exception where -- Safety: Safe @@ -5265,7 +5265,7 @@ module GHC.Exception where type ErrorCall :: * data ErrorCall = ErrorCallWithLocation GHC.Internal.Base.String GHC.Internal.Base.String type Exception :: * -> Constraint - class (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where + class (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where toException :: e -> SomeException fromException :: SomeException -> GHC.Internal.Maybe.Maybe e displayException :: e -> GHC.Internal.Base.String @@ -5294,7 +5294,7 @@ module GHC.Exception.Type where type ArithException :: * data ArithException = Overflow | Underflow | LossOfPrecision | DivideByZero | Denormal | RatioZeroDenominator type Exception :: * -> Constraint - class (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where + class (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where toException :: e -> SomeException fromException :: SomeException -> GHC.Internal.Maybe.Maybe e displayException :: e -> GHC.Internal.Base.String @@ -7847,8 +7847,8 @@ module GHC.IO.Handle where hTryLock :: Handle -> LockMode -> GHC.Types.IO GHC.Types.Bool hWaitForInput :: Handle -> GHC.Types.Int -> GHC.Types.IO GHC.Types.Bool isEOF :: GHC.Types.IO GHC.Types.Bool - mkDuplexHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> NewlineMode -> GHC.Types.IO Handle - mkFileHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> NewlineMode -> GHC.Types.IO Handle + mkDuplexHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> NewlineMode -> GHC.Types.IO Handle + mkFileHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> NewlineMode -> GHC.Types.IO Handle nativeNewline :: Newline nativeNewlineMode :: NewlineMode noNewlineTranslation :: NewlineMode @@ -7898,11 +7898,11 @@ module GHC.IO.Handle.Internals where ioe_notReadable :: forall a. GHC.Types.IO a ioe_notWritable :: forall a. GHC.Types.IO a ioe_semiclosedHandle :: forall a. GHC.Types.IO a - mkDuplexHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle - mkDuplexHandleNoFinalizer :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle - mkFileHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle - mkFileHandleNoFinalizer :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle - mkHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.Handle.Types.HandleType -> GHC.Types.Bool -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Internal.Maybe.Maybe HandleFinalizer -> GHC.Internal.Maybe.Maybe (GHC.Internal.MVar.MVar GHC.Internal.IO.Handle.Types.Handle__) -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle + mkDuplexHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle + mkDuplexHandleNoFinalizer :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle + mkFileHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle + mkFileHandleNoFinalizer :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle + mkHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.Handle.Types.HandleType -> GHC.Types.Bool -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Internal.Maybe.Maybe HandleFinalizer -> GHC.Internal.Maybe.Maybe (GHC.Internal.MVar.MVar GHC.Internal.IO.Handle.Types.Handle__) -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle openTextEncoding :: forall a. GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.HandleType -> (forall es ds. GHC.Internal.Maybe.Maybe (GHC.Internal.IO.Encoding.Types.TextEncoder es) -> GHC.Internal.Maybe.Maybe (GHC.Internal.IO.Encoding.Types.TextDecoder ds) -> GHC.Types.IO a) -> GHC.Types.IO a readTextDevice :: GHC.Internal.IO.Handle.Types.Handle__ -> GHC.Internal.IO.Buffer.CharBuffer -> GHC.Types.IO GHC.Internal.IO.Buffer.CharBuffer readTextDeviceNonBlocking :: GHC.Internal.IO.Handle.Types.Handle__ -> GHC.Internal.IO.Buffer.CharBuffer -> GHC.Types.IO GHC.Internal.IO.Buffer.CharBuffer @@ -7966,7 +7966,7 @@ module GHC.IO.Handle.Types where type Handle__ :: * data Handle__ = forall dev enc_state dec_state. - (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => + (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => Handle__ {haDevice :: !dev, haType :: HandleType, haByteBuffer :: ! {-# UNPACK #-}(GHC.Internal.IORef.N:IORef[0] _N)(GHC.Internal.IORef.IORef (GHC.Internal.IO.Buffer.Buffer GHC.Internal.Word.Word8)), @@ -12462,7 +12462,7 @@ module GHC.StaticPtr where -- Safety: None type IsStatic :: (* -> *) -> Constraint class IsStatic p where - fromStaticPtr :: forall a. ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a => StaticPtr a -> p a + fromStaticPtr :: forall a. ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a => StaticPtr a -> p a {-# MINIMAL fromStaticPtr #-} type StaticKey :: * type StaticKey = GHC.Internal.Fingerprint.Type.Fingerprint @@ -13857,8 +13857,8 @@ module Type.Reflection where data (:~~:) a b where HRefl :: forall {k1} (a :: k1). (:~~:) a a pattern App :: forall k2 (t :: k2). () => forall k1 (a :: k1 -> k2) (b :: k1). (t ~ a b) => TypeRep a -> TypeRep b -> TypeRep t - pattern Con :: forall k (a :: k). () => ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.NotApplication a => TyCon -> TypeRep a - pattern Con' :: forall k (a :: k). () => ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.NotApplication a => TyCon -> [SomeTypeRep] -> TypeRep a + pattern Con :: forall k (a :: k). () => ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.NotApplication a => TyCon -> TypeRep a + pattern Con' :: forall k (a :: k). () => ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.NotApplication a => TyCon -> [SomeTypeRep] -> TypeRep a pattern Fun :: forall k (fun :: k). () => forall (r1 :: GHC.Types.RuntimeRep) (r2 :: GHC.Types.RuntimeRep) (arg :: TYPE r1) (res :: TYPE r2). (k ~ *, fun ~~ (arg -> res)) => TypeRep arg -> TypeRep res -> TypeRep fun type Module :: * data Module = ... @@ -13875,7 +13875,7 @@ module Type.Reflection where type Typeable :: forall k. k -> Constraint class Typeable a where ... - {-# MINIMAL ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} + {-# MINIMAL ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} decTypeRep :: forall k1 k2 (a :: k1) (b :: k2). TypeRep a -> TypeRep b -> GHC.Internal.Data.Either.Either ((a :~~: b) -> GHC.Internal.Base.Void) (a :~~: b) eqTypeRep :: forall k1 k2 (a :: k1) (b :: k2). TypeRep a -> TypeRep b -> GHC.Internal.Maybe.Maybe (a :~~: b) moduleName :: Module -> GHC.Internal.Base.String @@ -13910,9 +13910,9 @@ module Type.Reflection.Unsafe where data TypeRep a where ... mkTrApp :: forall k1 k2 (a :: k1 -> k2) (b :: k1). TypeRep a -> TypeRep b -> TypeRep (a b) - mkTrCon :: forall k (a :: k). TyCon -> [ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep] -> TypeRep a + mkTrCon :: forall k (a :: k). TyCon -> [ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep] -> TypeRep a mkTyCon :: GHC.Internal.Base.String -> GHC.Internal.Base.String -> GHC.Internal.Base.String -> GHC.Types.Int -> KindRep -> TyCon - someTypeRepFingerprint :: ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -> GHC.Internal.Fingerprint.Type.Fingerprint + someTypeRepFingerprint :: ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -> GHC.Internal.Fingerprint.Type.Fingerprint tyConFingerprint :: TyCon -> GHC.Internal.Fingerprint.Type.Fingerprint tyConKindArgs :: TyCon -> GHC.Types.Int tyConKindRep :: TyCon -> KindRep @@ -14426,20 +14426,20 @@ instance GHC.Internal.Control.Monad.Fix.MonadFix Data.Semigroup.First -- Defined instance GHC.Internal.Control.Monad.Fix.MonadFix Data.Semigroup.Last -- Defined in ‘Data.Semigroup’ instance GHC.Internal.Control.Monad.Fix.MonadFix Data.Semigroup.Max -- Defined in ‘Data.Semigroup’ instance GHC.Internal.Control.Monad.Fix.MonadFix Data.Semigroup.Min -- Defined in ‘Data.Semigroup’ -instance forall (a :: * -> * -> *) b c. (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable b, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable c, GHC.Internal.Data.Data.Data (a b c)) => GHC.Internal.Data.Data.Data (Control.Applicative.WrappedArrow a b c) -- Defined in ‘Control.Applicative’ -instance forall (m :: * -> *) a. (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable m, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a, GHC.Internal.Data.Data.Data (m a)) => GHC.Internal.Data.Data.Data (Control.Applicative.WrappedMonad m a) -- Defined in ‘Control.Applicative’ +instance forall (a :: * -> * -> *) b c. (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable b, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable c, GHC.Internal.Data.Data.Data (a b c)) => GHC.Internal.Data.Data.Data (Control.Applicative.WrappedArrow a b c) -- Defined in ‘Control.Applicative’ +instance forall (m :: * -> *) a. (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable m, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a, GHC.Internal.Data.Data.Data (m a)) => GHC.Internal.Data.Data.Data (Control.Applicative.WrappedMonad m a) -- Defined in ‘Control.Applicative’ instance forall a. GHC.Internal.Data.Data.Data a => GHC.Internal.Data.Data.Data (GHC.Internal.Functor.ZipList.ZipList a) -- Defined in ‘GHC.Internal.Functor.ZipList’ instance GHC.Internal.Data.Data.Data Data.Array.Byte.ByteArray -- Defined in ‘Data.Array.Byte’ -instance forall s. ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable s => GHC.Internal.Data.Data.Data (Data.Array.Byte.MutableByteArray s) -- Defined in ‘Data.Array.Byte’ +instance forall s. ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable s => GHC.Internal.Data.Data.Data (Data.Array.Byte.MutableByteArray s) -- Defined in ‘Data.Array.Byte’ instance forall a. GHC.Internal.Data.Data.Data a => GHC.Internal.Data.Data.Data (Data.Complex.Complex a) -- Defined in ‘Data.Complex’ -instance forall i j (a :: i) (b :: j). (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable i, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable j, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable b, a ~~ b) => GHC.Internal.Data.Data.Data (a GHC.Internal.Data.Type.Equality.:~~: b) -- Defined in ‘GHC.Internal.Data.Data’ +instance forall i j (a :: i) (b :: j). (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable i, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable j, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable b, a ~~ b) => GHC.Internal.Data.Data.Data (a GHC.Internal.Data.Type.Equality.:~~: b) -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Internal.Data.Semigroup.Internal.All -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Internal.Data.Semigroup.Internal.Any -- Defined in ‘GHC.Internal.Data.Data’ instance forall a b. (GHC.Internal.Data.Data.Data a, GHC.Internal.Data.Data.Data b, GHC.Internal.Ix.Ix a) => GHC.Internal.Data.Data.Data (GHC.Internal.Arr.Array a b) -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Types.Bool -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Types.Char -- Defined in ‘GHC.Internal.Data.Data’ -instance forall k a (b :: k). (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable k, GHC.Internal.Data.Data.Data a, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable b) => GHC.Internal.Data.Data.Data (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Data’ +instance forall k a (b :: k). (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable k, GHC.Internal.Data.Data.Data a, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable b) => GHC.Internal.Data.Data.Data (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Data’ instance forall a. GHC.Internal.Data.Data.Data a => GHC.Internal.Data.Data.Data (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Types.Double -- Defined in ‘GHC.Internal.Data.Data’ @@ -14487,10 +14487,10 @@ instance GHC.Internal.Data.Data.Data GHC.Internal.Word.Word32 -- Defined in ‘G instance GHC.Internal.Data.Data.Data GHC.Internal.Word.Word64 -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Internal.Word.Word8 -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Internal.Foreign.Ptr.WordPtr -- Defined in ‘GHC.Internal.Data.Data’ -instance forall k (a :: k). (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable k, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a) => GHC.Internal.Data.Data.Data (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ -instance forall k1 (f :: k1 -> *) k2 (g :: k2 -> k1) (a :: k2). (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable f, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable g, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable k1, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable k2, GHC.Internal.Data.Data.Data (f (g a))) => GHC.Internal.Data.Data.Data (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ -instance [safe] forall k (f :: k -> *) (g :: k -> *) (a :: k). (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable f, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable g, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable k, GHC.Internal.Data.Data.Data (f a), GHC.Internal.Data.Data.Data (g a)) => GHC.Internal.Data.Data.Data (Data.Functor.Product.Product f g a) -- Defined in ‘Data.Functor.Product’ -instance [safe] forall k (f :: k -> *) (g :: k -> *) (a :: k). (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable f, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable g, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable k, GHC.Internal.Data.Data.Data (f a), GHC.Internal.Data.Data.Data (g a)) => GHC.Internal.Data.Data.Data (Data.Functor.Sum.Sum f g a) -- Defined in ‘Data.Functor.Sum’ +instance forall k (a :: k). (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable k, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a) => GHC.Internal.Data.Data.Data (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ +instance forall k1 (f :: k1 -> *) k2 (g :: k2 -> k1) (a :: k2). (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable f, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable g, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable k1, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable k2, GHC.Internal.Data.Data.Data (f (g a))) => GHC.Internal.Data.Data.Data (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ +instance [safe] forall k (f :: k -> *) (g :: k -> *) (a :: k). (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable f, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable g, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable k, GHC.Internal.Data.Data.Data (f a), GHC.Internal.Data.Data.Data (g a)) => GHC.Internal.Data.Data.Data (Data.Functor.Product.Product f g a) -- Defined in ‘Data.Functor.Product’ +instance [safe] forall k (f :: k -> *) (g :: k -> *) (a :: k). (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable f, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable g, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable k, GHC.Internal.Data.Data.Data (f a), GHC.Internal.Data.Data.Data (g a)) => GHC.Internal.Data.Data.Data (Data.Functor.Sum.Sum f g a) -- Defined in ‘Data.Functor.Sum’ instance forall a b. (GHC.Internal.Data.Data.Data a, GHC.Internal.Data.Data.Data b) => GHC.Internal.Data.Data.Data (Data.Semigroup.Arg a b) -- Defined in ‘Data.Semigroup’ instance forall a. GHC.Internal.Data.Data.Data a => GHC.Internal.Data.Data.Data (Data.Semigroup.First a) -- Defined in ‘Data.Semigroup’ instance forall a. GHC.Internal.Data.Data.Data a => GHC.Internal.Data.Data.Data (Data.Semigroup.Last a) -- Defined in ‘Data.Semigroup’ @@ -14556,7 +14556,7 @@ instance GHC.Internal.Data.Type.Equality.TestEquality GHC.Internal.TypeLits.SCha instance GHC.Internal.Data.Type.Equality.TestEquality GHC.Internal.TypeLits.SSymbol -- Defined in ‘GHC.Internal.TypeLits’ instance forall k (a :: k). GHC.Internal.Data.Type.Equality.TestEquality ((GHC.Internal.Data.Type.Equality.:~:) a) -- Defined in ‘GHC.Internal.Data.Type.Equality’ instance forall k1 k (a :: k1). GHC.Internal.Data.Type.Equality.TestEquality ((GHC.Internal.Data.Type.Equality.:~~:) a) -- Defined in ‘GHC.Internal.Data.Type.Equality’ -instance forall k. GHC.Internal.Data.Type.Equality.TestEquality ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.TypeRep -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal’ +instance forall k. GHC.Internal.Data.Type.Equality.TestEquality ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.TypeRep -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1). GHC.Internal.Data.Type.Equality.TestEquality f => GHC.Internal.Data.Type.Equality.TestEquality (Data.Functor.Compose.Compose f g) -- Defined in ‘Data.Functor.Compose’ instance forall a k (b :: k). GHC.Internal.Enum.Bounded a => GHC.Internal.Enum.Bounded (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall a. GHC.Internal.Enum.Bounded a => GHC.Internal.Enum.Bounded (GHC.Internal.Data.Bits.And a) -- Defined in ‘GHC.Internal.Data.Bits’ @@ -14636,6 +14636,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -14711,6 +14712,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ @@ -14753,7 +14755,7 @@ instance GHC.Internal.Exception.Type.Exception GHC.Internal.Control.Exception.Ba instance GHC.Internal.Exception.Type.Exception GHC.Internal.Control.Exception.Base.RecUpdError -- Defined in ‘GHC.Internal.Control.Exception.Base’ instance GHC.Internal.Exception.Type.Exception GHC.Internal.Control.Exception.Base.TypeError -- Defined in ‘GHC.Internal.Control.Exception.Base’ instance GHC.Internal.Exception.Type.Exception GHC.Internal.Data.Dynamic.Dynamic -- Defined in ‘GHC.Internal.Data.Dynamic’ -instance [safe] GHC.Internal.Exception.Type.Exception ghc-internal-0.1.0.0:GHC.Internal.IO.Handle.Lock.Common.FileLockingNotSupported -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.IO.Handle.Lock.Common’ +instance [safe] GHC.Internal.Exception.Type.Exception ghc-internal-9.1001.0:GHC.Internal.IO.Handle.Lock.Common.FileLockingNotSupported -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.IO.Handle.Lock.Common’ instance GHC.Internal.Exception.Type.Exception GHC.Internal.IOPort.IOPortException -- Defined in ‘GHC.Internal.IOPort’ instance GHC.Internal.Exception.Type.Exception GHC.Internal.JS.Prim.JSException -- Defined in ‘GHC.Internal.JS.Prim’ instance GHC.Internal.Exception.Type.Exception GHC.Internal.JS.Prim.WouldBlockException -- Defined in ‘GHC.Internal.JS.Prim’ @@ -15097,6 +15099,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -15208,6 +15211,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -15281,6 +15285,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -15327,6 +15332,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -15426,8 +15432,8 @@ instance GHC.Internal.Show.Show GHC.Internal.Data.Data.DataRep -- Defined in ‘ instance GHC.Internal.Show.Show GHC.Internal.Data.Data.DataType -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Show.Show GHC.Internal.Data.Data.Fixity -- Defined in ‘GHC.Internal.Data.Data’ instance forall k (s :: k). GHC.Internal.Show.Show (GHC.Internal.Data.Proxy.Proxy s) -- Defined in ‘GHC.Internal.Data.Proxy’ -instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal’ -instance forall k (a :: k). GHC.Internal.Show.Show (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.TypeRep a) -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal’ +instance GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal’ +instance forall k (a :: k). GHC.Internal.Show.Show (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.TypeRep a) -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal’ instance GHC.Internal.Show.Show GHC.Internal.Data.Dynamic.Dynamic -- Defined in ‘GHC.Internal.Data.Dynamic’ instance forall a b. (GHC.Internal.Show.Show a, GHC.Internal.Show.Show b) => GHC.Internal.Show.Show (GHC.Internal.Data.Either.Either a b) -- Defined in ‘GHC.Internal.Data.Either’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Show.Show (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ @@ -15498,6 +15504,7 @@ instance GHC.Internal.Show.Show GHC.Internal.Foreign.C.Types.CWchar -- Defined i instance forall a. GHC.Internal.Show.Show (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) -- Defined in ‘GHC.Internal.Foreign.C.ConstPtr’ instance forall a b. (GHC.Internal.Ix.Ix a, GHC.Internal.Show.Show a, GHC.Internal.Show.Show b) => GHC.Internal.Show.Show (GHC.Internal.Arr.Array a b) -- Defined in ‘GHC.Internal.Arr’ instance GHC.Internal.Show.Show GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Show.Show GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Show.Show GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance GHC.Internal.Show.Show GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Show.Show GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ @@ -15530,7 +15537,7 @@ instance GHC.Internal.Show.Show GHC.Internal.IO.Handle.Types.Handle -- Defined i instance GHC.Internal.Show.Show GHC.Internal.IO.Handle.Types.HandleType -- Defined in ‘GHC.Internal.IO.Handle.Types’ instance GHC.Internal.Show.Show GHC.Internal.IO.Handle.Types.Newline -- Defined in ‘GHC.Internal.IO.Handle.Types’ instance GHC.Internal.Show.Show GHC.Internal.IO.Handle.Types.NewlineMode -- Defined in ‘GHC.Internal.IO.Handle.Types’ -instance [safe] GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.IO.Handle.Lock.Common.FileLockingNotSupported -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.IO.Handle.Lock.Common’ +instance [safe] GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.IO.Handle.Lock.Common.FileLockingNotSupported -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.IO.Handle.Lock.Common’ instance GHC.Internal.Show.Show GHC.Internal.IO.Handle.HandlePosn -- Defined in ‘GHC.Internal.IO.Handle’ instance GHC.Internal.Show.Show GHC.Internal.IO.IOMode.IOMode -- Defined in ‘GHC.Internal.IO.IOMode’ instance GHC.Internal.Show.Show GHC.Internal.IOPort.IOPortException -- Defined in ‘GHC.Internal.IOPort’ @@ -15627,8 +15634,8 @@ instance GHC.Classes.Eq GHC.Internal.Data.Data.ConstrRep -- Defined in ‘GHC.In instance GHC.Classes.Eq GHC.Internal.Data.Data.DataRep -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Classes.Eq GHC.Internal.Data.Data.Fixity -- Defined in ‘GHC.Internal.Data.Data’ instance forall k (s :: k). GHC.Classes.Eq (GHC.Internal.Data.Proxy.Proxy s) -- Defined in ‘GHC.Internal.Data.Proxy’ -instance GHC.Classes.Eq ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal’ -instance forall k (a :: k). GHC.Classes.Eq (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.TypeRep a) -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal’ +instance GHC.Classes.Eq ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal’ +instance forall k (a :: k). GHC.Classes.Eq (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.TypeRep a) -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal’ instance forall a b. (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (GHC.Internal.Data.Either.Either a b) -- Defined in ‘GHC.Internal.Data.Either’ instance forall k (a :: k). GHC.Classes.Eq (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Classes.Eq (f (g a)) => GHC.Classes.Eq (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -15707,6 +15714,7 @@ instance GHC.Classes.Eq GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.In instance GHC.Classes.Eq GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -15801,8 +15809,8 @@ instance GHC.Classes.Ord GHC.Internal.Unicode.GeneralCategory -- Defined in ‘G instance forall k (a :: k) (b :: k). GHC.Classes.Ord (a GHC.Internal.Data.Type.Equality.:~: b) -- Defined in ‘GHC.Internal.Data.Type.Equality’ instance forall k1 k2 (a :: k1) (b :: k2). GHC.Classes.Ord (a GHC.Internal.Data.Type.Equality.:~~: b) -- Defined in ‘GHC.Internal.Data.Type.Equality’ instance forall k (s :: k). GHC.Classes.Ord (GHC.Internal.Data.Proxy.Proxy s) -- Defined in ‘GHC.Internal.Data.Proxy’ -instance GHC.Classes.Ord ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal’ -instance forall k (a :: k). GHC.Classes.Ord (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.TypeRep a) -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal’ +instance GHC.Classes.Ord ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal’ +instance forall k (a :: k). GHC.Classes.Ord (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.TypeRep a) -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal’ instance forall a b. (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (GHC.Internal.Data.Either.Either a b) -- Defined in ‘GHC.Internal.Data.Either’ instance forall k (a :: k). GHC.Classes.Ord (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Classes.Ord (f (g a)) => GHC.Classes.Ord (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -15873,6 +15881,7 @@ instance forall a. GHC.Classes.Ord (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) instance forall i e. (GHC.Internal.Ix.Ix i, GHC.Classes.Ord e) => GHC.Classes.Ord (GHC.Internal.Arr.Array i e) -- Defined in ‘GHC.Internal.Arr’ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -234,7 +234,7 @@ module Control.Exception where type ErrorCall :: * data ErrorCall = ErrorCallWithLocation GHC.Internal.Base.String GHC.Internal.Base.String type Exception :: * -> Constraint - class (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where + class (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where toException :: e -> SomeException fromException :: SomeException -> GHC.Internal.Maybe.Maybe e displayException :: e -> GHC.Internal.Base.String @@ -303,7 +303,7 @@ module Control.Exception where module Control.Exception.Annotation where -- Safety: None type ExceptionAnnotation :: * -> Constraint - class ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a => ExceptionAnnotation a where + class ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a => ExceptionAnnotation a where displayExceptionAnnotation :: a -> GHC.Internal.Base.String default displayExceptionAnnotation :: GHC.Internal.Show.Show a => a -> GHC.Internal.Base.String {-# MINIMAL #-} @@ -345,7 +345,7 @@ module Control.Exception.Base where type ErrorCall :: * data ErrorCall = ErrorCallWithLocation GHC.Internal.Base.String GHC.Internal.Base.String type Exception :: * -> Constraint - class (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where + class (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where toException :: e -> SomeException fromException :: SomeException -> GHC.Internal.Maybe.Maybe e displayException :: e -> GHC.Internal.Base.String @@ -848,11 +848,11 @@ module Data.Data where type TyCon :: * data TyCon = ... type TypeRep :: * - type TypeRep = ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep + type TypeRep = ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep type Typeable :: forall k. k -> Constraint class Typeable a where ... - {-# MINIMAL ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} + {-# MINIMAL ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} cast :: forall a b. (Typeable a, Typeable b) => a -> GHC.Internal.Maybe.Maybe b constrFields :: Constr -> [GHC.Internal.Base.String] constrFixity :: Constr -> Fixity @@ -895,7 +895,7 @@ module Data.Data where showConstr :: Constr -> GHC.Internal.Base.String showsTypeRep :: TypeRep -> GHC.Internal.Show.ShowS splitTyConApp :: TypeRep -> (TyCon, [TypeRep]) - trLiftedRep :: ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.TypeRep GHC.Types.LiftedRep + trLiftedRep :: ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.TypeRep GHC.Types.LiftedRep tyConFingerprint :: TyCon -> GHC.Internal.Fingerprint.Type.Fingerprint tyConModule :: TyCon -> GHC.Internal.Base.String tyConName :: TyCon -> GHC.Internal.Base.String @@ -919,14 +919,14 @@ module Data.Dynamic where -- Safety: Safe type Dynamic :: * data Dynamic where - Dynamic :: forall a. ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.TypeRep a -> a -> Dynamic + Dynamic :: forall a. ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.TypeRep a -> a -> Dynamic type Typeable :: forall k. k -> Constraint class Typeable a where ... - {-# MINIMAL ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} + {-# MINIMAL ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} dynApp :: Dynamic -> Dynamic -> Dynamic dynApply :: Dynamic -> Dynamic -> GHC.Internal.Maybe.Maybe Dynamic - dynTypeRep :: Dynamic -> ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep + dynTypeRep :: Dynamic -> ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep fromDyn :: forall a. Typeable a => Dynamic -> a -> a fromDynamic :: forall a. Typeable a => Dynamic -> GHC.Internal.Maybe.Maybe a toDyn :: forall a. Typeable a => a -> Dynamic @@ -1809,11 +1809,11 @@ module Data.Typeable where type TyCon :: * data TyCon = ... type TypeRep :: * - type TypeRep = ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep + type TypeRep = ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep type Typeable :: forall k. k -> Constraint class Typeable a where ... - {-# MINIMAL ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} + {-# MINIMAL ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} cast :: forall a b. (Typeable a, Typeable b) => a -> GHC.Internal.Maybe.Maybe b decT :: forall {k} (a :: k) (b :: k). (Typeable a, Typeable b) => GHC.Internal.Data.Either.Either ((a :~: b) -> GHC.Internal.Base.Void) (a :~: b) eqT :: forall {k} (a :: k) (b :: k). (Typeable a, Typeable b) => GHC.Internal.Maybe.Maybe (a :~: b) @@ -1828,7 +1828,7 @@ module Data.Typeable where rnfTypeRep :: TypeRep -> () showsTypeRep :: TypeRep -> GHC.Internal.Show.ShowS splitTyConApp :: TypeRep -> (TyCon, [TypeRep]) - trLiftedRep :: ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.TypeRep GHC.Types.LiftedRep + trLiftedRep :: ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.TypeRep GHC.Types.LiftedRep tyConFingerprint :: TyCon -> GHC.Internal.Fingerprint.Type.Fingerprint tyConModule :: TyCon -> GHC.Internal.Base.String tyConName :: TyCon -> GHC.Internal.Base.String @@ -5293,9 +5293,9 @@ module GHC.Event.TimeOut where type TimeoutEdit :: * type TimeoutEdit = TimeoutQueue -> TimeoutQueue type TimeoutKey :: * - newtype TimeoutKey = TK ghc-internal-0.1.0.0:GHC.Internal.Event.Unique.Unique + newtype TimeoutKey = TK ghc-internal-9.1001.0:GHC.Internal.Event.Unique.Unique type TimeoutQueue :: * - type TimeoutQueue = ghc-internal-0.1.0.0:GHC.Internal.Event.PSQ.PSQ TimeoutCallback + type TimeoutQueue = ghc-internal-9.1001.0:GHC.Internal.Event.PSQ.PSQ TimeoutCallback module GHC.Event.Windows where -- Safety: None @@ -5306,7 +5306,7 @@ module GHC.Event.Windows where type ConsoleEvent :: * data ConsoleEvent = ControlC | Break | Close | Logoff | Shutdown type HandleData :: * - data HandleData = HandleData {tokenKey :: {-# UNPACK #-}HandleKey, tokenEvents :: ! {-# UNPACK #-}(ghc-internal-0.1.0.0:GHC.Internal.Event.Internal.Types.N:EventLifetime[0])ghc-internal-0.1.0.0:GHC.Internal.Event.Internal.Types.EventLifetime, _handleCallback :: !GHC.Internal.Event.Windows.EventCallback} + data HandleData = HandleData {tokenKey :: {-# UNPACK #-}HandleKey, tokenEvents :: ! {-# UNPACK #-}(ghc-internal-9.1001.0:GHC.Internal.Event.Internal.Types.N:EventLifetime[0])ghc-internal-9.1001.0:GHC.Internal.Event.Internal.Types.EventLifetime, _handleCallback :: !GHC.Internal.Event.Windows.EventCallback} type HandleKey :: * data HandleKey = GHC.Internal.Event.Windows.HandleKey {handleValue :: {-# UNPACK #-}GHC.Internal.Windows.HANDLE, ...} type IOResult :: * -> * @@ -5334,7 +5334,7 @@ module GHC.Event.Windows where ioFailedAny :: forall a b. GHC.Internal.Real.Integral a => a -> GHC.Types.IO (IOResult b) ioSuccess :: forall a. a -> GHC.Types.IO (IOResult a) processRemoteCompletion :: GHC.Types.IO () - registerHandle :: Manager -> GHC.Internal.Event.Windows.EventCallback -> GHC.Internal.Windows.HANDLE -> ghc-internal-0.1.0.0:GHC.Internal.Event.Internal.Types.Event -> ghc-internal-0.1.0.0:GHC.Internal.Event.Internal.Types.Lifetime -> GHC.Types.IO HandleKey + registerHandle :: Manager -> GHC.Internal.Event.Windows.EventCallback -> GHC.Internal.Windows.HANDLE -> ghc-internal-9.1001.0:GHC.Internal.Event.Internal.Types.Event -> ghc-internal-9.1001.0:GHC.Internal.Event.Internal.Types.Lifetime -> GHC.Types.IO HandleKey registerTimeout :: Manager -> GHC.Types.Int -> TimeoutCallback -> GHC.Types.IO TimeoutKey start_console_handler :: GHC.Internal.Word.Word32 -> GHC.Types.IO () toWin32ConsoleEvent :: forall a. (GHC.Classes.Eq a, GHC.Internal.Num.Num a) => a -> GHC.Internal.Maybe.Maybe ConsoleEvent @@ -5393,7 +5393,7 @@ module GHC.Event.Windows.FFI where cancelIoEx :: GHC.Internal.Windows.HANDLE -> LPOVERLAPPED -> GHC.Types.IO () cancelIoEx' :: GHC.Internal.Windows.HANDLE -> LPOVERLAPPED -> GHC.Types.IO GHC.Types.Bool getOverlappedResult :: GHC.Internal.Windows.HANDLE -> GHC.Internal.Ptr.Ptr OVERLAPPED -> GHC.Internal.Windows.BOOL -> GHC.Types.IO (GHC.Internal.Maybe.Maybe GHC.Internal.Windows.DWORD) - getQueuedCompletionStatusEx :: IOCP -> ghc-internal-0.1.0.0:GHC.Internal.Event.Array.Array OVERLAPPED_ENTRY -> GHC.Internal.Windows.DWORD -> GHC.Types.IO GHC.Types.Int + getQueuedCompletionStatusEx :: IOCP -> ghc-internal-9.1001.0:GHC.Internal.Event.Array.Array OVERLAPPED_ENTRY -> GHC.Internal.Windows.DWORD -> GHC.Types.IO GHC.Types.Int getTickCount64 :: GHC.Types.IO GHC.Internal.Word.Word64 newIOCP :: GHC.Types.IO IOCP overlappedIONumBytes :: LPOVERLAPPED -> GHC.Types.IO GHC.Internal.Event.Windows.FFI.ULONG_PTR @@ -5418,8 +5418,8 @@ module GHC.Event.Windows.ManagedThreadPool where thrCallBack :: GHC.Internal.Event.Windows.ManagedThreadPool.WorkerJob, thrActiveThreads :: GHC.Internal.MVar.MVar GHC.Types.Int, thrMonitor :: GHC.Internal.MVar.MVar (), - thrThreadIds :: ! {-# UNPACK #-}(ghc-internal-0.1.0.0:GHC.Internal.Event.Array.N:Array[0] _P - ; GHC.Internal.IORef.N:IORef[0] _N)(ghc-internal-0.1.0.0:GHC.Internal.Event.Array.Array GHC.Internal.Conc.Sync.ThreadId)} + thrThreadIds :: ! {-# UNPACK #-}(ghc-internal-9.1001.0:GHC.Internal.Event.Array.N:Array[0] _P + ; GHC.Internal.IORef.N:IORef[0] _N)(ghc-internal-9.1001.0:GHC.Internal.Event.Array.Array GHC.Internal.Conc.Sync.ThreadId)} monitorThreadPool :: GHC.Internal.MVar.MVar () -> GHC.Types.IO () notifyRunning :: GHC.Internal.Maybe.Maybe ThreadPool -> GHC.Types.IO () notifyWaiting :: GHC.Internal.Maybe.Maybe ThreadPool -> GHC.Types.IO () @@ -5442,7 +5442,7 @@ module GHC.Exception where type ErrorCall :: * data ErrorCall = ErrorCallWithLocation GHC.Internal.Base.String GHC.Internal.Base.String type Exception :: * -> Constraint - class (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where + class (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where toException :: e -> SomeException fromException :: SomeException -> GHC.Internal.Maybe.Maybe e displayException :: e -> GHC.Internal.Base.String @@ -5471,7 +5471,7 @@ module GHC.Exception.Type where type ArithException :: * data ArithException = Overflow | Underflow | LossOfPrecision | DivideByZero | Denormal | RatioZeroDenominator type Exception :: * -> Constraint - class (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where + class (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable e, GHC.Internal.Show.Show e) => Exception e where toException :: e -> SomeException fromException :: SomeException -> GHC.Internal.Maybe.Maybe e displayException :: e -> GHC.Internal.Base.String @@ -8048,8 +8048,8 @@ module GHC.IO.Handle where hTryLock :: Handle -> LockMode -> GHC.Types.IO GHC.Types.Bool hWaitForInput :: Handle -> GHC.Types.Int -> GHC.Types.IO GHC.Types.Bool isEOF :: GHC.Types.IO GHC.Types.Bool - mkDuplexHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> NewlineMode -> GHC.Types.IO Handle - mkFileHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> NewlineMode -> GHC.Types.IO Handle + mkDuplexHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> NewlineMode -> GHC.Types.IO Handle + mkFileHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> NewlineMode -> GHC.Types.IO Handle nativeNewline :: Newline nativeNewlineMode :: NewlineMode noNewlineTranslation :: NewlineMode @@ -8099,11 +8099,11 @@ module GHC.IO.Handle.Internals where ioe_notReadable :: forall a. GHC.Types.IO a ioe_notWritable :: forall a. GHC.Types.IO a ioe_semiclosedHandle :: forall a. GHC.Types.IO a - mkDuplexHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle - mkDuplexHandleNoFinalizer :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle - mkFileHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle - mkFileHandleNoFinalizer :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle - mkHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.Handle.Types.HandleType -> GHC.Types.Bool -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Internal.Maybe.Maybe HandleFinalizer -> GHC.Internal.Maybe.Maybe (GHC.Internal.MVar.MVar GHC.Internal.IO.Handle.Types.Handle__) -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle + mkDuplexHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle + mkDuplexHandleNoFinalizer :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle + mkFileHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle + mkFileHandleNoFinalizer :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle + mkHandle :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.Handle.Types.HandleType -> GHC.Types.Bool -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.NewlineMode -> GHC.Internal.Maybe.Maybe HandleFinalizer -> GHC.Internal.Maybe.Maybe (GHC.Internal.MVar.MVar GHC.Internal.IO.Handle.Types.Handle__) -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle openTextEncoding :: forall a. GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Internal.IO.Handle.Types.HandleType -> (forall es ds. GHC.Internal.Maybe.Maybe (GHC.Internal.IO.Encoding.Types.TextEncoder es) -> GHC.Internal.Maybe.Maybe (GHC.Internal.IO.Encoding.Types.TextDecoder ds) -> GHC.Types.IO a) -> GHC.Types.IO a readTextDevice :: GHC.Internal.IO.Handle.Types.Handle__ -> GHC.Internal.IO.Buffer.CharBuffer -> GHC.Types.IO GHC.Internal.IO.Buffer.CharBuffer readTextDeviceNonBlocking :: GHC.Internal.IO.Handle.Types.Handle__ -> GHC.Internal.IO.Buffer.CharBuffer -> GHC.Types.IO GHC.Internal.IO.Buffer.CharBuffer @@ -8167,7 +8167,7 @@ module GHC.IO.Handle.Types where type Handle__ :: * data Handle__ = forall dev enc_state dec_state. - (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => + (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => Handle__ {haDevice :: !dev, haType :: HandleType, haByteBuffer :: ! {-# UNPACK #-}(GHC.Internal.IORef.N:IORef[0] _N)(GHC.Internal.IORef.IORef (GHC.Internal.IO.Buffer.Buffer GHC.Internal.Word.Word8)), @@ -8199,7 +8199,7 @@ module GHC.IO.Handle.Types where module GHC.IO.Handle.Windows where -- Safety: Safe-Inferred handleToHANDLE :: GHC.Internal.IO.Handle.Types.Handle -> GHC.Types.IO GHC.Internal.Windows.HANDLE - mkHandleFromHANDLE :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.Device.IODeviceType -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle + mkHandleFromHANDLE :: forall dev. (GHC.Internal.IO.Device.RawIO dev, GHC.Internal.IO.Device.IODevice dev, GHC.Internal.IO.BufferedIO.BufferedIO dev, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable dev) => dev -> GHC.Internal.IO.Device.IODeviceType -> GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Internal.Maybe.Maybe GHC.Internal.IO.Encoding.Types.TextEncoding -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle openBinaryFile :: GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle openFile :: GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle openFileBlocking :: GHC.Internal.IO.FilePath -> GHC.Internal.IO.IOMode.IOMode -> GHC.Types.IO GHC.Internal.IO.Handle.Types.Handle @@ -9644,7 +9644,7 @@ module GHC.StaticPtr where -- Safety: None type IsStatic :: (* -> *) -> Constraint class IsStatic p where - fromStaticPtr :: forall a. ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a => StaticPtr a -> p a + fromStaticPtr :: forall a. ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a => StaticPtr a -> p a {-# MINIMAL fromStaticPtr #-} type StaticKey :: * type StaticKey = GHC.Internal.Fingerprint.Type.Fingerprint @@ -11084,8 +11084,8 @@ module Type.Reflection where data (:~~:) a b where HRefl :: forall {k1} (a :: k1). (:~~:) a a pattern App :: forall k2 (t :: k2). () => forall k1 (a :: k1 -> k2) (b :: k1). (t ~ a b) => TypeRep a -> TypeRep b -> TypeRep t - pattern Con :: forall k (a :: k). () => ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.NotApplication a => TyCon -> TypeRep a - pattern Con' :: forall k (a :: k). () => ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.NotApplication a => TyCon -> [SomeTypeRep] -> TypeRep a + pattern Con :: forall k (a :: k). () => ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.NotApplication a => TyCon -> TypeRep a + pattern Con' :: forall k (a :: k). () => ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.NotApplication a => TyCon -> [SomeTypeRep] -> TypeRep a pattern Fun :: forall k (fun :: k). () => forall (r1 :: GHC.Types.RuntimeRep) (r2 :: GHC.Types.RuntimeRep) (arg :: TYPE r1) (res :: TYPE r2). (k ~ *, fun ~~ (arg -> res)) => TypeRep arg -> TypeRep res -> TypeRep fun type Module :: * data Module = ... @@ -11102,7 +11102,7 @@ module Type.Reflection where type Typeable :: forall k. k -> Constraint class Typeable a where ... - {-# MINIMAL ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} + {-# MINIMAL ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.typeRep# #-} decTypeRep :: forall k1 k2 (a :: k1) (b :: k2). TypeRep a -> TypeRep b -> GHC.Internal.Data.Either.Either ((a :~~: b) -> GHC.Internal.Base.Void) (a :~~: b) eqTypeRep :: forall k1 k2 (a :: k1) (b :: k2). TypeRep a -> TypeRep b -> GHC.Internal.Maybe.Maybe (a :~~: b) moduleName :: Module -> GHC.Internal.Base.String @@ -11137,9 +11137,9 @@ module Type.Reflection.Unsafe where data TypeRep a where ... mkTrApp :: forall k1 k2 (a :: k1 -> k2) (b :: k1). TypeRep a -> TypeRep b -> TypeRep (a b) - mkTrCon :: forall k (a :: k). TyCon -> [ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep] -> TypeRep a + mkTrCon :: forall k (a :: k). TyCon -> [ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep] -> TypeRep a mkTyCon :: GHC.Internal.Base.String -> GHC.Internal.Base.String -> GHC.Internal.Base.String -> GHC.Types.Int -> KindRep -> TyCon - someTypeRepFingerprint :: ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -> GHC.Internal.Fingerprint.Type.Fingerprint + someTypeRepFingerprint :: ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -> GHC.Internal.Fingerprint.Type.Fingerprint tyConFingerprint :: TyCon -> GHC.Internal.Fingerprint.Type.Fingerprint tyConKindArgs :: TyCon -> GHC.Types.Int tyConKindRep :: TyCon -> KindRep @@ -11655,20 +11655,20 @@ instance GHC.Internal.Control.Monad.Fix.MonadFix Data.Semigroup.First -- Defined instance GHC.Internal.Control.Monad.Fix.MonadFix Data.Semigroup.Last -- Defined in ‘Data.Semigroup’ instance GHC.Internal.Control.Monad.Fix.MonadFix Data.Semigroup.Max -- Defined in ‘Data.Semigroup’ instance GHC.Internal.Control.Monad.Fix.MonadFix Data.Semigroup.Min -- Defined in ‘Data.Semigroup’ -instance forall (a :: * -> * -> *) b c. (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable b, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable c, GHC.Internal.Data.Data.Data (a b c)) => GHC.Internal.Data.Data.Data (Control.Applicative.WrappedArrow a b c) -- Defined in ‘Control.Applicative’ -instance forall (m :: * -> *) a. (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable m, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a, GHC.Internal.Data.Data.Data (m a)) => GHC.Internal.Data.Data.Data (Control.Applicative.WrappedMonad m a) -- Defined in ‘Control.Applicative’ +instance forall (a :: * -> * -> *) b c. (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable b, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable c, GHC.Internal.Data.Data.Data (a b c)) => GHC.Internal.Data.Data.Data (Control.Applicative.WrappedArrow a b c) -- Defined in ‘Control.Applicative’ +instance forall (m :: * -> *) a. (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable m, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a, GHC.Internal.Data.Data.Data (m a)) => GHC.Internal.Data.Data.Data (Control.Applicative.WrappedMonad m a) -- Defined in ‘Control.Applicative’ instance forall a. GHC.Internal.Data.Data.Data a => GHC.Internal.Data.Data.Data (GHC.Internal.Functor.ZipList.ZipList a) -- Defined in ‘GHC.Internal.Functor.ZipList’ instance GHC.Internal.Data.Data.Data Data.Array.Byte.ByteArray -- Defined in ‘Data.Array.Byte’ -instance forall s. ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable s => GHC.Internal.Data.Data.Data (Data.Array.Byte.MutableByteArray s) -- Defined in ‘Data.Array.Byte’ +instance forall s. ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable s => GHC.Internal.Data.Data.Data (Data.Array.Byte.MutableByteArray s) -- Defined in ‘Data.Array.Byte’ instance forall a. GHC.Internal.Data.Data.Data a => GHC.Internal.Data.Data.Data (Data.Complex.Complex a) -- Defined in ‘Data.Complex’ -instance forall i j (a :: i) (b :: j). (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable i, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable j, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable b, a ~~ b) => GHC.Internal.Data.Data.Data (a GHC.Internal.Data.Type.Equality.:~~: b) -- Defined in ‘GHC.Internal.Data.Data’ +instance forall i j (a :: i) (b :: j). (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable i, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable j, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable b, a ~~ b) => GHC.Internal.Data.Data.Data (a GHC.Internal.Data.Type.Equality.:~~: b) -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Internal.Data.Semigroup.Internal.All -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Internal.Data.Semigroup.Internal.Any -- Defined in ‘GHC.Internal.Data.Data’ instance forall a b. (GHC.Internal.Data.Data.Data a, GHC.Internal.Data.Data.Data b, GHC.Internal.Ix.Ix a) => GHC.Internal.Data.Data.Data (GHC.Internal.Arr.Array a b) -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Types.Bool -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Types.Char -- Defined in ‘GHC.Internal.Data.Data’ -instance forall k a (b :: k). (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable k, GHC.Internal.Data.Data.Data a, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable b) => GHC.Internal.Data.Data.Data (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Data’ +instance forall k a (b :: k). (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable k, GHC.Internal.Data.Data.Data a, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable b) => GHC.Internal.Data.Data.Data (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Data’ instance forall a. GHC.Internal.Data.Data.Data a => GHC.Internal.Data.Data.Data (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Types.Double -- Defined in ‘GHC.Internal.Data.Data’ @@ -11716,10 +11716,10 @@ instance GHC.Internal.Data.Data.Data GHC.Internal.Word.Word32 -- Defined in ‘G instance GHC.Internal.Data.Data.Data GHC.Internal.Word.Word64 -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Internal.Word.Word8 -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Data.Data.Data GHC.Internal.Foreign.Ptr.WordPtr -- Defined in ‘GHC.Internal.Data.Data’ -instance forall k (a :: k). (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable k, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a) => GHC.Internal.Data.Data.Data (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ -instance forall k1 (f :: k1 -> *) k2 (g :: k2 -> k1) (a :: k2). (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable f, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable g, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable k1, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable k2, GHC.Internal.Data.Data.Data (f (g a))) => GHC.Internal.Data.Data.Data (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ -instance [safe] forall k (f :: k -> *) (g :: k -> *) (a :: k). (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable f, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable g, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable k, GHC.Internal.Data.Data.Data (f a), GHC.Internal.Data.Data.Data (g a)) => GHC.Internal.Data.Data.Data (Data.Functor.Product.Product f g a) -- Defined in ‘Data.Functor.Product’ -instance [safe] forall k (f :: k -> *) (g :: k -> *) (a :: k). (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable f, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable g, ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.Typeable k, GHC.Internal.Data.Data.Data (f a), GHC.Internal.Data.Data.Data (g a)) => GHC.Internal.Data.Data.Data (Data.Functor.Sum.Sum f g a) -- Defined in ‘Data.Functor.Sum’ +instance forall k (a :: k). (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable k, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a) => GHC.Internal.Data.Data.Data (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ +instance forall k1 (f :: k1 -> *) k2 (g :: k2 -> k1) (a :: k2). (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable f, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable g, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable k1, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable k2, GHC.Internal.Data.Data.Data (f (g a))) => GHC.Internal.Data.Data.Data (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ +instance [safe] forall k (f :: k -> *) (g :: k -> *) (a :: k). (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable f, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable g, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable k, GHC.Internal.Data.Data.Data (f a), GHC.Internal.Data.Data.Data (g a)) => GHC.Internal.Data.Data.Data (Data.Functor.Product.Product f g a) -- Defined in ‘Data.Functor.Product’ +instance [safe] forall k (f :: k -> *) (g :: k -> *) (a :: k). (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable a, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable f, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable g, ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.Typeable k, GHC.Internal.Data.Data.Data (f a), GHC.Internal.Data.Data.Data (g a)) => GHC.Internal.Data.Data.Data (Data.Functor.Sum.Sum f g a) -- Defined in ‘Data.Functor.Sum’ instance forall a b. (GHC.Internal.Data.Data.Data a, GHC.Internal.Data.Data.Data b) => GHC.Internal.Data.Data.Data (Data.Semigroup.Arg a b) -- Defined in ‘Data.Semigroup’ instance forall a. GHC.Internal.Data.Data.Data a => GHC.Internal.Data.Data.Data (Data.Semigroup.First a) -- Defined in ‘Data.Semigroup’ instance forall a. GHC.Internal.Data.Data.Data a => GHC.Internal.Data.Data.Data (Data.Semigroup.Last a) -- Defined in ‘Data.Semigroup’ @@ -11785,7 +11785,7 @@ instance GHC.Internal.Data.Type.Equality.TestEquality GHC.Internal.TypeLits.SCha instance GHC.Internal.Data.Type.Equality.TestEquality GHC.Internal.TypeLits.SSymbol -- Defined in ‘GHC.Internal.TypeLits’ instance forall k (a :: k). GHC.Internal.Data.Type.Equality.TestEquality ((GHC.Internal.Data.Type.Equality.:~:) a) -- Defined in ‘GHC.Internal.Data.Type.Equality’ instance forall k1 k (a :: k1). GHC.Internal.Data.Type.Equality.TestEquality ((GHC.Internal.Data.Type.Equality.:~~:) a) -- Defined in ‘GHC.Internal.Data.Type.Equality’ -instance forall k. GHC.Internal.Data.Type.Equality.TestEquality ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.TypeRep -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal’ +instance forall k. GHC.Internal.Data.Type.Equality.TestEquality ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.TypeRep -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1). GHC.Internal.Data.Type.Equality.TestEquality f => GHC.Internal.Data.Type.Equality.TestEquality (Data.Functor.Compose.Compose f g) -- Defined in ‘Data.Functor.Compose’ instance forall a k (b :: k). GHC.Internal.Enum.Bounded a => GHC.Internal.Enum.Bounded (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall a. GHC.Internal.Enum.Bounded a => GHC.Internal.Enum.Bounded (GHC.Internal.Data.Bits.And a) -- Defined in ‘GHC.Internal.Data.Bits’ @@ -11865,6 +11865,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -11941,6 +11942,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Internal.Enum.Enum GHC.Internal.Event.Windows.ConsoleEvent.ConsoleEvent -- Defined in ‘GHC.Internal.Event.Windows.ConsoleEvent’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ @@ -11983,7 +11985,7 @@ instance GHC.Internal.Exception.Type.Exception GHC.Internal.Control.Exception.Ba instance GHC.Internal.Exception.Type.Exception GHC.Internal.Control.Exception.Base.RecUpdError -- Defined in ‘GHC.Internal.Control.Exception.Base’ instance GHC.Internal.Exception.Type.Exception GHC.Internal.Control.Exception.Base.TypeError -- Defined in ‘GHC.Internal.Control.Exception.Base’ instance GHC.Internal.Exception.Type.Exception GHC.Internal.Data.Dynamic.Dynamic -- Defined in ‘GHC.Internal.Data.Dynamic’ -instance [safe] GHC.Internal.Exception.Type.Exception ghc-internal-0.1.0.0:GHC.Internal.IO.Handle.Lock.Common.FileLockingNotSupported -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.IO.Handle.Lock.Common’ +instance [safe] GHC.Internal.Exception.Type.Exception ghc-internal-9.1001.0:GHC.Internal.IO.Handle.Lock.Common.FileLockingNotSupported -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.IO.Handle.Lock.Common’ instance GHC.Internal.Exception.Type.Exception GHC.Internal.IOPort.IOPortException -- Defined in ‘GHC.Internal.IOPort’ instance [safe] GHC.Internal.Exception.Type.Exception System.Timeout.Timeout -- Defined in ‘System.Timeout’ instance forall a k (b :: k). GHC.Internal.Float.Floating a => GHC.Internal.Float.Floating (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -12337,6 +12339,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -12449,6 +12452,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Internal.Read.Read GHC.Internal.Event.Windows.ConsoleEvent.ConsoleEvent -- Defined in ‘GHC.Internal.Event.Windows.ConsoleEvent’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12522,6 +12526,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -12568,6 +12573,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -12667,8 +12673,8 @@ instance GHC.Internal.Show.Show GHC.Internal.Data.Data.DataRep -- Defined in ‘ instance GHC.Internal.Show.Show GHC.Internal.Data.Data.DataType -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Internal.Show.Show GHC.Internal.Data.Data.Fixity -- Defined in ‘GHC.Internal.Data.Data’ instance forall k (s :: k). GHC.Internal.Show.Show (GHC.Internal.Data.Proxy.Proxy s) -- Defined in ‘GHC.Internal.Data.Proxy’ -instance GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal’ -instance forall k (a :: k). GHC.Internal.Show.Show (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.TypeRep a) -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal’ +instance GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal’ +instance forall k (a :: k). GHC.Internal.Show.Show (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.TypeRep a) -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal’ instance GHC.Internal.Show.Show GHC.Internal.Data.Dynamic.Dynamic -- Defined in ‘GHC.Internal.Data.Dynamic’ instance forall a b. (GHC.Internal.Show.Show a, GHC.Internal.Show.Show b) => GHC.Internal.Show.Show (GHC.Internal.Data.Either.Either a b) -- Defined in ‘GHC.Internal.Data.Either’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Show.Show (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ @@ -12743,6 +12749,7 @@ instance GHC.Internal.Show.Show GHC.Internal.Event.Windows.ConsoleEvent.ConsoleE instance forall a. GHC.Internal.Show.Show a => GHC.Internal.Show.Show (GHC.Internal.Event.Windows.CbResult a) -- Defined in ‘GHC.Internal.Event.Windows’ instance GHC.Internal.Show.Show GHC.Internal.Event.Windows.HandleKey -- Defined in ‘GHC.Internal.Event.Windows’ instance GHC.Internal.Show.Show GHC.Internal.Event.Windows.FFI.IOCP -- Defined in ‘GHC.Internal.Event.Windows.FFI’ +instance GHC.Internal.Show.Show GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Show.Show GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance GHC.Internal.Show.Show GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Show.Show GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ @@ -12775,7 +12782,7 @@ instance GHC.Internal.Show.Show GHC.Internal.IO.Handle.Types.Handle -- Defined i instance GHC.Internal.Show.Show GHC.Internal.IO.Handle.Types.HandleType -- Defined in ‘GHC.Internal.IO.Handle.Types’ instance GHC.Internal.Show.Show GHC.Internal.IO.Handle.Types.Newline -- Defined in ‘GHC.Internal.IO.Handle.Types’ instance GHC.Internal.Show.Show GHC.Internal.IO.Handle.Types.NewlineMode -- Defined in ‘GHC.Internal.IO.Handle.Types’ -instance [safe] GHC.Internal.Show.Show ghc-internal-0.1.0.0:GHC.Internal.IO.Handle.Lock.Common.FileLockingNotSupported -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.IO.Handle.Lock.Common’ +instance [safe] GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.IO.Handle.Lock.Common.FileLockingNotSupported -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.IO.Handle.Lock.Common’ instance GHC.Internal.Show.Show GHC.Internal.IO.Handle.HandlePosn -- Defined in ‘GHC.Internal.IO.Handle’ instance GHC.Internal.Show.Show GHC.Internal.IO.IOMode.IOMode -- Defined in ‘GHC.Internal.IO.IOMode’ instance GHC.Internal.Show.Show GHC.Internal.IO.Windows.Handle.CONSOLE_READCONSOLE_CONTROL -- Defined in ‘GHC.Internal.IO.Windows.Handle’ @@ -12873,8 +12880,8 @@ instance GHC.Classes.Eq GHC.Internal.Data.Data.ConstrRep -- Defined in ‘GHC.In instance GHC.Classes.Eq GHC.Internal.Data.Data.DataRep -- Defined in ‘GHC.Internal.Data.Data’ instance GHC.Classes.Eq GHC.Internal.Data.Data.Fixity -- Defined in ‘GHC.Internal.Data.Data’ instance forall k (s :: k). GHC.Classes.Eq (GHC.Internal.Data.Proxy.Proxy s) -- Defined in ‘GHC.Internal.Data.Proxy’ -instance GHC.Classes.Eq ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal’ -instance forall k (a :: k). GHC.Classes.Eq (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.TypeRep a) -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal’ +instance GHC.Classes.Eq ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal’ +instance forall k (a :: k). GHC.Classes.Eq (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.TypeRep a) -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal’ instance forall a b. (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (GHC.Internal.Data.Either.Either a b) -- Defined in ‘GHC.Internal.Data.Either’ instance forall k (a :: k). GHC.Classes.Eq (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Classes.Eq (f (g a)) => GHC.Classes.Eq (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -12956,6 +12963,7 @@ instance GHC.Classes.Eq GHC.Internal.Event.Windows.HandleKey -- Defined in ‘GH instance GHC.Classes.Eq GHC.Internal.Event.Windows.FFI.IOCP -- Defined in ‘GHC.Internal.Event.Windows.FFI’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -13050,8 +13058,8 @@ instance GHC.Classes.Ord GHC.Internal.Unicode.GeneralCategory -- Defined in ‘G instance forall k (a :: k) (b :: k). GHC.Classes.Ord (a GHC.Internal.Data.Type.Equality.:~: b) -- Defined in ‘GHC.Internal.Data.Type.Equality’ instance forall k1 k2 (a :: k1) (b :: k2). GHC.Classes.Ord (a GHC.Internal.Data.Type.Equality.:~~: b) -- Defined in ‘GHC.Internal.Data.Type.Equality’ instance forall k (s :: k). GHC.Classes.Ord (GHC.Internal.Data.Proxy.Proxy s) -- Defined in ‘GHC.Internal.Data.Proxy’ -instance GHC.Classes.Ord ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal’ -instance forall k (a :: k). GHC.Classes.Ord (ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal.TypeRep a) -- Defined in ‘ghc-internal-0.1.0.0:GHC.Internal.Data.Typeable.Internal’ +instance GHC.Classes.Ord ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.SomeTypeRep -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal’ +instance forall k (a :: k). GHC.Classes.Ord (ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal.TypeRep a) -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Data.Typeable.Internal’ instance forall a b. (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (GHC.Internal.Data.Either.Either a b) -- Defined in ‘GHC.Internal.Data.Either’ instance forall k (a :: k). GHC.Classes.Ord (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Classes.Ord (f (g a)) => GHC.Classes.Ord (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -13124,6 +13132,7 @@ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.I instance GHC.Classes.Ord GHC.Internal.Event.Windows.ConsoleEvent.ConsoleEvent -- Defined in ‘GHC.Internal.Event.Windows.ConsoleEvent’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ instance GHC.Classes.Ord GHC.Internal.Event.Windows.FFI.IOCP -- Defined in ‘GHC.Internal.Event.Windows.FFI’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -11601,6 +11601,7 @@ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CULong -- Define instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Bounded GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Bounded GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’ instance GHC.Internal.Enum.Bounded GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’ @@ -11676,6 +11677,7 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Enum.Enum GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Enum.Enum GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’ @@ -12060,6 +12062,7 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Num.Num GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Num.Num GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Num.Num GHC.Types.Int -- Defined in ‘GHC.Internal.Num’ @@ -12171,6 +12174,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Define instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ +instance GHC.Internal.Read.Read GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12244,6 +12248,7 @@ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULLong -- Defi instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CULong -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Integral GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Integral GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance forall a k (b :: k). GHC.Internal.Real.Real a => GHC.Internal.Real.Real (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Real (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Real (f (g a)) => GHC.Internal.Real.Real (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’ @@ -12290,6 +12295,7 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance GHC.Internal.Real.Real GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Real.Real GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Real.Real GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ @@ -12468,6 +12474,7 @@ instance GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.Event.Interna instance GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.Event.Manager.FdKey -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.Event.Manager.State -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Event.Manager’ instance GHC.Internal.Show.Show ghc-internal-9.1001.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Event.TimerManager’ +instance GHC.Internal.Show.Show GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Internal.Show.Show GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance GHC.Internal.Show.Show GHC.Types.Double -- Defined in ‘GHC.Internal.Float’ instance GHC.Internal.Show.Show GHC.Types.Float -- Defined in ‘GHC.Internal.Float’ @@ -12681,6 +12688,7 @@ instance GHC.Classes.Eq GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘G instance GHC.Classes.Eq ghc-internal-9.1001.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-9.1001.0:GHC.Internal.Event.TimerManager’ instance GHC.Classes.Eq GHC.Internal.Stack.Types.SrcLoc -- Defined in ‘GHC.Internal.Stack.Types’ instance GHC.Classes.Eq GHC.Internal.Exts.SpecConstrAnnotation -- Defined in ‘GHC.Internal.Exts’ +instance GHC.Classes.Eq GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Eq GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12846,6 +12854,7 @@ instance forall a. GHC.Classes.Ord (GHC.Internal.Foreign.C.ConstPtr.ConstPtr a) instance forall i e. (GHC.Internal.Ix.Ix i, GHC.Classes.Ord e) => GHC.Classes.Ord (GHC.Internal.Arr.Array i e) -- Defined in ‘GHC.Internal.Arr’ instance GHC.Classes.Ord GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’ instance GHC.Classes.Ord GHC.Internal.Event.TimeOut.TimeoutKey -- Defined in ‘GHC.Internal.Event.TimeOut’ +instance GHC.Classes.Ord GHC.Internal.Stack.CCS.CostCentreId -- Defined in ‘GHC.Internal.Stack.CCS’ instance GHC.Classes.Ord GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a4c74ecd18f186ac297061546f2a784140953eff -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a4c74ecd18f186ac297061546f2a784140953eff You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 19:41:22 2024 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Sat, 04 May 2024 15:41:22 -0400 Subject: [Git][ghc/ghc][wip/t24277] 18 commits: GHCi: support inlining breakpoints (#24712) Message-ID: <66368f62e8df7_1b12c02c361607507c@gitlab.mail> Finley McIlwaine pushed to branch wip/t24277 at Glasgow Haskell Compiler / GHC Commits: b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 7889f39d by Finley McIlwaine at 2024-05-04T12:41:13-07:00 ghc-internal: Add CostCentreId, currentCallStackIds, ccsToIds, ccId Add functions for gettings the IDs of cost centres to the interface of `GHC.Internal.Stack`, `GHC.Internal.Stack.CCS`, and `GHC.Internal.Exts`. Also add an opaque type for cost center ids, `CostCentreId`, with appropriate instances. Resolves #24277 - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Eval/Types.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/Stg/Subst.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a4c74ecd18f186ac297061546f2a784140953eff...7889f39deca14d80a2e5a72426423e0e93684740 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a4c74ecd18f186ac297061546f2a784140953eff...7889f39deca14d80a2e5a72426423e0e93684740 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 19:46:15 2024 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Sat, 04 May 2024 15:46:15 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/9.10-specialist-compat Message-ID: <6636908744ef8_1b12c02dc5ae475997@gitlab.mail> Finley McIlwaine pushed new branch wip/9.10-specialist-compat at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/9.10-specialist-compat You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 20:13:36 2024 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Sat, 04 May 2024 16:13:36 -0400 Subject: [Git][ghc/ghc][wip/ghc-platform-setup] 17 commits: Expose constructors of SNat, SChar and SSymbol in ghc-internal Message-ID: <663696f0ad985_1b12c0324cc8480559@gitlab.mail> Cheng Shao pushed to branch wip/ghc-platform-setup at Glasgow Haskell Compiler / GHC Commits: 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 254b851d by Ben Gamari at 2024-05-04T20:13:27+00:00 ghc-platform: Add Setup.hs The Hadrian bootstrapping script relies upon `Setup.hs` to drive its build. Addresses #24761. - - - - - 30 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Stg/Subst.hs - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/StgToJS/Linker/Utils.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Utils.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cb5594f0ae85db3121eb4fc5908194b37d0c6325...254b851df9ba379da2a191f3b62b1ed5f0d4a711 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cb5594f0ae85db3121eb4fc5908194b37d0c6325...254b851df9ba379da2a191f3b62b1ed5f0d4a711 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 20:15:55 2024 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Sat, 04 May 2024 16:15:55 -0400 Subject: [Git][ghc/ghc][wip/mr-12520] 17 commits: Expose constructors of SNat, SChar and SSymbol in ghc-internal Message-ID: <6636977bca9be_1b12c0331b46c8098f@gitlab.mail> Cheng Shao pushed to branch wip/mr-12520 at Glasgow Haskell Compiler / GHC Commits: 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 04b3904e by Moritz Schuler at 2024-05-04T20:15:45+00:00 Fix parsing of module names in CLI arguments closes issue #24732 - - - - - 30 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Stg/Subst.hs - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/StgToJS/Linker/Utils.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Utils.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3ca78df6464c84208137973b472f5d08d4c9041d...04b3904e65ed3954d05cdd129dfa30f56ace7cdb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3ca78df6464c84208137973b472f5d08d4c9041d...04b3904e65ed3954d05cdd129dfa30f56ace7cdb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 20:39:02 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 04 May 2024 16:39:02 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: tests: Widen acceptance window for dir and so size tests Message-ID: <66369ce62be8e_1b12c036ba4888662@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 7eab4e01 by Alan Zimmerman at 2024-05-04T16:14:55+01:00 EPA: Widen stmtslist to include last semicolon Closes #24754 - - - - - 46b618dd by Teo Camarasu at 2024-05-04T16:38:51-04:00 doc: Fix type error in hs_try_putmvar example - - - - - 10 changed files: - compiler/GHC/Parser.y - docs/users_guide/exts/ffi.rst - libraries/template-haskell/Language/Haskell/TH/Lib/Syntax.hs - testsuite/tests/parser/should_compile/DumpSemis.stderr - testsuite/tests/perf/size/all.T - testsuite/tests/printer/Makefile - + testsuite/tests/printer/Test24754.hs - testsuite/tests/printer/all.T - + testsuite/tests/quotes/T24750.hs - testsuite/tests/quotes/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -3444,7 +3444,7 @@ stmts :: { forall b. DisambECP b => PV (Located (OrdList AddEpAnn,[LStmt GhcPs ( [] -> return (sLZ $1 $> ((fst $ unLoc $1) `snocOL` (mj AnnSemi $2),snd $ unLoc $1)) (h:t) -> do { h' <- addTrailingSemiA h (gl $2) - ; return $ sL1 $1 (fst $ unLoc $1,h':t) }} + ; return $ sLZ $1 $> (fst $ unLoc $1,h':t) }} | stmt { $1 >>= \ $1 -> return $ sL1 $1 (nilOL,[$1]) } | {- empty -} { return $ noLoc (nilOL,[]) } ===================================== docs/users_guide/exts/ffi.rst ===================================== @@ -998,7 +998,7 @@ the data. We can do it like this: sp <- newStablePtrPrimMVar mvar fp <- mallocForeignPtr withForeignPtr fp $ \presult -> do - cap <- threadCapability =<< myThreadId + (cap, _) <- threadCapability =<< myThreadId scheduleCallback sp cap presult takeMVar mvar `onException` forkIO (do takeMVar mvar; touchForeignPtr fp) ===================================== libraries/template-haskell/Language/Haskell/TH/Lib/Syntax.hs ===================================== @@ -1955,7 +1955,7 @@ unboxedSumDataName alt arity | otherwise = Name (mkOccName sum_occ) - (NameG DataName (mkPkgName "ghc-prim") (mkModName "GHC.Prim")) + (NameG DataName (mkPkgName "ghc-prim") (mkModName "GHC.Types")) where prefix = "unboxedSumDataName: " @@ -1974,11 +1974,11 @@ unboxedSumTypeName arity | otherwise = Name (mkOccName sum_occ) - (NameG TcClsName (mkPkgName "ghc-prim") (mkModName "GHC.Prim")) + (NameG TcClsName (mkPkgName "ghc-prim") (mkModName "GHC.Types")) where -- Synced with the definition of mkSumTyConOcc in GHC.Builtin.Types - sum_occ = '(' : '#' : replicate (arity - 1) '|' ++ "#)" + sum_occ = "Sum" ++ show arity ++ "#" ----------------------------------------------------- -- Locations ===================================== testsuite/tests/parser/should_compile/DumpSemis.stderr ===================================== @@ -856,7 +856,7 @@ (EpaSpan { DumpSemis.hs:22:10-30 }) (AnnList (Just - (EpaSpan { DumpSemis.hs:22:12-25 })) + (EpaSpan { DumpSemis.hs:22:12-28 })) (Just (AddEpAnn AnnOpenC (EpaSpan { DumpSemis.hs:22:10 }))) (Just ===================================== testsuite/tests/perf/size/all.T ===================================== @@ -3,77 +3,80 @@ test('size_hello_obj', [collect_size(5, 'size_hello_obj.o')], compile, ['']) test('size_hello_artifact', [collect_size(5, 'size_hello_artifact' + exe_extension())], compile_artifact, ['']) -test('array_dir' ,[collect_size_ghc_pkg(5 , 'array')] , static_stats , [] ) -test('base_dir' ,[collect_size_ghc_pkg(5 , 'base')] , static_stats , [] ) -test('binary_dir' ,[collect_size_ghc_pkg(5 , 'binary')] , static_stats , [] ) -test('bytestring_dir' ,[collect_size_ghc_pkg(5 , 'bytestring')] , static_stats , [] ) -test('cabal_dir' ,[collect_size_ghc_pkg(5 , 'Cabal')] , static_stats , [] ) -test('cabal_syntax_dir' ,[collect_size_ghc_pkg(5 , 'Cabal-syntax')] , static_stats , [] ) -test('containers_dir' ,[collect_size_ghc_pkg(5 , 'containers')] , static_stats , [] ) -test('deepseq_dir' ,[collect_size_ghc_pkg(5 , 'deepseq')] , static_stats , [] ) -test('directory_dir' ,[collect_size_ghc_pkg(5 , 'directory')] , static_stats , [] ) -test('exceptions_dir' ,[collect_size_ghc_pkg(5 , 'exceptions')] , static_stats , [] ) -test('ghc_bignum_dir' ,[collect_size_ghc_pkg(5 , 'ghc-bignum')] , static_stats , [] ) -test('ghc_boot_dir' ,[collect_size_ghc_pkg(5 , 'ghc-boot')] , static_stats , [] ) -test('ghc_boot_th_dir' ,[collect_size_ghc_pkg(5 , 'ghc-boot-th')] , static_stats , [] ) -test('ghc_compact_dir' ,[collect_size_ghc_pkg(5 , 'ghc-compact')] , static_stats , [] ) -test('ghc_dir' ,[collect_size_ghc_pkg(5 , 'ghc')] , static_stats , [] ) -test('ghc_experimental_dir',[collect_size_ghc_pkg(5 , 'ghc-experimental')], static_stats , [] ) -test('ghc_heap_dir' ,[collect_size_ghc_pkg(5 , 'ghc-heap')] , static_stats , [] ) -test('ghc_internal_dir' ,[collect_size_ghc_pkg(5 , 'ghc-internal')] , static_stats , [] ) -test('ghc_platform_dir' ,[collect_size_ghc_pkg(5 , 'ghc-platform')] , static_stats , [] ) -test('ghc_prim_dir' ,[collect_size_ghc_pkg(5 , 'ghc-prim')] , static_stats , [] ) -test('ghc_toolchain_dir' ,[collect_size_ghc_pkg(5 , 'ghc-toolchain')] , static_stats , [] ) -test('haskeline_dir' ,[collect_size_ghc_pkg(5 , 'haskeline')] , static_stats , [] ) -test('hpc_dir' ,[collect_size_ghc_pkg(5 , 'hpc')] , static_stats , [] ) -test('integer_gmp_dir' ,[collect_size_ghc_pkg(5 , 'integer-gmp')] , static_stats , [] ) -test('mtl_dir' ,[collect_size_ghc_pkg(5 , 'mtl')] , static_stats , [] ) -test('os_string_dir' ,[collect_size_ghc_pkg(5 , 'os-string')] , static_stats , [] ) -test('parsec_dir' ,[collect_size_ghc_pkg(5 , 'parsec')] , static_stats , [] ) -test('pretty_dir' ,[collect_size_ghc_pkg(5 , 'pretty')] , static_stats , [] ) -test('process_dir' ,[collect_size_ghc_pkg(5 , 'process')] , static_stats , [] ) -test('time_dir' ,[collect_size_ghc_pkg(5 , 'time')] , static_stats , [] ) -test('xhtml_dir' ,[collect_size_ghc_pkg(5 , 'xhtml')] , static_stats , [] ) +size_acceptance_threshold = 100 + +test('array_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'array')] , static_stats , [] ) +test('base_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'base')] , static_stats , [] ) +test('binary_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'binary')] , static_stats , [] ) +test('bytestring_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'bytestring')] , static_stats , [] ) +test('cabal_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'Cabal')] , static_stats , [] ) +test('cabal_syntax_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'Cabal-syntax')] , static_stats , [] ) +test('containers_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'containers')] , static_stats , [] ) +test('deepseq_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'deepseq')] , static_stats , [] ) +test('directory_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'directory')] , static_stats , [] ) +test('exceptions_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'exceptions')] , static_stats , [] ) +test('ghc_bignum_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-bignum')] , static_stats , [] ) +test('ghc_boot_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-boot')] , static_stats , [] ) +test('ghc_boot_th_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-boot-th')] , static_stats , [] ) +test('ghc_compact_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-compact')] , static_stats , [] ) +test('ghc_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc')] , static_stats , [] ) +test('ghc_experimental_dir',[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-experimental')], static_stats , [] ) +test('ghc_heap_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-heap')] , static_stats , [] ) +test('ghc_internal_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-internal')] , static_stats , [] ) +test('ghc_platform_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-platform')] , static_stats , [] ) +test('ghc_prim_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-prim')] , static_stats , [] ) +test('ghc_toolchain_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'ghc-toolchain')] , static_stats , [] ) +test('haskeline_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'haskeline')] , static_stats , [] ) +test('hpc_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'hpc')] , static_stats , [] ) +test('integer_gmp_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'integer-gmp')] , static_stats , [] ) +test('mtl_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'mtl')] , static_stats , [] ) +test('os_string_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'os-string')] , static_stats , [] ) +test('parsec_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'parsec')] , static_stats , [] ) +test('pretty_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'pretty')] , static_stats , [] ) +test('process_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'process')] , static_stats , [] ) +test('time_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'time')] , static_stats , [] ) +test('xhtml_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'xhtml')] , static_stats , [] ) # size of the entire libdir test('libdir' ,[collect_size_dir(10, config.libdir)] , static_stats , [] ) # skip these on windows -test('unix_dir' ,[windows_skip, collect_size_ghc_pkg(5, 'unix')] , static_stats, [] ) -test('terminfo_dir' ,[windows_skip, js_skip, collect_size_ghc_pkg(5, 'terminfo')], static_stats, [] ) +test('unix_dir' ,[windows_skip, collect_size_ghc_pkg(size_acceptance_threshold, 'unix')] , static_stats, [] ) +test('terminfo_dir' ,[windows_skip, js_skip, collect_size_ghc_pkg(size_acceptance_threshold, 'terminfo')], static_stats, [] ) # skip the shared object file tests on windows -test('array_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "array")] , static_stats, [] ) -test('base_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "base")] , static_stats, [] ) -test('binary_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "binary")] , static_stats, [] ) -test('bytestring_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "bytestring")] , static_stats, [] ) -test('cabal_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "Cabal")] , static_stats, [] ) -test('cabal_syntax_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "Cabal-syntax")] , static_stats, [] ) -test('containers_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "containers")] , static_stats, [] ) -test('deepseq_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "deepseq")] , static_stats, [] ) -test('directory_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "directory")] , static_stats, [] ) -test('exceptions_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "exceptions")] , static_stats, [] ) -test('filepath_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "filepath")] , static_stats, [] ) -test('ghc_bignum_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-bignum")] , static_stats, [] ) -test('ghc_boot_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-boot")] , static_stats, [] ) -test('ghc_boot_th_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-boot-th")] , static_stats, [] ) -test('ghc_experimental_so',[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-experimental")] , static_stats, [] ) -test('ghc_heap_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-heap")] , static_stats, [] ) -test('ghc_platform_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-platform")] , static_stats, [] ) -test('ghc_prim_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-prim")] , static_stats, [] ) -test('ghc_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc")] , static_stats, [] ) -test('ghc_toolchain_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghc-toolchain")] , static_stats, [] ) -test('ghci_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "ghci")] , static_stats, [] ) -test('haskeline_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "haskeline")] , static_stats, [] ) -test('hpc_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "hpc")] , static_stats, [] ) -test('mtl_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "mtl")] , static_stats, [] ) -test('os_string_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "os-string")] , static_stats, [] ) -test('parsec_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "parsec")] , static_stats, [] ) -test('process_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "process")] , static_stats, [] ) -test('rts_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "rts", True)] , static_stats, [] ) -test('template_haskell_so',[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "template-haskell")] , static_stats, [] ) -test('terminfo_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "terminfo")] , static_stats, [] ) -test('text_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "text")] , static_stats, [] ) -test('time_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "time")] , static_stats, [] ) -test('transformers_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "transformers")] , static_stats, [] ) -test('xhtml_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(5, "xhtml")] , static_stats, [] ) +test('array_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "array")] , static_stats, [] ) +test('base_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "base")] , static_stats, [] ) +test('binary_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "binary")] , static_stats, [] ) +test('bytestring_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "bytestring")] , static_stats, [] ) +test('cabal_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "Cabal")] , static_stats, [] ) +test('cabal_syntax_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "Cabal-syntax")] , static_stats, [] ) +test('containers_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "containers")] , static_stats, [] ) +test('deepseq_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "deepseq")] , static_stats, [] ) +test('directory_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "directory")] , static_stats, [] ) +test('exceptions_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "exceptions")] , static_stats, [] ) +test('filepath_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "filepath")] , static_stats, [] ) +test('ghc_bignum_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-bignum")] , static_stats, [] ) +test('ghc_boot_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-boot")] , static_stats, [] ) +test('ghc_boot_th_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-boot-th")] , static_stats, [] ) +test('ghc_experimental_so',[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-experimental")] , static_stats, [] ) +test('ghc_heap_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-heap")] , static_stats, [] ) +test('ghc_platform_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-platform")] , static_stats, [] ) +test('ghc_prim_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-prim")] , static_stats, [] ) +test('ghc_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc")] , static_stats, [] ) +test('ghc_toolchain_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghc-toolchain")] , static_stats, [] ) +test('ghci_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "ghci")] , static_stats, [] ) +test('haskeline_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "haskeline")] , static_stats, [] ) +test('hpc_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "hpc")] , static_stats, [] ) +test('mtl_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "mtl")] , static_stats, [] ) +test('os_string_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "os-string")] , static_stats, [] ) +test('parsec_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "parsec")] , static_stats, [] ) +test('process_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "process")] , static_stats, [] ) +# Disabled as extremely unstable +#test('rts_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "rts", True)] , static_stats, [] ) +test('template_haskell_so',[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "template-haskell")] , static_stats, [] ) +test('terminfo_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "terminfo")] , static_stats, [] ) +test('text_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "text")] , static_stats, [] ) +test('time_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "time")] , static_stats, [] ) +test('transformers_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "transformers")] , static_stats, [] ) +test('xhtml_so' ,[req_dynamic_ghc, js_skip, windows_skip, collect_object_size(size_acceptance_threshold, "xhtml")] , static_stats, [] ) ===================================== testsuite/tests/printer/Makefile ===================================== @@ -851,3 +851,8 @@ DataDeclShort: Test24749: $(CHECK_PPR) $(LIBDIR) Test24749.hs $(CHECK_EXACT) $(LIBDIR) Test24749.hs + +.PHONY: Test24754 +Test24754: + $(CHECK_PPR) $(LIBDIR) Test24754.hs + $(CHECK_EXACT) $(LIBDIR) Test24754.hs ===================================== testsuite/tests/printer/Test24754.hs ===================================== @@ -0,0 +1,4 @@ +module Test24754 where + +eh1 = try (do return r;) <|> (do + return r) ===================================== testsuite/tests/printer/all.T ===================================== @@ -203,3 +203,4 @@ test('MatchPatComments', [ignore_stderr, req_ppr_deps], makefile_test, ['MatchPa test('Test24748', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24748']) test('DataDeclShort', [ignore_stderr, req_ppr_deps], makefile_test, ['DataDeclShort']) test('Test24749', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24749']) +test('Test24754', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24754']) ===================================== testsuite/tests/quotes/T24750.hs ===================================== @@ -0,0 +1,35 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE TemplateHaskellQuotes #-} +{-# LANGUAGE UnboxedTuples #-} +-- A regression test for #24750. This test ensures that a family of functions +-- from the `template-haskell` library (tupeTypeName, tupleDataName, etc.) +-- returns the same Names as when you manually quote the names using +-- TemplateHaskellQuotes. +module Main (main) where + +import Control.Monad (unless) +import GHC.Tuple (Tuple2) +import GHC.Types (Sum2#, Tuple2#) +import Language.Haskell.TH + +test :: Name -> Name -> IO () +test n1 n2 = + unless (n1 == n2) $ + fail $ unlines + [ "Names are not equal" + , "LHS name: " ++ show n1 + , "RHS name: " ++ show n2 + ] + +main :: IO () +main = do + test (tupleTypeName 2) ''(,) + test (tupleTypeName 2) ''Tuple2 + test (tupleDataName 2) '(,) + test (unboxedTupleTypeName 2) ''(#,#) + test (unboxedTupleTypeName 2) ''Tuple2# + test (unboxedTupleDataName 2) '(#,#) + test (unboxedSumTypeName 2) ''Sum2# + -- There is currently no way to manually quote an unboxed sum data constructor + -- Name, as you cannot write unboxed sum data constructors in prefix form. As + -- such, a test case for `unboxedSumDataName` is omitted. ===================================== testsuite/tests/quotes/all.T ===================================== @@ -42,3 +42,4 @@ test('T20688', normal, compile, ['-Wimplicit-lift -Werror']) test('T20893', normal, compile_and_run, ['']) test('T21619', normal, compile, ['']) test('T20472_quotes', normal, compile, ['']) +test('T24750', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7c3dd23ae4a80dea03d7985fbcf3d9e3b8aa9656...46b618dd0cd7d894ce5da3319ed0da5963d87a9e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7c3dd23ae4a80dea03d7985fbcf3d9e3b8aa9656...46b618dd0cd7d894ce5da3319ed0da5963d87a9e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat May 4 21:59:40 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Sat, 04 May 2024 17:59:40 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24768 Message-ID: <6636afccbeba3_1b12c04120b20942f9@gitlab.mail> Simon Peyton Jones pushed new branch wip/T24768 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24768 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun May 5 04:19:36 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 05 May 2024 00:19:36 -0400 Subject: [Git][ghc/ghc][master] EPA: Widen stmtslist to include last semicolon Message-ID: <663708d82312_901b124b2790859a9@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 7eab4e01 by Alan Zimmerman at 2024-05-04T16:14:55+01:00 EPA: Widen stmtslist to include last semicolon Closes #24754 - - - - - 5 changed files: - compiler/GHC/Parser.y - testsuite/tests/parser/should_compile/DumpSemis.stderr - testsuite/tests/printer/Makefile - + testsuite/tests/printer/Test24754.hs - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -3444,7 +3444,7 @@ stmts :: { forall b. DisambECP b => PV (Located (OrdList AddEpAnn,[LStmt GhcPs ( [] -> return (sLZ $1 $> ((fst $ unLoc $1) `snocOL` (mj AnnSemi $2),snd $ unLoc $1)) (h:t) -> do { h' <- addTrailingSemiA h (gl $2) - ; return $ sL1 $1 (fst $ unLoc $1,h':t) }} + ; return $ sLZ $1 $> (fst $ unLoc $1,h':t) }} | stmt { $1 >>= \ $1 -> return $ sL1 $1 (nilOL,[$1]) } | {- empty -} { return $ noLoc (nilOL,[]) } ===================================== testsuite/tests/parser/should_compile/DumpSemis.stderr ===================================== @@ -856,7 +856,7 @@ (EpaSpan { DumpSemis.hs:22:10-30 }) (AnnList (Just - (EpaSpan { DumpSemis.hs:22:12-25 })) + (EpaSpan { DumpSemis.hs:22:12-28 })) (Just (AddEpAnn AnnOpenC (EpaSpan { DumpSemis.hs:22:10 }))) (Just ===================================== testsuite/tests/printer/Makefile ===================================== @@ -851,3 +851,8 @@ DataDeclShort: Test24749: $(CHECK_PPR) $(LIBDIR) Test24749.hs $(CHECK_EXACT) $(LIBDIR) Test24749.hs + +.PHONY: Test24754 +Test24754: + $(CHECK_PPR) $(LIBDIR) Test24754.hs + $(CHECK_EXACT) $(LIBDIR) Test24754.hs ===================================== testsuite/tests/printer/Test24754.hs ===================================== @@ -0,0 +1,4 @@ +module Test24754 where + +eh1 = try (do return r;) <|> (do + return r) ===================================== testsuite/tests/printer/all.T ===================================== @@ -203,3 +203,4 @@ test('MatchPatComments', [ignore_stderr, req_ppr_deps], makefile_test, ['MatchPa test('Test24748', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24748']) test('DataDeclShort', [ignore_stderr, req_ppr_deps], makefile_test, ['DataDeclShort']) test('Test24749', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24749']) +test('Test24754', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24754']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7eab4e019205cfced90f06242a9afa23dfcaa70b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7eab4e019205cfced90f06242a9afa23dfcaa70b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun May 5 04:20:34 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 05 May 2024 00:20:34 -0400 Subject: [Git][ghc/ghc][master] doc: Fix type error in hs_try_putmvar example Message-ID: <663709127160d_901b127d961c890f1@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 06f7db40 by Teo Camarasu at 2024-05-05T00:19:38-04:00 doc: Fix type error in hs_try_putmvar example - - - - - 1 changed file: - docs/users_guide/exts/ffi.rst Changes: ===================================== docs/users_guide/exts/ffi.rst ===================================== @@ -998,7 +998,7 @@ the data. We can do it like this: sp <- newStablePtrPrimMVar mvar fp <- mallocForeignPtr withForeignPtr fp $ \presult -> do - cap <- threadCapability =<< myThreadId + (cap, _) <- threadCapability =<< myThreadId scheduleCallback sp cap presult takeMVar mvar `onException` forkIO (do takeMVar mvar; touchForeignPtr fp) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/06f7db4001e4eee0f3076d949876f8f4af0eb6fb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/06f7db4001e4eee0f3076d949876f8f4af0eb6fb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun May 5 04:50:57 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 05 May 2024 00:50:57 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: doc: Fix type error in hs_try_putmvar example Message-ID: <66371031a2353_901b12c34c989044@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 06f7db40 by Teo Camarasu at 2024-05-05T00:19:38-04:00 doc: Fix type error in hs_try_putmvar example - - - - - fc9b9c68 by Moritz Schuler at 2024-05-05T00:50:50-04:00 Fix parsing of module names in CLI arguments closes issue #24732 - - - - - 7d772b1b by Ben Gamari at 2024-05-05T00:50:51-04:00 ghc-platform: Add Setup.hs The Hadrian bootstrapping script relies upon `Setup.hs` to drive its build. Addresses #24761. - - - - - 6 changed files: - compiler/Language/Haskell/Syntax/Module/Name.hs - docs/users_guide/exts/ffi.rst - + libraries/ghc-platform/Setup.hs - + testsuite/tests/rename/should_compile/T24732.hs - + testsuite/tests/rename/should_compile/T24732.stdout - testsuite/tests/rename/should_compile/all.T Changes: ===================================== compiler/Language/Haskell/Syntax/Module/Name.hs ===================================== @@ -56,5 +56,5 @@ moduleNameColons = dots_to_colons . moduleNameString parseModuleName :: Parse.ReadP ModuleName parseModuleName = fmap mkModuleName - $ Parse.munch1 (\c -> isAlphaNum c || c `elem` "_.") + $ Parse.munch1 (\c -> isAlphaNum c || c `elem` "_.'") ===================================== docs/users_guide/exts/ffi.rst ===================================== @@ -998,7 +998,7 @@ the data. We can do it like this: sp <- newStablePtrPrimMVar mvar fp <- mallocForeignPtr withForeignPtr fp $ \presult -> do - cap <- threadCapability =<< myThreadId + (cap, _) <- threadCapability =<< myThreadId scheduleCallback sp cap presult takeMVar mvar `onException` forkIO (do takeMVar mvar; touchForeignPtr fp) ===================================== libraries/ghc-platform/Setup.hs ===================================== @@ -0,0 +1,6 @@ +module Main (main) where + +import Distribution.Simple + +main :: IO () +main = defaultMain ===================================== testsuite/tests/rename/should_compile/T24732.hs ===================================== @@ -0,0 +1,4 @@ +import P' + +main :: IO () +main = printf "Hello World\n" \ No newline at end of file ===================================== testsuite/tests/rename/should_compile/T24732.stdout ===================================== @@ -0,0 +1 @@ +Hello World ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -223,3 +223,4 @@ test('T22478a', req_th, compile, ['']) test('RecordWildCardDeprecation', normal, multimod_compile, ['RecordWildCardDeprecation', '-Wno-duplicate-exports']) test('T14032b', normal, compile_and_run, ['']) test('T14032d', normal, compile, ['']) +test('T24732', normal, compile_and_run, ['-package "base(Prelude, Text.Printf as P\')"']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/46b618dd0cd7d894ce5da3319ed0da5963d87a9e...7d772b1b152264ba82bcd73457e63f3bdae0e7e0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/46b618dd0cd7d894ce5da3319ed0da5963d87a9e...7d772b1b152264ba82bcd73457e63f3bdae0e7e0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun May 5 09:05:52 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sun, 05 May 2024 05:05:52 -0400 Subject: [Git][ghc/ghc][wip/az/T24755-epa-checktyclhdr-comments] 21 commits: testsuite: expand size testing infrastructure Message-ID: <66374bf02b0d2_901b148782d898551@gitlab.mail> Alan Zimmerman pushed to branch wip/az/T24755-epa-checktyclhdr-comments at Glasgow Haskell Compiler / GHC Commits: 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 7eab4e01 by Alan Zimmerman at 2024-05-04T16:14:55+01:00 EPA: Widen stmtslist to include last semicolon Closes #24754 - - - - - 06f7db40 by Teo Camarasu at 2024-05-05T00:19:38-04:00 doc: Fix type error in hs_try_putmvar example - - - - - 5cd969ee by Alan Zimmerman at 2024-05-05T10:05:37+01:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Eval/Types.hs - compiler/GHC/Runtime/Interpreter.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0f1763a51973ea37fa041901acb8efc4a38d9cd0...5cd969eefded70ebe709ca42818eb089af79212a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0f1763a51973ea37fa041901acb8efc4a38d9cd0...5cd969eefded70ebe709ca42818eb089af79212a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun May 5 10:31:29 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 05 May 2024 06:31:29 -0400 Subject: [Git][ghc/ghc][master] Fix parsing of module names in CLI arguments Message-ID: <66376001c3fbc_3272685cf91895826@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: af000532 by Moritz Schuler at 2024-05-05T06:30:58-04:00 Fix parsing of module names in CLI arguments closes issue #24732 - - - - - 4 changed files: - compiler/Language/Haskell/Syntax/Module/Name.hs - + testsuite/tests/rename/should_compile/T24732.hs - + testsuite/tests/rename/should_compile/T24732.stdout - testsuite/tests/rename/should_compile/all.T Changes: ===================================== compiler/Language/Haskell/Syntax/Module/Name.hs ===================================== @@ -56,5 +56,5 @@ moduleNameColons = dots_to_colons . moduleNameString parseModuleName :: Parse.ReadP ModuleName parseModuleName = fmap mkModuleName - $ Parse.munch1 (\c -> isAlphaNum c || c `elem` "_.") + $ Parse.munch1 (\c -> isAlphaNum c || c `elem` "_.'") ===================================== testsuite/tests/rename/should_compile/T24732.hs ===================================== @@ -0,0 +1,4 @@ +import P' + +main :: IO () +main = printf "Hello World\n" \ No newline at end of file ===================================== testsuite/tests/rename/should_compile/T24732.stdout ===================================== @@ -0,0 +1 @@ +Hello World ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -223,3 +223,4 @@ test('T22478a', req_th, compile, ['']) test('RecordWildCardDeprecation', normal, multimod_compile, ['RecordWildCardDeprecation', '-Wno-duplicate-exports']) test('T14032b', normal, compile_and_run, ['']) test('T14032d', normal, compile, ['']) +test('T24732', normal, compile_and_run, ['-package "base(Prelude, Text.Printf as P\')"']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/af0005324ddc64daf717f5bdaa953ec26a9a2346 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/af0005324ddc64daf717f5bdaa953ec26a9a2346 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun May 5 10:32:06 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 05 May 2024 06:32:06 -0400 Subject: [Git][ghc/ghc][master] ghc-platform: Add Setup.hs Message-ID: <6637602614ad3_3272687348a89899@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: da74e9c9 by Ben Gamari at 2024-05-05T06:31:34-04:00 ghc-platform: Add Setup.hs The Hadrian bootstrapping script relies upon `Setup.hs` to drive its build. Addresses #24761. - - - - - 1 changed file: - + libraries/ghc-platform/Setup.hs Changes: ===================================== libraries/ghc-platform/Setup.hs ===================================== @@ -0,0 +1,6 @@ +module Main (main) where + +import Distribution.Simple + +main :: IO () +main = defaultMain View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/da74e9c9d4760dab453ca127bd69126a1cfce4ad -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/da74e9c9d4760dab453ca127bd69126a1cfce4ad You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun May 5 11:01:46 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sun, 05 May 2024 07:01:46 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/az/T24753-epa-mkhsoptypv-dup-comments Message-ID: <6637671ab973_327268adc94c9911a@gitlab.mail> Alan Zimmerman pushed new branch wip/az/T24753-epa-mkhsoptypv-dup-comments at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/T24753-epa-mkhsoptypv-dup-comments You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun May 5 11:32:45 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 05 May 2024 07:32:45 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Fix parsing of module names in CLI arguments Message-ID: <66376e5d51a35_327268e576a810374f@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: af000532 by Moritz Schuler at 2024-05-05T06:30:58-04:00 Fix parsing of module names in CLI arguments closes issue #24732 - - - - - da74e9c9 by Ben Gamari at 2024-05-05T06:31:34-04:00 ghc-platform: Add Setup.hs The Hadrian bootstrapping script relies upon `Setup.hs` to drive its build. Addresses #24761. - - - - - 48394a57 by Alan Zimmerman at 2024-05-05T07:32:32-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 - - - - - 5a02a27c by Simon Peyton Jones at 2024-05-05T07:32:32-04:00 Fix a float-out error Ticket #24768 showed that the Simplifier was accidentally destroying a join point. It turned out to be that we were sending a bottoming join point to the top, accidentally abstracting over /other/ join points. Easily fixed. - - - - - 12 changed files: - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Parser/PostProcess.hs - compiler/Language/Haskell/Syntax/Module/Name.hs - + libraries/ghc-platform/Setup.hs - testsuite/tests/printer/Makefile - + testsuite/tests/printer/Test24755.hs - testsuite/tests/printer/all.T - + testsuite/tests/rename/should_compile/T24732.hs - + testsuite/tests/rename/should_compile/T24732.stdout - testsuite/tests/rename/should_compile/all.T - + testsuite/tests/simplCore/should_compile/T24768.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -1088,6 +1088,11 @@ But, as ever, we need to be careful: as /another/ MFE, so we tell lvlFloatRhs not to do that, via the is_bot argument. + Do /not/ do this for bottoming /join-point/ bindings. They may call other + join points (#24768), and floating to the top would abstract over those join + points, which we should never do. + + See Maessen's paper 1999 "Bottom extraction: factoring error handling out of functional programs" (unpublished I think). @@ -1252,9 +1257,11 @@ lvlBind env (AnnNonRec bndr rhs) deann_rhs = deAnnotate rhs mb_bot_str = exprBotStrictness_maybe deann_rhs - is_bot_lam = isJust mb_bot_str + is_bot_lam = not is_join && isJust mb_bot_str -- is_bot_lam: looks like (\xy. bot), maybe zero lams - -- NB: not isBottomThunk! See Note [Bottoming floats] point (3) + -- NB: not isBottomThunk! + -- NB: not is_join: don't send bottoming join points to the top. + -- See Note [Bottoming floats] point (3) is_top_bindable = exprIsTopLevelBindable deann_rhs bndr_ty n_extra = count isId abs_vars ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -204,11 +204,11 @@ mkClassDecl :: SrcSpan -> P (LTyClDecl GhcPs) mkClassDecl loc' (L _ (mcxt, tycl_hdr)) fds where_cls layout annsIn - = do { let loc = noAnnSrcSpan loc' - ; (binds, sigs, ats, at_defs, _, docs) <- cvBindsAndSigs where_cls - ; (cls, tparams, fixity, ann) <- checkTyClHdr True tycl_hdr + = do { (binds, sigs, ats, at_defs, _, docs) <- cvBindsAndSigs where_cls + ; (cls, tparams, fixity, ann, cs) <- checkTyClHdr True tycl_hdr ; tyvars <- checkTyVars (text "class") whereDots cls tparams ; let anns' = annsIn Semi.<> ann + ; let loc = EpAnn (spanAsAnchor loc') noAnn cs ; return (L loc (ClassDecl { tcdCExt = (anns', layout, NoAnnSortKey) , tcdCtxt = mcxt , tcdLName = cls, tcdTyVars = tyvars @@ -231,12 +231,12 @@ mkTyData :: SrcSpan -> P (LTyClDecl GhcPs) mkTyData loc' is_type_data new_or_data cType (L _ (mcxt, tycl_hdr)) ksig data_cons (L _ maybe_deriv) annsIn - = do { let loc = noAnnSrcSpan loc' - ; (tc, tparams, fixity, ann) <- checkTyClHdr False tycl_hdr + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False tycl_hdr ; tyvars <- checkTyVars (ppr new_or_data) equalsDots tc tparams ; let anns' = annsIn Semi.<> ann - ; data_cons <- checkNewOrData (locA loc) (unLoc tc) is_type_data new_or_data data_cons + ; data_cons <- checkNewOrData loc' (unLoc tc) is_type_data new_or_data data_cons ; defn <- mkDataDefn cType mcxt ksig data_cons maybe_deriv + ; let loc = EpAnn (spanAsAnchor loc') noAnn cs ; return (L loc (DataDecl { tcdDExt = anns', tcdLName = tc, tcdTyVars = tyvars, tcdFixity = fixity, @@ -263,14 +263,14 @@ mkTySynonym :: SrcSpan -> [AddEpAnn] -> P (LTyClDecl GhcPs) mkTySynonym loc lhs rhs annsIn - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs ; tyvars <- checkTyVars (text "type") equalsDots tc tparams ; let anns' = annsIn Semi.<> ann - ; return (L (noAnnSrcSpan loc) (SynDecl - { tcdSExt = anns' - , tcdLName = tc, tcdTyVars = tyvars - , tcdFixity = fixity - , tcdRhs = rhs })) } + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (SynDecl { tcdSExt = anns' + , tcdLName = tc, tcdTyVars = tyvars + , tcdFixity = fixity + , tcdRhs = rhs })) } mkStandaloneKindSig :: SrcSpan @@ -303,8 +303,9 @@ mkTyFamInstEqn :: SrcSpan -> [AddEpAnn] -> P (LTyFamInstEqn GhcPs) mkTyFamInstEqn loc bndrs lhs rhs anns - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs - ; return (L (noAnnSrcSpan loc) $ FamEqn + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' $ FamEqn { feqn_ext = anns `mappend` ann , feqn_tycon = tc , feqn_bndrs = bndrs @@ -324,10 +325,11 @@ mkDataFamInst :: SrcSpan -> P (LInstDecl GhcPs) mkDataFamInst loc new_or_data cType (mcxt, bndrs, tycl_hdr) ksig data_cons (L _ maybe_deriv) anns - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False tycl_hdr + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False tycl_hdr ; data_cons <- checkNewOrData loc (unLoc tc) False new_or_data data_cons ; defn <- mkDataDefn cType mcxt ksig data_cons maybe_deriv - ; return (L (noAnnSrcSpan loc) (DataFamInstD noExtField (DataFamInstDecl + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (DataFamInstD noExtField (DataFamInstDecl (FamEqn { feqn_ext = ann Semi.<> anns , feqn_tycon = tc , feqn_bndrs = bndrs @@ -368,10 +370,10 @@ mkFamDecl :: SrcSpan -> [AddEpAnn] -> P (LTyClDecl GhcPs) mkFamDecl loc info topLevel lhs ksig injAnn annsIn - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs ; tyvars <- checkTyVars (ppr info) equals_or_where tc tparams - ; return (L (noAnnSrcSpan loc) (FamDecl noExtField - (FamilyDecl + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (FamDecl noExtField (FamilyDecl { fdExt = annsIn Semi.<> ann , fdTopLevel = topLevel , fdInfo = info, fdLName = tc @@ -1040,45 +1042,46 @@ checkTyClHdr :: Bool -- True <=> class header -> P (LocatedN RdrName, -- the head symbol (type or class name) [LHsTypeArg GhcPs], -- parameters of head symbol LexicalFixity, -- the declaration is in infix format - [AddEpAnn]) -- API Annotation for HsParTy + [AddEpAnn], -- API Annotation for HsParTy -- when stripping parens + EpAnnComments) -- Accumulated comments from re-arranging -- Well-formedness check and decomposition of type and class heads. -- Decomposes T ty1 .. tyn into (T, [ty1, ..., tyn]) -- Int :*: Bool into (:*:, [Int, Bool]) -- returning the pieces checkTyClHdr is_cls ty - = goL ty [] [] [] Prefix + = goL emptyComments ty [] [] [] Prefix where - goL (L l ty) acc ops cps fix = go l ty acc ops cps fix + goL cs (L l ty) acc ops cps fix = go cs l ty acc ops cps fix -- workaround to define '*' despite StarIsType - go ll (HsParTy an (L l (HsStarTy _ isUni))) acc ops' cps' fix + go cs ll (HsParTy an (L l (HsStarTy _ isUni))) acc ops' cps' fix = do { addPsMessage (locA l) PsWarnStarBinder ; let name = mkOccNameFS tcClsName (starSym isUni) ; let a' = newAnns ll l an ; return (L a' (Unqual name), acc, fix - , (reverse ops') ++ cps') } + , (reverse ops') ++ cps', cs) } - go _ (HsTyVar _ _ ltc@(L _ tc)) acc ops cps fix - | isRdrTc tc = return (ltc, acc, fix, (reverse ops) ++ cps) - go _ (HsOpTy _ _ t1 ltc@(L _ tc) t2) acc ops cps _fix - | isRdrTc tc = return (ltc, lhs:rhs:acc, Infix, (reverse ops) ++ cps) + go cs l (HsTyVar _ _ ltc@(L _ tc)) acc ops cps fix + | isRdrTc tc = return (ltc, acc, fix, (reverse ops) ++ cps, cs Semi.<> comments l) + go cs l (HsOpTy _ _ t1 ltc@(L _ tc) t2) acc ops cps _fix + | isRdrTc tc = return (ltc, lhs:rhs:acc, Infix, (reverse ops) ++ cps, cs Semi.<> comments l) where lhs = HsValArg noExtField t1 rhs = HsValArg noExtField t2 - go l (HsParTy _ ty) acc ops cps fix = goL ty acc (o:ops) (c:cps) fix + go cs l (HsParTy _ ty) acc ops cps fix = goL (cs Semi.<> comments l) ty acc (o:ops) (c:cps) fix where (o,c) = mkParensEpAnn (realSrcSpan (locA l)) - go _ (HsAppTy _ t1 t2) acc ops cps fix = goL t1 (HsValArg noExtField t2:acc) ops cps fix - go _ (HsAppKindTy at ty ki) acc ops cps fix = goL ty (HsTypeArg at ki:acc) ops cps fix - go l (HsTupleTy _ HsBoxedOrConstraintTuple ts) [] ops cps fix + go cs l (HsAppTy _ t1 t2) acc ops cps fix = goL (cs Semi.<> comments l) t1 (HsValArg noExtField t2:acc) ops cps fix + go cs l (HsAppKindTy at ty ki) acc ops cps fix = goL (cs Semi.<> comments l) ty (HsTypeArg at ki:acc) ops cps fix + go cs l (HsTupleTy _ HsBoxedOrConstraintTuple ts) [] ops cps fix = return (L (l2l l) (nameRdrName tup_name) - , map (HsValArg noExtField) ts, fix, (reverse ops)++cps) + , map (HsValArg noExtField) ts, fix, (reverse ops)++cps, cs Semi.<> comments l) where arity = length ts tup_name | is_cls = cTupleTyConName arity | otherwise = getName (tupleTyCon Boxed arity) -- See Note [Unit tuples] in GHC.Hs.Type (TODO: is this still relevant?) - go l _ _ _ _ _ + go _ l _ _ _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope (locA l) $ (PsErrMalformedTyOrClDecl ty) ===================================== compiler/Language/Haskell/Syntax/Module/Name.hs ===================================== @@ -56,5 +56,5 @@ moduleNameColons = dots_to_colons . moduleNameString parseModuleName :: Parse.ReadP ModuleName parseModuleName = fmap mkModuleName - $ Parse.munch1 (\c -> isAlphaNum c || c `elem` "_.") + $ Parse.munch1 (\c -> isAlphaNum c || c `elem` "_.'") ===================================== libraries/ghc-platform/Setup.hs ===================================== @@ -0,0 +1,6 @@ +module Main (main) where + +import Distribution.Simple + +main :: IO () +main = defaultMain ===================================== testsuite/tests/printer/Makefile ===================================== @@ -856,3 +856,8 @@ Test24749: Test24754: $(CHECK_PPR) $(LIBDIR) Test24754.hs $(CHECK_EXACT) $(LIBDIR) Test24754.hs + +.PHONY: Test24755 +Test24755: + $(CHECK_PPR) $(LIBDIR) Test24755.hs + $(CHECK_EXACT) $(LIBDIR) Test24755.hs ===================================== testsuite/tests/printer/Test24755.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeOperators #-} +module Test24755 where + +class + a -- Before operator + :+ + b -- After operator ===================================== testsuite/tests/printer/all.T ===================================== @@ -204,3 +204,4 @@ test('Test24748', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24748']) test('DataDeclShort', [ignore_stderr, req_ppr_deps], makefile_test, ['DataDeclShort']) test('Test24749', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24749']) test('Test24754', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24754']) +test('Test24755', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24755']) ===================================== testsuite/tests/rename/should_compile/T24732.hs ===================================== @@ -0,0 +1,4 @@ +import P' + +main :: IO () +main = printf "Hello World\n" \ No newline at end of file ===================================== testsuite/tests/rename/should_compile/T24732.stdout ===================================== @@ -0,0 +1 @@ +Hello World ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -223,3 +223,4 @@ test('T22478a', req_th, compile, ['']) test('RecordWildCardDeprecation', normal, multimod_compile, ['RecordWildCardDeprecation', '-Wno-duplicate-exports']) test('T14032b', normal, compile_and_run, ['']) test('T14032d', normal, compile, ['']) +test('T24732', normal, compile_and_run, ['-package "base(Prelude, Text.Printf as P\')"']) ===================================== testsuite/tests/simplCore/should_compile/T24768.hs ===================================== @@ -0,0 +1,56 @@ +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TupleSections #-} +{-# LANGUAGE TypeApplications #-} + +-- In this example the simplifer destroyed a join point, +-- namely the `loop` inside `detectLeaks` + +module T24768 (detectLeaks) where + +import Control.Monad (zipWithM_) +import Control.Monad.Reader (ReaderT(..)) +import Control.Monad.State (StateT, evalStateT) +import qualified Data.Map as M +import qualified Data.Set as S + +data Debuggee + +newtype DebugM a = DebugM (ReaderT Debuggee IO a) + deriving (Functor, Applicative, Monad) + +runSimple :: Debuggee -> DebugM a -> IO a +runSimple d (DebugM a) = runReaderT a d + +cands :: [a] +cands = [] +{-# NOINLINE cands #-} + +detectLeaks :: Debuggee -> IO () +detectLeaks e = loop M.empty + where + loop :: M.Map () RankInfo -> IO () + loop rm = do + gs <- runSimple e $ mapM (findSlice rm) cands + zipWithM_ (\n _g -> writeFile + ("slices/" ++ show @Int n ++ ".dot") + "abcd") + [0..] gs + loop rm + +data RankInfo = RankInfo !Double !Int + +lookupRM :: () -> M.Map () RankInfo -> [((), RankInfo)] +lookupRM k m = M.assocs filtered_map + where + (res_map, _) = M.partitionWithKey (\e _ -> e == k) m + filtered_map = M.filter (\(RankInfo r _) -> r > 0) res_map + +findSlice :: forall m a. Monad m => M.Map () RankInfo -> () -> m [a] +findSlice rm _k = evalStateT go S.empty + where + go :: StateT s m [a] + go = do + let next_edges = lookupRM () rm + _ss <- concat <$> mapM (\_ -> go) next_edges + return [] ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -515,3 +515,4 @@ test('T24229b', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typea test('T24370', normal, compile, ['-O']) test('T24551', normal, compile, ['-O -dcore-lint']) test('T24726', normal, compile, ['-dcore-lint -dsuppress-uniques']) +test('T24768', normal, compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7d772b1b152264ba82bcd73457e63f3bdae0e7e0...5a02a27cf93add1a80ec6404da928848bbae9fb4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7d772b1b152264ba82bcd73457e63f3bdae0e7e0...5a02a27cf93add1a80ec6404da928848bbae9fb4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun May 5 14:04:19 2024 From: gitlab at gitlab.haskell.org (Peter Trommler (@trommler)) Date: Sun, 05 May 2024 10:04:19 -0400 Subject: [Git][ghc/ghc][wip/T21191] 1883 commits: JS: fix implementation of forceBool to use JS backend syntax Message-ID: <663791e3c192b_53c4628ea2431025@gitlab.mail> Peter Trommler pushed to branch wip/T21191 at Glasgow Haskell Compiler / GHC Commits: 047e9d4f by Josh Meredith at 2023-03-13T03:56:03+00:00 JS: fix implementation of forceBool to use JS backend syntax - - - - - 559a4804 by Sebastian Graf at 2023-03-13T07:31:23-04:00 Simplifier: `countValArgs` should not count Type args (#23102) I observed miscompilations while working on !10088 caused by this. Fixes #23102. Metric Decrease: T10421 - - - - - 536d1f90 by Matthew Pickering at 2023-03-13T14:04:49+00:00 Bump Win32 to 2.13.4.0 Updates Win32 submodule - - - - - ee17001e by Ben Gamari at 2023-03-13T21:18:24-04:00 ghc-bignum: Drop redundant include-dirs field - - - - - c9c26cd6 by Teo Camarasu at 2023-03-16T12:17:50-04:00 Fix BCO creation setting caps when -j > -N * Remove calls to 'setNumCapabilities' in 'createBCOs' These calls exist to ensure that 'createBCOs' can benefit from parallelism. But this is not the right place to call `setNumCapabilities`. Furthermore the logic differs from that in the driver causing the capability count to be raised and lowered at each TH call if -j > -N. * Remove 'BCOOpts' No longer needed as it was only used to thread the job count down to `createBCOs` Resolves #23049 - - - - - 5ddbf5ed by Teo Camarasu at 2023-03-16T12:17:50-04:00 Add changelog entry for #23049 - - - - - 6e3ce9a4 by Ben Gamari at 2023-03-16T12:18:26-04:00 configure: Fix FIND_CXX_STD_LIB test on Darwin Annoyingly, Darwin's <cstddef> includes <version> and APFS is case-insensitive. Consequently, it will end up #including the `VERSION` file generated by the `configure` script on the second and subsequent runs of the `configure` script. See #23116. - - - - - 19d6d039 by sheaf at 2023-03-16T21:31:22+01:00 ghci: only keep the GlobalRdrEnv in ModInfo The datatype GHC.UI.Info.ModInfo used to store a ModuleInfo, which includes a TypeEnv. This can easily cause space leaks as we have no way of forcing everything in a type environment. In GHC, we only use the GlobalRdrEnv, which we can force completely. So we only store that instead of a fully-fledged ModuleInfo. - - - - - 73d07c6e by Torsten Schmits at 2023-03-17T14:36:49-04:00 Add structured error messages for GHC.Tc.Utils.Backpack Tracking ticket: #20119 MR: !10127 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. One occurrence, when handing a nested error from the interface loading machinery, was omitted. It will be handled by a subsequent changeset that addresses interface errors. - - - - - a13affce by Andrei Borzenkov at 2023-03-21T11:17:17-04:00 Rename () into Unit, (,,...,,) into Tuple<n> (#21294) This patch implements a part of GHC Proposal #475. The key change is in GHC.Tuple.Prim: - data () = () - data (a,b) = (a,b) - data (a,b,c) = (a,b,c) ... + data Unit = () + data Tuple2 a b = (a,b) + data Tuple3 a b c = (a,b,c) ... And the rest of the patch makes sure that Unit and Tuple<n> are pretty-printed as () and (,,...,,) in various contexts. Updates the haddock submodule. Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - 23642bf6 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: fix some wrongs in the eventlog format documentation - - - - - 90159773 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: explain the BLOCK_MARKER event - - - - - ab1c25e8 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: add BlockedOnMVarRead thread status in eventlog encodings - - - - - 898afaef by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: add TASK_DELETE event in eventlog encodings - - - - - bb05b4cc by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: add WALL_CLOCK_TIME event in eventlog encodings - - - - - eeea0343 by Torsten Schmits at 2023-03-21T11:18:34-04:00 Add structured error messages for GHC.Tc.Utils.Env Tracking ticket: #20119 MR: !10129 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - be1d4be8 by Andrew Lelechenko at 2023-03-21T11:19:13-04:00 Document pdep / pext primops - - - - - e8b4aac4 by Alex Mason at 2023-03-21T18:11:04-04:00 Allow LLVM backend to use HDoc for faster file generation. Also remove the MetaStmt constructor from LlvmStatement and places the annotations into the Store statement. Includes “Implement a workaround for -no-asm-shortcutting bug“ (https://gitlab.haskell.org/ghc/ghc/-/commit/2fda9e0df886cc551e2cd6b9c2a384192bdc3045) - - - - - ea24360d by Luite Stegeman at 2023-03-21T18:11:44-04:00 Compute LambdaFormInfo when using JavaScript backend. CmmCgInfos is needed to write interface files, but the JavaScript backend does not generate it, causing "Name without LFInfo" warnings. This patch adds a conservative but always correct CmmCgInfos when the JavaScript backend is used. Fixes #23053 - - - - - 926ad6de by Simon Peyton Jones at 2023-03-22T01:03:08-04:00 Be more careful about quantification This MR is driven by #23051. It does several things: * It is guided by the generalisation plan described in #20686. But it is still far from a complete implementation of that plan. * Add Note [Inferred type with escaping kind] to GHC.Tc.Gen.Bind. This explains that we don't (yet, pending #20686) directly prevent generalising over escaping kinds. * In `GHC.Tc.Utils.TcMType.defaultTyVar` we default RuntimeRep and Multiplicity variables, beause we don't want to quantify over them. We want to do the same for a Concrete tyvar, but there is nothing sensible to default it to (unless it has kind RuntimeRep, in which case it'll be caught by an earlier case). So we promote instead. * Pure refactoring in GHC.Tc.Solver: * Rename decideMonoTyVars to decidePromotedTyVars, since that's what it does. * Move the actual promotion of the tyvars-to-promote from `defaultTyVarsAndSimplify` to `decidePromotedTyVars`. This is a no-op; just tidies up the code. E.g then we don't need to return the promoted tyvars from `decidePromotedTyVars`. * A little refactoring in `defaultTyVarsAndSimplify`, but no change in behaviour. * When making a TauTv unification variable into a ConcreteTv (in GHC.Tc.Utils.Concrete.makeTypeConcrete), preserve the occ-name of the type variable. This just improves error messages. * Kill off dead code: GHC.Tc.Utils.TcMType.newConcreteHole - - - - - 0ab0cc11 by Sylvain Henry at 2023-03-22T01:03:48-04:00 Testsuite: use appropriate predicate for ManyUbxSums test (#22576) - - - - - 048c881e by romes at 2023-03-22T01:04:24-04:00 fix: Incorrect @since annotations in GHC.TypeError Fixes #23128 - - - - - a1528b68 by Sylvain Henry at 2023-03-22T01:05:04-04:00 Testsuite: use req_interp predicate for T16318 (#22370) - - - - - ad765b6f by Sylvain Henry at 2023-03-22T01:05:04-04:00 Testsuite: use req_interp predicate for T20214 - - - - - e0b8eaf3 by Simon Peyton Jones at 2023-03-22T09:50:13+00:00 Refactor the constraint solver pipeline The big change is to put the entire type-equality solver into GHC.Tc.Solver.Equality, rather than scattering it over Canonical and Interact. Other changes * EqCt becomes its own data type, a bit like QCInst. This is great because EqualCtList is then just [EqCt] * New module GHC.Tc.Solver.Dict has come of the class-contraint solver. In due course it will be all. One step at a time. This MR is intended to have zero change in behaviour: it is a pure refactor. It opens the way to subsequent tidying up, we believe. - - - - - cedf9a3b by Torsten Schmits at 2023-03-22T15:31:18-04:00 Add structured error messages for GHC.Tc.Utils.TcMType Tracking ticket: #20119 MR: !10138 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 30d45e97 by Sylvain Henry at 2023-03-22T15:32:01-04:00 Testsuite: use js_skip for T2615 (#22374) - - - - - 8c98deba by Armando Ramirez at 2023-03-23T09:19:32-04:00 Optimized Foldable methods for Data.Functor.Compose Explicitly define length, elem, etc. in Foldable instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/57 - - - - - bc066108 by Armando Ramirez at 2023-03-23T09:19:32-04:00 Additional optimized versions - - - - - 80fce576 by Andrew Lelechenko at 2023-03-23T09:19:32-04:00 Simplify minimum/maximum in instance Foldable (Compose f g) - - - - - 8cb88a5a by Andrew Lelechenko at 2023-03-23T09:19:32-04:00 Update changelog to mention changes to instance Foldable (Compose f g) - - - - - e1c8c41d by Torsten Schmits at 2023-03-23T09:20:13-04:00 Add structured error messages for GHC.Tc.TyCl.PatSyn Tracking ticket: #20117 MR: !10158 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - f932c589 by Adam Gundry at 2023-03-24T02:36:09-04:00 Allow WARNING pragmas to be controlled with custom categories Closes #17209. This implements GHC Proposal 541, allowing a WARNING pragma to be annotated with a category like so: {-# WARNING in "x-partial" head "This function is undefined on empty lists." #-} The user can then enable, disable and set the severity of such warnings using command-line flags `-Wx-partial`, `-Werror=x-partial` and so on. There is a new warning group `-Wextended-warnings` containing all these warnings. Warnings without a category are treated as if the category was `deprecations`, and are (still) controlled by the flags `-Wdeprecations` and `-Wwarnings-deprecations`. Updates Haddock submodule. - - - - - 0426515b by Adam Gundry at 2023-03-24T02:36:09-04:00 Move mention of warning groups change to 9.8.1 release notes - - - - - b8d783d2 by Ben Gamari at 2023-03-24T02:36:45-04:00 nativeGen/AArch64: Fix bitmask immediate predicate Previously the predicate for determining whether a logical instruction operand could be encoded as a bitmask immediate was far too conservative. This meant that, e.g., pointer untagged required five instructions whereas it should only require one. Fixes #23030. - - - - - 46120bb6 by Joachim Breitner at 2023-03-24T13:09:43-04:00 User's guide: Improve docs for -Wall previously it would list the warnings _not_ enabled by -Wall. That’s unnecessary round-about and was out of date. So let's just name the relevant warnings (based on `compiler/GHC/Driver/Flags.hs`). - - - - - 509d1f11 by Ben Gamari at 2023-03-24T13:10:20-04:00 codeGen/tsan: Disable instrumentation of unaligned stores There is some disagreement regarding the prototype of `__tsan_unaligned_write` (specifically whether it takes just the written address, or the address and the value as an argument). Moreover, I have observed crashes which appear to be due to it. Disable instrumentation of unaligned stores as a temporary mitigation. Fixes #23096. - - - - - 6a73655f by Li-yao Xia at 2023-03-25T00:02:44-04:00 base: Document GHC versions associated with past base versions in the changelog - - - - - 43bd7694 by Teo Camarasu at 2023-03-25T00:03:24-04:00 Add regression test for #17574 This test currently fails in the nonmoving way - - - - - f2d56bf7 by Teo Camarasu at 2023-03-25T00:03:24-04:00 fix: account for large and compact object stats with nonmoving gc Make sure that we keep track of the size of large and compact objects that have been moved onto the nonmoving heap. We keep track of their size and add it to the amount of live bytes in nonmoving segments to get the total size of the live nonmoving heap. Resolves #17574 - - - - - 7131b705 by David Feuer at 2023-03-25T00:04:04-04:00 Modify ThreadId documentation and comments For a long time, `GHC.Conc.Sync` has said ```haskell -- ToDo: data ThreadId = ThreadId (Weak ThreadId#) -- But since ThreadId# is unlifted, the Weak type must use open -- type variables. ``` We are now actually capable of using `Weak# ThreadId#`, but the world has moved on. To support the `Show` and `Ord` instances, we'd need to store the thread ID number in the `ThreadId`. And it seems very difficult to continue to support `threadStatus` in that regime, since it needs to be able to explain how threads died. In addition, garbage collection of weak references can be quite expensive, and it would be hard to evaluate the cost over he whole ecosystem. As discussed in [this CLC issue](https://github.com/haskell/core-libraries-committee/issues/125), it doesn't seem very likely that we'll actually switch to weak references here. - - - - - c421bbbb by Ben Gamari at 2023-03-25T00:04:41-04:00 rts: Fix barriers of IND and IND_STATIC Previously IND and IND_STATIC lacked the acquire barriers enjoyed by BLACKHOLE. As noted in the (now updated) Note [Heap memory barriers], this barrier is critical to ensure that the indirectee is visible to the entering core. Fixes #22872. - - - - - 62fa7faa by Andrew Lelechenko at 2023-03-25T00:05:22-04:00 Improve documentation of atomicModifyMutVar2# - - - - - b2d14d0b by Cheng Shao at 2023-03-25T03:46:43-04:00 rts: use performBlockingMajorGC in hs_perform_gc and fix ffi023 This patch does a few things: - Add the missing RtsSymbols.c entry of performBlockingMajorGC - Make hs_perform_gc call performBlockingMajorGC, which restores previous behavior - Use hs_perform_gc in ffi023 - Remove rts_clearMemory() call in ffi023, it now works again in some test ways previously marked as broken. Fixes #23089 - - - - - d9ae24ad by Cheng Shao at 2023-03-25T03:46:44-04:00 testsuite: add the rts_clearMemory test case This patch adds a standalone test case for rts_clearMemory that mimics how it's typically used by wasm backend users and ensures this RTS API isn't broken by future RTS refactorings. Fixes #23901. - - - - - 80729d96 by Andrew Lelechenko at 2023-03-25T03:47:22-04:00 Improve documentation for resizing of byte arrays - - - - - c6ec4cd1 by Ben Gamari at 2023-03-25T20:23:47-04:00 rts: Don't rely on EXTERN_INLINE for slop-zeroing logic Previously we relied on calling EXTERN_INLINE functions defined in ClosureMacros.h from Cmm to zero slop. However, as far as I can tell, this is no longer safe to do in C99 as EXTERN_INLINE definitions may be emitted in each compilation unit. Fix this by explicitly declaring a new set of non-inline functions in ZeroSlop.c which can be called from Cmm and marking the ClosureMacros.h definitions as INLINE_HEADER. In the future we should try to eliminate EXTERN_INLINE. - - - - - c32abd4b by Ben Gamari at 2023-03-25T20:23:48-04:00 rts: Fix capability-count check in zeroSlop Previously `zeroSlop` examined `RtsFlags` to determine whether the program was single-threaded. This is wrong; a program may be started with `+RTS -N1` yet the process may later increase the capability count with `setNumCapabilities`. This lead to quite subtle and rare crashes. Fixes #23088. - - - - - 656d4cb3 by Ryan Scott at 2023-03-25T20:24:23-04:00 Add Eq/Ord instances for SSymbol, SChar, and SNat This implements [CLC proposal #148](https://github.com/haskell/core-libraries-committee/issues/148). - - - - - 4f93de88 by David Feuer at 2023-03-26T15:33:02-04:00 Update and expand atomic modification Haddocks * The documentation for `atomicModifyIORef` and `atomicModifyIORef'` were incomplete, and the documentation for `atomicModifyIORef` was out of date. Update and expand. * Remove a useless lazy pattern match in the definition of `atomicModifyIORef`. The pair it claims to match lazily was already forced by `atomicModifyIORef2`. - - - - - e1fb56b2 by David Feuer at 2023-03-26T15:33:41-04:00 Document the constructor name for lists Derived `Data` instances use raw infix constructor names when applicable. The `Data.Data [a]` instance, if derived, would have a constructor name of `":"`. However, it actually uses constructor name `"(:)"`. Document this peculiarity. See https://github.com/haskell/core-libraries-committee/issues/147 - - - - - c1f755c4 by Simon Peyton Jones at 2023-03-27T22:09:41+01:00 Make exprIsConApp_maybe a bit cleverer Addresses #23159. See Note Note [Exploit occ-info in exprIsConApp_maybe] in GHC.Core.SimpleOpt. Compile times go down very slightly, but always go down, never up. Good! Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Singletons(normal) -1.8% T15703(normal) -1.2% GOOD geo. mean -0.1% minimum -1.8% maximum +0.0% Metric Decrease: CoOpt_Singletons T15703 - - - - - 76bb4c58 by Ryan Scott at 2023-03-28T08:12:08-04:00 Add COMPLETE pragmas to TypeRep, SSymbol, SChar, and SNat This implements [CLC proposal #149](https://github.com/haskell/core-libraries-committee/issues/149). - - - - - 3f374399 by sheaf at 2023-03-29T13:57:33+02:00 Handle records in the renamer This patch moves the field-based logic for disambiguating record updates to the renamer. The type-directed logic, scheduled for removal, remains in the typechecker. To do this properly (and fix the myriad of bugs surrounding the treatment of duplicate record fields), we took the following main steps: 1. Create GREInfo, a renamer-level equivalent to TyThing which stores information pertinent to the renamer. This allows us to uniformly treat imported and local Names in the renamer, as described in Note [GREInfo]. 2. Remove GreName. Instead of a GlobalRdrElt storing GreNames, which distinguished between normal names and field names, we now store simple Names in GlobalRdrElt, along with the new GREInfo information which allows us to recover the FieldLabel for record fields. 3. Add namespacing for record fields, within the OccNames themselves. This allows us to remove the mangling of duplicate field selectors. This change ensures we don't print mangled names to the user in error messages, and allows us to handle duplicate record fields in Template Haskell. 4. Move record disambiguation to the renamer, and operate on the level of data constructors instead, to handle #21443. The error message text for ambiguous record updates has also been changed to reflect that type-directed disambiguation is on the way out. (3) means that OccEnv is now a bit more complex: we first key on the textual name, which gives an inner map keyed on NameSpace: OccEnv a ~ FastStringEnv (UniqFM NameSpace a) Note that this change, along with (2), both increase the memory residency of GlobalRdrEnv = OccEnv [GlobalRdrElt], which causes a few tests to regress somewhat in compile-time allocation. Even though (3) simplified a lot of code (in particular the treatment of field selectors within Template Haskell and in error messages), it came with one important wrinkle: in the situation of -- M.hs-boot module M where { data A; foo :: A -> Int } -- M.hs module M where { data A = MkA { foo :: Int } } we have that M.hs-boot exports a variable foo, which is supposed to match with the record field foo that M exports. To solve this issue, we add a new impedance-matching binding to M foo{var} = foo{fld} This mimics the logic that existed already for impedance-binding DFunIds, but getting it right was a bit tricky. See Note [Record field impedance matching] in GHC.Tc.Module. We also needed to be careful to avoid introducing space leaks in GHCi. So we dehydrate the GlobalRdrEnv before storing it anywhere, e.g. in ModIface. This means stubbing out all the GREInfo fields, with the function forceGlobalRdrEnv. When we read it back in, we rehydrate with rehydrateGlobalRdrEnv. This robustly avoids any space leaks caused by retaining old type environments. Fixes #13352 #14848 #17381 #17551 #19664 #21443 #21444 #21720 #21898 #21946 #21959 #22125 #22160 #23010 #23062 #23063 Updates haddock submodule ------------------------- Metric Increase: MultiComponentModules MultiLayerModules MultiLayerModulesDefsGhci MultiLayerModulesNoCode T13701 T14697 hard_hole_fits ------------------------- - - - - - 4f1940f0 by sheaf at 2023-03-29T13:57:33+02:00 Avoid repeatedly shadowing in shadowNames This commit refactors GHC.Type.Name.Reader.shadowNames to first accumulate all the shadowing arising from the introduction of a new set of GREs, and then applies all the shadowing to the old GlobalRdrEnv in one go. - - - - - d246049c by sheaf at 2023-03-29T13:57:34+02:00 igre_prompt_env: discard "only-qualified" names We were unnecessarily carrying around names only available qualified in igre_prompt_env, violating the icReaderEnv invariant. We now get rid of these, as they aren't needed for the shadowing computation that igre_prompt_env exists for. Fixes #23177 ------------------------- Metric Decrease: T14052 T14052Type ------------------------- - - - - - 41a572f6 by Matthew Pickering at 2023-03-29T16:17:21-04:00 hadrian: Fix path to HpcParser.y The source for this project has been moved into a src/ folder so we also need to update this path. Fixes #23187 - - - - - b159e0e9 by doyougnu at 2023-03-30T01:40:08-04:00 js: split JMacro into JS eDSL and JS syntax This commit: Splits JExpr and JStat into two nearly identical DSLs: - GHC.JS.Syntax is the JMacro based DSL without unsaturation, i.e., a value cannot be unsaturated, or, a value of this DSL is a witness that a value of GHC.JS.Unsat has been saturated - GHC.JS.Unsat is the JMacro DSL from GHCJS with Unsaturation. Then all binary and outputable instances are changed to use GHC.JS.Syntax. This moves us closer to closing out #22736 and #22352. See #22736 for roadmap. ------------------------- Metric Increase: CoOpt_Read LargeRecord ManyAlternatives PmSeriesS PmSeriesT PmSeriesV T10421 T10858 T11195 T11374 T11822 T12227 T12707 T13035 T13253 T13253-spj T13379 T14683 T15164 T15703 T16577 T17096 T17516 T17836 T18140 T18282 T18304 T18478 T18698a T18698b T18923 T1969 T19695 T20049 T21839c T3064 T4801 T5321FD T5321Fun T5631 T5642 T783 T9198 T9233 T9630 TcPlugin_RewritePerf WWRec ------------------------- - - - - - f4f1f14f by Sylvain Henry at 2023-03-30T01:40:49-04:00 ghc-heap: remove wrong Addr# coercion (#23181) Conversion from Addr# to I# isn't correct with the JS backend. Also used the opportunity to reenable 64-bit Word/Int tests - - - - - a5360490 by Ben Gamari at 2023-03-30T01:41:25-04:00 testsuite: Fix racing prints in T21465 As noted in #23155, we previously failed to add flushes necessary to ensure predictable output. Fixes #23155. - - - - - 98b5cf67 by Matthew Pickering at 2023-03-30T09:58:40+01:00 Revert "ghc-heap: remove wrong Addr# coercion (#23181)" This reverts commit f4f1f14f8009c3c120b8b963ec130cbbc774ec02. This fails to build with GHC-9.2 as a boot compiler. See #23195 for tracking this issue. - - - - - 61a2dfaa by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Add {-# WARNING #-} to Data.List.{head,tail} - - - - - 8f15c47c by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Fixes to accomodate Data.List.{head,tail} with {-# WARNING #-} - - - - - 7c7dbade by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Bump submodules - - - - - d2d8251b by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Fix tests - - - - - 3d38dcb6 by sheaf at 2023-03-30T14:35:57-04:00 Proxies for head and tail: review suggestions - - - - - 930edcfd by sheaf at 2023-03-30T14:36:33-04:00 docs: move RecordUpd changelog entry to 9.8 This was accidentally included in the 9.6 changelog instead of the 9.6 changelog. - - - - - 6f885e65 by sheaf at 2023-03-30T14:37:09-04:00 Add LANGUAGE GADTs to GHC.Rename.Env We need to enable this extension for the file to compile with ghc 9.2, as we are pattern matching on a GADT and this required the GADT extension to be enabled until 9.4. - - - - - 6d6a37a8 by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: make lint-ci-config job fast again We don't pin our nixpkgs revision and tracks the default nixpkgs-unstable channel anyway. Instead of using haskell.packages.ghc924, we should be using haskell.packages.ghc92 to maximize the binary cache hit rate and make lint-ci-config job fast again. Also bumps the nix docker image to the latest revision. - - - - - ef1548c4 by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: ensure that all non-i386 pipelines do parallel xz compression We can safely enable parallel xz compression for non-i386 pipelines. However, previously we didn't export XZ_OPT, so the xz process won't see it if XZ_OPT hasn't already been set in the current job. - - - - - 20432d16 by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: unset CROSS_EMULATOR for js job - - - - - 4a24dbbe by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: fix lint-testsuite job The list_broken make target will transitively depend on the calibrate.out target, which used STAGE1_GHC instead of TEST_HC. It really should be TEST_HC since that's what get passed in the gitlab CI config. - - - - - cea56ccc by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: use alpine3_17-wasm image for wasm jobs Bump the ci-images dependency and use the new alpine3_17-wasm docker image for wasm jobs. - - - - - 79d0cb32 by Ben Gamari at 2023-03-30T18:43:53+00:00 testsuite/driver: Add basic support for testing cross-compilers - - - - - e7392b4e by Ben Gamari at 2023-03-30T18:43:53+00:00 testsuite/driver: Normalize away differences in ghc executable name - - - - - ee160d06 by Ben Gamari at 2023-03-30T18:43:53+00:00 hadrian: Pass CROSS_EMULATOR to runtests.py - - - - - 30c84511 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: don't add optllvm way for wasm32 - - - - - f1beee36 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: normalize the .wasm extension - - - - - a984a103 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: strip the cross ghc prefix in output and error message - - - - - f7478d95 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: handle target executable extension - - - - - 8fe8b653 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: mypy typing error fixes This patch fixes some mypy typing errors which weren't caught in previous linting jobs. - - - - - 0149f32f by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: use context variable instead of thread-local variable This patch changes a thread-local variable to context variable instead, which works as intended when the testsuite transitions to use asyncio & coroutines instead of multi-threading to concurrently run test cases. Note that this also raises the minimum Python version to 3.7. - - - - - ea853ff0 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: asyncify the testsuite driver This patch refactors the testsuite driver, gets rid of multi-threading logic for running test cases concurrently, and uses asyncio & coroutines instead. This is not yak shaving for its own sake; the previous multi-threading logic is prone to livelock/deadlock conditions for some reason, even if the total number of threads is bounded to a thread pool's capacity. The asyncify change is an internal implementation detail of the testsuite driver and does not impact most GHC maintainers out there. The patch does not touch the .T files, test cases can be added/modified the exact same way as before. - - - - - 0077cb22 by Matthew Pickering at 2023-03-31T21:28:28-04:00 Add test for T23184 There was an outright bug, which Simon fixed in July 2021, as a little side-fix on a complicated patch: ``` commit 6656f0165a30fc2a22208532ba384fc8e2f11b46 Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Fri Jul 23 23:57:01 2021 +0100 A bunch of changes related to eta reduction This is a large collection of changes all relating to eta reduction, originally triggered by #18993, but there followed a long saga. Specifics: ...lots of lines omitted... Other incidental changes * Fix a fairly long-standing outright bug in the ApplyToVal case of GHC.Core.Opt.Simplify.mkDupableContWithDmds. I was failing to take the tail of 'dmds' in the recursive call, which meant the demands were All Wrong. I have no idea why this has not caused problems before now. ``` Note this "Fix a fairly longstanding outright bug". This is the specific fix ``` @@ -3552,8 +3556,8 @@ mkDupableContWithDmds env dmds -- let a = ...arg... -- in [...hole...] a -- NB: sc_dup /= OkToDup; that is caught earlier by contIsDupable - do { let (dmd:_) = dmds -- Never fails - ; (floats1, cont') <- mkDupableContWithDmds env dmds cont + do { let (dmd:cont_dmds) = dmds -- Never fails + ; (floats1, cont') <- mkDupableContWithDmds env cont_dmds cont ; let env' = env `setInScopeFromF` floats1 ; (_, se', arg') <- simplArg env' dup se arg ; (let_floats2, arg'') <- makeTrivial env NotTopLevel dmd (fsLit "karg") arg' ``` Ticket #23184 is a report of the bug that this diff fixes. - - - - - 62d25071 by mangoiv at 2023-04-01T04:20:01-04:00 [feat] make ($) representation polymorphic - this change was approved by the CLC in [1] following a CLC proposal [2] - make ($) representation polymorphic (adjust the type signature) - change ($) implementation to allow additional polymorphism - adjust the haddock of ($) to reflect these changes - add additional documentation to document these changes - add changelog entry - adjust tests (move now succeeding tests and adjust stdout of some tests) [1] https://github.com/haskell/core-libraries-committee/issues/132#issuecomment-1487456854 [2] https://github.com/haskell/core-libraries-committee/issues/132 - - - - - 77c33fb9 by Artem Pelenitsyn at 2023-04-01T04:20:41-04:00 User Guide: update copyright year: 2020->2023 - - - - - 3b5be05a by doyougnu at 2023-04-01T09:42:31-04:00 driver: Unit State Data.Map -> GHC.Unique.UniqMap In pursuit of #22426. The driver and unit state are major contributors. This commit also bumps the haddock submodule to reflect the API changes in UniqMap. ------------------------- Metric Decrease: MultiComponentModules MultiComponentModulesRecomp T10421 T10547 T12150 T12234 T12425 T13035 T16875 T18140 T18304 T18698a T18698b T18923 T20049 T5837 T6048 T9198 ------------------------- - - - - - a84fba6e by Torsten Schmits at 2023-04-01T09:43:12-04:00 Add structured error messages for GHC.Tc.TyCl Tracking ticket: #20117 MR: !10183 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 6e2eb275 by doyougnu at 2023-04-01T18:27:56-04:00 JS: Linker: use saturated JExpr Follow on to MR!10142 in pursuit of #22736 - - - - - 3da69346 by sheaf at 2023-04-01T18:28:37-04:00 Improve haddocks of template-haskell Con datatype This adds a bit more information, in particular about the lists of constructors in the GadtC and RecGadtC cases. - - - - - 3b7bbb39 by sheaf at 2023-04-01T18:28:37-04:00 TH: revert changes to GadtC & RecGadtC Commit 3f374399 included a breaking-change to the template-haskell library when it made the GadtC and RecGadtC constructors take non-empty lists of names. As this has the potential to break many users' packages, we decided to revert these changes for now. - - - - - f60f6110 by Andrew Lelechenko at 2023-04-02T18:59:30-04:00 Rework documentation for data Char - - - - - 43ebd5dc by Andrew Lelechenko at 2023-04-02T19:00:09-04:00 cmm: implement parsing of MO_AtomicRMW from hand-written CMM files Fixes #23206 - - - - - ab9cd52d by Sylvain Henry at 2023-04-03T08:15:21-04:00 ghc-heap: remove wrong Addr# coercion (#23181) Conversion from Addr# to I# isn't correct with the JS backend. - - - - - 2b2afff3 by Matthew Pickering at 2023-04-03T08:15:58-04:00 hadrian: Update bootstrap plans for 9.2.6, 9.2.7, 9.4.4, 9.4.5, 9.6.1 Also fixes the ./generate_bootstrap_plans script which was recently broken We can hopefully drop the 9.2 plans soon but they still work so kept them around for now. - - - - - c2605e25 by Matthew Pickering at 2023-04-03T08:15:58-04:00 ci: Add job to test 9.6 bootstrapping - - - - - 53e4d513 by Krzysztof Gogolewski at 2023-04-03T08:16:35-04:00 hadrian: Improve option parsing Several options in Hadrian had their argument marked as optional (`OptArg`), but if the argument wasn't there they were just giving an error. It's more idiomatic to mark the argument as required instead; the code uses less Maybes, the parser can enforce that the argument is present, --help gives better output. - - - - - a8e36892 by Sylvain Henry at 2023-04-03T08:17:16-04:00 JS: fix issues with FD api support - Add missing implementations for fcntl_read/write/lock - Fix fdGetMode These were found while implementing TH in !9779. These functions must be used somehow by the external interpreter code. - - - - - 8b092910 by Haskell-mouse at 2023-04-03T19:31:26-04:00 Convert diagnostics in GHC.Rename.HsType to proper TcRnMessage I've turned all occurrences of TcRnUnknownMessage in GHC.Rename.HsType module into a proper TcRnMessage. Instead, these TcRnMessage messages were introduced: TcRnDataKindsError TcRnUnusedQuantifiedTypeVar TcRnIllegalKindSignature TcRnUnexpectedPatSigType TcRnSectionPrecedenceError TcRnPrecedenceParsingError TcRnIllegalKind TcRnNegativeNumTypeLiteral TcRnUnexpectedKindVar TcRnBindMultipleVariables TcRnBindVarAlreadyInScope - - - - - 220a7a48 by Krzysztof Gogolewski at 2023-04-03T19:32:02-04:00 Fixes around unsafeCoerce# 1. `unsafeCoerce#` was documented in `GHC.Prim`. But since the overhaul in 74ad75e87317, `unsafeCoerce#` is no longer defined there. I've combined the documentation in `GHC.Prim` with the `Unsafe.Coerce` module. 2. The documentation of `unsafeCoerce#` stated that you should not cast a function to an algebraic type, even if you later cast it back before applying it. But ghci was doing that type of cast, as can be seen with 'ghci -ddump-ds' and typing 'x = not'. I've changed it to use Any following the documentation. - - - - - 9095e297 by Matthew Craven at 2023-04-04T01:04:10-04:00 Add a few more memcpy-ish primops * copyMutableByteArrayNonOverlapping# * copyAddrToAddr# * copyAddrToAddrNonOverlapping# * setAddrRange# The implementations of copyBytes, moveBytes, and fillBytes in base:Foreign.Marshal.Utils now use these new primops, which can cause us to work a bit harder generating code for them, resulting in the metric increase in T21839c observed by CI on some architectures. But in exchange, we get better code! Metric Increase: T21839c - - - - - f7da530c by Matthew Craven at 2023-04-04T01:04:10-04:00 StgToCmm: Upgrade -fcheck-prim-bounds behavior Fixes #21054. Additionally, we can now check for range overlap when generating Cmm for primops that use memcpy internally. - - - - - cd00e321 by sheaf at 2023-04-04T01:04:50-04:00 Relax assertion in varToRecFieldOcc When using Template Haskell, it is possible to re-parent a field OccName belonging to one data constructor to another data constructor. The lsp-types package did this in order to "extend" a data constructor with additional fields. This ran into an assertion in 'varToRecFieldOcc'. This assertion can simply be relaxed, as the resulting splices are perfectly sound. Fixes #23220 - - - - - eed0d930 by Sylvain Henry at 2023-04-04T11:09:15-04:00 GHCi.RemoteTypes: fix doc and avoid unsafeCoerce (#23201) - - - - - 071139c3 by Ryan Scott at 2023-04-04T11:09:51-04:00 Make INLINE pragmas for pattern synonyms work with TH Previously, the code for converting `INLINE <name>` pragmas from TH splices used `vNameN`, which assumed that `<name>` must live in the variable namespace. Pattern synonyms, on the other hand, live in the constructor namespace. I've fixed the issue by switching to `vcNameN` instead, which works for both the variable and constructor namespaces. Fixes #23203. - - - - - 7c16f3be by Krzysztof Gogolewski at 2023-04-04T17:13:00-04:00 Fix unification with oversaturated type families unify_ty was incorrectly saying that F x y ~ T x are surely apart, where F x y is an oversaturated type family and T x is a tyconapp. As a result, the simplifier dropped a live case alternative (#23134). - - - - - c165f079 by sheaf at 2023-04-04T17:13:40-04:00 Add testcase for #23192 This issue around solving of constraints arising from superclass expansion using other constraints also borned from superclass expansion was the topic of commit aed1974e. That commit made sure we don't emit a "redundant constraint" warning in a situation in which removing the constraint would cause errors. Fixes #23192 - - - - - d1bb16ed by Ben Gamari at 2023-04-06T03:40:45-04:00 nonmoving: Disable slop-zeroing As noted in #23170, the nonmoving GC can race with a mutator zeroing the slop of an updated thunk (in much the same way that two mutators would race). Consequently, we must disable slop-zeroing when the nonmoving GC is in use. Closes #23170 - - - - - 04b80850 by Brandon Chinn at 2023-04-06T03:41:21-04:00 Fix reverse flag for -Wunsupported-llvm-version - - - - - 0c990e13 by Pierre Le Marre at 2023-04-06T10:16:29+00:00 Add release note for GHC.Unicode refactor in base-4.18. Also merge CLC proposal 130 in base-4.19 with CLC proposal 59 in base-4.18 and add proper release date. - - - - - cbbfb283 by Alex Dixon at 2023-04-07T18:27:45-04:00 Improve documentation for ($) (#22963) - - - - - 5193c2b0 by Alex Dixon at 2023-04-07T18:27:45-04:00 Remove trailing whitespace from ($) commentary - - - - - b384523b by Sebastian Graf at 2023-04-07T18:27:45-04:00 Adjust wording wrt representation polymorphism of ($) - - - - - 6a788f0a by Torsten Schmits at 2023-04-07T22:29:28-04:00 Add structured error messages for GHC.Tc.TyCl.Utils Tracking ticket: #20117 MR: !10251 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 3ba77b36 by sheaf at 2023-04-07T22:30:07-04:00 Renamer: don't call addUsedGRE on an exact Name When looking up a record field in GHC.Rename.Env.lookupRecFieldOcc, we could end up calling addUsedGRE on an exact Name, which would then lead to a panic in the bestImport function: it would be incapable of processing a GRE which is not local but also not brought into scope by any imports (as it is referred to by its unique instead). Fixes #23240 - - - - - bc4795d2 by Krzysztof Gogolewski at 2023-04-11T19:24:54-04:00 Add support for -debug in the testsuite Confusingly, GhcDebugged referred to GhcDebugAssertions. - - - - - b7474b57 by Krzysztof Gogolewski at 2023-04-11T19:24:54-04:00 Add missing cases in -Di prettyprinter Fixes #23142 - - - - - 6c392616 by Cheng Shao at 2023-04-11T19:25:31-04:00 compiler: make WasmCodeGenM an instance of MonadUnique - - - - - 05d26a65 by Cheng Shao at 2023-04-11T19:25:31-04:00 compiler: apply cmm node-splitting for wasm backend This patch applies cmm node-splitting for wasm32 NCG, which is required when handling irreducible CFGs. Fixes #23237. - - - - - f1892cc0 by Andrew Lelechenko at 2023-04-11T19:26:09-04:00 Set base 'maintainer' field to CLC - - - - - ecf22da3 by Simon Peyton Jones at 2023-04-11T19:26:45-04:00 Clarify a couple of Notes about 'nospec' - - - - - ebd8918b by Oleg Grenrus at 2023-04-12T12:32:57-04:00 Allow generation of TTH syntax with TH In other words allow generation of typed splices and brackets with Untyped Template Haskell. That is useful in cases where a library is build with TTH in mind, but we still want to generate some auxiliary declarations, where TTH cannot help us, but untyped TH can. Such example is e.g. `staged-sop` which works with TTH, but we would like to derive `Generic` declarations with TH. An alternative approach is to use `unsafeCodeCoerce`, but then the derived `Generic` instances would be type-checked only at use sites, i.e. much later. Also `-ddump-splices` output is quite ugly: user-written instances would use TTH brackets, not `unsafeCodeCoerce`. This commit doesn't allow generating of untyped template splices and brackets with untyped TH, as I don't know why one would want to do that (instead of merging the splices, e.g.) - - - - - 690d0225 by Rodrigo Mesquita at 2023-04-12T12:33:33-04:00 Add regression test for #23229 - - - - - 59321879 by Sylvain Henry at 2023-04-13T08:50:33-04:00 Add quotRem rules (#22152) case quotRemInt# x y of (# q, _ #) -> body ====> case quotInt# x y of q -> body case quotRemInt# x y of (# _, r #) -> body ====> case remInt# x y of r -> body - - - - - 4dd02122 by Sylvain Henry at 2023-04-13T08:50:33-04:00 Add quot folding rule (#22152) (x / l1) / l2 l1 and l2 /= 0 l1*l2 doesn't overflow ==> x / (l1 * l2) - - - - - 1148ac72 by Sylvain Henry at 2023-04-13T08:50:33-04:00 Make Int64/Word64 division ok for speculation too. Only when the divisor is definitely non-zero. - - - - - 8af401cc by Sylvain Henry at 2023-04-13T08:50:33-04:00 Make WordQuotRem2Op ok-for-speculation too - - - - - 27d2978e by Josh Meredith at 2023-04-13T08:51:09-04:00 Base/JS: GHC.JS.Foreign.Callback module (issue 23126) * Add the Callback module for "exporting" Haskell functions to be available to plain JavaScript code * Fix some primitives defined in GHC.JS.Prim * Add a JavaScript section to the user guide with instructions on how to use the JavaScript FFI, building up to using Callbacks to interact with the browser * Add tests for the JavaScript FFI and Callbacks - - - - - a34aa8da by Adam Sandberg Ericsson at 2023-04-14T04:17:52-04:00 rts: improve memory ordering and add some comments in the StablePtr implementation - - - - - d7a768a4 by Matthew Pickering at 2023-04-14T04:18:28-04:00 docs: Generate docs/index.html with version number * Generate docs/index.html to include the version of the ghc library * This also fixes the packageVersions interpolations which were - Missing an interpolation for `LIBRARY_ghc_VERSION` - Double quoting the version so that "9.7" was being inserted. Fixes #23121 - - - - - d48fbfea by Simon Peyton Jones at 2023-04-14T04:19:05-04:00 Stop if type constructors have kind errors Otherwise we get knock-on errors, such as #23252. This makes GHC fail a bit sooner, and I have not attempted to add recovery code, to add a fake TyCon place of the erroneous one, in an attempt to get more type errors in one pass. We could do that (perhaps) if there was a call for it. - - - - - 2371d6b2 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Major refactor in the handling of equality constraints This MR substantially refactors the way in which the constraint solver deals with equality constraints. The big thing is: * Intead of a pipeline in which we /first/ canonicalise and /then/ interact (the latter including performing unification) the two steps are more closely integreated into one. That avoids the current rather indirect communication between the two steps. The proximate cause for this refactoring is fixing #22194, which involve solving [W] alpha[2] ~ Maybe (F beta[4]) by doing this: alpha[2] := Maybe delta[2] [W] delta[2] ~ F beta[4] That is, we don't promote beta[4]! This is very like introducing a cycle breaker, and was very awkward to do before, but now it is all nice. See GHC.Tc.Utils.Unify Note [Promotion and level-checking] and Note [Family applications in canonical constraints]. The big change is this: * Several canonicalisation checks (occurs-check, cycle-breaking, checking for concreteness) are combined into one new function: GHC.Tc.Utils.Unify.checkTyEqRhs This function is controlled by `TyEqFlags`, which says what to do for foralls, type families etc. * `canEqCanLHSFinish` now sees if unification is possible, and if so, actually does it: see `canEqCanLHSFinish_try_unification`. There are loads of smaller changes: * The on-the-fly unifier `GHC.Tc.Utils.Unify.unifyType` has a cheap-and-cheerful version of `checkTyEqRhs`, called `simpleUnifyCheck`. If `simpleUnifyCheck` succeeds, it can unify, otherwise it defers by emitting a constraint. This is simpler than before. * I simplified the swapping code in `GHC.Tc.Solver.Equality.canEqCanLHS`. Especially the nasty stuff involving `swap_for_occurs` and `canEqTyVarFunEq`. Much nicer now. See Note [Orienting TyVarLHS/TyFamLHS] Note [Orienting TyFamLHS/TyFamLHS] * Added `cteSkolemOccurs`, `cteConcrete`, and `cteCoercionHole` to the problems that can be discovered by `checkTyEqRhs`. * I fixed #23199 `pickQuantifiablePreds`, which actually allows GHC to to accept both cases in #22194 rather than rejecting both. Yet smaller: * Added a `synIsConcrete` flag to `SynonymTyCon` (alongside `synIsFamFree`) to reduce the need for synonym expansion when checking concreteness. Use it in `isConcreteType`. * Renamed `isConcrete` to `isConcreteType` * Defined `GHC.Core.TyCo.FVs.isInjectiveInType` as a more efficient way to find if a particular type variable is used injectively than finding all the injective variables. It is called in `GHC.Tc.Utils.Unify.definitely_poly`, which in turn is used quite a lot. * Moved `rewriterView` to `GHC.Core.Type`, so we can use it from the constraint solver. Fixes #22194, #23199 Compile times decrease by an average of 0.1%; but there is a 7.4% drop in compiler allocation on T15703. Metric Decrease: T15703 - - - - - 99b2734b by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Add some documentation about redundant constraints - - - - - 3f2d0eb8 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Improve partial signatures This MR fixes #23223. The changes are in two places: * GHC.Tc.Bind.checkMonomorphismRestriction See the new `Note [When the MR applies]` We now no longer stupidly attempt to apply the MR when the user specifies a context, e.g. f :: Eq a => _ -> _ * GHC.Tc.Solver.decideQuantification See rewritten `Note [Constraints in partial type signatures]` Fixing this bug apparently breaks three tests: * partial-sigs/should_compile/T11192 * partial-sigs/should_fail/Defaulting1MROff * partial-sigs/should_fail/T11122 However they are all symptoms of #23232, so I'm marking them as expect_broken(23232). I feel happy about this MR. Nice. - - - - - 23e2a8a0 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Make approximateWC a bit cleverer This MR fixes #23224: making approximateWC more clever See the long `Note [ApproximateWC]` in GHC.Tc.Solver All this is delicate and ad-hoc -- but it /has/ to be: we are talking about inferring a type for a binding in the presence of GADTs, type families and whatnot: known difficult territory. We just try as hard as we can. - - - - - 2c040246 by Matthew Pickering at 2023-04-15T00:57:14-04:00 docs: Update template-haskell docs to use Code Q a rather than Q (TExp a) Since GHC Proposal #195, the type of [|| ... ||] has been Code Q a rather than Q (TExp a). The documentation in the `template-haskell` library wasn't updated to reflect this change. Fixes #23148 - - - - - 0da18eb7 by Krzysztof Gogolewski at 2023-04-15T14:35:53+02:00 Show an error when we cannot default a concrete tyvar Fixes #23153 - - - - - bad2f8b8 by sheaf at 2023-04-15T15:14:36+02:00 Handle ConcreteTvs in inferResultToType inferResultToType was discarding the ir_frr information, which meant some metavariables ended up being MetaTvs instead of ConcreteTvs. This function now creates new ConcreteTvs as necessary, instead of always creating MetaTvs. Fixes #23154 - - - - - 3b0ea480 by Simon Peyton Jones at 2023-04-16T18:12:20-04:00 Transfer DFunId_ness onto specialised bindings Whether a binding is a DFunId or not has consequences for the `-fdicts-strict` flag, essentially if we are doing demand analysis for a DFunId then `-fdicts-strict` does not apply because the constraint solver can create recursive groups of dictionaries. In #22549 this was fixed for the "normal" case, see Note [Do not strictify the argument dictionaries of a dfun]. However the loop still existed if the DFunId was being specialised. The problem was that the specialiser would specialise a DFunId and turn it into a VanillaId and so the demand analyser didn't know to apply special treatment to the binding anymore and the whole recursive group was optimised to bottom. The solution is to transfer over the DFunId-ness of the binding in the specialiser so that the demand analyser knows not to apply the `-fstrict-dicts`. Fixes #22549 - - - - - a1371ebb by Oleg Grenrus at 2023-04-16T18:12:59-04:00 Add import lists to few GHC.Driver.Session imports Related to https://gitlab.haskell.org/ghc/ghc/-/issues/23261. There are a lot of GHC.Driver.Session which only use DynFlags, but not the parsing code. - - - - - 51479ceb by Matthew Pickering at 2023-04-17T08:08:48-04:00 Account for special GHC.Prim import in warnUnusedPackages The GHC.Prim import is treated quite specially primarily because there isn't an interface file for GHC.Prim. Therefore we record separately in the ModSummary if it's imported or not so we don't go looking for it. This logic hasn't made it's way to `-Wunused-packages` so if you imported GHC.Prim then the warning would complain you didn't use `-package ghc-prim`. Fixes #23212 - - - - - 1532a8b2 by Simon Peyton Jones at 2023-04-17T08:09:24-04:00 Add regression test for #23199 - - - - - 0158c5f1 by Ryan Scott at 2023-04-17T18:43:27-04:00 validDerivPred: Reject exotic constraints in IrredPreds This brings the `IrredPred` case in sync with the treatment of `ClassPred`s as described in `Note [Valid 'deriving' predicate]` in `GHC.Tc.Validity`. Namely, we should reject `IrredPred`s that are inferred from `deriving` clauses whose arguments contain other type constructors, as described in `(VD2) Reject exotic constraints` of that Note. This has the nice property that `deriving` clauses whose inferred instance context mention `TypeError` will now emit the type error in the resulting error message, which better matches existing intuitions about how `TypeError` should work. While I was in town, I noticed that much of `Note [Valid 'deriving' predicate]` was duplicated in a separate `Note [Exotic derived instance contexts]` in `GHC.Tc.Deriv.Infer`. I decided to fold the latter Note into the former so that there is a single authority on describing the conditions under which an inferred `deriving` constraint can be considered valid. This changes the behavior of `deriving` in a way that existing code might break, so I have made a mention of this in the GHC User's Guide. It seems very, very unlikely that much code is relying on this strange behavior, however, and even if there is, there is a clear, backwards-compatible migration path using `StandaloneDeriving`. Fixes #22696. - - - - - 10364818 by Krzysztof Gogolewski at 2023-04-17T18:44:03-04:00 Misc cleanup - Use dedicated list functions - Make cloneBndrs and cloneRecIdBndrs monadic - Fix invalid haddock comments in libraries/base - - - - - 5e1d33d7 by Matthew Pickering at 2023-04-18T10:31:02-04:00 Convert interface file loading errors into proper diagnostics This patch converts all the errors to do with loading interface files into proper structured diagnostics. * DriverMessage: Sometimes in the driver we attempt to load an interface file so we embed the IfaceMessage into the DriverMessage. * TcRnMessage: Most the time we are loading interface files during typechecking, so we embed the IfaceMessage This patch also removes the TcRnInterfaceLookupError constructor which is superceded by the IfaceMessage, which is now structured compared to just storing an SDoc before. - - - - - df1a5811 by sheaf at 2023-04-18T10:31:43-04:00 Don't panic in ltPatersonSize The function GHC.Tc.Utils.TcType.ltPatersonSize would panic when it encountered a type family on the RHS, as usually these are not allowed (type families are not allowed on the RHS of class instances or of quantified constraints). However, it is possible to still encounter type families on the RHS after doing a bit of constraint solving, as seen in test case T23171. This could trigger the panic in the call to ltPatersonSize in GHC.Tc.Solver.Canonical.mk_strict_superclasses, which is involved in avoiding loopy superclass constraints. This patch simply changes ltPatersonSize to return "I don't know, because there's a type family involved" in these cases. Fixes #23171 - - - - - d442ac05 by Sylvain Henry at 2023-04-19T20:04:35-04:00 JS: fix thread-related primops - - - - - 7a96f90b by Bryan Richter at 2023-04-19T20:05:11-04:00 CI: Disable abi-test-nightly See #23269 - - - - - ab6c1d29 by Sylvain Henry at 2023-04-19T20:05:50-04:00 Testsuite: don't use obsolescent egrep (#22351) Recent egrep displays the following message, breaking golden tests: egrep: warning: egrep is obsolescent; using grep -E Switch to using "grep -E" instead - - - - - f15b0ce5 by Matthew Pickering at 2023-04-20T11:01:06-04:00 hadrian: Pass haddock file arguments in a response file In !10119 CI was failing on windows because the command line was too long. We can mitigate this by passing the file arguments to haddock in a response file. We can't easily pass all the arguments in a response file because the `+RTS` arguments can't be placed in the response file. Fixes #23273 - - - - - 7012ec2f by tocic at 2023-04-20T11:01:42-04:00 Fix doc typo in GHC.Read.readList - - - - - 5c873124 by sheaf at 2023-04-20T18:33:34-04:00 Implement -jsem: parallelism controlled by semaphores See https://github.com/ghc-proposals/ghc-proposals/pull/540/ for a complete description for the motivation for this feature. The `-jsem` option allows a build tool to pass a semaphore to GHC which GHC can use in order to control how much parallelism it requests. GHC itself acts as a client in the GHC jobserver protocol. ``` GHC Jobserver Protocol ~~~~~~~~~~~~~~~~~~~~~~ This proposal introduces the GHC Jobserver Protocol. This protocol allows a server to dynamically invoke many instances of a client process, while restricting all of those instances to use no more than <n> capabilities. This is achieved by coordination over a system semaphore (either a POSIX semaphore [6]_ in the case of Linux and Darwin, or a Win32 semaphore [7]_ in the case of Windows platforms). There are two kinds of participants in the GHC Jobserver protocol: - The *jobserver* creates a system semaphore with a certain number of available tokens. Each time the jobserver wants to spawn a new jobclient subprocess, it **must** first acquire a single token from the semaphore, before spawning the subprocess. This token **must** be released once the subprocess terminates. Once work is finished, the jobserver **must** destroy the semaphore it created. - A *jobclient* is a subprocess spawned by the jobserver or another jobclient. Each jobclient starts with one available token (its *implicit token*, which was acquired by the parent which spawned it), and can request more tokens through the Jobserver Protocol by waiting on the semaphore. Each time a jobclient wants to spawn a new jobclient subprocess, it **must** pass on a single token to the child jobclient. This token can either be the jobclient's implicit token, or another token which the jobclient acquired from the semaphore. Each jobclient **must** release exactly as many tokens as it has acquired from the semaphore (this does not include the implicit tokens). ``` Build tools such as cabal act as jobservers in the protocol and are responsibile for correctly creating, cleaning up and managing the semaphore. Adds a new submodule (semaphore-compat) for managing and interacting with semaphores in a cross-platform way. Fixes #19349 - - - - - 52d3e9b4 by Ben Gamari at 2023-04-20T18:34:11-04:00 rts: Initialize Array# header in listThreads# Previously the implementation of listThreads# failed to initialize the header of the created array, leading to various nastiness. Fixes #23071 - - - - - 1db30fe1 by Ben Gamari at 2023-04-20T18:34:11-04:00 testsuite: Add test for #23071 - - - - - dae514f9 by tocic at 2023-04-21T13:31:21-04:00 Fix doc typos in libraries/base/GHC - - - - - 113e21d7 by Sylvain Henry at 2023-04-21T13:32:01-04:00 Testsuite: replace some js_broken/js_skip predicates with req_c Using req_c is more precise. - - - - - 038bb031 by Krzysztof Gogolewski at 2023-04-21T18:03:04-04:00 Minor doc fixes - Add docs/index.html to .gitignore. It is created by ./hadrian/build docs, and it was the only file in Hadrian's templateRules not present in .gitignore. - Mention that MultiWayIf supports non-boolean guards - Remove documentation of optdll - removed in 2007, 763daed95 - Fix markdown syntax - - - - - e826cdb2 by amesgen at 2023-04-21T18:03:44-04:00 User's guide: DeepSubsumption is implied by Haskell{98,2010} - - - - - 499a1c20 by PHO at 2023-04-23T13:39:32-04:00 Implement executablePath for Solaris and make getBaseDir less platform-dependent Use base-4.17 executablePath when possible, and fall back on getExecutablePath when it's not available. The sole reason why getBaseDir had #ifdef's was apparently that getExecutablePath wasn't reliable, and we could reduce the number of CPP conditionals by making use of executablePath instead. Also export executablePath on js_HOST_ARCH. - - - - - 97a6f7bc by tocic at 2023-04-23T13:40:08-04:00 Fix doc typos in libraries/base - - - - - 787c6e8c by Ben Gamari at 2023-04-24T12:19:06-04:00 testsuite/T20137: Avoid impl.-defined behavior Previously we would cast pointers to uint64_t. However, implementations are allowed to either zero- or sign-extend such casts. Instead cast to uintptr_t to avoid this. Fixes #23247. - - - - - 87095f6a by Cheng Shao at 2023-04-24T12:19:44-04:00 rts: always build 64-bit atomic ops This patch does a few things: - Always build 64-bit atomic ops in rts/ghc-prim, even on 32-bit platforms - Remove legacy "64bit" cabal flag of rts package - Fix hs_xchg64 function prototype for 32-bit platforms - Fix AtomicFetch test for wasm32 - - - - - 2685a12d by Cheng Shao at 2023-04-24T12:20:21-04:00 compiler: don't install signal handlers when the host platform doesn't have signals Previously, large parts of GHC API will transitively invoke withSignalHandlers, which doesn't work on host platforms without signal functionality at all (e.g. wasm32-wasi). By making withSignalHandlers a no-op on those platforms, we can make more parts of GHC API work out of the box when signals aren't supported. - - - - - 1338b7a3 by Cheng Shao at 2023-04-24T16:21:30-04:00 hadrian: fix non-ghc program paths passed to testsuite driver when testing cross GHC - - - - - 1a10f556 by Andrew Lelechenko at 2023-04-24T16:22:09-04:00 Add since pragma to Data.Functor.unzip - - - - - 0da9e882 by Soham Chowdhury at 2023-04-25T00:15:22-04:00 More informative errors for bad imports (#21826) - - - - - ebd5b078 by Josh Meredith at 2023-04-25T00:15:58-04:00 JS/base: provide implementation for mkdir (issue 22374) - - - - - 8f656188 by Josh Meredith at 2023-04-25T18:12:38-04:00 JS: Fix h$base_access implementation (issue 22576) - - - - - 74c55712 by Andrei Borzenkov at 2023-04-25T18:13:19-04:00 Give more guarntees about ImplicitParams (#23289) - Added new section in the GHC user's guide that legends behavior of nested implicit parameter bindings in these two cases: let ?f = 1 in let ?f = 2 in ?f and data T where MkT :: (?f :: Int) => T f :: T -> T -> Int f MkT MkT = ?f - Added new test case to examine this behavior. - - - - - c30ac25f by Sebastian Graf at 2023-04-26T14:50:51-04:00 DmdAnal: Unleash demand signatures of free RULE and unfolding binders (#23208) In #23208 we observed that the demand signature of a binder occuring in a RULE wasn't unleashed, leading to a transitively used binder being discarded as absent. The solution was to use the same code path that we already use for handling exported bindings. See the changes to `Note [Absence analysis for stable unfoldings and RULES]` for more details. I took the chance to factor out the old notion of a `PlusDmdArg` (a pair of a `VarEnv Demand` and a `Divergence`) into `DmdEnv`, which fits nicely into our existing framework. As a result, I had to touch quite a few places in the code. This refactoring exposed a few small bugs around correct handling of bottoming demand environments. As a result, some strictness signatures now mention uniques that weren't there before which caused test output changes to T13143, T19969 and T22112. But these tests compared whole -ddump-simpl listings which is a very fragile thing to begin with. I changed what exactly they test for based on the symptoms in the corresponding issues. There is a single regression in T18894 because we are more conservative around stable unfoldings now. Unfortunately it is not easily fixed; let's wait until there is a concrete motivation before invest more time. Fixes #23208. - - - - - 77f506b8 by Josh Meredith at 2023-04-26T14:51:28-04:00 Refactor GenStgRhs to include the Type in both constructors (#23280, #22576, #22364) Carry the actual type of an expression through the PreStgRhs and into GenStgRhs for use in later stages. Currently this is used in the JavaScript backend to fix some tests from the above mentioned issues: EtaExpandLevPoly, RepPolyWrappedVar2, T13822, T14749. - - - - - 052e2bb6 by Alan Zimmerman at 2023-04-26T14:52:05-04:00 EPA: Use ExplicitBraces only in HsModule !9018 brought in exact print annotations in LayoutInfo for open and close braces at the top level. But it retained them in the HsModule annotations too. Remove the originals, so exact printing uses LayoutInfo - - - - - d5c4629b by Cheng Shao at 2023-04-27T16:00:35-04:00 ci: update ci.sh to actually run the entire testsuite for wasm backend For the time being, we still need to use in-tree mode and can't test the bindist yet. - - - - - 533d075e by Cheng Shao at 2023-04-27T16:00:35-04:00 ci: additional wasm32 manual jobs in validate pipelines This patch enables bignum native & unregisterised wasm32 jobs as manual jobs in validate pipelines, which can be useful to prevent breakage when working on wasm32 related patches. - - - - - b5f00811 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: fix cross prefix stripping This patch fixes cross prefix stripping in the testsuite driver. The normalization logic used to only handle prefixes of the triple form <arch>-<vendor>-<os>, now it's relaxed to allow any number of tokens in the prefix tuple, so the cross prefix stripping logic would work when ghc is configured with something like --target=wasm32-wasi. - - - - - 6f511c36 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: include target exe extension in heap profile filenames This patch fixes hp2ps related framework failures when testing the wasm backend by including target exe extension in heap profile filenames. - - - - - e6416b10 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: exclude ghci ways if no rts linker is present This patch implements logic to automatically exclude ghci ways when there is no rts linker. It's way better than having to annotate individual test cases. - - - - - 791cce64 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: fix permission bits in copy_files When the testsuite driver copy files instead of symlinking them, it should also copy the permission bits, otherwise there'll be permission denied errors. Also, enforce file copying when testing wasm32, since wasmtime doesn't handle host symlinks quite well (https://github.com/bytecodealliance/wasmtime/issues/6227). - - - - - aa6afe8a by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add the req_ghc_with_threaded_rts predicate This patch adds the req_ghc_with_threaded_rts predicate to the testsuite to assert the platform has threaded RTS, and mark some tests as req_ghc_with_threaded_rts. Also makes ghc_with_threaded_rts a config field instead of a global variable. - - - - - ce580426 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add the req_process predicate This patch adds the req_process predicate to the testsuite to assert the platform has a process model, also marking tests that involve spawning processes as req_process. Also bumps hpc & process submodule. - - - - - cb933665 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add the req_host_target_ghc predicate This patch adds the req_host_target_ghc predicate to the testsuite to assert the ghc compiler being tested can compile both host/target code. When testing cross GHCs this is not supported yet, but it may change in the future. - - - - - b174a110 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add missing annotations for some tests This patch adds missing annotations (req_th, req_dynamic_lib_support, req_rts_linker) to some tests. They were discovered when testing wasm32, though it's better to be explicit about what features they require, rather than simply adding when(arch('wasm32'), skip). - - - - - bd2bfdec by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: wasm32-specific fixes This patch includes all wasm32-specific testsuite fixes. - - - - - 4eaf2c2a by Josh Meredith at 2023-04-27T16:01:11-04:00 JS: change GHC.JS.Transform.identsS/E/V to take a saturated IR (#23304) - - - - - 57277662 by sheaf at 2023-04-29T20:23:06+02:00 Add the Unsatisfiable class This commit implements GHC proposal #433, adding the Unsatisfiable class to the GHC.TypeError module. This provides an alternative to TypeError for which error reporting is more predictable: we report it when we are reporting unsolved Wanted constraints. Fixes #14983 #16249 #16906 #18310 #20835 - - - - - 00a8a5ff by Torsten Schmits at 2023-04-30T03:45:09-04:00 Add structured error messages for GHC.Rename.Names Tracking ticket: #20115 MR: !10336 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 931c8d82 by Ben Orchard at 2023-05-03T20:16:18-04:00 Add sized primitive literal syntax Adds a new LANGUAGE pragma ExtendedLiterals, which enables defining unboxed numeric literals such as `0xFF#Word8 :: Word8#`. Implements GHC proposal 0451: https://github.com/ghc-proposals/ghc-proposals/blob/b384a538b34f79d18a0201455b7b3c473bc8c936/proposals/0451-sized-literals.rst Fixes #21422. Bumps haddock submodule. Co-authored-by: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> - - - - - f3460845 by Andrew Lelechenko at 2023-05-03T20:16:57-04:00 Document instances of Double - - - - - 1e9caa1a by Sylvain Henry at 2023-05-03T20:17:37-04:00 Bump Cabal submodule (#22356) - - - - - 4eafb52a by sheaf at 2023-05-03T20:18:16-04:00 Don't forget to check the parent in an export list Commit 3f374399 introduced a bug which caused us to forget to include the parent of an export item of the form T(..) (that is, IEThingAll) when checking for duplicate exports. Fixes #23318 - - - - - 8fde4ac8 by amesgen at 2023-05-03T20:18:57-04:00 Fix unlit path in cross bindists - - - - - 8cc9a534 by Matthew Pickering at 2023-05-04T14:58:14-04:00 hadrian: Flavour: Change args -> extraArgs Previously in a flavour definition you could override all the flags which were passed to GHC. This causes issues when needed to compute a package hash because we need to know what these extra arguments are going to be before computing the hash. The solution is to modify flavour so that the arguments you pass here are just extra ones rather than all the arguments that you need to compile something. This makes things work more like how cabal.project files work when you give extra arguments to a package and also means that flavour transformers correctly affect the hash. - - - - - 3fdb18f8 by romes at 2023-05-04T14:58:14-04:00 Hardwire a better unit-id for ghc Previously, the unit-id of ghc-the-library was fixed as `ghc`. This was done primarily because the compiler must know the unit-id of some packages (including ghc) a-priori to define wired-in names. However, as seen in #20742, a reinstallable `ghc` whose unit-id is fixed to `ghc` might result in subtle bugs when different ghc's interact. A good example of this is having GHC_A load a plugin compiled by GHC_B, where GHC_A and GHC_B are linked to ghc-libraries that are ABI incompatible. Without a distinction between the unit-id of the ghc library GHC_A is linked against and the ghc library the plugin it is loading was compiled against, we can't check compatibility. This patch gives a slightly better unit-id to ghc (ghc-version) by (1) Not setting -this-unit-id to ghc, but rather to the new unit-id (modulo stage0) (2) Adding a definition to `GHC.Settings.Config` whose value is the new unit-id. (2.1) `GHC.Settings.Config` is generated by Hadrian (2.2) and also by cabal through `compiler/Setup.hs` This unit-id definition is imported by `GHC.Unit.Types` and used to set the wired-in unit-id of "ghc", which was previously fixed to "ghc" The commits following this one will improve the unit-id with a cabal-style package hash and check compatibility when loading plugins. Note that we also ensure that ghc's unit key matches unit id both when hadrian or cabal builds ghc, and in this way we no longer need to add `ghc` to the WiringMap. - - - - - 6689c9c6 by romes at 2023-05-04T14:58:14-04:00 Validate compatibility of ghcs when loading plugins Ensure, when loading plugins, that the ghc the plugin depends on is the ghc loading the plugin -- otherwise fail to load the plugin. Progress towards #20742. - - - - - db4be339 by romes at 2023-05-04T14:58:14-04:00 Add hashes to unit-ids created by hadrian This commit adds support for computing an inputs hash for packages compiled by hadrian. The result is that ABI incompatible packages should be given different hashes and therefore be distinct in a cabal store. Hashing is enabled by the `--flag`, and is off by default as the hash contains a hash of the source files. We enable it when we produce release builds so that the artifacts we distribute have the right unit ids. - - - - - 944a9b94 by Matthew Pickering at 2023-05-04T14:58:14-04:00 Use hash-unit-ids in release jobs Includes fix upload_ghc_libs glob - - - - - 116d7312 by Josh Meredith at 2023-05-04T14:58:51-04:00 JS: fix bounds checking (Issue 23123) * For ByteArray-based bounds-checking, the JavaScript backend must use the `len` field, instead of the inbuild JavaScript `length` field. * Range-based operations must also check both the start and end of the range for bounds * All indicies are valid for ranges of size zero, since they are essentially no-ops * For cases of ByteArray accesses (e.g. read as Int), the end index is (i * sizeof(type) + sizeof(type) - 1), while the previous implementation uses (i + sizeof(type) - 1). In the Int32 example, this is (i * 4 + 3) * IndexByteArrayOp_Word8As* primitives use byte array indicies (unlike the previous point), but now check both start and end indicies * Byte array copies now check if the arrays are the same by identity and then if the ranges overlap. - - - - - 2d5c1dde by Sylvain Henry at 2023-05-04T14:58:51-04:00 Fix remaining issues with bound checking (#23123) While fixing these I've also changed the way we store addresses into ByteArray#. Addr# are composed of two parts: a JavaScript array and an offset (32-bit number). Suppose we want to store an Addr# in a ByteArray# foo at offset i. Before this patch, we were storing both fields as a tuple in the "arr" array field: foo.arr[i] = [addr_arr, addr_offset]; Now we only store the array part in the "arr" field and the offset directly in the array: foo.dv.setInt32(i, addr_offset): foo.arr[i] = addr_arr; It avoids wasting space for the tuple. - - - - - 98c5ee45 by Luite Stegeman at 2023-05-04T14:59:31-04:00 JavaScript: Correct arguments to h$appendToHsStringA fixes #23278 - - - - - ca611447 by Josh Meredith at 2023-05-04T15:00:07-04:00 base/encoding: add an allocations performance test (#22946) - - - - - e3ddf58d by Krzysztof Gogolewski at 2023-05-04T15:00:44-04:00 linear types: Don't add external names to the usage env This has no observable effect, but avoids storing useless data. - - - - - b3226616 by Andrei Borzenkov at 2023-05-04T15:01:25-04:00 Improved documentation for the Data.OldList.nub function There was recomentation to use map head . group . sort instead of nub function, but containers library has more suitable and efficient analogue - - - - - e8b72ff6 by Ryan Scott at 2023-05-04T15:02:02-04:00 Fix type variable substitution in gen_Newtype_fam_insts Previously, `gen_Newtype_fam_insts` was substituting the type variable binders of a type family instance using `substTyVars`, which failed to take type variable dependencies into account. There is similar code in `GHC.Tc.TyCl.Class.tcATDefault` that _does_ perform this substitution properly, so this patch: 1. Factors out this code into a top-level `substATBndrs` function, and 2. Uses `substATBndrs` in `gen_Newtype_fam_insts`. Fixes #23329. - - - - - 275836d2 by Torsten Schmits at 2023-05-05T08:43:02+00:00 Add structured error messages for GHC.Rename.Utils Tracking ticket: #20115 MR: !10350 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 983ce558 by Oleg Grenrus at 2023-05-05T13:11:29-04:00 Use TemplateHaskellQuotes in TH.Syntax to construct Names - - - - - a5174a59 by Matthew Pickering at 2023-05-05T18:42:31-04:00 driver: Use hooks from plugin_hsc_env This fixes a bug in oneshot mode where hooks modified in a plugin wouldn't be used in oneshot mode because we neglected to use the right hsc_env. This was observed by @csabahruska. - - - - - 18a7d03d by Aaron Allen at 2023-05-05T18:42:31-04:00 Rework plugin initialisation points In general this patch pushes plugin initialisation points to earlier in the pipeline. As plugins can modify the `HscEnv`, it's imperative that the plugins are initialised as soon as possible and used thereafter. For example, there are some new tests which modify hsc_logger and other hooks which failed to fire before (and now do) One consequence of this change is that the error for specifying the usage of a HPT plugin from the command line has changed, because it's now attempted to be loaded at initialisation rather than causing a cyclic module import. Closes #21279 Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 6e776ed3 by Matthew Pickering at 2023-05-05T18:42:31-04:00 docs: Add Note [Timing of plugin initialization] - - - - - e1df8511 by Matthew Pickering at 2023-05-05T18:43:07-04:00 Incrementally update ghcup metadata in ghc/ghcup-metadata This job paves the way for distributing nightly builds * A new repo https://gitlab.haskell.org/ghc/ghcup-metadata stores the metadata on the "updates" branch. * Each night this metadata is downloaded and the nightly builds are appended to the end of the metadata. * The update job only runs on the scheduled nightly pipeline, not just when NIGHTLY=1. Things which are not done yet * Modify the retention policy for nightly jobs * Think about building release flavour compilers to distribute nightly. Fixes #23334 - - - - - 8f303d27 by Rodrigo Mesquita at 2023-05-05T22:04:31-04:00 docs: Remove mentions of ArrayArray# from unlifted FFI section Fixes #23277 - - - - - 994bda56 by Torsten Schmits at 2023-05-05T22:05:12-04:00 Add structured error messages for GHC.Rename.Module Tracking ticket: #20115 MR: !10361 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. Only addresses the single warning missing from the previous MR. - - - - - 3e3a6be4 by Ben Gamari at 2023-05-08T12:15:19+00:00 rts: Fix data-race in hs_init_ghc As noticed by @Terrorjack, `hs_init_ghc` previously used non-atomic increment/decrement on the RTS's initialization count. This may go wrong in a multithreaded program which initializes the runtime multiple times. Closes #22756. - - - - - 78c8dc50 by Torsten Schmits at 2023-05-08T21:41:51-04:00 Add structured error messages for GHC.IfaceToCore Tracking ticket: #20114 MR: !10390 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 0e2df4c9 by Bryan Richter at 2023-05-09T12:03:35+03:00 Fix up rules for ghcup-metadata-nightly-push - - - - - b970e64f by Ben Gamari at 2023-05-09T08:41:33-04:00 testsuite: Add test for atomicSwapIORef - - - - - 81cfefd2 by Ben Gamari at 2023-05-09T08:41:53-04:00 compiler: Implement atomicSwapIORef with xchg As requested by @treeowl in CLC#139. - - - - - 6b29154d by Ben Gamari at 2023-05-09T08:41:53-04:00 Make atomicSwapMutVar# an inline primop - - - - - 64064cfe by doyougnu at 2023-05-09T18:40:01-04:00 JS: add GHC.JS.Optimizer, remove RTS.Printer, add Linker.Opt This MR changes some simple optimizations and is a first step in re-architecting the JS backend pipeline to add the optimizer. In particular it: - removes simple peep hole optimizations from `GHC.StgToJS.Printer` and removes that module - adds module `GHC.JS.Optimizer` - defines the same peep hole opts that were removed only now they are `Syntax -> Syntax` transformations rather than `Syntax -> JS code` optimizations - hooks the optimizer into code gen - adds FuncStat and ForStat constructors to the backend. Working Ticket: - #22736 Related MRs: - MR !10142 - MR !10000 ------------------------- Metric Decrease: CoOpt_Read ManyAlternatives PmSeriesS PmSeriesT PmSeriesV T10421 T12707 T13253 T13253-spj T15164 T17516 T18140 T18282 T18698a T18698b T18923 T1969 T19695 T20049 T3064 T5321FD T5321Fun T783 T9198 T9233 T9630 ------------------------- - - - - - 6738c01d by Krzysztof Gogolewski at 2023-05-09T18:40:38-04:00 Add a regression test for #21050 - - - - - b2cdb7da by Ben Gamari at 2023-05-09T18:41:14-04:00 nonmoving: Account for mutator allocations in bytes_allocated Previously we failed to account direct mutator allocations into the nonmoving heap against the mutator's allocation limit and `cap->total_allocated`. This only manifests during CAF evaluation (since we allocate the CAF's blackhole directly into the nonmoving heap). Fixes #23312. - - - - - 0657b482 by Sven Tennie at 2023-05-09T22:22:42-04:00 Adjust AArch64 stackFrameHeaderSize The prologue of each stack frame are the saved LR and FP registers, 8 byte each. I.e. the size of the stack frame header is 2 * 8 byte. - - - - - 7788c09c by konsumlamm at 2023-05-09T22:23:23-04:00 Make `(&)` representation polymorphic in the return type - - - - - b3195922 by Ben Gamari at 2023-05-10T05:06:45-04:00 ghc-prim: Generalize keepAlive#/touch# in state token type Closes #23163. - - - - - 1e6861dd by Cheng Shao at 2023-05-10T05:07:25-04:00 Bump hsc2hs submodule Fixes #22981. - - - - - 0a513952 by Ben Gamari at 2023-05-11T04:10:17-04:00 base: Export GHC.Conc.Sync.fromThreadId Closes #22706. - - - - - 29be39ba by Matthew Pickering at 2023-05-11T04:10:54-04:00 Build vanilla alpine bindists We currently attempt to build and distribute fully static alpine bindists (ones which could be used on any linux platform) but most people who use the alpine bindists want to use alpine to build their own static applications (for which a fully static bindist is not necessary). We should build and distribute these bindists for these users whilst the fully-static bindist is still unusable. Fixes #23349 - - - - - 40c7daed by Simon Peyton Jones at 2023-05-11T04:11:30-04:00 Look both ways when looking for quantified equalities When looking up (t1 ~# t2) in the quantified constraints, check both orientations. Forgetting this led to #23333. - - - - - c17bb82f by Rodrigo Mesquita at 2023-05-11T04:12:07-04:00 Move "target has RTS linker" out of settings We move the "target has RTS linker" information out of configure into a predicate in GHC, and remove this option from the settings file where it is unnecessary -- it's information statically known from the platform. Note that previously we would consider `powerpc`s and `s390x`s other than `powerpc-ibm-aix*` and `s390x-ibm-linux` to have an RTS linker, but the RTS linker supports neither platform. Closes #23361 - - - - - bd0b056e by Krzysztof Gogolewski at 2023-05-11T04:12:44-04:00 Add a test for #17284 Since !10123 we now reject this program. - - - - - 630b1fea by Andrew Lelechenko at 2023-05-11T04:13:24-04:00 Document unlawfulness of instance Num Fixed Fixes #22712 - - - - - 87eebf98 by sheaf at 2023-05-11T11:55:22-04:00 Add fused multiply-add instructions This patch adds eight new primops that fuse a multiplication and an addition or subtraction: - `{fmadd,fmsub,fnmadd,fnmsub}{Float,Double}#` fmadd x y z is x * y + z, computed with a single rounding step. This patch implements code generation for these primops in the following backends: - X86, AArch64 and PowerPC NCG, - LLVM - C WASM uses the C implementation. The primops are unsupported in the JavaScript backend. The following constant folding rules are also provided: - compute a * b + c when a, b, c are all literals, - x * y + 0 ==> x * y, - ±1 * y + z ==> z ± y and x * ±1 + z ==> z ± x. NB: the constant folding rules incorrectly handle signed zero. This is a known limitation with GHC's floating-point constant folding rules (#21227), which we hope to resolve in the future. - - - - - ad16a066 by Krzysztof Gogolewski at 2023-05-11T11:55:59-04:00 Add a test for #21278 - - - - - 05cea68c by Matthew Pickering at 2023-05-11T11:56:36-04:00 rts: Refine memory retention behaviour to account for pinned/compacted objects When using the copying collector there is still a lot of data which isn't copied (such as pinned, compacted, large objects etc). The logic to decide how much memory to retain didn't take into account that these wouldn't be copied. Therefore we pessimistically retained 2* the amount of memory for these blocks even though they wouldn't be copied by the collector. The solution is to split up the heap into two parts, the parts which will be copied and the parts which won't be copied. Then the appropiate factor is applied to each part individually (2 * for copying and 1.2 * for not copying). The T23221 test demonstrates this improvement with a program which first allocates many unpinned ByteArray# followed by many pinned ByteArray# and observes the difference in the ultimate memory baseline between the two. There are some charts on #23221. Fixes #23221 - - - - - 1bb24432 by Cheng Shao at 2023-05-11T11:57:15-04:00 hadrian: fix no_dynamic_libs flavour transformer This patch fixes the no_dynamic_libs flavour transformer and make fully_static reuse it. Previously building with no_dynamic_libs fails since ghc program is still dynamic and transitively brings in dyn ways of rts which are produced by no rules. - - - - - 0ed493a3 by Josh Meredith at 2023-05-11T23:08:27-04:00 JS: refactor jsSaturate to return a saturated JStat (#23328) - - - - - a856d98e by Pierre Le Marre at 2023-05-11T23:09:08-04:00 Doc: Fix out-of-sync using-optimisation page - Make explicit that default flag values correspond to their -O0 value. - Fix -fignore-interface-pragmas, -fstg-cse, -fdo-eta-reduction, -fcross-module-specialise, -fsolve-constant-dicts, -fworker-wrapper. - - - - - c176ad18 by sheaf at 2023-05-12T06:10:57-04:00 Don't panic in mkNewTyConRhs This function could come across invalid newtype constructors, as we only perform validity checking of newtypes once we are outside the knot-tied typechecking loop. This patch changes this function to fake up a stub type in the case of an invalid newtype, instead of panicking. This patch also changes "checkNewDataCon" so that it reports as many errors as possible at once. Fixes #23308 - - - - - ab63daac by Krzysztof Gogolewski at 2023-05-12T06:11:38-04:00 Allow Core optimizations when interpreting bytecode Tracking ticket: #23056 MR: !10399 This adds the flag `-funoptimized-core-for-interpreter`, permitting use of the `-O` flag to enable optimizations when compiling with the interpreter backend, like in ghci. - - - - - c6cf9433 by Ben Gamari at 2023-05-12T06:12:14-04:00 hadrian: Fix mention of non-existent removeFiles function Previously Hadrian's bindist Makefile referred to a `removeFiles` function that was previously defined by the `make` build system. Since the `make` build system is no longer around, this function is now undefined. Naturally, make being make, this appears to be silently ignored instead of producing an error. Fix this by rewriting it to `rm -f`. Closes #23373. - - - - - eb60ec18 by Andrew Lelechenko at 2023-05-12T06:12:54-04:00 Mention new implementation of GHC.IORef.atomicSwapIORef in the changelog - - - - - aa84cff4 by Teo Camarasu at 2023-05-12T19:27:23-04:00 rts: Ensure non-moving gc is not running when pausing - - - - - 5ad776ab by Teo Camarasu at 2023-05-12T19:27:23-04:00 rts: Teach listAllBlocks about nonmoving heap List all blocks on the non-moving heap. Resolves #22627 - - - - - d683b2e5 by Krzysztof Gogolewski at 2023-05-12T19:28:00-04:00 Fix coercion optimisation for SelCo (#23362) setNominalRole_maybe is supposed to output a nominal coercion. In the SelCo case, it was not updating the stored role to Nominal, causing #23362. - - - - - 59aa4676 by Alexis King at 2023-05-12T19:28:47-04:00 hadrian: Fix linker script flag for MergeObjects builder This fixes what appears to have been a typo in !9530. The `-t` flag just enables tracing on all versions of `ld` I’ve looked at, while `-T` is used to specify a linker script. It seems that this worked anyway for some reason on some `ld` implementations (perhaps because they automatically detect linker scripts), but the missing `-T` argument causes `gold` to complain. - - - - - 4bf9fa0f by Adam Gundry at 2023-05-12T23:49:49-04:00 Less coercion optimization for non-newtype axioms See Note [Push transitivity inside newtype axioms only] for an explanation of the change here. This change substantially improves the performance of coercion optimization for programs involving transitive type family reductions. ------------------------- Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12545 T13386 T15703 T5030 T8095 ------------------------- - - - - - dc0c9574 by Adam Gundry at 2023-05-12T23:49:49-04:00 Move checkAxInstCo to GHC.Core.Lint A consequence of the previous change is that checkAxInstCo is no longer called during coercion optimization, so it can be moved back where it belongs. Also includes some edits to Note [Conflict checking with AxiomInstCo] as suggested by @simonpj. - - - - - 8b9b7dbc by Simon Peyton Jones at 2023-05-12T23:50:25-04:00 Use the eager unifier in the constraint solver This patch continues the refactoring of the constraint solver described in #23070. The Big Deal in this patch is to call the regular, eager unifier from the constraint solver, when we want to create new equalities. This replaces the existing, unifyWanted which amounted to yet-another-unifier, so it reduces duplication of a rather subtle piece of technology. See * Note [The eager unifier] in GHC.Tc.Utils.Unify * GHC.Tc.Solver.Monad.wrapUnifierTcS I did lots of other refactoring along the way * I simplified the treatment of right hand sides that contain CoercionHoles. Now, a constraint that contains a hetero-kind CoercionHole is non-canonical, and cannot be used for rewriting or unification alike. This required me to add the ch_hertero_kind flag to CoercionHole, with consequent knock-on effects. See wrinkle (2) of `Note [Equalities with incompatible kinds]` in GHC.Tc.Solver.Equality. * I refactored the StopOrContinue type to add StartAgain, so that after a fundep improvement (for example) we can simply start the pipeline again. * I got rid of the unpleasant (and inefficient) rewriterSetFromType/Co functions. With Richard I concluded that they are never needed. * I discovered Wrinkle (W1) in Note [Wanteds rewrite Wanteds] in GHC.Tc.Types.Constraint, and therefore now prioritise non-rewritten equalities. Quite a few error messages change, I think always for the better. Compiler runtime stays about the same, with one outlier: a 17% improvement in T17836 Metric Decrease: T17836 T18223 - - - - - 5cad28e7 by Bartłomiej Cieślar at 2023-05-12T23:51:06-04:00 Cleanup of dynflags override in export renaming The deprecation warnings are normally emitted whenever the name's GRE is being looked up, which calls the GHC.Rename.Env.addUsedGRE function. We do not want those warnings to be emitted when renaming export lists, so they are artificially turned off by removing all warning categories from DynFlags at the beginning of GHC.Tc.Gen.Export.rnExports. This commit removes that dependency by unifying the function used for GRE lookup in lookup_ie to lookupGreAvailRn and disabling the call to addUsedGRE in said function (the warnings are also disabled in a call to lookupSubBndrOcc_helper in lookupChildrenExport), as per #17957. This commit also changes the setting for whether to warn about deprecated names in addUsedGREs to be an explicit enum instead of a boolean. - - - - - d85ed900 by Alexis King at 2023-05-13T08:45:18-04:00 Use a uniform return convention in bytecode for unary results fixes #22958 - - - - - 8a0d45f7 by Andrew Lelechenko at 2023-05-13T08:45:58-04:00 Add more instances for Compose: Enum, Bounded, Num, Real, Integral See https://github.com/haskell/core-libraries-committee/issues/160 for discussion - - - - - 902f0730 by Simon Peyton Jones at 2023-05-13T14:58:34-04:00 Make GHC.Types.Id.Make.shouldUnpackTy a bit more clever As #23307, GHC.Types.Id.Make.shouldUnpackTy was leaving money on the table, failing to unpack arguments that are perfectly unpackable. The fix is pretty easy; see Note [Recursive unboxing] - - - - - a5451438 by sheaf at 2023-05-13T14:59:13-04:00 Fix bad multiplicity role in tyConAppFunCo_maybe The function tyConAppFunCo_maybe produces a multiplicity coercion for the multiplicity argument of the function arrow, except that it could be at the wrong role if asked to produce a representational coercion. We fix this by using the 'funRole' function, which computes the right roles for arguments to the function arrow TyCon. Fixes #23386 - - - - - 5b9e9300 by sheaf at 2023-05-15T11:26:59-04:00 Turn "ambiguous import" error into a panic This error should never occur, as a lookup of a type or data constructor should never be ambiguous. This is because a single module cannot export multiple Names with the same OccName, as per item (1) of Note [Exporting duplicate declarations] in GHC.Tc.Gen.Export. This code path was intended to handle duplicate record fields, but the rest of the code had since been refactored to handle those in a different way. We also remove the AmbiguousImport constructor of IELookupError, as it is no longer used. Fixes #23302 - - - - - e305e60c by M Farkas-Dyck at 2023-05-15T11:27:41-04:00 Unbreak some tests with latest GNU grep, which now warns about stray '\'. Confusingly, the testsuite mangled the error to say "stray /". We also migrate some tests from grep to grep -E, as it seems the author actually wanted an "POSIX extended" (a.k.a. sane) regex. Background: POSIX specifies 2 "regex" syntaxen: "basic" and "extended". Of these, only "extended" syntax is actually a regular expression. Furthermore, "basic" syntax is inconsistent in its use of the '\' character — sometimes it escapes a regex metacharacter, but sometimes it unescapes it, i.e. it makes an otherwise normal character become a metacharacter. This baffles me and it seems also the authors of these tests. Also, the regex(7) man page (at least on Linux) says "basic" syntax is obsolete. Nearly all modern tools and libraries are consistent in this use of the '\' character (of which many use "extended" syntax by default). - - - - - 5ae81842 by sheaf at 2023-05-15T14:49:17-04:00 Improve "ambiguous occurrence" error messages This error was sometimes a bit confusing, especially when data families were involved. This commit improves the general presentation of the "ambiguous occurrence" error, and adds a bit of extra context in the case of data families. Fixes #23301 - - - - - 2f571afe by Sylvain Henry at 2023-05-15T14:50:07-04:00 Fix GHCJS OS platform (fix #23346) - - - - - 86aae570 by Oleg Grenrus at 2023-05-15T14:50:43-04:00 Split DynFlags structure into own module This will allow to make command line parsing to depend on diagnostic system (which depends on dynflags) - - - - - fbe3fe00 by Josh Meredith at 2023-05-15T18:01:43-04:00 Replace the implementation of CodeBuffers with unboxed types - - - - - 21f3aae7 by Josh Meredith at 2023-05-15T18:01:43-04:00 Use unboxed codebuffers in base Metric Decrease: encodingAllocations - - - - - 18ea2295 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Weak pointer cleanups Various stylistic cleanups. No functional changes. - - - - - c343112f by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Don't force debug output to stderr Previously `+RTS -Dw -l` would emit debug output to the eventlog while `+RTS -l -Dw` would emit it to stderr. This was because the parser for `-D` would unconditionally override the debug output target. Now we instead only do so if no it is currently `TRACE_NONE`. - - - - - a5f5f067 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Forcibly flush eventlog on barf Previously we would attempt to flush via `endEventLogging` which can easily deadlock, e.g., if `barf` fails during GC. Using `flushEventLog` directly may result in slightly less consistent eventlog output (since we don't take all capabilities before flushing) but avoids deadlocking. - - - - - 73b1e87c by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Assert that pointers aren't cleared by -DZ This turns many segmentation faults into much easier-to-debug assertion failures by ensuring that LOOKS_LIKE_*_PTR checks recognize bit-patterns produced by `+RTS -DZ` clearing as invalid pointers. This is a bit ad-hoc but this is the debug runtime. - - - - - 37fb61d8 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Introduce printGlobalThreads - - - - - 451d65a6 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Don't sanity-check StgTSO.global_link See Note [Avoid dangling global_link pointers]. Fixes #19146. - - - - - d69cbd78 by sheaf at 2023-05-15T18:03:00-04:00 Split up tyThingToIfaceDecl from GHC.Iface.Make This commit moves tyThingToIfaceDecl and coAxiomToIfaceDecl from GHC.Iface.Make into GHC.Iface.Decl. This avoids GHC.Types.TyThing.Ppr, which needs tyThingToIfaceDecl, transitively depending on e.g. GHC.Iface.Load and GHC.Tc.Utils.Monad. - - - - - 4d29ecdf by sheaf at 2023-05-15T18:03:00-04:00 Migrate errors to diagnostics in GHC.Tc.Module This commit migrates the errors in GHC.Tc.Module to use the new diagnostic infrastructure. It required a significant overhaul of the compatibility checks between an hs-boot or signature module and its implementation; we now use a Writer monad to accumulate errors; see the BootMismatch datatype in GHC.Tc.Errors.Types, with its panoply of subtypes. For the sake of readability, several local functions inside the 'checkBootTyCon' function were split off into top-level functions. We split off GHC.Types.HscSource into a "boot or sig" vs "normal hs file" datatype, as this mirrors the logic in several other places where we want to treat hs-boot and hsig files in a similar fashion. This commit also refactors the Backpack checks for type synonyms implementing abstract data, to correctly reject implementations that contain qualified or quantified types (this fixes #23342 and #23344). - - - - - d986c98e by Rodrigo Mesquita at 2023-05-16T00:14:04-04:00 configure: Drop unused AC_PROG_CPP In configure, we were calling `AC_PROG_CPP` but never making use of the $CPP variable it sets or reads. The issue is $CPP will show up in the --help output of configure, falsely advertising a configuration option that does nothing. The reason we don't use the $CPP variable is because HS_CPP_CMD is expected to be a single command (without flags), but AC_PROG_CPP, when CPP is unset, will set said variable to something like `/usr/bin/gcc -E`. Instead, we configure HS_CPP_CMD through $CC. - - - - - a8f0435f by Cheng Shao at 2023-05-16T00:14:42-04:00 rts: fix --disable-large-address-space This patch moves ACQUIRE_ALLOC_BLOCK_SPIN_LOCK/RELEASE_ALLOC_BLOCK_SPIN_LOCK from Storage.h to HeapAlloc.h. When --disable-large-address-space is passed to configure, the code in HeapAlloc.h makes use of these two macros. Fixes #23385. - - - - - bdb93cd2 by Oleg Grenrus at 2023-05-16T07:59:21+03:00 Add -Wmissing-role-annotations Implements #22702 - - - - - 41ecfc34 by Ben Gamari at 2023-05-16T07:28:15-04:00 base: Export {get,set}ExceptionFinalizer from System.Mem.Weak As proposed in CLC Proposal #126 [1]. [1]: https://github.com/haskell/core-libraries-committee/issues/126 - - - - - 67330303 by Ben Gamari at 2023-05-16T07:28:16-04:00 base: Introduce printToHandleFinalizerExceptionHandler - - - - - 5e3f9bb5 by Josh Meredith at 2023-05-16T13:59:22-04:00 JS: Implement h$clock_gettime in the JavaScript RTS (#23360) - - - - - 90e69d5d by Zubin Duggal at 2023-05-16T14:00:00-04:00 compiler: Use compact representation for SourceText SourceText is serialized along with INLINE pragmas into interface files. Many of these SourceTexts are identical, for example "{-# INLINE#". When deserialized, each such SourceText was previously expanded out into a [Char], which is highly wasteful of memory, and each such instance of the text would allocate an independent list with its contents as deserializing breaks any sharing that might have existed. Instead, we use a `FastString` to represent these, so that each instance unique text will be interned and stored in a memory efficient manner. - - - - - b70bc690 by Zubin Duggal at 2023-05-16T14:00:00-04:00 compiler: Use compact representation/FastStrings for `SourceNote`s `SourceNote`s should not be stored as [Char] as this is highly wasteful and in certain scenarios can be highly duplicated. Metric Decrease: hard_hole_fits - - - - - 6231a126 by Zubin Duggal at 2023-05-16T14:00:00-04:00 compiler: Use compact representation for UsageFile (#22744) Use FastString to store filepaths in interface files, as this data is highly redundant so we want to share all instances of filepaths in the compiler session. - - - - - 47a58150 by Zubin Duggal at 2023-05-16T14:00:00-04:00 testsuite: add test for T22744 This test checks for #22744 by compiling 100 modules which each have a dependency on 1000 distinct external files. Previously, when loading these interfaces from disk, each individual instance of a filepath in the interface will would be allocated as an individual object on the heap, meaning we have heap objects for 100*1000 files, when there are only 1000 distinct files we care about. This test checks this by first compiling the module normally, then measuring the peak memory usage in a no-op recompile, as the recompilation checking will force the allocation of all these filepaths. - - - - - 0451bdc9 by Ben Gamari at 2023-05-16T21:31:40-04:00 users guide: Add glossary Currently this merely explains the meaning of "technology preview" in the context of released features. - - - - - 0ba52e4e by Ben Gamari at 2023-05-16T21:31:40-04:00 Update glossary.rst - - - - - 3d23060c by Ben Gamari at 2023-05-16T21:31:40-04:00 Use glossary directive - - - - - 2972fd66 by Sylvain Henry at 2023-05-16T21:32:20-04:00 JS: fix getpid (fix #23399) - - - - - 5fe1d3e6 by Matthew Pickering at 2023-05-17T21:42:00-04:00 Use setSrcSpan rather than setLclEnv in solveForAll In subsequent MRs (#23409) we want to remove the TcLclEnv argument from a CtLoc. This MR prepares us for that by removing the one place where the entire TcLclEnv is used, by using it more precisely to just set the contexts source location. Fixes #23390 - - - - - 385edb65 by Torsten Schmits at 2023-05-17T21:42:40-04:00 Update the users guide paragraph on -O in GHCi In relation to #23056 - - - - - 87626ef0 by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Add test for #13660 - - - - - 9eef53b1 by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Move implementation of GHC.Foreign to GHC.Internal - - - - - 174ea2fa by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Introduce {new,with}CStringLen0 These are useful helpers for implementing the internal-NUL code unit check needed to fix #13660. - - - - - a46ced16 by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Clean up documentation - - - - - b98d99cc by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Ensure that FilePaths don't contain NULs POSIX filepaths may not contain the NUL octet but previously we did not reject such paths. This could be exploited by untrusted input to cause discrepancies between various `FilePath` queries and the opened filename. For instance, `readFile "hello.so\x00.txt"` would open the file `"hello.so"` yet `takeFileExtension` would return `".txt"`. The same argument applies to Windows FilePaths Fixes #13660. - - - - - 7ae45459 by Simon Peyton Jones at 2023-05-18T15:19:29-04:00 Allow the demand analyser to unpack tuple and equality dictionaries Addresses #23398. The demand analyser usually does not unpack class dictionaries: see Note [Do not unbox class dictionaries] in GHC.Core.Opt.DmdAnal. This patch makes an exception for tuple dictionaries and equality dictionaries, for reasons explained in wrinkles (DNB1) and (DNB2) of the above Note. Compile times fall by 0.1% for some reason (max 0.7% on T18698b). - - - - - b53a9086 by Greg Steuck at 2023-05-18T15:20:08-04:00 Use a simpler and more portable construct in ld.ldd check printf '%q\n' is a bash extension which led to incorrectly failing an ld.lld test on OpenBSD which uses pdksh as /bin/sh - - - - - dd5710af by Torsten Schmits at 2023-05-18T15:20:50-04:00 Update the warning about interpreter optimizations to reflect that they're not incompatible anymore, but guarded by a flag - - - - - 4f6dd999 by Matthew Pickering at 2023-05-18T15:21:26-04:00 Remove stray dump flags in GHC.Rename.Names - - - - - 4bca0486 by Oleg Grenrus at 2023-05-19T11:51:33+03:00 Make Warn = Located DriverMessage This change makes command line argument parsing use diagnostic framework for producing warnings. - - - - - 525ed554 by Simon Peyton Jones at 2023-05-19T10:09:15-04:00 Type inference for data family newtype instances This patch addresses #23408, a tricky case with data family newtype instances. Consider type family TF a where TF Char = Bool data family DF a newtype instance DF Bool = MkDF Int and [W] Int ~R# DF (TF a), with a Given (a ~# Char). We must fully rewrite the Wanted so the tpye family can fire; that wasn't happening. - - - - - c6fb6690 by Peter Trommler at 2023-05-20T03:16:08-04:00 testsuite: fix predicate on rdynamic test Test rdynamic requires dynamic linking support, which is orthogonal to RTS linker support. Change the predicate accordingly. Fixes #23316 - - - - - 735d504e by Matthew Pickering at 2023-05-20T03:16:44-04:00 docs: Use ghc-ticket directive where appropiate in users guide Using the directive automatically formats and links the ticket appropiately. - - - - - b56d7379 by Sylvain Henry at 2023-05-22T14:21:22-04:00 NCG: remove useless .align directive (#20758) - - - - - 15b93d2f by Simon Peyton Jones at 2023-05-22T14:21:58-04:00 Add test for #23156 This program had exponential typechecking time in GHC 9.4 and 9.6 - - - - - 2b53f206 by Greg Steuck at 2023-05-22T20:23:11-04:00 Revert "Change hostSupportsRPaths to report False on OpenBSD" This reverts commit 1e0d8fdb55a38ece34fa6cf214e1d2d46f5f5bf2. - - - - - 882e43b7 by Greg Steuck at 2023-05-22T20:23:11-04:00 Disable T17414 on OpenBSD Like on other systems it's not guaranteed that there's sufficient space in /tmp to write 2G out. - - - - - 9d531f9a by Greg Steuck at 2023-05-22T20:23:11-04:00 Bring back getExecutablePath to getBaseDir on OpenBSD Fix #18173 - - - - - 9db0eadd by Krzysztof Gogolewski at 2023-05-22T20:23:47-04:00 Add an error origin for impedance matching (#23427) - - - - - 33cf4659 by Ben Gamari at 2023-05-23T03:46:20-04:00 testsuite: Add tests for #23146 Both lifted and unlifted variants. - - - - - 76727617 by Ben Gamari at 2023-05-23T03:46:21-04:00 codeGen: Fix some Haddocks - - - - - 33a8c348 by Ben Gamari at 2023-05-23T03:46:21-04:00 codeGen: Give proper LFInfo to datacon wrappers As noted in `Note [Conveying CAF-info and LFInfo between modules]`, when importing a binding from another module we must ensure that it gets the appropriate `LambdaFormInfo` if it is in WHNF to ensure that references to it are tagged correctly. However, the implementation responsible for doing this, `GHC.StgToCmm.Closure.mkLFImported`, only dealt with datacon workers and not wrappers. This lead to the crash of this program in #23146: module B where type NP :: [UnliftedType] -> UnliftedType data NP xs where UNil :: NP '[] module A where import B fieldsSam :: NP xs -> NP xs -> Bool fieldsSam UNil UNil = True x = fieldsSam UNil UNil Due to its GADT nature, `UNil` produces a trivial wrapper $WUNil :: NP '[] $WUNil = UNil @'[] @~(<co:1>) which is referenced in the RHS of `A.x`. Due to the above-mentioned bug in `mkLFImported`, the references to `$WUNil` passed to `fieldsSam` were not tagged. This is problematic as `fieldsSam` expected its arguments to be tagged as they are unlifted. The fix is straightforward: extend the logic in `mkLFImported` to cover (nullary) datacon wrappers as well as workers. This is safe because we know that the wrapper of a nullary datacon will be in WHNF, even if it includes equalities evidence (since such equalities are not runtime relevant). Thanks to @MangoIV for the great ticket and @alt-romes for his minimization and help debugging. Fixes #23146. - - - - - 2fc18e9e by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 codeGen: Fix LFInfo of imported datacon wrappers As noted in #23231 and in the previous commit, we were failing to give a an LFInfo of LFCon to a nullary datacon wrapper from another module, failing to properly tag pointers which ultimately led to the segmentation fault in #23146. On top of the previous commit which now considers wrappers where we previously only considered workers, we change the order of the guards so that we check for the arity of the binding before we check whether it is a constructor. This allows us to (1) Correctly assign `LFReEntrant` to imported wrappers whose worker was nullary, which we previously would fail to do (2) Remove the `isNullaryRepDataCon` predicate: (a) which was previously wrong, since it considered wrappers whose workers had zero-width arguments to be non-nullary and would fail to give `LFCon` to them (b) is now unnecessary, since arity == 0 guarantees - that the worker takes no arguments at all - and the wrapper takes no arguments and its RHS must be an application of the worker to zero-width-args only. - we lint these two items with an assertion that the datacon `hasNoNonZeroWidthArgs` We also update `isTagged` to use the new logic in determining the LFInfos of imported Ids. The creation of LFInfos for imported Ids and this detail are explained in Note [The LFInfo of Imported Ids]. Note that before the patch to those issues we would already consider these nullary wrappers to have `LFCon` lambda form info; but failed to re-construct that information in `mkLFImported` Closes #23231, #23146 (I've additionally batched some fixes to documentation I found while investigating this issue) - - - - - 0598f7f0 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Make LFInfos for DataCons on construction As a result of the discussion in !10165, we decided to amend the previous commit which fixed the logic of `mkLFImported` with regard to datacon workers and wrappers. Instead of having the logic for the LFInfo of datacons be in `mkLFImported`, we now construct an LFInfo for all data constructors on GHC.Types.Id.Make and store it in the `lfInfo` field. See the new Note [LFInfo of DataCon workers and wrappers] and ammendments to Note [The LFInfo of Imported Ids] - - - - - 12294b22 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Update Note [Core letrec invariant] Authored by @simonpj - - - - - e93ab972 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Rename mkLFImported to importedIdLFInfo The `mkLFImported` sounded too much like a constructor of sorts, when really it got the `LFInfo` of an imported Id from its `lf_info` field when this existed, and otherwise returned a conservative estimate of that imported Id's LFInfo. This in contrast to functions such as `mkLFReEntrant` which really are about constructing an `LFInfo`. - - - - - e54d9259 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Enforce invariant on typePrimRepArgs in the types As part of the documentation effort in !10165 I came across this invariant on 'typePrimRepArgs' which is easily expressed at the type-level through a NonEmpty list. It allowed us to remove one panic. - - - - - b8fe6a0c by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Merge outdated Note [Data con representation] into Note [Data constructor representation] Introduce new Note [Constructor applications in STG] to better support the merge, and reference it from the relevant bits in the STG syntax. - - - - - e1590ddc by Simon Peyton Jones at 2023-05-23T03:46:57-04:00 Add the SolverStage monad This refactoring makes a substantial improvement in the structure of the type-checker's constraint solver: #23070. Specifically: * Introduced the SolverStage monad. See GHC.Tc.Solver.Monad Note [The SolverStage monad] * Make each solver pipeline (equalities, dictionaries, irreds etc) deal with updating the inert set, as a separate SolverStage. There is sometimes special stuff to do, and it means that each full pipeline can have type SolverStage Void, indicating that they never return anything. * Made GHC.Tc.Solver.Equality.zonkEqTypes into a SolverStage. Much nicer. * Combined the remnants of GHC.Tc.Solver.Canonical and GHC.Tc.Solver.Interact into a new module GHC.Tc.Solver.Solve. (Interact and Canonical are removed.) * Gave the same treatment to dictionary and irred constraints as I have already done for equality constraints: * New types (akin to EqCt): IrredCt and DictCt * Ct is now just a simple sum type data Ct = CDictCan DictCt | CIrredCan IrredCt | CEqCan EqCt | CQuantCan QCInst | CNonCanonical CtEvidence * inert_dicts can now have the better type DictMap DictCt, instead of DictMap Ct; and similarly inert_irreds. * Significantly simplified the treatment of implicit parameters. Previously we had a number of special cases * interactGivenIP, an entire function * special case in maybeKickOut * special case in findDict, when looking up dictionaries But actually it's simpler than that. When adding a new Given, implicit parameter constraint to the InertSet, we just need to kick out any existing inert constraints that mention that implicit parameter. The main work is done in GHC.Tc.Solver.InertSet.delIPDict, along with its auxiliary GHC.Core.Predicate.mentionsIP. See Note [Shadowing of implicit parameters] in GHC.Tc.Solver.Dict. * Add a new fast-path in GHC.Tc.Errors.Hole.tcCheckHoleFit. See Note [Fast path for tcCheckHoleFit]. This is a big win in some cases: test hard_hole_fits gets nearly 40% faster (at compile time). * Add a new fast-path for solving /boxed/ equality constraints (t1 ~ t2). See Note [Solving equality classes] in GHC.Tc.Solver.Dict. This makes a big difference too: test T17836 compiles 40% faster. * Implement the PermissivePlan of #23413, which concerns what happens with insoluble Givens. Our previous treatment was wildly inconsistent as that ticket pointed out. A part of this, I simplified GHC.Tc.Validity.checkAmbiguity: now we simply don't run the ambiguity check at all if -XAllowAmbiguousTypes is on. Smaller points: * In `GHC.Tc.Errors.misMatchOrCND` instead of having a special case for insoluble /occurs/ checks, broaden in to all insouluble constraints. Just generally better. See Note [Insoluble mis-match] in that module. As noted above, compile time perf gets better. Here are the changes over 0.5% on Fedora. (The figures are slightly larger on Windows for some reason.) Metrics: compile_time/bytes allocated ------------------------------------- LargeRecord(normal) -0.9% MultiLayerModulesTH_OneShot(normal) +0.5% T11822(normal) -0.6% T12227(normal) -1.8% GOOD T12545(normal) -0.5% T13035(normal) -0.6% T15703(normal) -1.4% GOOD T16875(normal) -0.5% T17836(normal) -40.7% GOOD T17836b(normal) -12.3% GOOD T17977b(normal) -0.5% T5837(normal) -1.1% T8095(normal) -2.7% GOOD T9020(optasm) -1.1% hard_hole_fits(normal) -37.0% GOOD geo. mean -1.3% minimum -40.7% maximum +0.5% Metric Decrease: T12227 T15703 T17836 T17836b T8095 hard_hole_fits LargeRecord T9198 T13035 - - - - - 6abf3648 by Simon Peyton Jones at 2023-05-23T03:46:57-04:00 Avoid an assertion failure in abstractFloats The function GHC.Core.Opt.Simplify.Utils.abstractFloats was carelessly calling lookupIdSubst_maybe on a CoVar; but a precondition of the latter is being given an Id. In fact it's harmless to call it on a CoVar, but still, the precondition on lookupIdSubst_maybe makes sense, so I added a test for CoVars. This avoids a crash in a DEBUG compiler, but otherwise has no effect. Fixes #23426. - - - - - 838aaf4b by hainq at 2023-05-24T12:41:19-04:00 Migrate errors in GHC.Tc.Validity This patch migrates the error messages in GHC.Tc.Validity to use the new diagnostic infrastructure. It adds the constructors: - TcRnSimplifiableConstraint - TcRnArityMismatch - TcRnIllegalInstanceDecl, with sub-datatypes for HasField errors and fundep coverage condition errors. - - - - - 8539764b by Krzysztof Gogolewski at 2023-05-24T12:41:56-04:00 linear lint: Add missing processing of DEFAULT In this correct program f :: a %1 -> a f x = case x of x { _DEFAULT -> x } after checking the alternative we weren't popping the case binder 'x' from the usage environment, which meant that the lambda-bound 'x' was counted twice: in the scrutinee and (incorrectly) in the alternative. In fact, we weren't checking the usage of 'x' at all. Now the code for handling _DEFAULT is similar to the one handling data constructors. Fixes #23025. - - - - - ae683454 by Matthew Pickering at 2023-05-24T12:42:32-04:00 Remove outdated "Don't check hs-boot type family instances too early" note This note was introduced in 25b70a29f623 which delayed performing some consistency checks for type families. However, the change was reverted later in 6998772043a7f0b0360116eb5ffcbaa5630b21fb but the note was not removed. I found it confusing when reading to code to try and work out what special behaviour there was for hs-boot files (when in-fact there isn't any). - - - - - 44af57de by Matthew Pickering at 2023-05-24T12:43:08-04:00 rts: Define ticky macro stubs These macros have long been undefined which has meant we were missing reporting these allocations in ticky profiles. The most critical missing definition was TICK_ALLOC_HEAP_NOCTR which was missing all the RTS calls to allocate, this leads to a the overall ALLOC_RTS_tot number to be severaly underreported. Of particular interest though is the ALLOC_STACK_ctr and ALLOC_STACK_tot counters which are useful to tracking stack allocations. Fixes #23421 - - - - - b2dabe3a by Matthew Pickering at 2023-05-24T12:43:08-04:00 rts: ticky: Rename TICK_ALLOC_HEAP_NOCTR to TICK_ALLOC_RTS This macro increments the ALLOC_HEAP_tot and ALLOC_HEAP_ctr so it makes more sense to name it after that rather than the suffix NOCTR, whose meaning has been lost to the mists of time. - - - - - eac4420a by Ben Gamari at 2023-05-24T12:43:45-04:00 users guide: A few small mark-up fixes - - - - - a320ca76 by Rodrigo Mesquita at 2023-05-24T12:44:20-04:00 configure: Fix support check for response files. In failing to escape the '-o' in '-o\nconftest\nconftest.o\n' argument to printf, the writing of the arguments response file always failed. The fix is to pass the arguments after `--` so that they are treated positional arguments rather than flags to printf. Closes #23435 - - - - - f21ce0e4 by mangoiv at 2023-05-24T12:45:00-04:00 [feat] add .direnv to the .gitignore file - - - - - 36d5944d by Andrew Lelechenko at 2023-05-24T20:58:34-04:00 Add Data.List.unsnoc See https://github.com/haskell/core-libraries-committee/issues/165 for discussion - - - - - c0f2f9e3 by Bartłomiej Cieślar at 2023-05-24T20:59:14-04:00 Fix crash in backpack signature merging with -ddump-rn-trace In some cases, backpack signature merging could crash in addUsedGRE when -ddump-rn-trace was enabled, as pretty-printing the GREInfo would cause unavailable interfaces to be loaded. This commit fixes that issue by not pretty-printing the GREInfo in addUsedGRE when -ddump-rn-trace is enabled. Fixes #23424 Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - 5a07d94a by Krzysztof Gogolewski at 2023-05-25T03:30:20-04:00 Add a regression test for #13981 The panic was fixed by 6998772043a7f0b. Fixes #13981. - - - - - 182df90e by Krzysztof Gogolewski at 2023-05-25T03:30:57-04:00 Add a test for #23355 It was fixed by !10061, so I'm adding it in the same group. - - - - - 1b31b039 by uhbif19 at 2023-05-25T12:08:28+02:00 Migrate errors in GHC.Rename.Splice GHC.Rename.Pat This commit migrates the errors in GHC.Rename.Splice and GHC.Rename.Pat to use the new diagnostic infrastructure. - - - - - 56abe494 by sheaf at 2023-05-25T12:09:55+02:00 Common up Template Haskell errors in TcRnMessage This commit commons up the various Template Haskell errors into a single constructor, TcRnTHError, of TcRnMessage. - - - - - a487ba9e by Krzysztof Gogolewski at 2023-05-25T14:35:56-04:00 Enable ghci tests for unboxed tuples The tests were originally skipped because ghci used not to support unboxed tuples/sums. - - - - - dc3422d4 by Matthew Pickering at 2023-05-25T18:57:19-04:00 rts: Build ticky GHC with single-threaded RTS The threaded RTS allows you to use ticky profiling but only for the counters in the generated code. The counters used in the C portion of the RTS are disabled. Updating the counters is also racy using the threaded RTS which can lead to misleading or incorrect ticky results. Therefore we change the hadrian flavour to build using the single-threaded RTS (mainly in order to get accurate C code counter increments) Fixes #23430 - - - - - fbc8e04e by sheaf at 2023-05-25T18:58:00-04:00 Propagate long-distance info in generated code When desugaring generated pattern matches, we skip pattern match checks. However, this ended up also discarding long-distance information, which might be needed for user-written sub-expressions. Example: ```haskell okay (GADT di) cd = let sr_field :: () sr_field = case getFooBar di of { Foo -> () } in case cd of { SomeRec _ -> SomeRec sr_field } ``` With sr_field a generated FunBind, we still want to propagate the outer long-distance information from the GADT pattern match into the checks for the user-written RHS of sr_field. Fixes #23445 - - - - - f8ced241 by Matthew Pickering at 2023-05-26T15:26:21-04:00 Introduce GHCiMessage to wrap GhcMessage By introducing a wrapped message type we can control how certain messages are printed in GHCi (to add extra information for example) - - - - - 58e554c1 by Matthew Pickering at 2023-05-26T15:26:22-04:00 Generalise UnknownDiagnostic to allow embedded diagnostics to access parent diagnostic options. * Split default diagnostic options from Diagnostic class into HasDefaultDiagnosticOpts class. * Generalise UnknownDiagnostic to allow embedded diagnostics to access options. The principle idea here is that when wrapping an error message (such as GHCMessage to make GHCiMessage) then we need to also be able to lift the configuration when overriding how messages are printed (see load' for an example). - - - - - b112546a by Matthew Pickering at 2023-05-26T15:26:22-04:00 Allow API users to wrap error messages created during 'load' This allows API users to configure how messages are rendered when they are emitted from the load function. For an example see how 'loadWithCache' is used in GHCi. - - - - - 2e4cf0ee by Matthew Pickering at 2023-05-26T15:26:22-04:00 Abstract cantFindError and turn Opt_BuildingCabal into a print-time option * cantFindError is abstracted so that the parts which mention specific things about ghc/ghci are parameters. The intention being that GHC/GHCi can specify the right values to put here but otherwise display the same error message. * The BuildingCabalPackage argument from GenericMissing is removed and turned into a print-time option. The reason for the error is not dependent on whether `-fbuilding-cabal-package` is passed, so we don't want to store that in the error message. - - - - - 34b44f7d by Matthew Pickering at 2023-05-26T15:26:22-04:00 error messages: Don't display ghci specific hints for missing packages Tickets like #22884 suggest that it is confusing that GHC used on the command line can suggest options which only work in GHCi. This ticket uses the error message infrastructure to override certain error messages which displayed GHCi specific information so that this information is only showed when using GHCi. The main annoyance is that we mostly want to display errors in the same way as before, but with some additional information. This means that the error rendering code has to be exported from the Iface/Errors/Ppr.hs module. I am unsure about whether the approach taken here is the best or most maintainable solution. Fixes #22884 - - - - - 05a1b626 by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Don't override existing metadata if version already exists. If a nightly pipeline runs twice for some reason for the same version then we really don't want to override an existing entry with new bindists. This could cause ABI compatability issues for users or break ghcup's caching logic. - - - - - fcbcb3cc by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Use proper API url for bindist download Previously we were using links from the web interface, but it's more robust and future-proof to use the documented links to the artifacts. https://docs.gitlab.com/ee/api/job_artifacts.html - - - - - 5b59c8fe by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Set Nightly and LatestNightly tags The latest nightly release needs the LatestNightly tag, and all other nightly releases need the Nightly tag. Therefore when the metadata is updated we need to replace all LatestNightly with Nightly.` - - - - - 914e1468 by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Download nightly metadata for correct date The metadata now lives in https://gitlab.haskell.org/ghc/ghcup-metadata with one metadata file per year. When we update the metadata we download and update the right file for the current year. - - - - - 16cf7d2e by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Download metadata and update for correct year something about pipeline date - - - - - 14792c4b by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Don't skip CI On a push we now have a CI job which updates gitlab pages with the metadata files. - - - - - 1121bdd8 by Matthew Pickering at 2023-05-26T15:26:59-04:00 ghcup-metadata: Add --date flag to specify the release date The ghcup-metadata now has a viReleaseDay field which needs to be populated with the day of the release. - - - - - bc478bee by Matthew Pickering at 2023-05-26T15:26:59-04:00 ghcup-metadata: Add dlOutput field ghcup now requires us to add this field which specifies where it should download the bindist to. See https://gitlab.haskell.org/ghc/ghcup-metadata/-/issues/1 for some more discussion. - - - - - 2bdbd9da by Josh Meredith at 2023-05-26T15:27:35-04:00 JS: Convert rendering to use HLine instead of SDoc (#22455) - - - - - abd9e37c by Norman Ramsey at 2023-05-26T15:28:12-04:00 testsuite: add WasmControlFlow test This patch adds the WasmControlFlow test to test the wasm backend's relooper component. - - - - - 07f858eb by Sylvain Henry at 2023-05-26T15:28:53-04:00 Factorize getLinkDeps Prepare reuse of getLinkDeps for TH implementation in the JS backend (cf #22261 and review of !9779). - - - - - fad9d092 by Oleg Grenrus at 2023-05-27T13:38:08-04:00 Change GHC.Driver.Session import to .DynFlags Also move targetPlatform selector Plenty of GHC needs just DynFlags. Even more can be made to use .DynFlags if more selectors is migrated. This is a low hanging fruit. - - - - - 69fdbece by Alan Zimmerman at 2023-05-27T13:38:45-04:00 EPA: Better fix for #22919 The original fix for #22919 simply removed the ability to match up prior comments with the first declaration in the file. Restore it, but add a check that the comment is on a single line, by ensuring that it comes immediately prior to the next thing (comment or start of declaration), and that the token preceding it is not on the same line. closes #22919 - - - - - 0350b186 by Josh Meredith at 2023-05-29T12:46:27+00:00 Remove JavaScriptFFI from --supported-extensions for non-JS targets (#11214) - - - - - b4816919 by Matthew Pickering at 2023-05-30T17:07:43-04:00 testsuite: Pass -kb16k -kc128k for performance tests Setting a larger stack chunk size gives a greater protection from stack thrashing (where the repeated overflow/underflow allocates a lot of stack chunks which sigificantly impact allocations). This stabilises some tests against differences cause by more things being pushed onto the stack. The performance tests are generally testing work done by the compiler, using allocation as a proxy, so removing/stabilising the allocations due to the stack gives us more stable tests which are also more sensitive to actual changes in compiler performance. The tests which increase are ones where we compile a lot of modules, and for each module we spawn a thread to compile the module in. Therefore increasing these numbers has a multiplying effect on these tests because there are many more stacks which we can increase in size. The most significant improvements though are cases such as T8095 which reduce significantly in allocations (30%). This isn't a performance improvement really but just helps stabilise the test against this threshold set by the defaults. Fixes #23439 ------------------------- Metric Decrease: InstanceMatching T14683 T8095 T9872b_defer T9872d T9961 hie002 T19695 T3064 Metric Increase: MultiLayerModules T13701 T14697 ------------------------- - - - - - 6629f1c5 by Ben Gamari at 2023-05-30T17:08:20-04:00 Move via-C flags into GHC These were previously hardcoded in configure (with no option for overriding them) and simply passed onto ghc through the settings file. Since configure already guarantees gcc supports those flags, we simply move them into GHC. - - - - - 981e5e11 by Arnaud Spiwack at 2023-05-31T08:34:33-04:00 Allow CPR on unrestricted constructors Per the new `Note [Linting linearity]`, we want optimisations over trying to preserve linearity. This will allow CPR to handle `Ur`, in particular. - - - - - bf9344d2 by Arnaud Spiwack at 2023-05-31T08:34:33-04:00 Push coercions across multiplicity boundaries Per the new `Note [Linting linearity]`, we want optimisations over trying to preserve linearity. This will avoid preventing inlinings and reductions and make linear programs more efficient. - - - - - d56dd695 by sheaf at 2023-05-31T11:37:12-04:00 Data.Bag: add INLINEABLE to polymorphic functions This commit allows polymorphic methods in GHC.Data.Bag to be specialised, avoiding having to pass explicit dictionaries when they are instantiated with e.g. a known monad. - - - - - 5366cd35 by sheaf at 2023-05-31T11:37:12-04:00 Split off TcBinderStack into its own module This commit splits off TcBinderStack into its own module, to avoid module cycles: we might want to refer to it without also pulling in the TcM monad. - - - - - 09d4d307 by sheaf at 2023-05-31T11:37:12-04:00 Split off TcRef into its own module This helps avoid pull in the full TcM monad when we just want access to mutable references in the typechecker. This facilitates later patches which introduce a slimmed down TcM monad for zonking. - - - - - 88cc19b3 by sheaf at 2023-05-31T11:37:12-04:00 Introduce Codensity monad The Codensity monad is useful to write state-passing computations in continuation-passing style, e.g. to implement a State monad as continuation-passing style over a Reader monad. - - - - - f62d8195 by sheaf at 2023-05-31T11:37:12-04:00 Restructure the zonker This commit splits up the zonker into a few separate components, described in Note [The structure of the zonker] in `GHC.Tc.Zonk.Type`. 1. `GHC.Tc.Zonk.Monad` introduces a pared-down `TcM` monad, `ZonkM`, which has enough information for zonking types. This allows us to refactor `ErrCtxt` to use `ZonkM` instead of `TcM`, which guarantees we don't throw an error while reporting an error. 2. `GHC.Tc.Zonk.Env` is the new home of `ZonkEnv`, and also defines two zonking monad transformers, `ZonkT` and `ZonkBndrT`. `ZonkT` is a reader monad transformer over `ZonkEnv`. `ZonkBndrT m` is the codensity monad over `ZonkT m`. `ZonkBndrT` is used for computations that accumulate binders in the `ZonkEnv`. 3. `GHC.Tc.Zonk.TcType` contains the code for zonking types, for use in the typechecker. It uses the `ZonkM` monad. 4. `GHC.Tc.Zonk.Type` contains the code for final zonking to `Type`, which has been refactored to use `ZonkTcM = ZonkT TcM` and `ZonkBndrTcM = ZonkBndrT TcM`. Allocations slightly decrease on the whole due to using continuation-passing style instead of manual state passing of ZonkEnv in the final zonking to Type. ------------------------- Metric Decrease: T4029 T8095 T14766 T15304 hard_hole_fits RecordUpdPerf Metric Increase: T10421 ------------------------- - - - - - 70526f5b by mimi.vx at 2023-05-31T11:37:53-04:00 Update rdt-theme to latest upstream version Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/23444 - - - - - f3556d6c by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Restructure IPE buffer layout Reference ticket #21766 This commit restructures IPE buffer list entries to not contain references to their corresponding info tables. IPE buffer list nodes now point to two lists of equal length, one holding the list of info table pointers and one holding the corresponding entries for each info table. This will allow the entry data to be compressed without losing the references to the info tables. - - - - - 5d1f2411 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add IPE compression to configure Reference ticket #21766 Adds an `--enable-ipe-data-compreesion` flag to the configure script which will check for libzstd and set the appropriate flags to allow for IPE data compression in the compiler - - - - - b7a640ac by Finley McIlwaine at 2023-06-01T04:53:12-04:00 IPE data compression Reference ticket #21766 When IPE data compression is enabled, compress the emitted IPE buffer entries and decompress them in the RTS. - - - - - 5aef5658 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Fix libzstd detection in configure and RTS Ensure that `HAVE_LIBZSTD` gets defined to either 0 or 1 in all cases and properly check that before IPE data decompression in the RTS. See ticket #21766. - - - - - 69563c97 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add note describing IPE data compression See ticket #21766 - - - - - 7872e2b6 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Fix byte order of IPE data, fix IPE tests Make sure byte order of written IPE buffer entries matches target. Make sure the IPE-related tests properly access the fields of IPE buffer entry nodes with the new IPE layout. This commit also introduces checks to avoid importing modules if IPE compression is not enabled. See ticket #21766. - - - - - 0e85099b by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Fix IPE data decompression buffer allocation Capacity of buffers allocated for decompressed IPE data was incorrect due to a misuse of the `ZSTD_findFrameCompressedSize` function. Fix by always storing decompressed size of IPE data in IPE buffer list nodes and using `ZSTD_findFrameCompressedSize` to determine the size of the compressed data. See ticket #21766 - - - - - a0048866 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add optional dependencies to ./configure output Changes the configure script to indicate whether libnuma, libzstd, or libdw are being used as dependencies due to their optional features being enabled. - - - - - 09d93bd0 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add IPE-enabled builds to CI - Adds an IPE job to the CI pipeline which is triggered by the ~IPE label - Introduces CI logic to enable IPE data compression - Enables uncompressed IPE data on debug CI job - Regenerates jobs.yaml MR https://gitlab.haskell.org/ghc/ci-images/-/merge_requests/112 on the images repository is meant to ensure that the proper images have libzstd-dev installed. - - - - - 3ded9a1c by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Update user's guide and release notes, small fixes Add mention of IPE data compression to user's guide and the release notes for 9.8.1. Also note the impact compression has on binary size in both places. Change IpeBufferListNode compression check so only the value `1` indicates compression. See ticket #21766 - - - - - 41b41577 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Remove IPE enabled builds from CI We don't need to explicitly specify the +ipe transformer to test IPE data since there are tests which manually enable IPE information. This commit does leave zstd IPE data compression enabled on the debian CI jobs. - - - - - 982bef3a by Krzysztof Gogolewski at 2023-06-01T04:53:49-04:00 Fix build with 9.2 GHC.Tc.Zonk.Type uses an equality constraint. ghc.nix currently provides 9.2. - - - - - 1c96bc3d by Krzysztof Gogolewski at 2023-06-01T10:56:11-04:00 Output Lint errors to stderr instead of stdout This is a continuation of 7b095b99, which fixed warnings but not errors. Refs #13342 - - - - - 8e81f140 by sheaf at 2023-06-01T10:56:51-04:00 Refactor lookupExactOrOrig & friends This refactors the panoply of renamer lookup functions relating to lookupExactOrOrig to more graciously handle Exact and Orig names. In particular, we avoid the situation in which we would add Exact/Orig GREs to the tcg_used_gres field, which could cause a panic in bestImport like in #23240. Fixes #23428 - - - - - 5d415bfd by Krzysztof Gogolewski at 2023-06-01T10:57:31-04:00 Use the one-shot trick for UM and RewriteM functors As described in Note [The one-shot state monad trick], we shouldn't use derived Functor instances for monads using one-shot. This was done for most of them, but UM and RewriteM were missed. - - - - - 2c38551e by Krzysztof Gogolewski at 2023-06-01T10:58:08-04:00 Fix testsuite skipping Lint setTestOpts() is used to modify the test options for an entire .T file, rather than a single test. If there was a test using collect_compiler_stats, all of the tests in the same file had lint disabled. Fixes #21247 - - - - - 00a1e50b by Krzysztof Gogolewski at 2023-06-01T10:58:44-04:00 Add testcases for already fixed #16432 They were fixed by 40c7daed0. Fixes #16432 - - - - - f6e060cc by Krzysztof Gogolewski at 2023-06-02T09:07:25-04:00 cleanup: Remove unused field from SelfBoot It is no longer needed since Note [Extra dependencies from .hs-boot files] was deleted in 6998772043. I've also added tildes to Note headers, otherwise they're not detected by the linter. - - - - - 82eacab6 by sheaf at 2023-06-02T09:08:01-04:00 Delete GHC.Tc.Utils.Zonk This module was split up into GHC.Tc.Zonk.Type and GHC.Tc.Zonk.TcType in commit f62d8195, but I forgot to delete the original module - - - - - 4a4eb761 by Ben Gamari at 2023-06-02T23:53:21-04:00 base: Add build-order import of GHC.Types in GHC.IO.Handle.Types For reasons similar to those described in Note [Depend on GHC.Num.Integer]. Fixes #23411. - - - - - f53ac0ae by Sylvain Henry at 2023-06-02T23:54:01-04:00 JS: fix and enhance non-minimized code generation (#22455) Flag -ddisable-js-minimizer was producing invalid code. Fix that and also a few other things to generate nicer JS code for debugging. The added test checks that we don't regress when using the flag. - - - - - f7744e8e by Andrey Mokhov at 2023-06-03T16:49:44-04:00 [hadrian] Fix multiline synopsis rendering - - - - - b2c745db by Andrew Lelechenko at 2023-06-03T16:50:23-04:00 Elaborate on performance properties of Data.List.++ - - - - - 7cd8a61e by Matthew Pickering at 2023-06-05T11:46:23+01:00 Big TcLclEnv and CtLoc refactoring The overall goal of this refactoring is to reduce the dependency footprint of the parser and syntax tree. Good reasons include: - Better module graph parallelisability - Make it easier to migrate error messages without introducing module loops - Philosophically, there's not reason for the AST to depend on half the compiler. One of the key edges which added this dependency was > GHC.Hs.Expr -> GHC.Tc.Types (TcLclEnv) As this in turn depending on TcM which depends on HscEnv and so on. Therefore the goal of this patch is to move `TcLclEnv` out of `GHC.Tc.Types` so that `GHC.Hs.Expr` can import TcLclEnv without incurring a huge dependency chain. The changes in this patch are: * Move TcLclEnv from GHC.Tc.Types to GHC.Tc.Types.LclEnv * Create new smaller modules for the types used in TcLclEnv New Modules: - GHC.Tc.Types.ErrCtxt - GHC.Tc.Types.BasicTypes - GHC.Tc.Types.TH - GHC.Tc.Types.LclEnv - GHC.Tc.Types.CtLocEnv - GHC.Tc.Errors.Types.PromotionErr Removed Boot File: - {-# SOURCE #-} GHC.Tc.Types * Introduce TcLclCtxt, the part of the TcLclEnv which doesn't participate in restoreLclEnv. * Replace TcLclEnv in CtLoc with specific CtLocEnv which is defined in GHC.Tc.Types.CtLocEnv. Use CtLocEnv in Implic and CtLoc to record the location of the implication and constraint. By splitting up TcLclEnv from GHC.Tc.Types we allow GHC.Hs.Expr to no longer depend on the TcM monad and all that entails. Fixes #23389 #23409 - - - - - 3d8d39d1 by Matthew Pickering at 2023-06-05T11:46:23+01:00 Remove dependency of GHC.Tc.Utils.TcType on GHC.Driver.Session This removes the usage of DynFlags from Tc.Utils.TcType so that it no longer depends on GHC.Driver.Session. In general we don't want anything which is a dependency of Language.Haskell.Syntax to depend on GHC.Driver.Session and removing this edge gets us closer to that goal. - - - - - 18db5ada by Matthew Pickering at 2023-06-05T11:46:23+01:00 Move isIrrefutableHsPat to GHC.Rename.Utils and rename to isIrrefutableHsPatRn This removes edge from GHC.Hs.Pat to GHC.Driver.Session, which makes Language.Haskell.Syntax end up depending on GHC.Driver.Session. - - - - - 12919dd5 by Matthew Pickering at 2023-06-05T11:46:23+01:00 Remove dependency of GHC.Tc.Types.Constraint on GHC.Driver.Session - - - - - eb852371 by Matthew Pickering at 2023-06-05T11:46:24+01:00 hole fit plugins: Split definition into own module The hole fit plugins are defined in terms of TcM, a type we want to avoid depending on from `GHC.Tc.Errors.Types`. By moving it into its own module we can remove this dependency. It also simplifies the necessary boot file. - - - - - 9e5246d7 by Matthew Pickering at 2023-06-05T11:46:24+01:00 Move GHC.Core.Opt.CallerCC Types into separate module This allows `GHC.Driver.DynFlags` to depend on these types without depending on CoreM and hence the entire simplifier pipeline. We can also remove a hs-boot file with this change. - - - - - 52d6a7d7 by Matthew Pickering at 2023-06-05T11:46:24+01:00 Remove unecessary SOURCE import - - - - - 698d160c by Matthew Pickering at 2023-06-05T11:46:24+01:00 testsuite: Accept new output for CountDepsAst and CountDepsParser tests These are in a separate commit as the improvement to these tests is the cumulative effect of the previous set of patches rather than just the responsibility of the last one in the patchset. - - - - - 58ccf02e by sheaf at 2023-06-05T16:00:47-04:00 TTG: only allow VarBind at GhcTc The VarBind constructor of HsBind is only used at the GhcTc stage. This commit makes that explicit by setting the extension field of VarBind to be DataConCantHappen at all other stages. This allows us to delete a dead code path in GHC.HsToCore.Quote.rep_bind, and remove some panics. - - - - - 54b83253 by Matthew Craven at 2023-06-06T12:59:25-04:00 Generate Addr# access ops programmatically The existing utils/genprimopcode/gen_bytearray_ops.py was relocated and extended for this purpose. Additionally, hadrian now knows about this script and uses it when generating primops.txt - - - - - ecadbc7e by Matthew Pickering at 2023-06-06T13:00:01-04:00 ghcup-metadata: Only add Nightly tag when replacing LatestNightly Previously we were always adding the Nightly tag, but this led to all the previous builds getting an increasing number of nightly tags over time. Now we just add it once, when we remove the LatestNightly tag. - - - - - 4aea0a72 by Vladislav Zavialov at 2023-06-07T12:06:46+02:00 Invisible binders in type declarations (#22560) This patch implements @k-binders introduced in GHC Proposal #425 and guarded behind the TypeAbstractions extension: type D :: forall k j. k -> j -> Type data D @k @j a b = ... ^^ ^^ To represent the new syntax, we modify LHsQTyVars as follows: - hsq_explicit :: [LHsTyVarBndr () pass] + hsq_explicit :: [LHsTyVarBndr (HsBndrVis pass) pass] HsBndrVis is a new data type that records the distinction between type variable binders written with and without the @ sign: data HsBndrVis pass = HsBndrRequired | HsBndrInvisible (LHsToken "@" pass) The rest of the patch updates GHC, template-haskell, and haddock to handle the new syntax. Parser: The PsErrUnexpectedTypeAppInDecl error message is removed. The syntax it used to reject is now permitted. Renamer: The @ sign does not affect the scope of a binder, so the changes to the renamer are minimal. See rnLHsTyVarBndrVisFlag. Type checker: There are three code paths that were updated to deal with the newly introduced invisible type variable binders: 1. checking SAKS: see kcCheckDeclHeader_sig, matchUpSigWithDecl 2. checking CUSK: see kcCheckDeclHeader_cusk 3. inference: see kcInferDeclHeader, rejectInvisibleBinders Helper functions bindExplicitTKBndrs_Q_Skol and bindExplicitTKBndrs_Q_Tv are generalized to work with HsBndrVis. Updates the haddock submodule. Metric Increase: MultiLayerModulesTH_OneShot Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - b7600997 by Josh Meredith at 2023-06-07T13:10:21-04:00 JS: clean up FFI 'fat arrow' calls in base:System.Posix.Internals (#23481) - - - - - e5d3940d by Sebastian Graf at 2023-06-07T18:01:28-04:00 Update CODEOWNERS - - - - - 960ef111 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Remove IPE enabled builds from CI" This reverts commit 41b41577c8a28c236fa37e8f73aa1c6dc368d951. - - - - - bad1c8cc by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Update user's guide and release notes, small fixes" This reverts commit 3ded9a1cd22f9083f31bc2f37ee1b37f9d25dab7. - - - - - 12726d90 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add IPE-enabled builds to CI" This reverts commit 09d93bd0305b0f73422ce7edb67168c71d32c15f. - - - - - dbdd989d by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add optional dependencies to ./configure output" This reverts commit a00488665cd890a26a5564a64ba23ff12c9bec58. - - - - - 240483af by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Fix IPE data decompression buffer allocation" This reverts commit 0e85099b9316ee24565084d5586bb7290669b43a. - - - - - 9b8c7dd8 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Fix byte order of IPE data, fix IPE tests" This reverts commit 7872e2b6f08ea40d19a251c4822a384d0b397327. - - - - - 3364379b by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add note describing IPE data compression" This reverts commit 69563c97396b8fde91678fae7d2feafb7ab9a8b0. - - - - - fda30670 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Fix libzstd detection in configure and RTS" This reverts commit 5aef5658ad5fb96bac7719710e0ea008bf7b62e0. - - - - - 1cbcda9a by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "IPE data compression" This reverts commit b7a640acf7adc2880e5600d69bcf2918fee85553. - - - - - fb5e99aa by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add IPE compression to configure" This reverts commit 5d1f2411f4becea8650d12d168e989241edee186. - - - - - 2cdcb3a5 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Restructure IPE buffer layout" This reverts commit f3556d6cefd3d923b36bfcda0c8185abb1d11a91. - - - - - 2b0c9f5e by Simon Peyton Jones at 2023-06-08T07:52:34+00:00 Don't report redundant Givens from quantified constraints This fixes #23323 See (RC4) in Note [Tracking redundant constraints] - - - - - 567b32e1 by David Binder at 2023-06-08T18:41:29-04:00 Update the outdated instructions in HACKING.md on how to compile GHC - - - - - 2b1a4abe by Ryan Scott at 2023-06-09T07:56:58-04:00 Restore mingwex dependency on Windows This partially reverts some of the changes in !9475 to make `base` and `ghc-prim` depend on the `mingwex` library on Windows. It also restores the RTS's stubs for `mingwex`-specific symbols such as `_lock_file`. This is done because the C runtime provides `libmingwex` nowadays, and moreoever, not linking against `mingwex` requires downstream users to link against it explicitly in difficult-to-predict circumstances. Better to always link against `mingwex` and prevent users from having to do the guesswork themselves. See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10360#note_495873 for the discussion that led to this. - - - - - 28954758 by Ryan Scott at 2023-06-09T07:56:58-04:00 RtsSymbols.c: Remove mingwex symbol stubs As of !9475, the RTS now links against `ucrt` instead of `msvcrt` on Windows, which means that the RTS no longer needs to declare stubs for the `__mingw_*` family of symbols. Let's remove these stubs to avoid confusion. Fixes #23309. - - - - - 3ab0155b by Ryan Scott at 2023-06-09T07:57:35-04:00 Consistently use validity checks for TH conversion of data constructors We were checking that TH-spliced data declarations do not look like this: ```hs data D :: Type = MkD Int ``` But we were only doing so for `data` declarations' data constructors, not for `newtype`s, `data instance`s, or `newtype instance`s. This patch factors out the necessary validity checks into its own `cvtDataDefnCons` function and uses it in all of the places where it needs to be. Fixes #22559. - - - - - a24b83dd by Matthew Pickering at 2023-06-09T15:19:00-04:00 Fix behaviour of -keep-tmp-files when used in OPTIONS_GHC pragma This fixes the behaviour of -keep-tmp-files when used in an OPTIONS_GHC pragma for files with module level scope. Instead of simple not deleting the files, we also need to remove them from the TmpFs so they are not deleted later on when all the other files are deleted. There are additional complications because you also need to remove the directory where these files live from the TmpFs so we don't try to delete those later either. I added two tests. 1. Tests simply that -keep-tmp-files works at all with a single module and --make mode. 2. The other tests that temporary files are deleted for other modules which don't enable -keep-tmp-files. Fixes #23339 - - - - - dcf32882 by Matthew Pickering at 2023-06-09T15:19:00-04:00 withDeferredDiagnostics: When debugIsOn, write landmine into IORef to catch use-after-free. Ticket #23305 reports an error where we were attempting to use the logger which was created by withDeferredDiagnostics after its scope had ended. This problem would have been caught by this patch and a validate build: ``` +*** Exception: Use after free +CallStack (from HasCallStack): + error, called at compiler/GHC/Driver/Make.hs:<line>:<column> in <package-id>:GHC.Driver.Make ``` This general issue is tracked by #20981 - - - - - 432c736c by Matthew Pickering at 2023-06-09T15:19:00-04:00 Don't return complete HscEnv from upsweep By returning a complete HscEnv from upsweep the logger (as introduced by withDeferredDiagnostics) was escaping the scope of withDeferredDiagnostics and hence we were losing error messages. This is reminiscent of #20981, which also talks about writing errors into messages after their scope has ended. See #23305 for details. - - - - - 26013cdc by Alexander McKenna at 2023-06-09T15:19:41-04:00 Dump `SpecConstr` specialisations separately Introduce a `-ddump-spec-constr` flag which debugs specialisations from `SpecConstr`. These are no longer shown when you use `-ddump-spec`. - - - - - 4639100b by Matthew Pickering at 2023-06-09T18:50:43-04:00 Add role annotations to SNat, SSymbol and SChar Ticket #23454 explained it was possible to implement unsafeCoerce because SNat was lacking a role annotation. As these are supposed to be singleton types but backed by an efficient representation the correct annotation is nominal to ensure these kinds of coerces are forbidden. These annotations were missed from https://github.com/haskell/core-libraries-committee/issues/85 which was implemented in 532de36870ed9e880d5f146a478453701e9db25d. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/170 Fixes #23454 - - - - - 9c0dcff7 by Matthew Pickering at 2023-06-09T18:51:19-04:00 Remove non-existant bytearray-ops.txt.pp file from ghc.cabal.in This broke the sdist generation. Fixes #23489 - - - - - 273ff0c7 by David Binder at 2023-06-09T18:52:00-04:00 Regression test T13438 is no longer marked as "expect_broken" in the testsuite driver. - - - - - b84a2900 by Andrei Borzenkov at 2023-06-10T08:27:28-04:00 Fix -Wterm-variable-capture scope (#23434) -Wterm-variable-capture wasn't accordant with type variable scoping in associated types, in type classes. For example, this code produced the warning: k = 12 class C k a where type AT a :: k -> Type I solved this issue by reusing machinery of newTyVarNameRn function that is accordand with associated types: it does lookup for each free type variable when we are in the type class context. And in this patch I use result of this work to make sure that -Wterm-variable-capture warns only on implicitly quantified type variables. - - - - - 9d1a8d87 by Jorge Mendes at 2023-06-10T08:28:10-04:00 Remove redundant case statement in rts/js/mem.js. - - - - - a1f350e2 by Oleg Grenrus at 2023-06-13T09:42:16-04:00 Change WarningWithFlag to plural WarningWithFlags Resolves #22825 Now each diagnostic can name multiple different warning flags for its reason. There is currently one use case: missing signatures. Currently we need to check which warning flags are enabled when generating the diagnostic, which is against the declarative nature of the diagnostic framework. This patch allows a warning diagnostic to have multiple warning flags, which makes setup more declarative. The WarningWithFlag pattern synonym is added for backwards compatibility The 'msgEnvReason' field is added to MsgEnvelope to store the `ResolvedDiagnosticReason`, which accounts for the enabled flags, and then that is used for pretty printing the diagnostic. - - - - - ec01f0ec by Matthew Pickering at 2023-06-13T09:42:59-04:00 Add a test Way for running ghci with Core optimizations Tracking ticket: #23059 This runs compile_and_run tests with optimised code with bytecode interpreter Changed submodules: hpc, process Co-authored-by: Torsten Schmits <git at tryp.io> - - - - - c6741e72 by Rodrigo Mesquita at 2023-06-13T09:43:38-04:00 Configure -Qunused-arguments instead of hardcoding it When GHC invokes clang, it currently passes -Qunused-arguments to discard warnings resulting from GHC using multiple options that aren't used. In this commit, we configure -Qunused-arguments into the Cc options instead of checking if the compiler is clang at runtime and hardcoding the flag into GHC. This is part of the effort to centralise toolchain information in toolchain target files at configure time with the end goal of a runtime retargetable GHC. This also means we don't need to call getCompilerInfo ever, which improves performance considerably (see !10589). Metric Decrease: PmSeriesG T10421 T11303b T12150 T12227 T12234 T12425 T13035 T13253-spj T13386 T15703 T16875 T17836b T17977 T17977b T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T3064 T5030 T5321FD T5321Fun T5837 T6048 T9020 T9198 T9872d T9961 - - - - - 0128db87 by Victor Cacciari Miraldo at 2023-06-13T09:44:18-04:00 Improve docs for Data.Fixed; adds 'realToFrac' as an option for conversion between different precisions. - - - - - 95b69cfb by Ryan Scott at 2023-06-13T09:44:55-04:00 Add regression test for #23143 !10541, the fix for #23323, also fixes #23143. Let's add a regression test to ensure that it stays fixed. Fixes #23143. - - - - - ed2dbdca by Emily Martins at 2023-06-13T09:45:37-04:00 delete GHCi.UI.Tags module and remove remaining references Co-authored-by: Tilde Rose <t1lde at protonmail.com> - - - - - c90d96e4 by Victor Cacciari Miraldo at 2023-06-13T09:46:26-04:00 Add regression test for 17328 - - - - - de58080c by Victor Cacciari Miraldo at 2023-06-13T09:46:26-04:00 Skip checking whether constructors are in scope when deriving newtype instances. Fixes #17328 - - - - - 5e3c2b05 by Philip Hazelden at 2023-06-13T09:47:07-04:00 Don't suggest `DeriveAnyClass` when instance can't be derived. Fixes #19692. Prototypical cases: class C1 a where x1 :: a -> Int data G1 = G1 deriving C1 class C2 a where x2 :: a -> Int x2 _ = 0 data G2 = G2 deriving C2 Both of these used to give this suggestion, but for C1 the suggestion would have failed (generated code with undefined methods, which compiles but warns). Now C2 still gives the suggestion but C1 doesn't. - - - - - 80a0b099 by David Binder at 2023-06-13T09:47:49-04:00 Add testcase for error GHC-00711 to testsuite - - - - - e4b33a1d by Oleg Grenrus at 2023-06-14T07:01:21-04:00 Add -Wmissing-poly-kind-signatures Implements #22826 This is a restricted version of -Wmissing-kind-signatures shown only for polykinded types. - - - - - f8395b94 by doyougnu at 2023-06-14T07:02:01-04:00 ci: special case in req_host_target_ghc for JS - - - - - b852a5b6 by Gergő Érdi at 2023-06-14T07:02:42-04:00 When forcing a `ModIface`, force the `MINIMAL` pragmas in class definitions Fixes #23486 - - - - - c29b45ee by Krzysztof Gogolewski at 2023-06-14T07:03:19-04:00 Add a testcase for #20076 Remove 'recursive' in the error message, since the error can arise without recursion. - - - - - b80ef202 by Krzysztof Gogolewski at 2023-06-14T07:03:56-04:00 Use tcInferFRR to prevent bad generalisation Fixes #23176 - - - - - bd8ef37d by Matthew Pickering at 2023-06-14T07:04:31-04:00 ci: Add dependenices on necessary aarch64 jobs for head.hackage ci These need to be added since we started testing aarch64 on head.hackage CI. The jobs will sometimes fail because they will start before the relevant aarch64 job has finished. Fixes #23511 - - - - - a0c27cee by Vladislav Zavialov at 2023-06-14T07:05:08-04:00 Add standalone kind signatures for Code and TExp CodeQ and TExpQ already had standalone kind signatures even before this change: type TExpQ :: TYPE r -> Kind.Type type CodeQ :: TYPE r -> Kind.Type Now Code and TExp have signatures too: type TExp :: TYPE r -> Kind.Type type Code :: (Kind.Type -> Kind.Type) -> TYPE r -> Kind.Type This is a stylistic change. - - - - - e70c1245 by Tom Ellis at 2023-06-14T07:05:48-04:00 Warn that GHC.TypeLits.Internal should not be used - - - - - 100650e3 by Tom Ellis at 2023-06-14T07:05:48-04:00 Warn that GHC.TypeNats.Internal should not be used - - - - - 078250ef by Jacco Krijnen at 2023-06-14T17:17:53-04:00 Add more flags for dumping core passes (#23491) - - - - - 1b7604af by Jacco Krijnen at 2023-06-14T17:17:53-04:00 Add tests for dumping flags (#23491) - - - - - 42000000 by Sebastian Graf at 2023-06-14T17:18:29-04:00 Provide a demand signature for atomicModifyMutVar.# (#23047) Fixes #23047 - - - - - 8f27023b by Ben Gamari at 2023-06-15T03:10:24-04:00 compiler: Cross-reference Note [StgToJS design] In particular, the numeric representations are quite useful context in a few places. - - - - - a71b60e9 by Andrei Borzenkov at 2023-06-15T03:11:00-04:00 Implement the -Wimplicit-rhs-quantification warning (#23510) GHC Proposal #425 "Invisible binders in type declarations" forbids implicit quantification of type variables that occur free on the right-hand side of a type synonym but are not mentioned on the left-hand side. The users are expected to rewrite this using invisible binders: type T1 :: forall a . Maybe a type T1 = 'Nothing :: Maybe a -- old type T1 @a = 'Nothing :: Maybe a -- new Since the @k-binders are a new feature, we need to wait for three releases before we require the use of the new syntax. In the meantime, we ought to provide users with a new warning, -Wimplicit-rhs-quantification, that would detect when such implicit quantification takes place, and include it in -Wcompat. - - - - - 0078dd00 by Sven Tennie at 2023-06-15T03:11:36-04:00 Minor refactorings to mkSpillInstr and mkLoadInstr Better error messages. And, use the existing `off` constant to reduce duplication. - - - - - 1792b57a by doyougnu at 2023-06-15T03:12:17-04:00 JS: merge util modules Merge Core and StgUtil modules for StgToJS pass. Closes: #23473 - - - - - 469ff08b by Vladislav Zavialov at 2023-06-15T03:12:57-04:00 Check visibility of nested foralls in can_eq_nc (#18863) Prior to this change, `can_eq_nc` checked the visibility of the outermost layer of foralls: forall a. forall b. forall c. phi1 forall x. forall y. forall z. phi2 ^^ up to here Then it delegated the rest of the work to `can_eq_nc_forall`, which split off all foralls: forall a. forall b. forall c. phi1 forall x. forall y. forall z. phi2 ^^ up to here This meant that some visibility flags were completely ignored. We fix this oversight by moving the check to `can_eq_nc_forall`. - - - - - 59c9065b by Luite Stegeman at 2023-06-15T03:13:37-04:00 JS: use regular mask for blocking IO Blocking IO used uninterruptibleMask which should make any thread blocked on IO unreachable by async exceptions (such as those from timeout). This changes it to a regular mask. It's important to note that the nodejs runtime does not actually interrupt the blocking IO when the Haskell thread receives an async exception, and that file positions may be updated and buffers may be written after the Haskell thread has already resumed. Any file descriptor affected by an async exception interruption should therefore be used with caution. - - - - - 907c06c3 by Luite Stegeman at 2023-06-15T03:13:37-04:00 JS: nodejs: do not set 'readable' handler on stdin at startup The Haskell runtime used to install a 'readable' handler on stdin at startup in nodejs. This would cause the nodejs system to start buffering the stream, causing data loss if the stdin file descriptor is passed to another process. This change delays installation of the 'readable' handler until the first read of stdin by Haskell code. - - - - - a54b40a9 by Luite Stegeman at 2023-06-15T03:13:37-04:00 JS: reserve one more virtual (negative) file descriptor This is needed for upcoming support of the process package - - - - - 78cd1132 by Andrei Borzenkov at 2023-06-15T11:16:11+04:00 Report scoped kind variables at the type-checking phase (#16635) This patch modifies the renamer to respect ScopedTypeVariables in kind signatures. This means that kind variables bound by the outermost `forall` now scope over the type: type F = '[Right @a @() () :: forall a. Either a ()] -- ^^^^^^^^^^^^^^^ ^^^ -- in scope here bound here However, any use of such variables is a type error, because we don't have type-level lambdas to bind them in Core. This is described in the new Note [Type variable scoping errors during type check] in GHC.Tc.Types. - - - - - 4a41ba75 by Sylvain Henry at 2023-06-15T18:09:15-04:00 JS: testsuite: use correct ticket number Replace #22356 with #22349 for these tests because #22356 has been fixed but now these tests fail because of #22349. - - - - - 15f150c8 by Sylvain Henry at 2023-06-15T18:09:16-04:00 JS: testsuite: update ticket numbers - - - - - 08d8e9ef by Sylvain Henry at 2023-06-15T18:09:16-04:00 JS: more triage - - - - - e8752e12 by Krzysztof Gogolewski at 2023-06-15T18:09:52-04:00 Fix test T18522-deb-ppr Fixes #23509 - - - - - 62c56416 by Ben Price at 2023-06-16T05:52:39-04:00 Lint: more details on "Occurrence is GlobalId, but binding is LocalId" This is helpful when debugging a pass which accidentally shadowed a binder. - - - - - d4c10238 by Ryan Hendrickson at 2023-06-16T05:53:22-04:00 Clean a stray bit of text in user guide - - - - - 93647b5c by Vladislav Zavialov at 2023-06-16T05:54:02-04:00 testsuite: Add forall visibility test cases The added tests ensure that the type checker does not confuse visible and invisible foralls. VisFlag1: kind-checking type applications and inferred type variable instantiations VisFlag1_ql: kind-checking Quick Look instantiations VisFlag2: kind-checking type family instances VisFlag3: checking kind annotations on type parameters of associated type families VisFlag4: checking kind annotations on type parameters in type declarations with SAKS VisFlag5: checking the result kind annotation of data family instances - - - - - a5f0c00e by Sylvain Henry at 2023-06-16T12:25:40-04:00 JS: factorize SaneDouble into its own module Follow-up of b159e0e9 whose ticket is #22736 - - - - - 0baf9e7c by Krzysztof Gogolewski at 2023-06-16T12:26:17-04:00 Add tests for #21973 - - - - - 640ea90e by Diego Diverio at 2023-06-16T23:07:55-04:00 Update documentation for `<**>` - - - - - 2469a813 by Diego Diverio at 2023-06-16T23:07:55-04:00 Update text - - - - - 1f515bbb by Diego Diverio at 2023-06-16T23:07:55-04:00 Update examples - - - - - 7af99a0d by Diego Diverio at 2023-06-16T23:07:55-04:00 Update documentation to actually display code correctly - - - - - 800aad7e by Andrei Borzenkov at 2023-06-16T23:08:32-04:00 Type/data instances: require that variables on the RHS are mentioned on the LHS (#23512) GHC Proposal #425 "Invisible binders in type declarations" restricts the scope of type and data family instances as follows: In type family and data family instances, require that every variable mentioned on the RHS must also occur on the LHS. For example, here are three equivalent type instance definitions accepted before this patch: type family F1 a :: k type instance F1 Int = Any :: j -> j type family F2 a :: k type instance F2 @(j -> j) Int = Any :: j -> j type family F3 a :: k type instance forall j. F3 Int = Any :: j -> j - In F1, j is implicitly quantified and it occurs only on the RHS; - In F2, j is implicitly quantified and it occurs both on the LHS and the RHS; - In F3, j is explicitly quantified. Now F1 is rejected with an out-of-scope error, while F2 and F3 continue to be accepted. - - - - - 9132d529 by Sylvain Henry at 2023-06-18T02:50:34-04:00 JS: testsuite: use correct ticket numbers - - - - - c3a1274c by Sylvain Henry at 2023-06-18T02:50:34-04:00 JS: don't dump eventlog to stderr by default Fix T16707 Bump stm submodule - - - - - 89bb8ad8 by Ryan Hendrickson at 2023-06-18T02:51:14-04:00 Fix TH name lookup for symbolic tycons (#23525) - - - - - cb9e1ce4 by Finley McIlwaine at 2023-06-18T21:16:45-06:00 IPE data compression IPE data resulting from the `-finfo-table-map` flag may now be compressed by configuring the GHC build with the `--enable-ipe-data-compression` flag. This results in about a 20% reduction in the size of IPE-enabled build results. The compression library, zstd, may optionally be statically linked by configuring with the `--enabled-static-libzstd` flag (on non-darwin platforms) libzstd version 1.4.0 or greater is required. - - - - - 0cbc3ae0 by Gergő Érdi at 2023-06-19T09:11:38-04:00 Add `IfaceWarnings` to represent the `ModIface`-storable parts of a `Warnings GhcRn`. Fixes #23516 - - - - - 3e80c2b4 by Arnaud Spiwack at 2023-06-20T03:19:41-04:00 Avoid desugaring non-recursive lets into recursive lets This prepares for having linear let expressions in the frontend. When desugaring lets, SPECIALISE statements create more copies of a let binding. Because of the rewrite rules attached to the bindings, there are dependencies between the generated binds. Before this commit, we simply wrapped all these in a mutually recursive let block, and left it to the simplified to sort it out. With this commit: we are careful to generate the bindings in dependency order, so that we can wrap them in consecutive lets (if the source is non-recursive). - - - - - 9fad49e0 by Ben Gamari at 2023-06-20T03:20:19-04:00 rts: Do not call exit() from SIGINT handler Previously `shutdown_handler` would call `stg_exit` if the scheduler was Oalready found to be in `SCHED_INTERRUPTING` state (or higher). However, `stg_exit` is not signal-safe as it calls `exit` (which calls `atexit` handlers). The only safe thing to do in this situation is to call `_exit`, which terminates with minimal cleanup. Fixes #23417. - - - - - 7485f848 by Andrew Lelechenko at 2023-06-20T03:20:57-04:00 Bump Cabal submodule This requires changing the recomp007 test because now cabal passes `this-unit-id` to executable components, and that unit-id contains a hash which includes the ABI of the dependencies. Therefore changing the dependencies means that -this-unit-id changes and recompilation is triggered. The spririt of the test is to test GHC's recompilation logic assuming that `-this-unit-id` is constant, so we explicitly pass `-ipid` to `./configure` rather than letting `Cabal` work it out. - - - - - 1464a2a8 by mangoiv at 2023-06-20T03:21:34-04:00 [feat] add a hint to `HasField` error message - add a hint that indicates that the record that the record dot is used on might just be missing a field - as the intention of the programmer is not entirely clear, it is only shown if the type is known - This addresses in part issue #22382 - - - - - b65e78dd by Ben Gamari at 2023-06-20T16:56:43-04:00 rts/ipe: Fix unused lock warning - - - - - 6086effd by Ben Gamari at 2023-06-20T16:56:44-04:00 rts/ProfilerReportJson: Fix memory leak - - - - - 1e48c434 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Various warnings fixes - - - - - 471486b9 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix printf format mismatch - - - - - 80603fb3 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix incorrect #include <sys/poll.h> According to Alpine's warnings and poll(2), <poll.h> should be preferred. - - - - - ff18e6fd by Ben Gamari at 2023-06-20T16:56:44-04:00 nonmoving: Fix unused definition warrnings - - - - - 6e7fe8ee by Ben Gamari at 2023-06-20T16:56:44-04:00 Disable futimens on Darwin. See #22938 - - - - - b7706508 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix incorrect CPP guard - - - - - 94f00e9b by Ben Gamari at 2023-06-20T16:56:44-04:00 hadrian: Ensure that -Werror is passed when compiling the RTS. Previously the `+werror` transformer would only pass `-Werror` to GHC, which does not ensure that the same is passed to the C compiler when building the RTS. Arguably this is itself a bug but for now we will just work around this by passing `-optc-Werror` to GHC. I tried to enable `-Werror` in all C compilations but the boot libraries are something of a portability nightmare. - - - - - 5fb54bf8 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Disable `#pragma GCC`s on clang compilers Otherwise the build fails due to warnings. See #23530. - - - - - cf87f380 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix capitalization of prototype - - - - - 17f250d7 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix incorrect format specifier - - - - - 0ff1c501 by Josh Meredith at 2023-06-20T16:57:20-04:00 JS: remove js_broken(22576) in favour of the pre-existing wordsize(32) condition (#22576) - - - - - 3d1d42b7 by Finley McIlwaine at 2023-06-21T12:04:58-04:00 Memory usage fixes for Haddock - Do not include `mi_globals` in the `NoBackend` backend. It was only included for Haddock, but Haddock does not actually need it. This causes a 200MB reduction in max residency when generating haddocks on the Agda codebase (roughly 1GB to 800MB). - Make haddock_{parser,renamer}_perf tests more accurate by forcing docs to be written to interface files using `-fwrite-interface` Bumps haddock submodule. Metric Decrease: haddock.base - - - - - 8185b1c2 by Finley McIlwaine at 2023-06-21T12:04:58-04:00 Fix associated data family doc structure items Associated data families were being given their own export DocStructureItems, which resulted in them being documented separately from their classes in haddocks. This commit fixes it. - - - - - 4d356ea3 by Sylvain Henry at 2023-06-21T12:04:59-04:00 JS: implement TH support - Add ghc-interp.js bootstrap script for the JS interpreter - Interactively link and execute iserv code from the ghci package - Incrementally load and run JS code for splices into the running iserv Co-authored-by: Luite Stegeman <stegeman at gmail.com> - - - - - 3249cf12 by Sylvain Henry at 2023-06-21T12:04:59-04:00 Don't use getKey - - - - - f84ff161 by Sylvain Henry at 2023-06-21T12:04:59-04:00 Stg: return imported FVs This is used to determine what to link when using the interpreter. For now it's only used by the JS interpreter but it could easily be used by the native interpreter too (instead of extracting names from compiled BCOs). - - - - - fab2ad23 by Sylvain Henry at 2023-06-21T12:04:59-04:00 Fix some recompilation avoidance tests - - - - - a897dc13 by Sylvain Henry at 2023-06-21T12:04:59-04:00 TH_import_loop is now broken as expected - - - - - dbb4ad51 by Sylvain Henry at 2023-06-21T12:04:59-04:00 JS: always recompile when TH is enabled (cf #23013) - - - - - 711b1d24 by Bartłomiej Cieślar at 2023-06-21T12:59:27-04:00 Add support for deprecating exported items (proposal #134) This is an implementation of the deprecated exports proposal #134. The proposal introduces an ability to introduce warnings to exports. This allows for deprecating a name only when it is exported from a specific module, rather than always depreacting its usage. In this example: module A ({-# DEPRECATED "do not use" #-} x) where x = undefined --- module B where import A(x) `x` will emit a warning when it is explicitly imported. Like the declaration warnings, export warnings are first accumulated within the `Warnings` struct, then passed into the ModIface, from which they are then looked up and warned about in the importing module in the `lookup_ie` helpers of the `filterImports` function (for the explicitly imported names) and in the `addUsedGRE(s)` functions where they warn about regular usages of the imported name. In terms of the AST information, the custom warning is stored in the extension field of the variants of the `IE` type (see Trees that Grow for more information). The commit includes a bump to the haddock submodule added in MR #28 Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - c1865854 by Ben Gamari at 2023-06-21T12:59:30-04:00 configure: Bump version to 9.8 Bumps Haddock submodule - - - - - 4e1de71c by Ben Gamari at 2023-06-21T21:07:48-04:00 configure: Bump version to 9.9 Bumps haddock submodule. - - - - - 5b6612bc by Ben Gamari at 2023-06-23T03:56:49-04:00 rts: Work around missing prototypes errors Darwin's toolchain inexpliciably claims that `write_barrier` and friends have declarations without prototypes, despite the fact that (a) they are definitions, and (b) the prototypes appear only a few lines above. Work around this by making the definitions proper prototypes. - - - - - 43b66a13 by Matthew Pickering at 2023-06-23T03:57:26-04:00 ghcup-metadata: Fix date modifier (M = minutes, m = month) Fixes #23552 - - - - - 564164ef by Luite Stegeman at 2023-06-24T10:27:29+09:00 Support large stack frames/offsets in GHCi bytecode interpreter Bytecode instructions like PUSH_L (push a local variable) contain an operand that refers to the stack slot. Before this patch, the operand type was SmallOp (Word16), limiting the maximum stack offset to 65535 words. This could cause compiler panics in some cases (See #22888). This patch changes the operand type for stack offsets from SmallOp to Op, removing the stack offset limit. Fixes #22888 - - - - - 8d6574bc by Sylvain Henry at 2023-06-26T13:15:06-04:00 JS: support levity-polymorphic datatypes (#22360,#22291) - thread knowledge about levity into PrimRep instead of panicking - JS: remove assumption that unlifted heap objects are rts objects (TVar#, etc.) Doing this also fixes #22291 (test added). There is a small performance hit (~1% more allocations). Metric Increase: T18698a T18698b - - - - - 5578bbad by Matthew Pickering at 2023-06-26T13:15:43-04:00 MR Review Template: Mention "Blocked on Review" label In order to improve our MR review processes we now have the label "Blocked on Review" which allows people to signal that a MR is waiting on a review to happen. See: https://mail.haskell.org/pipermail/ghc-devs/2023-June/021255.html - - - - - 4427e9cf by Matthew Pickering at 2023-06-26T13:15:43-04:00 Move MR template to Default.md This makes it more obvious what you have to modify to affect the default template rather than looking in the project settings. - - - - - 522bd584 by Arnaud Spiwack at 2023-06-26T13:16:33-04:00 Revert "Avoid desugaring non-recursive lets into recursive lets" This (temporary) reverts commit 3e80c2b40213bebe302b1bd239af48b33f1b30ef. Fixes #23550 - - - - - c59fbb0b by Torsten Schmits at 2023-06-26T19:34:20+02:00 Propagate breakpoint information when inlining across modules Tracking ticket: #23394 MR: !10448 * Add constructor `IfaceBreakpoint` to `IfaceTickish` * Store breakpoint data in interface files * Store `BreakArray` for the breakpoint's module, not the current module, in BCOs * Store module name in BCOs instead of `Unique`, since the `Unique` from an `Iface` doesn't match the modules in GHCi's state * Allocate module name in `ModBreaks`, like `BreakArray` * Lookup breakpoint by module name in GHCi * Skip creating breakpoint instructions when no `ModBreaks` are available, rather than injecting `ModBreaks` in the linker when breakpoints are enabled, and panicking when `ModBreaks` is missing - - - - - 6f904808 by Greg Steuck at 2023-06-27T16:53:07-04:00 Remove undefined FP_PROG_LD_BUILD_ID from configure.ac's - - - - - e89aa072 by Andrei Borzenkov at 2023-06-27T16:53:44-04:00 Remove arity inference in type declarations (#23514) Arity inference in type declarations was introduced as a workaround for the lack of @k-binders. They were added in 4aea0a72040, so I simplified all of this by simply removing arity inference altogether. This is part of GHC Proposal #425 "Invisible binders in type declarations". - - - - - 459dee1b by Torsten Schmits at 2023-06-27T16:54:20-04:00 Relax defaulting of RuntimeRep/Levity when printing Fixes #16468 MR: !10702 Only default RuntimeRep to LiftedRep when variables are bound by the toplevel forall - - - - - 151f8f18 by Torsten Schmits at 2023-06-27T16:54:57-04:00 Remove duplicate link label in linear types docs - - - - - ecdc4353 by Rodrigo Mesquita at 2023-06-28T12:24:57-04:00 Stop configuring unused Ld command in `settings` GHC has no direct dependence on the linker. Rather, we depend upon the C compiler for linking and an object-merging program (which is typically `ld`) for production of GHCi objects and merging of C stubs into final object files. Despite this, for historical reasons we still recorded information about the linker into `settings`. Remove these entries from `settings`, `hadrian/cfg/system.config`, as well as the `configure` logic responsible for this information. Closes #23566. - - - - - bf9ec3e4 by Bryan Richter at 2023-06-28T12:25:33-04:00 Remove extraneous debug output - - - - - 7eb68dd6 by Bryan Richter at 2023-06-28T12:25:33-04:00 Work with unset vars in -e mode - - - - - 49c27936 by Bryan Richter at 2023-06-28T12:25:33-04:00 Pass positional arguments in their positions By quoting $cmd, the default "bash -i" is a single argument to run, and no file named "bash -i" actually exists to be run. - - - - - 887dc4fc by Bryan Richter at 2023-06-28T12:25:33-04:00 Handle unset value in -e context - - - - - 5ffc7d7b by Rodrigo Mesquita at 2023-06-28T21:07:36-04:00 Configure CPP into settings There is a distinction to be made between the Haskell Preprocessor and the C preprocessor. The former is used to preprocess Haskell files, while the latter is used in C preprocessing such as Cmm files. In practice, they are both the same program (usually the C compiler) but invoked with different flags. Previously we would, at configure time, configure the haskell preprocessor and save the configuration in the settings file, but, instead of doing the same for CPP, we had hardcoded in GHC that the CPP program was either `cc -E` or `cpp`. This commit fixes that asymmetry by also configuring CPP at configure time, and tries to make more explicit the difference between HsCpp and Cpp (see Note [Preprocessing invocations]). Note that we don't use the standard CPP and CPPFLAGS to configure Cpp, but instead use the non-standard --with-cpp and --with-cpp-flags. The reason is that autoconf sets CPP to "$CC -E", whereas we expect the CPP command to be configured as a standalone executable rather than a command. These are symmetrical with --with-hs-cpp and --with-hs-cpp-flags. Cleanup: Hadrian no longer needs to pass the CPP configuration for CPP to be C99 compatible through -optP, since we now configure that into settings. Closes #23422 - - - - - 5efa9ca5 by Ben Gamari at 2023-06-28T21:08:13-04:00 hadrian: Always canonicalize topDirectory Hadrian's `topDirectory` is intended to provide an absolute path to the root of the GHC tree. However, if the tree is reached via a symlink this One question here is whether the `canonicalizePath` call is expensive enough to warrant caching. In a quick microbenchmark I observed that `canonicalizePath "."` takes around 10us per call; this seems sufficiently low not to worry. Alternatively, another approach here would have been to rather move the canonicalization into `m4/fp_find_root.m4`. This would have avoided repeated canonicalization but sadly path canonicalization is a hard problem in POSIX shell. Addresses #22451. - - - - - b3e1436f by aadaa_fgtaa at 2023-06-28T21:08:53-04:00 Optimise ELF linker (#23464) - cache last elements of `relTable`, `relaTable` and `symbolTables` in `ocInit_ELF` - cache shndx table in ObjectCode - run `checkProddableBlock` only with debug rts - - - - - 30525b00 by Ben Gamari at 2023-06-28T21:09:30-04:00 compiler: Introduce MO_{ACQUIRE,RELEASE}_FENCE - - - - - b787e259 by Ben Gamari at 2023-06-28T21:09:30-04:00 compiler: Drop MO_WriteBarrier rts: Drop write_barrier - - - - - 7550b4a5 by Ben Gamari at 2023-06-28T21:09:30-04:00 rts: Drop load_store_barrier() This is no longer used. - - - - - d5f2875e by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Drop last instances of prim_{write,read}_barrier - - - - - 965ac2ba by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Eliminate remaining uses of load_load_barrier - - - - - 0fc5cb97 by Sven Tennie at 2023-06-28T21:09:31-04:00 compiler: Drop MO_ReadBarrier - - - - - 7a7d326c by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Drop load_load_barrier This is no longer used. - - - - - 9f63da66 by Sven Tennie at 2023-06-28T21:09:31-04:00 Delete write_barrier function - - - - - bb0ed354 by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Make collectFreshWeakPtrs definition a prototype x86-64/Darwin's toolchain inexplicably warns that collectFreshWeakPtrs needs to be a prototype. - - - - - ef81a1eb by Sven Tennie at 2023-06-28T21:10:08-04:00 Fix number of free double regs D1..D4 are defined for aarch64 and thus not free. - - - - - c335fb7c by Ryan Scott at 2023-06-28T21:10:44-04:00 Fix typechecking of promoted empty lists The `'[]` case in `tc_infer_hs_type` is smart enough to handle arity-0 uses of `'[]` (see the newly added `T23543` test case for an example), but the `'[]` case in `tc_hs_type` was not. We fix this by changing the `tc_hs_type` case to invoke `tc_infer_hs_type`, as prescribed in `Note [Future-proofing the type checker]`. There are some benign changes to test cases' expected output due to the new code path using `forall a. [a]` as the kind of `'[]` rather than `[k]`. Fixes #23543. - - - - - fcf310e7 by Rodrigo Mesquita at 2023-06-28T21:11:21-04:00 Configure MergeObjs supports response files rather than Ld The previous configuration script to test whether Ld supported response files was * Incorrect (see #23542) * Used, in practice, to check if the *merge objects tool* supported response files. This commit modifies the macro to run the merge objects tool (rather than Ld), using a response file, and checking the result with $NM Fixes #23542 - - - - - 78b2f3cc by Sylvain Henry at 2023-06-28T21:12:02-04:00 JS: fix JS stack printing (#23565) - - - - - 9f01d14b by Matthew Pickering at 2023-06-29T04:13:41-04:00 Add -fpolymorphic-specialisation flag (off by default at all optimisation levels) Polymorphic specialisation has led to a number of hard to diagnose incorrect runtime result bugs (see #23469, #23109, #21229, #23445) so this commit introduces a flag `-fpolymorhphic-specialisation` which allows users to turn on this experimental optimisation if they are willing to buy into things going very wrong. Ticket #23469 - - - - - b1e611d5 by Ben Gamari at 2023-06-29T04:14:17-04:00 Rip out runtime linker/compiler checks We used to choose flags to pass to the toolchain at runtime based on the platform running GHC, and in this commit we drop all of those runtime linker checks Ultimately, this represents a change in policy: We no longer adapt at runtime to the toolchain being used, but rather make final decisions about the toolchain used at /configure time/ (we have deleted Note [Run-time linker info] altogether!). This works towards the goal of having all toolchain configuration logic living in the same place, which facilities the work towards a runtime-retargetable GHC (see #19877). As of this commit, the runtime linker/compiler logic was moved to autoconf, but soon it, and the rest of the existing toolchain configuration logic, will live in the standalone ghc-toolchain program (see !9263) In particular, what used to be done at runtime is now as follows: * The flags -Wl,--no-as-needed for needed shared libs are configured into settings * The flag -fstack-check is configured into settings * The check for broken tables-next-to-code was outdated * We use the configured c compiler by default as the assembler program * We drop `asmOpts` because we already configure -Qunused-arguments flag into settings (see !10589) Fixes #23562 Co-author: Rodrigo Mesquita (@alt-romes) - - - - - 8b35e8ca by Ben Gamari at 2023-06-29T18:46:12-04:00 Define FFI_GO_CLOSURES The libffi shipped with Apple's XCode toolchain does not contain a definition of the FFI_GO_CLOSURES macro, despite containing references to said macro. Work around this by defining the macro, following the model of a similar workaround in OpenJDK [1]. [1] https://github.com/openjdk/jdk17u-dev/pull/741/files - - - - - d7ef1704 by Ben Gamari at 2023-06-29T18:46:12-04:00 base: Fix incorrect CPP guard This was guarded on `darwin_HOST_OS` instead of `defined(darwin_HOST_OS)`. - - - - - 7c7d1f66 by Ben Gamari at 2023-06-29T18:46:48-04:00 rts/Trace: Ensure that debugTrace arguments are used As debugTrace is a macro we must take care to ensure that the fact is clear to the compiler lest we see warnings. - - - - - cb92051e by Ben Gamari at 2023-06-29T18:46:48-04:00 rts: Various warnings fixes - - - - - dec81dd1 by Ben Gamari at 2023-06-29T18:46:48-04:00 hadrian: Ignore warnings in unix and semaphore-compat - - - - - d7f6448a by Matthew Pickering at 2023-06-30T12:38:43-04:00 hadrian: Fix dependencies of docs:* rule For the docs:* rule we need to actually build the package rather than just the haddocks for the dependent packages. Therefore we depend on the .conf files of the packages we are trying to build documentation for as well as the .haddock files. Fixes #23472 - - - - - cec90389 by sheaf at 2023-06-30T12:39:27-04:00 Add tests for #22106 Fixes #22106 - - - - - 083794b1 by Torsten Schmits at 2023-07-03T03:27:27-04:00 Add -fbreak-points to control breakpoint insertion Rather than statically enabling breakpoints only for the interpreter, this adds a new flag. Tracking ticket: #23057 MR: !10466 - - - - - fd8c5769 by Ben Gamari at 2023-07-03T03:28:04-04:00 rts: Ensure that pinned allocations respect block size Previously, it was possible for pinned, aligned allocation requests to allocate beyond the end of the pinned accumulator block. Specifically, we failed to account for the padding needed to achieve the requested alignment in the "large object" check. With large alignment requests, this can result in the allocator using the capability's pinned object accumulator block to service a request which is larger than `PINNED_EMPTY_SIZE`. To fix this we reorganize `allocatePinned` to consistently account for the alignment padding in all large object checks. This is a bit subtle as we must handle the case of a small allocation request filling the accumulator block, as well as large requests. Fixes #23400. - - - - - 98185d52 by Ben Gamari at 2023-07-03T03:28:05-04:00 testsuite: Add test for #23400 - - - - - 4aac0540 by Ben Gamari at 2023-07-03T03:28:42-04:00 ghc-heap: Support for BLOCKING_QUEUE closures - - - - - 03f941f4 by Ben Bellick at 2023-07-03T03:29:29-04:00 Add some structured diagnostics in Tc/Validity.hs This addresses the work of ticket #20118 Created the following constructors for TcRnMessage - TcRnInaccessibleCoAxBranch - TcRnPatersonCondFailure - - - - - 6074cc3c by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Add failing test case for #23492 - - - - - 356a2692 by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Use generated src span for catch-all case of record selector functions This fixes #23492. The problem was that we used the real source span of the field declaration for the generated catch-all case in the selector function, in particular in the generated call to `recSelError`, which meant it was included in the HIE output. Using `generatedSrcSpan` instead means that it is not included. - - - - - 3efe7f39 by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Introduce genLHsApp and genLHsLit helpers in GHC.Rename.Utils - - - - - dd782343 by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Construct catch-all default case using helpers GHC.Rename.Utils concrete helpers instead of wrapGenSpan + HS AST constructors - - - - - 0e09c38e by Ryan Hendrickson at 2023-07-03T03:30:56-04:00 Add regression test for #23549 - - - - - 32741743 by Alexis King at 2023-07-03T03:31:36-04:00 perf tests: Increase default stack size for MultiLayerModules An unhelpfully small stack size appears to have been the real culprit behind the metric fluctuations in #19293. Debugging metric decreases triggered by !10729 helped to finally identify the problem. Metric Decrease: MultiLayerModules MultiLayerModulesTH_Make T13701 T14697 - - - - - 82ac6bf1 by Bryan Richter at 2023-07-03T03:32:15-04:00 Add missing void prototypes to rts functions See #23561. - - - - - 6078b429 by Ben Gamari at 2023-07-03T03:32:51-04:00 gitlab-ci: Refactor compilation of gen_ci Flakify and document it, making it far less sensitive to the build environment. - - - - - aa2db0ae by Ben Gamari at 2023-07-03T03:33:29-04:00 testsuite: Update documentation - - - - - 924a2362 by Gregory Gerasev at 2023-07-03T03:34:10-04:00 Better error for data deriving of type synonym/family. Closes #23522 - - - - - 4457da2a by Dave Barton at 2023-07-03T03:34:51-04:00 Fix some broken links and typos - - - - - de5830d0 by Ben Gamari at 2023-07-04T22:03:59-04:00 configure: Rip out Solaris dyld check Solaris 11 was released over a decade ago and, moreover, I doubt we have any Solaris users - - - - - 59c5fe1d by doyougnu at 2023-07-04T22:04:56-04:00 CI: add JS release and debug builds, regen CI jobs - - - - - 679bbc97 by Vladislav Zavialov at 2023-07-04T22:05:32-04:00 testsuite: Do not require CUSKs Numerous tests make use of CUSKs (complete user-supplied kinds), a legacy feature scheduled for deprecation. In order to proceed with the said deprecation, the tests have been updated to use SAKS instead (standalone kind signatures). This also allows us to remove the Haskell2010 language pragmas that were added in 115cd3c85a8 to work around the lack of CUSKs in GHC2021. - - - - - 945d3599 by Ben Gamari at 2023-07-04T22:06:08-04:00 gitlab: Drop backport-for-8.8 MR template Its usefulness has long passed. - - - - - 66c721d3 by Alan Zimmerman at 2023-07-04T22:06:44-04:00 EPA: Simplify GHC/Parser.y comb2 Use the HasLoc instance from Ast.hs to allow comb2 to work with anything with a SrcSpan This gets rid of the custom comb2A, comb2Al, comb2N functions, and removes various reLoc calls. - - - - - 2be99b7e by Matthew Pickering at 2023-07-04T22:07:21-04:00 Fix deprecation warning when deprecated identifier is from another module A stray 'Just' was being printed in the deprecation message. Fixes #23573 - - - - - 46c9bcd6 by Ben Gamari at 2023-07-04T22:07:58-04:00 rts: Don't rely on initializers for sigaction_t As noted in #23577, CentOS's ancient toolchain throws spurious missing-field-initializer warnings. - - - - - ec55035f by Ben Gamari at 2023-07-04T22:07:58-04:00 hadrian: Don't treat -Winline warnings as fatal Such warnings are highly dependent upon the toolchain, platform, and build configuration. It's simply too fragile to rely on these. - - - - - 3a09b789 by Ben Gamari at 2023-07-04T22:07:58-04:00 hadrian: Only pass -Wno-nonportable-include-path on Darwin This flag, which was introduced due to #17798, is only understood by Clang and consequently throws warnings on platforms using gcc. Sadly, there is no good way to treat such warnings as non-fatal with `-Werror` so for now we simply make this flag specific to platforms known to use Clang and case-insensitive filesystems (Darwin and Windows). See #23577. - - - - - 4af7eac2 by Mario Blažević at 2023-07-04T22:08:38-04:00 Fixed ticket #23571, TH.Ppr.pprLit hanging on large numeric literals - - - - - 2304c697 by Ben Gamari at 2023-07-04T22:09:15-04:00 compiler: Make OccSet opaque - - - - - cf735db8 by Andrei Borzenkov at 2023-07-04T22:09:51-04:00 Add Note about why we need forall in Code to be on the right - - - - - fb140f82 by Hécate Moonlight at 2023-07-04T22:10:34-04:00 Relax the constraint about the foreign function's calling convention of FinalizerPtr to capi as well as ccall. - - - - - 9ce44336 by meooow25 at 2023-07-05T11:42:37-04:00 Improve the situation with the stimes cycle Currently the Semigroup stimes cycle is resolved in GHC.Base by importing stimes implementations from a hs-boot file. Resolve the cycle using hs-boot files for required classes (Num, Integral) instead. Now stimes can be defined directly in GHC.Base, making inlining and specialization possible. This leads to some new boot files for `GHC.Num` and `GHC.Real`, the methods for those are only used to implement `stimes` so it doesn't appear that these boot files will introduce any new performance traps. Metric Decrease: T13386 T8095 Metric Increase: T13253 T13386 T18698a T18698b T19695 T8095 - - - - - 9edcb1fb by Jaro Reinders at 2023-07-05T11:43:24-04:00 Refactor Unique to be represented by Word64 In #22010 we established that Int was not always sufficient to store all the uniques we generate during compilation on 32-bit platforms. This commit addresses that problem by using Word64 instead of Int for uniques. The core of the change is in GHC.Core.Types.Unique and GHC.Core.Types.Unique.Supply. However, the representation of uniques is used in many other places, so those needed changes too. Additionally, the RTS has been extended with an atomic_inc64 operation. One major change from this commit is the introduction of the Word64Set and Word64Map data types. These are adapted versions of IntSet and IntMap from the containers package. These are planned to be upstreamed in the future. As a natural consequence of these changes, the compiler will be a bit slower and take more space on 32-bit platforms. Our CI tests indicate around a 5% residency increase. Metric Increase: CoOpt_Read CoOpt_Singletons LargeRecord ManyAlternatives ManyConstructors MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot RecordUpdPerf T10421 T10547 T12150 T12227 T12234 T12425 T12707 T13035 T13056 T13253 T13253-spj T13379 T13386 T13719 T14683 T14697 T14766 T15164 T15703 T16577 T16875 T17516 T18140 T18223 T18282 T18304 T18698a T18698b T18923 T1969 T19695 T20049 T21839c T3064 T3294 T4801 T5030 T5321FD T5321Fun T5631 T5642 T5837 T6048 T783 T8095 T9020 T9198 T9233 T9630 T9675 T9872a T9872b T9872b_defer T9872c T9872d T9961 TcPlugin_RewritePerf UniqLoop WWRec hard_hole_fits - - - - - 6b9db7d4 by Brandon Chinn at 2023-07-05T11:44:03-04:00 Fix docs for __GLASGOW_HASKELL_FULL_VERSION__ macro - - - - - 40f4ef7c by Torsten Schmits at 2023-07-05T18:06:19-04:00 Substitute free variables captured by breakpoints in SpecConstr Fixes #23267 - - - - - 2b55cb5f by sheaf at 2023-07-05T18:07:07-04:00 Reinstate untouchable variable error messages This extra bit of information was accidentally being discarded after a refactoring of the way we reported problems when unifying a type variable with another type. This patch rectifies that. - - - - - 53ed21c5 by Rodrigo Mesquita at 2023-07-05T18:07:47-04:00 configure: Drop Clang command from settings Due to 01542cb7227614a93508b97ecad5b16dddeb6486 we no longer use the `runClang` function, and no longer need to configure into settings the Clang command. We used to determine options at runtime to pass clang when it was used as an assembler, but now that we configure at configure time we no longer need to. - - - - - 6fdcf969 by Torsten Schmits at 2023-07-06T12:12:09-04:00 Filter out nontrivial substituted expressions in substTickish Fixes #23272 - - - - - 41968fd6 by Sylvain Henry at 2023-07-06T12:13:02-04:00 JS: testsuite: use req_c predicate instead of js_broken - - - - - 74a4dd2e by Sylvain Henry at 2023-07-06T12:13:02-04:00 JS: implement some file primitives (lstat,rmdir) (#22374) - Implement lstat and rmdir. - Implement base_c_s_is* functions (testing a file type) - Enable passing tests - - - - - 7e759914 by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: cleanup utils (#23314) - Removed unused code - Don't export unused functions - Move toTypeList to Closure module - - - - - f617655c by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: rename VarType/Vt into JSRep - - - - - 19216ca5 by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: remove custom PrimRep conversion (#23314) We use the usual conversion to PrimRep and then we convert these PrimReps to JSReps. - - - - - d3de8668 by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: don't use isRuntimeRepKindedTy in JS FFI - - - - - 8d1b75cb by Matthew Pickering at 2023-07-07T02:40:15-04:00 ghcup-metadata: Also updates ghcup-nightlies-0.0.7.yaml file Fixes #23600 - - - - - e524fa7f by Matthew Pickering at 2023-07-07T02:40:15-04:00 ghcup-metadata: Use dynamically linked alpine bindists In theory these will work much better on alpine to allow people to build statically linked applications there. We don't need to distribute a statically linked application ourselves in order to allow that. Fixes #23602 - - - - - b9e7beb9 by Ben Gamari at 2023-07-07T11:32:22-04:00 Drop circle-ci-job.sh - - - - - 9955eead by Ben Gamari at 2023-07-07T11:32:22-04:00 testsuite: Allow preservation of unexpected output Here we introduce a new flag to the testsuite driver, --unexpected-output-dir=<dir>, which allows the user to ask the driver to preserve unexpected output from tests. The intent is for this to be used in CI to allow users to more easily fix unexpected platform-dependent output. - - - - - 48f80968 by Ben Gamari at 2023-07-07T11:32:22-04:00 gitlab-ci: Preserve unexpected output Here we enable use of the testsuite driver's `--unexpected-output-dir` flag by CI, preserving the result as an artifact for use by users. - - - - - 76983a0d by Matthew Pickering at 2023-07-07T11:32:58-04:00 driver: Fix -S with .cmm files There was an oversight in the driver which assumed that you would always produce a `.o` file when compiling a .cmm file. Fixes #23610 - - - - - 6df15e93 by Mike Pilgrem at 2023-07-07T11:33:40-04:00 Update Hadrian's stack.yaml - - - - - 1dff43cf by Ben Gamari at 2023-07-08T05:05:37-04:00 compiler: Rework ShowSome Previously the field used to filter the sub-declarations to show was rather ad-hoc and was only able to show at most one sub-declaration. - - - - - 8165404b by Ben Gamari at 2023-07-08T05:05:37-04:00 testsuite: Add test to catch changes in core libraries This adds testing infrastructure to ensure that changes in core libraries (e.g. `base` and `ghc-prim`) are caught in CI. - - - - - ec1c32e2 by Melanie Phoenix at 2023-07-08T05:06:14-04:00 Deprecate Data.List.NonEmpty.unzip - - - - - 5d2442b8 by Ben Gamari at 2023-07-08T05:06:51-04:00 Drop latent mentions of -split-objs Closes #21134. - - - - - a9bc20cb by Oleg Grenrus at 2023-07-08T05:07:31-04:00 Add warn_and_run test kind This is a compile_and_run variant which also captures the GHC's stderr. The warn_and_run name is best I can come up with, as compile_and_run is taken. This is useful specifically for testing warnings. We want to test that when warning triggers, and it's not a false positive, i.e. that the runtime behaviour is indeed "incorrect". As an example a single test is altered to use warn_and_run - - - - - c7026962 by Ben Gamari at 2023-07-08T05:08:11-04:00 configure: Don't use ld.gold on i386 ld.gold appears to produce invalid static constructor tables on i386. While ideally we would add an autoconf check to check for this brokenness, sadly such a check isn't easy to compose. Instead to summarily reject such linkers on i386. Somewhat hackily closes #23579. - - - - - 054261dd by Andrew Lelechenko at 2023-07-08T19:32:47-04:00 Add since annotations for Data.Foldable1 - - - - - 550af505 by Sylvain Henry at 2023-07-08T19:33:28-04:00 JS: support -this-unit-id for programs in the linker (#23613) - - - - - d284470a by Andrew Lelechenko at 2023-07-08T19:34:08-04:00 Bump text submodule - - - - - 8e11630e by jade at 2023-07-10T16:58:40-04:00 Add a hint to enable ExplicitNamespaces for type operator imports (Fixes/Enhances #20007) As suggested in #20007 and implemented in !8895, trying to import type operators will suggest a fix to use the 'type' keyword, without considering whether ExplicitNamespaces is enabled. This patch will query whether ExplicitNamespaces is enabled and add a hint to suggest enabling ExplicitNamespaces if it isn't enabled, alongside the suggestion of adding the 'type' keyword. - - - - - 61b1932e by sheaf at 2023-07-10T16:59:26-04:00 tyThingLocalGREs: include all DataCons for RecFlds The GREInfo for a record field should include the collection of all the data constructors of the parent TyCon that have this record field. This information was being incorrectly computed in the tyThingLocalGREs function for a DataCon, as we were not taking into account other DataCons with the same parent TyCon. Fixes #23546 - - - - - e6627cbd by Alan Zimmerman at 2023-07-10T17:00:05-04:00 EPA: Simplify GHC/Parser.y comb3 A follow up to !10743 - - - - - ee20da34 by Andrew Lelechenko at 2023-07-10T17:01:01-04:00 Document that compareByteArrays# is available since ghc-prim-0.5.2.0 - - - - - 4926af7b by Matthew Pickering at 2023-07-10T17:01:38-04:00 Revert "Bump text submodule" This reverts commit d284470a77042e6bc17bdb0ab0d740011196958a. This commit requires that we bootstrap with ghc-9.4, which we do not require until #23195 has been completed. Subsequently this has broken nighty jobs such as the rocky8 job which in turn has broken nightly releases. - - - - - d1c92bf3 by Ben Gamari at 2023-07-11T08:07:02-04:00 compiler: Fingerprint more code generation flags Previously our recompilation check was quite inconsistent in its coverage of non-optimisation code generation flags. Specifically, we failed to account for most flags that would affect the behavior of generated code in ways that might affect the result of a program's execution (e.g. `-feager-blackholing`, `-fstrict-dicts`) Closes #23369. - - - - - eb623149 by Ben Gamari at 2023-07-11T08:07:02-04:00 compiler: Record original thunk info tables on stack Here we introduce a new code generation option, `-forig-thunk-info`, which ensures that an `stg_orig_thunk_info` frame is pushed before every update frame. This can be invaluable when debugging thunk cycles and similar. See Note [Original thunk info table frames] for details. Closes #23255. - - - - - 4731f44e by Jaro Reinders at 2023-07-11T08:07:40-04:00 Fix wrong MIN_VERSION_GLASGOW_HASKELL macros I forgot to change these after rebasing. - - - - - dd38aca9 by Andreas Schwab at 2023-07-11T13:55:56+00:00 Hadrian: enable GHCi support on riscv64 - - - - - 09a5c6cc by Josh Meredith at 2023-07-12T11:25:13-04:00 JavaScript: support unicode code points > 2^16 in toJSString using String.fromCodePoint (#23628) - - - - - 29fbbd4e by Matthew Pickering at 2023-07-12T11:25:49-04:00 Remove references to make build system in mk/build.mk Fixes #23636 - - - - - 630e3026 by sheaf at 2023-07-12T11:26:43-04:00 Valid hole fits: don't panic on a Given The function GHC.Tc.Errors.validHoleFits would end up panicking when encountering a Given constraint. To fix this, it suffices to filter out the Givens before continuing. Fixes #22684 - - - - - c39f279b by Matthew Pickering at 2023-07-12T23:18:38-04:00 Use deb10 for i386 bindists deb9 is now EOL so it's time to upgrade the i386 bindist to use deb10 Fixes #23585 - - - - - bf9b9de0 by Krzysztof Gogolewski at 2023-07-12T23:19:15-04:00 Fix #23567, a specializer bug Found by Simon in https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507834 The testcase isn't ideal because it doesn't detect the bug in master, unless doNotUnbox is removed as in https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507692. But I have confirmed that with that modification, it fails before and passes afterwards. - - - - - 84c1a4a2 by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00 Comments - - - - - b2846cb5 by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00 updates to comments - - - - - 2af23f0e by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00 changes - - - - - 6143838a by sheaf at 2023-07-13T08:02:17-04:00 Fix deprecation of record fields Commit 3f374399 inadvertently broke the deprecation/warning mechanism for record fields due to its introduction of record field namespaces. This patch ensures that, when a top-level deprecation is applied to an identifier, it applies to all the record fields as well. This is achieved by refactoring GHC.Rename.Env.lookupLocalTcNames, and GHC.Rename.Env.lookupBindGroupOcc, to not look up a fixed number of NameSpaces but to look up all NameSpaces and filter out the irrelevant ones. - - - - - 6fd8f566 by sheaf at 2023-07-13T08:02:17-04:00 Introduce greInfo, greParent These are simple helper functions that wrap the internal field names gre_info, gre_par. - - - - - 7f0a86ed by sheaf at 2023-07-13T08:02:17-04:00 Refactor lookupGRE_... functions This commit consolidates all the logic for looking up something in the Global Reader Environment into the single function lookupGRE. This allows us to declaratively specify all the different modes of looking up in the GlobalRdrEnv, and avoids manually passing around filtering functions as was the case in e.g. the function GHC.Rename.Env.lookupSubBndrOcc_helper. ------------------------- Metric Decrease: T8095 ------------------------- ------------------------- Metric Increase: T8095 ------------------------- - - - - - 5e951395 by Rodrigo Mesquita at 2023-07-13T08:02:54-04:00 configure: Drop DllWrap command We used to configure into settings a DllWrap command for windows builds and distributions, however, we no longer do, and dllwrap is effectively unused. This simplification is motivated in part by the larger toolchain-selection project (#19877, !9263) - - - - - e10556b6 by Teo Camarasu at 2023-07-14T16:28:46-04:00 base: fix haddock syntax in GHC.Profiling - - - - - 0f3fda81 by Matthew Pickering at 2023-07-14T16:29:23-04:00 Revert "CI: add JS release and debug builds, regen CI jobs" This reverts commit 59c5fe1d4b624423b1c37891710f2757bb58d6af. This commit added two duplicate jobs on all validate pipelines, so we are reverting for now whilst we work out what the best way forward is. Ticket #23618 - - - - - 54bca324 by Alan Zimmerman at 2023-07-15T03:23:26-04:00 EPA: Simplify GHC/Parser.y sLL Follow up to !10743 - - - - - c8863828 by sheaf at 2023-07-15T03:24:06-04:00 Configure: canonicalise PythonCmd on Windows This change makes PythonCmd resolve to a canonical absolute path on Windows, which prevents HLS getting confused (now that we have a build-time dependency on python). fixes #23652 - - - - - ca1e636a by Rodrigo Mesquita at 2023-07-15T03:24:42-04:00 Improve Note [Binder-swap during float-out] - - - - - cf86f3ec by Matthew Craven at 2023-07-16T01:42:09+02:00 Equality of forall-types is visibility aware This patch finally (I hope) nails the question of whether (forall a. ty) and (forall a -> ty) are `eqType`: they aren't! There is a long discussion in #22762, plus useful Notes: * Note [ForAllTy and type equality] in GHC.Core.TyCo.Compare * Note [Comparing visiblities] in GHC.Core.TyCo.Compare * Note [ForAllCo] in GHC.Core.TyCo.Rep It also establishes a helpful new invariant for ForAllCo, and ForAllTy, when the bound variable is a CoVar:in that case the visibility must be coreTyLamForAllTyFlag. All this is well documented in revised Notes. - - - - - 7f13acbf by Vladislav Zavialov at 2023-07-16T01:56:27-04:00 List and Tuple<n>: update documentation Add the missing changelog.md entries and @since-annotations. - - - - - 2afbddb0 by Andrei Borzenkov at 2023-07-16T10:21:24+04:00 Type patterns (#22478, #18986) Improved name resolution and type checking of type patterns in constructors: 1. HsTyPat: a new dedicated data type that represents type patterns in HsConPatDetails instead of reusing HsPatSigType 2. rnHsTyPat: a new function that renames a type pattern and collects its binders into three groups: - explicitly bound type variables, excluding locally bound variables - implicitly bound type variables from kind signatures (only if ScopedTypeVariables are enabled) - named wildcards (only from kind signatures) 2a. rnHsPatSigTypeBindingVars: removed in favour of rnHsTyPat 2b. rnImplcitTvBndrs: removed because no longer needed 3. collect_pat: updated to collect type variable binders from type patterns (this means that types and terms use the same infrastructure to detect conflicting bindings, unused variables and name shadowing) 3a. CollVarTyVarBinders: a new CollectFlag constructor that enables collection of type variables 4. tcHsTyPat: a new function that typechecks type patterns, capable of handling polymorphic kinds. See Note [Type patterns: binders and unifiers] Examples of code that is now accepted: f = \(P @a) -> \(P @a) -> ... -- triggers -Wname-shadowing g :: forall a. Proxy a -> ... g (P @a) = ... -- also triggers -Wname-shadowing h (P @($(TH.varT (TH.mkName "t")))) = ... -- t is bound at splice time j (P @(a :: (x,x))) = ... -- (x,x) is no longer rejected data T where MkT :: forall (f :: forall k. k -> Type). f Int -> f Maybe -> T k :: T -> () k (MkT @f (x :: f Int) (y :: f Maybe)) = () -- f :: forall k. k -> Type Examples of code that is rejected with better error messages: f (Left @a @a _) = ... -- new message: -- • Conflicting definitions for ‘a’ -- Bound at: Test.hs:1:11 -- Test.hs:1:14 Examples of code that is now rejected: {-# OPTIONS_GHC -Werror=unused-matches #-} f (P @a) = () -- Defined but not used: type variable ‘a’ - - - - - eb1a6ab1 by sheaf at 2023-07-16T09:20:45-04:00 Don't use substTyUnchecked in newMetaTyVar There were some comments that explained that we needed to use an unchecked substitution function because of issue #12931, but that has since been fixed, so we should be able to use substTy instead now. - - - - - c7bbad9a by sheaf at 2023-07-17T02:48:19-04:00 rnImports: var shouldn't import NoFldSelectors In an import declaration such as import M ( var ) the import of the variable "var" should **not** bring into scope record fields named "var" which are defined with NoFieldSelectors. Doing so can cause spurious "unused import" warnings, as reported in ticket #23557. Fixes #23557 - - - - - 1af2e773 by sheaf at 2023-07-17T02:48:19-04:00 Suggest similar names in imports This commit adds similar name suggestions when importing. For example module A where { spelling = 'o' } module B where { import B ( speling ) } will give rise to the error message: Module ‘A’ does not export ‘speling’. Suggested fix: Perhaps use ‘spelling’ This also provides hints when users try to import record fields defined with NoFieldSelectors. - - - - - 654fdb98 by Alan Zimmerman at 2023-07-17T02:48:55-04:00 EPA: Store leading AnnSemi for decllist in al_rest This simplifies the markAnnListA implementation in ExactPrint - - - - - 22565506 by sheaf at 2023-07-17T21:12:59-04:00 base: add COMPLETE pragma to BufferCodec PatSyn This implements CLC proposal #178, rectifying an oversight in the implementation of CLC proposal #134 which could lead to spurious pattern match warnings. https://github.com/haskell/core-libraries-committee/issues/178 https://github.com/haskell/core-libraries-committee/issues/134 - - - - - 860f6269 by sheaf at 2023-07-17T21:13:00-04:00 exactprint: silence incomplete record update warnings - - - - - df706de3 by sheaf at 2023-07-17T21:13:00-04:00 Re-instate -Wincomplete-record-updates Commit e74fc066 refactored the handling of record updates to use the HsExpanded mechanism. This meant that the pattern matching inherent to a record update was considered to be "generated code", and thus we stopped emitting "incomplete record update" warnings entirely. This commit changes the "data Origin = Source | Generated" datatype, adding a field to the Generated constructor to indicate whether we still want to perform pattern-match checking. We also have to do a bit of plumbing with HsCase, to record that the HsCase arose from an HsExpansion of a RecUpd, so that the error message continues to mention record updates as opposed to a generic "incomplete pattern matches in case" error. Finally, this patch also changes the way we handle inaccessible code warnings. Commit e74fc066 was also a regression in this regard, as we were emitting "inaccessible code" warnings for case statements spuriously generated when desugaring a record update (remember: the desugaring mechanism happens before typechecking; it thus can't take into account e.g. GADT information in order to decide which constructors to include in the RHS of the desugaring of the record update). We fix this by changing the mechanism through which we disable inaccessible code warnings: we now check whether we are in generated code in GHC.Tc.Utils.TcMType.newImplication in order to determine whether to emit inaccessible code warnings. Fixes #23520 Updates haddock submodule, to avoid incomplete record update warnings - - - - - 1d05971e by sheaf at 2023-07-17T21:13:00-04:00 Propagate long-distance information in do-notation The preceding commit re-enabled pattern-match checking inside record updates. This revealed that #21360 was in fact NOT fixed by e74fc066. This commit makes sure we correctly propagate long-distance information in do blocks, e.g. in ```haskell data T = A { fld :: Int } | B f :: T -> Maybe T f r = do a at A{} <- Just r Just $ case a of { A _ -> A 9 } ``` we need to propagate the fact that "a" is headed by the constructor "A" to see that the case expression "case a of { A _ -> A 9 }" cannot fail. Fixes #21360 - - - - - bea0e323 by sheaf at 2023-07-17T21:13:00-04:00 Skip PMC for boring patterns Some patterns introduce no new information to the pattern-match checker (such as plain variable or wildcard patterns). We can thus skip doing any pattern-match checking on them when the sole purpose for doing so was introducing new long-distance information. See Note [Boring patterns] in GHC.Hs.Pat. Doing this avoids regressing in performance now that we do additional pattern-match checking inside do notation. - - - - - ddcdd88c by Rodrigo Mesquita at 2023-07-17T21:13:36-04:00 Split GHC.Platform.ArchOS from ghc-boot into ghc-platform Split off the `GHC.Platform.ArchOS` module from the `ghc-boot` package into this reinstallable standalone package which abides by the PVP, in part motivated by the ongoing work on `ghc-toolchain` towards runtime retargetability. - - - - - b55a8ea7 by Sylvain Henry at 2023-07-17T21:14:27-04:00 JS: better implementation for plusWord64 (#23597) - - - - - 889c2bbb by sheaf at 2023-07-18T06:37:32-04:00 Do primop rep-poly checks when instantiating This patch changes how we perform representation-polymorphism checking for primops (and other wired-in Ids such as coerce). When instantiating the primop, we check whether each type variable is required to instantiated to a concrete type, and if so we create a new concrete metavariable (a ConcreteTv) instead of a simple MetaTv. (A little subtlety is the need to apply the substitution obtained from instantiating to the ConcreteTvOrigins, see Note [substConcreteTvOrigin] in GHC.Tc.Utils.TcMType.) This allows us to prevent representation-polymorphism in non-argument position, as that is required for some of these primops. We can also remove the logic in tcRemainingValArgs, except for the part concerning representation-polymorphic unlifted newtypes. The function has been renamed rejectRepPolyNewtypes; all it does now is reject unsaturated occurrences of representation-polymorphic newtype constructors when the representation of its argument isn't a concrete RuntimeRep (i.e. still a PHASE 1 FixedRuntimeRep check). The Note [Eta-expanding rep-poly unlifted newtypes] in GHC.Tc.Gen.Head gives more explanation about a possible path to PHASE 2, which would be in line with the treatment for primops taken in this patch. We also update the Core Lint check to handle this new framework. This means Core Lint now checks representation-polymorphism in continuation position like needed for catch#. Fixes #21906 ------------------------- Metric Increase: LargeRecord ------------------------- - - - - - 00648e5d by Krzysztof Gogolewski at 2023-07-18T06:38:10-04:00 Core Lint: distinguish let and letrec in locations Lint messages were saying "in the body of letrec" even for non-recursive let. I've also renamed BodyOfLetRec to BodyOfLet in stg, since there's no separate letrec. - - - - - 787bae96 by Krzysztof Gogolewski at 2023-07-18T06:38:50-04:00 Use extended literals when deriving Show This implements GHC proposal https://github.com/ghc-proposals/ghc-proposals/pull/596 Also add support for Int64# and Word64#; see testcase ShowPrim. - - - - - 257f1567 by Jaro Reinders at 2023-07-18T06:39:29-04:00 Add StgFromCore and StgCodeGen linting - - - - - 34d08a20 by Ben Gamari at 2023-07-19T03:33:22-04:00 Reg.Liveness: Strictness - - - - - c5deaa27 by Ben Gamari at 2023-07-19T03:33:22-04:00 Reg.Liveness: Don't repeatedly construct UniqSets - - - - - b947250b by Ben Gamari at 2023-07-19T03:33:22-04:00 compiler/Types: Ensure that fromList-type operations can fuse In #20740 I noticed that mkUniqSet does not fuse. In practice, allowing it to do so makes a considerable difference in allocations due to the backend. Metric Decrease: T12707 T13379 T3294 T4801 T5321FD T5321Fun T783 - - - - - 6c88c2ba by Sven Tennie at 2023-07-19T03:33:59-04:00 x86 Codegen: Implement MO_S_MulMayOflo for W16 - - - - - 5f1154e0 by Sven Tennie at 2023-07-19T03:33:59-04:00 x86 CodeGen: MO_S_MulMayOflo better error message for rep > W64 It's useful to see which value made the pattern match fail. (If it ever occurs.) - - - - - e8c9a95f by Sven Tennie at 2023-07-19T03:33:59-04:00 x86 CodeGen: Implement MO_S_MulMayOflo for W8 This case wasn't handled before. But, the test-primops test suite showed that it actually might appear. - - - - - a36f9dc9 by Sven Tennie at 2023-07-19T03:33:59-04:00 Add test for %mulmayoflo primop The test expects a perfect implementation with no false positives. - - - - - 38a36248 by Matthew Pickering at 2023-07-19T03:34:36-04:00 lint-ci-config: Generate jobs-metadata.json We also now save the jobs-metadata.json and jobs.yaml file as artifacts as: * It might be useful for someone who is modifying CI to copy jobs.yaml if they are having trouble regenerating locally. * jobs-metadata.json is very useful for downstream pipelines to work out the right job to download. Fixes #23654 - - - - - 1535a671 by Vladislav Zavialov at 2023-07-19T03:35:12-04:00 Initialize 9.10.1-notes.rst Create new release notes for the next GHC release (GHC 9.10) - - - - - 3bd4d5b5 by sheaf at 2023-07-19T03:35:53-04:00 Prioritise Parent when looking up class sub-binder When we look up children GlobalRdrElts of a given Parent, we sometimes would rather prioritise those GlobalRdrElts which have the right Parent, and sometimes prioritise those that have the right NameSpace: - in export lists, we should prioritise NameSpace - for class/instance binders, we should prioritise Parent See Note [childGREPriority] in GHC.Types.Name.Reader. fixes #23664 - - - - - 9c8fdda3 by Alan Zimmerman at 2023-07-19T03:36:29-04:00 EPA: Improve annotation management in getMonoBind Ensure the LHsDecl for a FunBind has the correct leading comments and trailing annotations. See the added note for details. - - - - - ff884b77 by Matthew Pickering at 2023-07-19T11:42:02+01:00 Remove unused files in .gitlab These were left over after 6078b429 - - - - - 29ef590c by Matthew Pickering at 2023-07-19T11:42:52+01:00 gen_ci: Add hie.yaml file This allows you to load `gen_ci.hs` into HLS, and now it is a huge module, that is quite useful. - - - - - 808b55cf by Matthew Pickering at 2023-07-19T12:24:41+01:00 ci: Make "fast-ci" the default validate configuration We are trying out a lighter weight validation pipeline where by default we just test on 5 platforms: * x86_64-deb10-slow-validate * windows * x86_64-fedora33-release * aarch64-darwin * aarch64-linux-deb10 In order to enable the "full" validation pipeline you can apply the `full-ci` label which will enable all the validation pipelines. All the validation jobs are still run on a marge batch. The goal is to reduce the overall CI capacity so that pipelines start faster for MRs and marge bot batches are faster. Fixes #23694 - - - - - 0b23db03 by Alan Zimmerman at 2023-07-20T05:28:47-04:00 EPA: Simplify GHC/Parser.y sL1 This is the next patch in a series simplifying location management in GHC/Parser.y This one simplifies sL1, to use the HasLoc instances introduced in !10743 (closed) - - - - - 3ece9856 by Ben Gamari at 2023-07-21T07:30:45-04:00 nativeGen: Explicitly set flags of text sections on Windows The binutils documentation (for COFF) claims, > If no flags are specified, the default flags depend upon the section > name. If the section name is not recognized, the default will be for the > section to be loaded and writable. We previously assumed that this would do the right thing for split sections (e.g. a section named `.text$foo` would be correctly inferred to be a text section). However, we have observed that this is not the case (at least under the clang toolchain used on Windows): when split-sections is enabled, text sections are treated by the assembler as data (matching the "default" behavior specified by the documentation). Avoid this by setting section flags explicitly. This should fix split sections on Windows. Fixes #22834. - - - - - db7f7240 by Ben Gamari at 2023-07-21T07:30:45-04:00 nativeGen: Set explicit section types on all platforms - - - - - b444c16f by Finley McIlwaine at 2023-07-21T07:31:28-04:00 Insert documentation into parsed signature modules Causes haddock comments in signature modules to be properly inserted into the AST (just as they are for regular modules) if the `-haddock` flag is given. Also adds a test that compares `-ddump-parsed-ast` output for a signature module to prevent further regressions. Fixes #23315 - - - - - c30cea53 by Ben Gamari at 2023-07-21T23:23:49-04:00 primops: Introduce unsafeThawByteArray# This addresses an odd asymmetry in the ByteArray# primops, which previously provided unsafeFreezeByteArray# but no corresponding thaw operation. Closes #22710 - - - - - 87f9bd47 by Ben Gamari at 2023-07-21T23:23:49-04:00 testsuite: Elaborate in interface stability README This discussion didn't make it into the original MR. - - - - - e4350b41 by Matthew Pickering at 2023-07-21T23:24:25-04:00 Allow users to override non-essential haddock options in a Flavour We now supply the non-essential options to haddock using the `extraArgs` field, which can be specified in a Flavour so that if an advanced user wants to change how documentation is generated then they can use something other than the `defaultHaddockExtraArgs`. This does have the potential to regress some packaging if a user has overridden `extraArgs` themselves, because now they also need to add the haddock options to extraArgs. This can easily be done by appending `defaultHaddockExtraArgs` to their extraArgs invocation but someone might not notice this behaviour has changed. In any case, I think passing the non-essential options in this manner is the right thing to do and matches what we do for the "ghc" builder, which by default doesn't pass any optmisation levels, and would likewise be very bad if someone didn't pass suitable `-O` levels for builds. Fixes #23625 - - - - - fc186b0c by Ilias Tsitsimpis at 2023-07-21T23:25:03-04:00 ghc-prim: Link against libatomic Commit b4d39adbb58 made 'hs_cmpxchg64()' available to all architectures. Unfortunately this made GHC to fail to build on armel, since armel needs libatomic to support atomic operations on 64-bit word sizes. Configure libraries/ghc-prim/ghc-prim.cabal to link against libatomic, the same way as we do in rts/rts.cabal. - - - - - 4f5538a8 by Matthew Pickering at 2023-07-21T23:25:39-04:00 simplifier: Correct InScopeSet in rule matching The in-scope set passedto the `exprIsLambda_maybe` call lacked all the in-scope binders. @simonpj suggests this fix where we augment the in-scope set with the free variables of expression which fixes this failure mode in quite a direct way. Fixes #23630 - - - - - 5ad8d597 by Krzysztof Gogolewski at 2023-07-21T23:26:17-04:00 Add a test for #23413 It was fixed by commit e1590ddc661d6: Add the SolverStage monad. - - - - - 7e05f6df by sheaf at 2023-07-21T23:26:56-04:00 Finish migration of diagnostics in GHC.Tc.Validity This patch finishes migrating the error messages in GHC.Tc.Validity to use the new diagnostic infrastructure. It also refactors the error message datatypes for class and family instances, to common them up under a single datatype as much as possible. - - - - - 4876fddc by Matthew Pickering at 2023-07-21T23:27:33-04:00 ci: Enable some more jobs to run in a marge batch In !10907 I made the majority of jobs not run on a validate pipeline but then forgot to renable a select few jobs on the marge batch MR. - - - - - 026991d7 by Jens Petersen at 2023-07-21T23:28:13-04:00 user_guide/flags.py: python-3.12 no longer includes distutils packaging.version seems able to handle this fine - - - - - b91bbc2b by Matthew Pickering at 2023-07-21T23:28:50-04:00 ci: Mention ~full-ci label in MR template We mention that if you need a full validation pipeline then you can apply the ~full-ci label to your MR in order to test against the full validation pipeline (like we do for marge). - - - - - 42b05e9b by sheaf at 2023-07-22T12:36:00-04:00 RTS: declare setKeepCAFs symbol Commit 08ba8720 failed to declare the dependency of keepCAFsForGHCi on the symbol setKeepCAFs in the RTS, which led to undefined symbol errors on Windows, as exhibited by the testcase frontend001. Thanks to Moritz Angermann and Ryan Scott for the diagnosis and fix. Fixes #22961 - - - - - a72015d6 by sheaf at 2023-07-22T12:36:01-04:00 Mark plugins-external as broken on Windows This test is broken on Windows, so we explicitly mark it as such now that we stop skipping plugin tests on Windows. - - - - - cb9c93d7 by sheaf at 2023-07-22T12:36:01-04:00 Stop marking plugin tests as fragile on Windows Now that b2bb3e62 has landed we are in a better situation with regards to plugins on Windows, allowing us to unmark many plugin tests as fragile. Fixes #16405 - - - - - a7349217 by Krzysztof Gogolewski at 2023-07-22T12:36:37-04:00 Misc cleanup - Remove unused RDR names - Fix typos in comments - Deriving: simplify boxConTbl and remove unused litConTbl - chmod -x GHC/Exts.hs, this seems accidental - - - - - 33b6850a by Vladislav Zavialov at 2023-07-23T10:27:37-04:00 Visible forall in types of terms: Part 1 (#22326) This patch implements part 1 of GHC Proposal #281, introducing explicit `type` patterns and `type` arguments. Summary of the changes: 1. New extension flag: RequiredTypeArguments 2. New user-facing syntax: `type p` patterns (represented by EmbTyPat) `type e` expressions (represented by HsEmbTy) 3. Functions with required type arguments (visible forall) can now be defined and applied: idv :: forall a -> a -> a -- signature (relevant change: checkVdqOK in GHC/Tc/Validity.hs) idv (type a) (x :: a) = x -- definition (relevant change: tcPats in GHC/Tc/Gen/Pat.hs) x = idv (type Int) 42 -- usage (relevant change: tcInstFun in GHC/Tc/Gen/App.hs) 4. template-haskell support: TH.TypeE corresponds to HsEmbTy TH.TypeP corresponds to EmbTyPat 5. Test cases and a new User's Guide section Changes *not* included here are the t2t (term-to-type) transformation and term variable capture; those belong to part 2. - - - - - 73b5c7ce by sheaf at 2023-07-23T10:28:18-04:00 Add test for #22424 This is a simple Template Haskell test in which we refer to record selectors by their exact Names, in two different ways. Fixes #22424 - - - - - 83cbc672 by Ben Gamari at 2023-07-24T07:40:49+00:00 ghc-toolchain: Initial commit - - - - - 31dcd26c by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 ghc-toolchain: Toolchain Selection This commit integrates ghc-toolchain, the brand new way of configuring toolchains for GHC, with the Hadrian build system, with configure, and extends and improves the first iteration of ghc-toolchain. The general overview is * We introduce a program invoked `ghc-toolchain --triple=...` which, when run, produces a file with a `Target`. A `GHC.Toolchain.Target.Target` describes the properties of a target and the toolchain (executables and configured flags) to produce code for that target * Hadrian was modified to read Target files, and will both * Invoke the toolchain configured in the Target file as needed * Produce a `settings` file for GHC based on the Target file for that stage * `./configure` will invoke ghc-toolchain to generate target files, but it will also generate target files based on the flags configure itself configured (through `.in` files that are substituted) * By default, the Targets generated by configure are still (for now) the ones used by Hadrian * But we additionally validate the Target files generated by ghc-toolchain against the ones generated by configure, to get a head start on catching configuration bugs before we transition completely. * When we make that transition, we will want to drop a lot of the toolchain configuration logic from configure, but keep it otherwise. * For each compiler stage we should have 1 target file (up to a stage compiler we can't run in our machine) * We just have a HOST target file, which we use as the target for stage0 * And a TARGET target file, which we use for stage1 (and later stages, if not cross compiling) * Note there is no BUILD target file, because we only support cross compilation where BUILD=HOST * (for more details on cross-compilation see discussion on !9263) See also * Note [How we configure the bundled windows toolchain] * Note [ghc-toolchain consistency checking] * Note [ghc-toolchain overview] Ticket: #19877 MR: !9263 - - - - - a732b6d3 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Add flag to enable/disable ghc-toolchain based configurations This flag is disabled by default, and we'll use the configure-generated-toolchains by default until we remove the toolchain configuration logic from configure. - - - - - 61eea240 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Split ghc-toolchain executable to new packge In light of #23690, we split the ghc-toolchain executable out of the library package to be able to ship it in the bindist using Hadrian. Ideally, we eventually revert this commit. - - - - - 38e795ff by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Ship ghc-toolchain in the bindist Add the ghc-toolchain binary to the binary distribution we ship to users, and teach the bindist configure to use the existing ghc-toolchain. - - - - - 32cae784 by Matthew Craven at 2023-07-24T16:48:24-04:00 Kill off gen_bytearray_addr_access_ops.py The relevant primop descriptions are now generated directly by genprimopcode. This makes progress toward fixing #23490, but it is not a complete fix since there is more than one way in which cabal-reinstall (hadrian/build build-cabal) is broken. - - - - - 02e6a6ce by Matthew Pickering at 2023-07-24T16:49:00-04:00 compiler: Remove unused `containers.h` include Fixes #23712 - - - - - 822ef66b by Matthew Pickering at 2023-07-25T08:44:50-04:00 Fix pretty printing of WARNING pragmas There is still something quite unsavoury going on with WARNING pragma printing because the printing relies on the fact that for decl deprecations the SourceText of WarningTxt is empty. However, I let that lion sleep and just fixed things directly. Fixes #23465 - - - - - e7b38ede by Matthew Pickering at 2023-07-25T08:45:28-04:00 ci-images: Bump to commit which has 9.6 image The test-bootstrap job has been failing for 9.6 because we accidentally used a non-master commit. - - - - - bb408936 by Matthew Pickering at 2023-07-25T08:45:28-04:00 Update bootstrap plans for 9.6.2 and 9.4.5 - - - - - 355e1792 by Alan Zimmerman at 2023-07-26T10:17:32-04:00 EPA: Simplify GHC/Parser.y comb4/comb5 Use the HasLoc instance from Ast.hs to allow comb4/comb5 to work with anything with a SrcSpan Also get rid of some more now unnecessary reLoc calls. - - - - - 9393df83 by Gavin Zhao at 2023-07-26T10:18:16-04:00 compiler: make -ddump-asm work with wasm backend NCG Fixes #23503. Now the `-ddump-asm` flag is respected in the wasm backend NCG, so developers can directly view the generated ASM instead of needing to pass `-S` or `-keep-tmp-files` and manually find & open the assembly file. Ideally, we should be able to output the assembly files in smaller chunks like in other NCG backends. This would also make dumping assembly stats easier. However, this would require a large refactoring, so for short-term debugging purposes I think the current approach works fine. Signed-off-by: Gavin Zhao <git at gzgz.dev> - - - - - 79463036 by Krzysztof Gogolewski at 2023-07-26T10:18:54-04:00 llvm: Restore accidentally deleted code in 0fc5cb97 Fixes #23711 - - - - - 20db7e26 by Rodrigo Mesquita at 2023-07-26T10:19:33-04:00 configure: Default missing options to False when preparing ghc-toolchain Targets This commit fixes building ghc with 9.2 as the boostrap compiler. The ghc-toolchain patch assumed all _STAGE0 options were available, and forgot to account for this missing information in 9.2. Ghc 9.2 does not have in settings whether ar supports -l, hence can't report it with --info (unliked 9.4 upwards). The fix is to default the missing information (we default "ar supports -l" and other missing options to False) - - - - - fac9e84e by Naïm Favier at 2023-07-26T10:20:16-04:00 docs: Fix typo - - - - - 503fd647 by Bartłomiej Cieślar at 2023-07-26T17:23:10-04:00 This MR is an implementation of the proposal #516. It adds a warning -Wincomplete-record-selectors for usages of a record field access function (either a record selector or getField @"rec"), while trying to silence the warning whenever it can be sure that a constructor without the record field would not be invoked (which would otherwise cause the program to fail). For example: data T = T1 | T2 {x :: Bool} f a = x a -- this would throw an error g T1 = True g a = x a -- this would not throw an error h :: HasField "x" r Bool => r -> Bool h = getField @"x" j :: T -> Bool j = h -- this would throw an error because of the `HasField` -- constraint being solved See the tests DsIncompleteRecSel* and TcIncompleteRecSel for more examples of the warning. See Note [Detecting incomplete record selectors] in GHC.HsToCore.Expr for implementation details - - - - - af6fdf42 by Arnaud Spiwack at 2023-07-26T17:23:52-04:00 Fix user-facing label in MR template - - - - - 5d45b92a by Matthew Pickering at 2023-07-27T05:46:46-04:00 ci: Test bootstrapping configurations with full-ci and on marge batches There have been two incidents recently where bootstrapping has been broken by removing support for building with 9.2.*. The process for bumping the minimum required version starts with bumping the configure version and then other CI jobs such as the bootstrap jobs have to be updated. We must not silently bump the minimum required version. Now we are running a slimmed down validate pipeline it seems worthwile to test these bootstrap configurations in the full-ci pipeline. - - - - - 25d4fee7 by Matthew Pickering at 2023-07-27T05:46:46-04:00 bootstrap: Remove ghc-9_2_* plans We are anticipating shortly making it necessary to use ghc-9.4 to boot the compiler. - - - - - 2f66da16 by Matthew Pickering at 2023-07-27T05:46:46-04:00 Update bootstrap plans for ghc-platform and ghc-toolchain dependencies Fixes #23735 - - - - - c8c6eab1 by Matthew Pickering at 2023-07-27T05:46:46-04:00 bootstrap: Disable -selftest flag from bootstrap plans This saves on building one dependency (QuickCheck) which is unecessary for bootstrapping. - - - - - a80ca086 by Andrew Lelechenko at 2023-07-27T05:47:26-04:00 Link reference paper and package from System.Mem.{StableName,Weak} - - - - - a5319358 by David Knothe at 2023-07-28T13:13:10-04:00 Update Match Datatype EquationInfo currently contains a list of the equation's patterns together with a CoreExpr that is to be evaluated after a successful match on this equation. All the match-functions only operate on the first pattern of an equation - after successfully matching it, match is called recursively on the tail of the pattern list. We can express this more clearly and make the code a little more elegant by updating the datatype of EquationInfo as follows: data EquationInfo = EqnMatch { eqn_pat = Pat GhcTc, eqn_rest = EquationInfo } | EqnDone { eqn_rhs = MatchResult CoreExpr } An EquationInfo now explicitly exposes its first pattern which most functions operate on, and exposes the equation that remains after processing the first pattern. An EqnDone signifies an empty equation where the CoreExpr can now be evaluated. - - - - - 86ad1af9 by David Binder at 2023-07-28T13:13:53-04:00 Improve documentation for Data.Fixed - - - - - f8fa1d08 by Ben Gamari at 2023-07-28T13:14:31-04:00 ghc-prim: Use C11 atomics Previously `ghc-prim`'s atomic wrappers used the legacy `__sync_*` family of C builtins. Here we refactor these to rather use the appropriate C11 atomic equivalents, allowing us to be more explicit about the expected ordering semantics. - - - - - 0bfc8908 by Finley McIlwaine at 2023-07-28T18:46:26-04:00 Include -haddock in DynFlags fingerprint The -haddock flag determines whether or not the resulting .hi files contain haddock documentation strings. If the existing .hi files do not contain haddock documentation strings and the user requests them, we should recompile. - - - - - 40425c50 by Andreas Klebinger at 2023-07-28T18:47:02-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - e9a0fa3f by Andrew Lelechenko at 2023-07-28T18:47:42-04:00 Bump filepath submodule to 1.4.100.4 Resolves #23741 Metric Decrease: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T12234 T12425 T13035 T13701 T13719 T16875 T18304 T18698a T18698b T21839c T9198 TcPlugin_RewritePerf hard_hole_fits Metric decrease on Windows can be probably attributed to https://github.com/haskell/filepath/pull/183 - - - - - ee93edfd by Andrew Lelechenko at 2023-07-28T18:48:21-04:00 Add since pragmas to GHC.IO.Handle.FD - - - - - d0369802 by Simon Peyton Jones at 2023-07-30T09:24:48+01:00 Make the occurrence analyser smarter about join points This MR addresses #22404. There is a big Note Note [Occurrence analysis for join points] that explains it all. Significant changes * New field occ_join_points in OccEnv * The NonRec case of occAnalBind splits into two cases: one for existing join points (which does the special magic for Note [Occurrence analysis for join points], and one for other bindings. * mkOneOcc adds in info from occ_join_points. * All "bring into scope" activity is centralised in the new function `addInScope`. * I made a local data type LocalOcc for use inside the occurrence analyser It is like OccInfo, but lacks IAmDead and IAmALoopBreaker, which in turn makes computationns over it simpler and more efficient. * I found quite a bit of allocation in GHC.Core.Rules.getRules so I optimised it a bit. More minor changes * I found I was using (Maybe Arity) a lot, so I defined a new data type JoinPointHood and used it everwhere. This touches a lot of non-occ-anal files, but it makes everything more perspicuous. * Renamed data constructor WithUsageDetails to WUD, and WithTailUsageDetails to WTUD This also fixes #21128, on the way. --------- Compiler perf ----------- I spent quite a time on performance tuning, so even though it does more than before, the occurrence analyser runs slightly faster on average. Here are the compile-time allocation changes over 0.5% CoOpt_Read(normal) ghc/alloc 766,025,520 754,561,992 -1.5% CoOpt_Singletons(normal) ghc/alloc 759,436,840 762,925,512 +0.5% LargeRecord(normal) ghc/alloc 1,814,482,440 1,799,530,456 -0.8% PmSeriesT(normal) ghc/alloc 68,159,272 67,519,720 -0.9% T10858(normal) ghc/alloc 120,805,224 118,746,968 -1.7% T11374(normal) ghc/alloc 164,901,104 164,070,624 -0.5% T11545(normal) ghc/alloc 79,851,808 78,964,704 -1.1% T12150(optasm) ghc/alloc 73,903,664 71,237,544 -3.6% GOOD T12227(normal) ghc/alloc 333,663,200 331,625,864 -0.6% T12234(optasm) ghc/alloc 52,583,224 52,340,344 -0.5% T12425(optasm) ghc/alloc 81,943,216 81,566,720 -0.5% T13056(optasm) ghc/alloc 294,517,928 289,642,512 -1.7% T13253-spj(normal) ghc/alloc 118,271,264 59,859,040 -49.4% GOOD T15164(normal) ghc/alloc 1,102,630,352 1,091,841,296 -1.0% T15304(normal) ghc/alloc 1,196,084,000 1,166,733,000 -2.5% T15630(normal) ghc/alloc 148,729,632 147,261,064 -1.0% T15703(normal) ghc/alloc 379,366,664 377,600,008 -0.5% T16875(normal) ghc/alloc 32,907,120 32,670,976 -0.7% T17516(normal) ghc/alloc 1,658,001,888 1,627,863,848 -1.8% T17836(normal) ghc/alloc 395,329,400 393,080,248 -0.6% T18140(normal) ghc/alloc 71,968,824 73,243,040 +1.8% T18223(normal) ghc/alloc 456,852,568 453,059,088 -0.8% T18282(normal) ghc/alloc 129,105,576 131,397,064 +1.8% T18304(normal) ghc/alloc 71,311,712 70,722,720 -0.8% T18698a(normal) ghc/alloc 208,795,112 210,102,904 +0.6% T18698b(normal) ghc/alloc 230,320,736 232,697,976 +1.0% BAD T19695(normal) ghc/alloc 1,483,648,128 1,504,702,976 +1.4% T20049(normal) ghc/alloc 85,612,024 85,114,376 -0.6% T21839c(normal) ghc/alloc 415,080,992 410,906,216 -1.0% GOOD T4801(normal) ghc/alloc 247,590,920 250,726,272 +1.3% T6048(optasm) ghc/alloc 95,699,416 95,080,680 -0.6% T783(normal) ghc/alloc 335,323,384 332,988,120 -0.7% T9233(normal) ghc/alloc 709,641,224 685,947,008 -3.3% GOOD T9630(normal) ghc/alloc 965,635,712 948,356,120 -1.8% T9675(optasm) ghc/alloc 444,604,152 428,987,216 -3.5% GOOD T9961(normal) ghc/alloc 303,064,592 308,798,800 +1.9% BAD WWRec(normal) ghc/alloc 503,728,832 498,102,272 -1.1% geo. mean -1.0% minimum -49.4% maximum +1.9% In fact these figures seem to vary between platforms; generally worse on i386 for some reason. The Windows numbers vary by 1% espec in benchmarks where the total allocation is low. But the geom mean stays solidly negative, which is good. The "increase/decrease" list below covers all platforms. The big win on T13253-spj comes because it has a big nest of join points, each occurring twice in the next one. The new occ-anal takes only one iteration of the simplifier to do the inlining; the old one took four. Moreover, we get much smaller code with the new one: New: Result size of Tidy Core = {terms: 429, types: 84, coercions: 0, joins: 14/14} Old: Result size of Tidy Core = {terms: 2,437, types: 304, coercions: 0, joins: 10/10} --------- Runtime perf ----------- No significant changes in nofib results, except a 1% reduction in compiler allocation. Metric Decrease: CoOpt_Read T13253-spj T9233 T9630 T9675 T12150 T21839c LargeRecord MultiComponentModulesRecomp T10421 T13701 T10421 T13701 T12425 Metric Increase: T18140 T9961 T18282 T18698a T18698b T19695 - - - - - 42aa7fbd by Julian Ospald at 2023-07-30T17:22:01-04:00 Improve documentation around IOException and ioe_filename See: * https://github.com/haskell/core-libraries-committee/issues/189 * https://github.com/haskell/unix/pull/279 * https://github.com/haskell/unix/pull/289 - - - - - 33598ecb by Sylvain Henry at 2023-08-01T14:45:54-04:00 JS: implement getMonotonicTime (fix #23687) - - - - - d2bedffd by Bartłomiej Cieślar at 2023-08-01T14:46:40-04:00 Implementation of the Deprecated Instances proposal #575 This commit implements the ability to deprecate certain instances, which causes the compiler to emit the desired deprecation message whenever they are instantiated. For example: module A where class C t where instance {-# DEPRECATED "dont use" #-} C Int where module B where import A f :: C t => t f = undefined g :: Int g = f -- "dont use" emitted here The implementation is as follows: - In the parser, we parse deprecations/warnings attached to instances: instance {-# DEPRECATED "msg" #-} Show X deriving instance {-# WARNING "msg2" #-} Eq Y (Note that non-standalone deriving instance declarations do not support this mechanism.) - We store the resulting warning message in `ClsInstDecl` (respectively, `DerivDecl`). In `GHC.Tc.TyCl.Instance.tcClsInstDecl` (respectively, `GHC.Tc.Deriv.Utils.newDerivClsInst`), we pass on that information to `ClsInst` (and eventually store it in `IfaceClsInst` too). - Finally, when we solve a constraint using such an instance, in `GHC.Tc.Instance.Class.matchInstEnv`, we emit the appropriate warning that was stored in `ClsInst`. Note that we only emit a warning when the instance is used in a different module than it is defined, which keeps the behaviour in line with the deprecation of top-level identifiers. Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - d5a65af6 by Ben Gamari at 2023-08-01T14:47:18-04:00 compiler: Style fixes - - - - - 7218c80a by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Fix implicit cast This ensures that Task.h can be built with a C++ compiler. - - - - - d6d5aafc by Ben Gamari at 2023-08-01T14:47:19-04:00 testsuite: Fix warning in hs_try_putmvar001 - - - - - d9eddf7a by Ben Gamari at 2023-08-01T14:47:19-04:00 testsuite: Add AtomicModifyIORef test - - - - - f9eea4ba by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce NO_WARN macro This allows fine-grained ignoring of warnings. - - - - - 497b24ec by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Simplify atomicModifyMutVar2# implementation Previously we would perform a redundant load in the non-threaded RTS in atomicModifyMutVar2# implementation for the benefit of the non-moving GC's write barrier. Eliminate this. - - - - - 52ee082b by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce more principled fence operations - - - - - cd3c0377 by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce SET_INFO_RELAXED - - - - - 6df2352a by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Style fixes - - - - - 4ef6f319 by Ben Gamari at 2023-08-01T14:47:19-04:00 codeGen/tsan: Rework handling of spilling - - - - - f9ca7e27 by Ben Gamari at 2023-08-01T14:47:19-04:00 hadrian: More debug information - - - - - df4153ac by Ben Gamari at 2023-08-01T14:47:19-04:00 Improve TSAN documentation - - - - - fecae988 by Ben Gamari at 2023-08-01T14:47:19-04:00 hadrian: More selective TSAN instrumentation - - - - - 465a9a0b by Alan Zimmerman at 2023-08-01T14:47:56-04:00 EPA: Provide correct annotation span for ImportDecl Use the whole declaration, rather than just the span of the 'import' keyword. Metric Decrease: T9961 T5205 Metric Increase: T13035 - - - - - ae63d0fa by Bartłomiej Cieślar at 2023-08-01T14:48:40-04:00 Add cases to T23279: HasField for deprecated record fields This commit adds additional tests from ticket #23279 to ensure that we don't regress on reporting deprecated record fields in conjunction with HasField, either when using overloaded record dot syntax or directly through `getField`. Fixes #23279 - - - - - 00fb6e6b by Andreas Klebinger at 2023-08-01T14:49:17-04:00 AArch NCG: Pure refactor Combine some alternatives. Add some line breaks for overly long lines - - - - - 8f3b3b78 by Andreas Klebinger at 2023-08-01T14:49:54-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - 74a882dc by MorrowM at 2023-08-02T06:00:03-04:00 Add a RULE to make lookup fuse See https://github.com/haskell/core-libraries-committee/issues/175 Metric Increase: T18282 - - - - - cca74dab by Ben Gamari at 2023-08-02T06:00:39-04:00 hadrian: Ensure that way-flags are passed to CC Previously the way-specific compilation flags (e.g. `-DDEBUG`, `-DTHREADED_RTS`) would not be passed to the CC invocations. This meant that C dependency files would not correctly reflect dependencies predicated on the way, resulting in the rather painful #23554. Closes #23554. - - - - - 622b483c by Jaro Reinders at 2023-08-02T06:01:20-04:00 Native 32-bit Enum Int64/Word64 instances This commits adds more performant Enum Int64 and Enum Word64 instances for 32-bit platforms, replacing the Integer-based implementation. These instances are a copy of the Enum Int and Enum Word instances with minimal changes to manipulate Int64 and Word64 instead. On i386 this yields a 1.5x performance increase and for the JavaScript back end it even yields a 5.6x speedup. Metric Decrease: T18964 - - - - - c8bd7fa4 by Sylvain Henry at 2023-08-02T06:02:03-04:00 JS: fix typos in constants (#23650) - - - - - b9d5bfe9 by Josh Meredith at 2023-08-02T06:02:40-04:00 JavaScript: update MK_TUP macros to use current tuple constructors (#23659) - - - - - 28211215 by Matthew Pickering at 2023-08-02T06:03:19-04:00 ci: Pass -Werror when building hadrian in hadrian-ghc-in-ghci job Warnings when building Hadrian can end up cluttering the output of HLS, and we've had bug reports in the past about these warnings when building Hadrian. It would be nice to turn on -Werror on at least one build of Hadrian in CI to avoid a patch introducing warnings when building Hadrian. Fixes #23638 - - - - - aca20a5d by Ben Gamari at 2023-08-02T06:03:55-04:00 codeGen: Ensure that TSAN is aware of writeArray# write barriers By using a proper release store instead of a fence. - - - - - 453c0531 by Ben Gamari at 2023-08-02T06:03:55-04:00 codeGen: Ensure that array reads have necessary barriers This was the cause of #23541. - - - - - 93a0d089 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00 Add test for #23550 - - - - - 6a2f4a20 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00 Desugar non-recursive lets to non-recursive lets (take 2) This reverts commit 522bd584f71ddeda21efdf0917606ce3d81ec6cc. And takes care of the case that I missed in my previous attempt. Namely the case of an AbsBinds with no type variables and no dictionary variable. Ironically, the comment explaining why non-recursive lets were desugared to recursive lets were pointing specifically at this case as the reason. I just failed to understand that it was until Simon PJ pointed it out to me. See #23550 for more discussion. - - - - - ff81d53f by jade at 2023-08-02T06:05:20-04:00 Expand documentation of List & Data.List This commit aims to improve the documentation and examples of symbols exported from Data.List - - - - - fa4e5913 by Jade at 2023-08-02T06:06:03-04:00 Improve documentation of Semigroup & Monoid This commit aims to improve the documentation of various symbols exported from Data.Semigroup and Data.Monoid - - - - - e2c91bff by Gergő Érdi at 2023-08-03T02:55:46+01:00 Desugar bindings in the context of their evidence Closes #23172 - - - - - 481f4a46 by Gergő Érdi at 2023-08-03T07:48:43+01:00 Add flag to `-f{no-}specialise-incoherents` to enable/disable specialisation of incoherent instances Fixes #23287 - - - - - d751c583 by Profpatsch at 2023-08-04T12:24:26-04:00 base: Improve String & IsString documentation - - - - - 01db1117 by Ben Gamari at 2023-08-04T12:25:02-04:00 rts/win32: Ensure reliability of IO manager shutdown When the Win32 threaded IO manager shuts down, `ioManagerDie` sends an `IO_MANAGER_DIE` event to the IO manager thread using the `io_manager_event` event object. Finally, it will closes the event object, and invalidate `io_manager_event`. Previously, `readIOManagerEvent` would see that `io_manager_event` is invalid and return `0`, suggesting that everything is right with the world. This meant that if `ioManagerDie` invalidated the handle before the event manager was blocked on the event we would end up in a situation where the event manager would never realize it was asked to shut down. Fix this by ensuring that `readIOManagerEvent` instead returns `IO_MANAGER_DIE` when we detect that the event object has been invalidated by `ioManagerDie`. Fixes #23691. - - - - - fdef003a by Ryan Scott at 2023-08-04T12:25:39-04:00 Look through TH splices in splitHsApps This modifies `splitHsApps` (a key function used in typechecking function applications) to look through untyped TH splices and quasiquotes. Not doing so was the cause of #21077. This builds on !7821 by making `splitHsApps` match on `HsUntypedSpliceTop`, which contains the `ThModFinalizers` that must be run as part of invoking the TH splice. See the new `Note [Looking through Template Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`. Along the way, I needed to make the type of `splitHsApps.set` slightly more general to accommodate the fact that the location attached to a quasiquote is a `SrcAnn NoEpAnns` rather than a `SrcSpanAnnA`. Fixes #21077. - - - - - e77a0b41 by Ben Gamari at 2023-08-04T12:26:15-04:00 Bump deepseq submodule to 1.5. And bump bounds (cherry picked from commit 1228d3a4a08d30eaf0138a52d1be25b38339ef0b) - - - - - cebb5819 by Ben Gamari at 2023-08-04T12:26:15-04:00 configure: Bump minimal boot GHC version to 9.4 (cherry picked from commit d3ffdaf9137705894d15ccc3feff569d64163e8e) - - - - - 83766dbf by Ben Gamari at 2023-08-04T12:26:15-04:00 template-haskell: Bump version to 2.21.0.0 Bumps exceptions submodule. (cherry picked from commit bf57fc9aea1196f97f5adb72c8b56434ca4b87cb) - - - - - 1211112a by Ben Gamari at 2023-08-04T12:26:15-04:00 base: Bump version to 4.19 Updates all boot library submodules. (cherry picked from commit 433d99a3c24a55b14ec09099395e9b9641430143) - - - - - 3ab5efd9 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Normalise versions more aggressively In backpack hashes can contain `+` characters. (cherry picked from commit 024861af51aee807d800e01e122897166a65ea93) - - - - - d52be957 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Declare bkpcabal08 as fragile Due to spurious output changes described in #23648. (cherry picked from commit c046a2382420f2be2c4a657c56f8d95f914ea47b) - - - - - e75a58d1 by Ben Gamari at 2023-08-04T12:26:15-04:00 gitlab-ci: Only mark linker_unload_native as broken in static jobs This test passes on dynamically-linked Alpine. (cherry picked from commit f356a7e8ec8ec3d6b2b30fd175598b9b80065d87) - - - - - 8b176514 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Update base-exports - - - - - 4b647936 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite/interface-stability: normalise versions This eliminates spurious changes from version bumps. - - - - - 0eb54c05 by Ben Gamari at 2023-08-04T12:26:51-04:00 linker/PEi386: Don't sign-extend symbol section number Previously we incorrectly interpreted PE section numbers as signed values. However, this isn't the case; rather, it's an unsigned 16-bit number with a few special bit-patterns (0xffff and 0xfffe). This resulted in #22941 as the linker would conclude that the sections were invalid. Fixing this required quite a bit of refactoring. Closes #22941. - - - - - fd7ce39c by Ben Gamari at 2023-08-04T12:27:28-04:00 testsuite: Mark MulMayOflo_full as broken rather than skipping To ensure that we don't accidentally fix it. See #23742. - - - - - 824092f2 by Ben Gamari at 2023-08-04T12:27:28-04:00 nativeGen/AArch64: Fix sign extension in MulMayOflo Previously the 32-bit implementations of MulMayOflo would use the a non-sensical sign-extension mode. Rewrite these to reflect what gcc 11 produces. Also similarly rework the 16- and 8-bit cases. This now passes the MulMayOflo tests in ghc/test-primops> in all four widths, including the precision tests. Fixes #23721. - - - - - 1b15dbc4 by Jan Hrček at 2023-08-04T12:28:08-04:00 Fix haddock markup in code example for coerce - - - - - 46fd8ced by Vladislav Zavialov at 2023-08-04T12:28:44-04:00 Fix (~) and (@) infix operators in TH splices (#23748) 8168b42a "Whitespace-sensitive bang patterns" allows GHC to accept the following infix operators: a ~ b = () a @ b = () But not if TH is used to generate those declarations: $([d| a ~ b = () a @ b = () |]) -- Test.hs:5:2: error: [GHC-55017] -- Illegal variable name: ‘~’ -- When splicing a TH declaration: (~_0) a_1 b_2 = GHC.Tuple.Prim.() This is easily fixed by modifying `reservedOps` in GHC.Utils.Lexeme - - - - - a1899d8f by Aaron Allen at 2023-08-04T12:29:24-04:00 [#23663] Show Flag Suggestions in GHCi Makes suggestions when using `:set` in GHCi with a misspelled flag. This mirrors how invalid flags are handled when passed to GHC directly. Logic for producing flag suggestions was moved to GHC.Driver.Sesssion so it can be shared. resolves #23663 - - - - - 03f2debd by Rodrigo Mesquita at 2023-08-04T12:30:00-04:00 Improve ghc-toolchain validation configure warning Fixes the layout of the ghc-toolchain validation warning produced by configure. - - - - - de25487d by Alan Zimmerman at 2023-08-04T12:30:36-04:00 EPA make getLocA a synonym for getHasLoc This is basically a no-op change, but allows us to make future changes that can rely on the HasLoc instances And I presume this means we can use more precise functions based on class resolution, so the Windows CI build reports Metric Decrease: T12234 T13035 - - - - - 3ac423b9 by Ben Gamari at 2023-08-04T12:31:13-04:00 ghc-platform: Add upper bound on base Hackage upload requires this. - - - - - 8ba20b21 by Matthew Craven at 2023-08-04T17:22:59-04:00 Adjust and clarify handling of primop effects Fixes #17900; fixes #20195. The existing "can_fail" and "has_side_effects" primop attributes that previously governed this were used in inconsistent and confusingly-documented ways, especially with regard to raising exceptions. This patch replaces them with a single "effect" attribute, which has four possible values: NoEffect, CanFail, ThrowsException, and ReadWriteEffect. These are described in Note [Classifying primop effects]. A substantial amount of related documentation has been re-drafted for clarity and accuracy. In the process of making this attribute format change for literally every primop, several existing mis-classifications were detected and corrected. One of these mis-classifications was tagToEnum#, which is now considered CanFail; this particular fix is known to cause a regression in performance for derived Enum instances. (See #23782.) Fixing this is left as future work. New primop attributes "cheap" and "work_free" were also added, and used in the corresponding parts of GHC.Core.Utils. In view of their actual meaning and uses, `primOpOkForSideEffects` and `exprOkForSideEffects` have been renamed to `primOpOkToDiscard` and `exprOkToDiscard`, respectively. Metric Increase: T21839c - - - - - 41bf2c09 by sheaf at 2023-08-04T17:23:42-04:00 Update inert_solved_dicts for ImplicitParams When adding an implicit parameter dictionary to the inert set, we must make sure that it replaces any previous implicit parameter dictionaries that overlap, in order to get the appropriate shadowing behaviour, as in let ?x = 1 in let ?x = 2 in ?x We were already doing this for inert_cans, but we weren't doing the same thing for inert_solved_dicts, which lead to the bug reported in #23761. The fix is thus to make sure that, when handling an implicit parameter dictionary in updInertDicts, we update **both** inert_cans and inert_solved_dicts to ensure a new implicit parameter dictionary correctly shadows old ones. Fixes #23761 - - - - - 43578d60 by Matthew Craven at 2023-08-05T01:05:36-04:00 Bump bytestring submodule to 0.11.5.1 - - - - - 91353622 by Ben Gamari at 2023-08-05T01:06:13-04:00 Initial commit of Note [Thunks, blackholes, and indirections] This Note attempts to summarize the treatment of thunks, thunk update, and indirections. This fell out of work on #23185. - - - - - 8d686854 by sheaf at 2023-08-05T01:06:54-04:00 Remove zonk in tcVTA This removes the zonk in GHC.Tc.Gen.App.tc_inst_forall_arg and its accompanying Note [Visible type application zonk]. Indeed, this zonk is no longer necessary, as we no longer maintain the invariant that types are well-kinded without zonking; only that typeKind does not crash; see Note [The Purely Kinded Type Invariant (PKTI)]. This commit removes this zonking step (as well as a secondary zonk), and replaces the aforementioned Note with the explanatory Note [Type application substitution], which justifies why the substitution performed in tc_inst_forall_arg remains valid without this zonking step. Fixes #23661 - - - - - 19dea673 by Ben Gamari at 2023-08-05T01:07:30-04:00 Bump nofib submodule Ensuring that nofib can be build using the same range of bootstrap compilers as GHC itself. - - - - - aa07402e by Luite Stegeman at 2023-08-05T23:15:55+09:00 JS: Improve compatibility with recent emsdk The JavaScript code in libraries/base/jsbits/base.js had some hardcoded offsets for fields in structs, because we expected the layout of the data structures to remain unchanged. Emsdk 3.1.42 changed the layout of the stat struct, breaking this assumption, and causing code in .hsc files accessing the stat struct to fail. This patch improves compatibility with recent emsdk by removing the assumption that data layouts stay unchanged: 1. offsets of fields in structs used by JavaScript code are now computed by the configure script, so both the .js and .hsc files will automatically use the new layout if anything changes. 2. the distrib/configure script checks that the emsdk version on a user's system is the same version that a bindist was booted with, to avoid data layout inconsistencies See #23641 - - - - - b938950d by Luite Stegeman at 2023-08-07T06:27:51-04:00 JS: Fix missing local variable declarations This fixes some missing local variable declarations that were found by running the testsuite in strict mode. Fixes #23775 - - - - - 6c0e2247 by sheaf at 2023-08-07T13:31:21-04:00 Update Haddock submodule to fix #23368 This submodule update adds the following three commits: bbf1c8ae - Check for puns 0550694e - Remove fake exports for (~), List, and Tuple<n> 5877bceb - Fix pretty-printing of Solo and MkSolo These commits fix the issues with Haddock HTML rendering reported in ticket #23368. Fixes #23368 - - - - - 5b5be3ea by Matthew Pickering at 2023-08-07T13:32:00-04:00 Revert "Bump bytestring submodule to 0.11.5.1" This reverts commit 43578d60bfc478e7277dcd892463cec305400025. Fixes #23789 - - - - - 01961be3 by Ben Gamari at 2023-08-08T02:47:14-04:00 configure: Derive library version from ghc-prim.cabal.in Since ghc-prim.cabal is now generated by Hadrian, we cannot depend upon it. Closes #23726. - - - - - 3b373838 by Ryan Scott at 2023-08-08T02:47:49-04:00 tcExpr: Push expected types for untyped TH splices inwards In !10911, I deleted a `tcExpr` case for `HsUntypedSplice` in favor of a much simpler case that simply delegates to `tcApp`. Although this passed the test suite at the time, this was actually an error, as the previous `tcExpr` case was critically pushing the expected type inwards. This actually matters for programs like the one in #23796, which GHC would not accept with type inference alone—we need full-blown type _checking_ to accept these. I have added back the previous `tcExpr` case for `HsUntypedSplice` and now explain why we have two different `HsUntypedSplice` cases (one in `tcExpr` and another in `splitHsApps`) in `Note [Looking through Template Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`. Fixes #23796. - - - - - 0ef1d8ae by sheaf at 2023-08-08T21:26:51-04:00 Compute all emitted diagnostic codes This commit introduces in GHC.Types.Error.Codes the function constructorCodes :: forall diag. (...) => Map DiagnosticCode String which computes a collection of all the diagnostic codes that correspond to a particular type. In particular, we can compute the collection of all diagnostic codes emitted by GHC using the invocation constructorCodes @GhcMessage We then make use of this functionality in the new "codes" test which checks consistency and coverage of GHC diagnostic codes. It performs three checks: - check 1: all non-outdated GhcDiagnosticCode equations are statically used. - check 2: all outdated GhcDiagnosticCode equations are statically unused. - check 3: all statically used diagnostic codes are covered by the testsuite (modulo accepted exceptions). - - - - - 4bc7b1e5 by Fraser Tweedale at 2023-08-08T21:27:32-04:00 numberToRangedRational: fix edge cases for exp ≈ (maxBound :: Int) Currently a negative exponent less than `minBound :: Int` results in Infinity, which is very surprising and obviously wrong. ``` λ> read "1e-9223372036854775808" :: Double 0.0 λ> read "1e-9223372036854775809" :: Double Infinity ``` There is a further edge case where the exponent can overflow when increased by the number of tens places in the integer part, or underflow when decreased by the number of leading zeros in the fractional part if the integer part is zero: ``` λ> read "10e9223372036854775807" :: Double 0.0 λ> read "0.01e-9223372036854775808" :: Double Infinity ``` To resolve both of these issues, perform all arithmetic and comparisons involving the exponent in type `Integer`. This approach also eliminates the need to explicitly check the exponent against `maxBound :: Int` and `minBound :: Int`, because the allowed range of the exponent (i.e. the result of `floatRange` for the target floating point type) is certainly within those bounds. This change implements CLC proposal 192: https://github.com/haskell/core-libraries-committee/issues/192 - - - - - 6eab07b2 by Alan Zimmerman at 2023-08-08T21:28:10-04:00 EPA: Remove Location from WarningTxt source This is not needed. - - - - - 1a98d673 by Sebastian Graf at 2023-08-09T16:24:29-04:00 Cleanup a TODO introduced in 1f94e0f7 The change must have slipped through review of !4412 - - - - - 2274abc8 by Sebastian Graf at 2023-08-09T16:24:29-04:00 More explicit strictness in GHC.Real - - - - - ce8aa54c by Sebastian Graf at 2023-08-09T16:24:30-04:00 exprIsTrivial: Factor out shared implementation The duplication between `exprIsTrivial` and `getIdFromTrivialExpr_maybe` has been bugging me for a long time. This patch introduces an inlinable worker function `trivial_expr_fold` acting as the single, shared decision procedure of triviality. It "returns" a Church-encoded `Maybe (Maybe Id)`, so when it is inlined, it fuses to similar code as before. (Better code, even, in the case of `getIdFromTrivialExpr` which presently allocates a `Just` constructor that cancels away after this patch.) - - - - - d004a36d by Sebastian Graf at 2023-08-09T16:24:30-04:00 Simplify: Simplification of arguments in a single function The Simplifier had a function `simplArg` that wasn't called in `rebuildCall`, which seems to be the main way to simplify args. Hence I consolidated the code path to call `simplArg`, too, renaming to `simplLazyArg`. - - - - - 8c73505e by Sebastian Graf at 2023-08-09T16:24:30-04:00 Core.Ppr: Omit case binder for empty case alternatives A minor improvement to pretty-printing - - - - - d8d993f1 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Disable tests RepPolyWrappedVar2 and RepPolyUnsafeCoerce1 in JS backend ... because those coerce between incompatible/unknown PrimReps. - - - - - f06e87e4 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Inlining literals into boring contexts is OK - - - - - 4a6b7c87 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Clarify floating of unsafeEqualityProofs (#23754) - - - - - b0f4752e by Sebastian Graf at 2023-08-09T16:24:30-04:00 Kill SetLevel.notWorthFloating.is_triv (#23270) We have had it since b84ba676034, when it operated on annotated expressions. Nowadays it operates on vanilla `CoreExpr` though, so we should just call `exprIsTrivial`; thus handling empty cases and string literals correctly. - - - - - 7e0c8b3b by Sebastian Graf at 2023-08-09T16:24:30-04:00 ANFise string literal arguments (#23270) This instates the invariant that a trivial CoreExpr translates to an atomic StgExpr. Nice. Annoyingly, in -O0 we sometimes generate ``` foo = case "blah"# of sat { __DEFAULT -> unpackCString# sat } ``` which makes it a bit harder to spot that we can emit a standard `stg_unpack_cstring` thunk. Fixes #23270. - - - - - 357f2738 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Deactivate -fcatch-nonexhaustive-cases in ghc-bignum (#23345) - - - - - 59202c80 by Sebastian Graf at 2023-08-09T16:24:30-04:00 CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now. The main reason is that it plays far better in conjunction with eta expansion (as we aim to do for arguments in CorePrep, #23083), because we can discard any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta` it's impossible to discard the argument. We do also give the same treatment to unsafeCoerce proofs and treat them as trivial iff their RHS is trivial. It is also both much simpler to describe than the previous mechanism of emitting an unsafe coercion and simpler to implement, removing quite a bit of commentary and `CorePrepProv`. In the ghc/alloc perf test `LargeRecord`, we introduce an additional Simplifier iteration due to #17910. E.g., FloatOut produces a binding ``` lvl_s6uK [Occ=Once1] :: GHC.Types.Int [LclId] lvl_s6uK = GHC.Types.I# 2# lvl_s6uL [Occ=Once1] :: GHC.Types.Any [LclId] lvl_s6uL = case Unsafe.Coerce.unsafeEqualityProof ... of { Unsafe.Coerce.UnsafeRefl v2_i6tr -> lvl_s6uK `cast` (... v2_i6tr ...) } ``` That occurs once and hence is pre-inlined unconditionally in the next Simplifier pass. It's non-trivial to find a way around that, but not really harmful otherwise. Hence we accept a 1.2% increase on some architectures. Metric Increase: LargeRecord - - - - - 00d31188 by Sebastian Graf at 2023-08-09T16:24:30-04:00 CorePrep: Eta expand arguments (#23083) Previously, we'd only eta expand let bindings and lambdas, now we'll also eta expand arguments such as in T23083: ```hs g f h = f (h `seq` (h $)) ``` Unless `-fpedantic-bottoms` is set, we'll now transform to ```hs g f h = f (\eta -> h eta) ``` in CorePrep. See the new `Note [Eta expansion of arguments in CorePrep]` for the details. We only do this optimisation with -O2 because we saw 2-3% ghc/alloc regressions in T4801 and T5321FD. Fixes #23083. - - - - - bf885d7a by Matthew Craven at 2023-08-09T16:25:07-04:00 Bump bytestring submodule to 0.11.5, again Fixes #23789. The bytestring commit used here is unreleased; a release can be made when necessary. - - - - - 7acbf0fd by Sven Tennie at 2023-08-10T19:17:11-04:00 Serialize CmmRetInfo in .rodata The handling of case was missing. - - - - - 0c3136f2 by Sven Tennie at 2023-08-10T19:17:11-04:00 Reference StgRetFun payload by its struct field address This is easier to grasp than relative pointer offsets. - - - - - f68ff313 by Sven Tennie at 2023-08-10T19:17:11-04:00 Better variable name: u -> frame The 'u' was likely introduced by copy'n'paste. - - - - - 0131bb7f by Sven Tennie at 2023-08-10T19:17:11-04:00 Make checkSTACK() public Such that it can also be used in tests. - - - - - 7b6e1e53 by Sven Tennie at 2023-08-10T19:17:11-04:00 Publish stack related fields in DerivedConstants.h These will be used in ghc-heap to decode these parts of the stack. - - - - - 907ed054 by Sven Tennie at 2023-08-10T19:17:11-04:00 ghc-heap: Decode StgStack and its stack frames Previously, ghc-heap could only decode heap closures. The approach is explained in detail in note [Decoding the stack]. - - - - - 6beb6ac2 by Sven Tennie at 2023-08-10T19:17:11-04:00 Remove RetFunType from RetFun stack frame representation It's a technical detail. The single usage is replaced by a predicate. - - - - - 006bb4f3 by Sven Tennie at 2023-08-10T19:17:11-04:00 Better parameter name The call-site uses the term "offset", too. - - - - - d4c2c1af by Sven Tennie at 2023-08-10T19:17:11-04:00 Make closure boxing pure There seems to be no need to do something complicated. However, the strictness of the closure pointer matters, otherwise a thunk gets decoded. - - - - - 8d8426c9 by Sven Tennie at 2023-08-10T19:17:11-04:00 Document entertainGC in test It wasn't obvious why it's there and what its role is. Also, increase the "entertainment level" a bit. I checked in STG and Cmm dumps that this really generates closures (and is not e.g. constant folded away.) - - - - - cc52c358 by Finley McIlwaine at 2023-08-10T19:17:47-04:00 Add -dipe-stats flag This is useful for seeing which info tables have information. - - - - - 261c4acb by Finley McIlwaine at 2023-08-10T19:17:47-04:00 Add -finfo-table-map-with-fallback -finfo-table-map-with-stack The -fno-info-table-map-with-stack flag omits STACK info tables from the info table map, and the -fno-info-table-map-with-fallback flag omits info tables with defaulted source locations from the map. In a test on the Agda codebase the build results were about 7% smaller when both of those types of tables were omitted. Adds a test that verifies that passing each combination of these flags results in the correct output for -dipe-stats, which is disabled for the js backend since profiling is not implemented. This commit also refactors a lot of the logic around extracting info tables from the Cmm results and building the info table map. This commit also fixes some issues in the users guide rst source to fix warnings that were noticed while debugging the documentation for these flags. Fixes #23702 - - - - - d7047e0d by Jaro Reinders at 2023-08-14T04:41:42-04:00 Add changelog entry for specialised Enum Int64/Word64 instances - - - - - 52f5e8fb by cydparser at 2023-08-14T04:42:20-04:00 Fix -ddump-to-file and -ddump-timings interaction (#20316) - - - - - 1274c5d6 by cydparser at 2023-08-14T04:42:20-04:00 Update release notes (#20316) - - - - - 8e699b23 by Matthew Pickering at 2023-08-14T10:44:47-04:00 base: Add changelog entry for CLC #188 This proposal modified the implementations of copyBytes, moveBytes and fillBytes (as detailed in the proposal) https://github.com/haskell/core-libraries-committee/issues/188 - - - - - 026f040a by Matthew Pickering at 2023-08-14T10:45:23-04:00 packaging: Build manpage in separate directory to other documentation We were installing two copies of the manpage: * One useless one in the `share/doc` folder, because we copy the doc/ folder into share/ * The one we deliberately installed into `share/man` etc The solution is to build the manpage into the `manpage` directory when building the bindist, and then just install it separately. Fixes #23707 - - - - - 524c60c8 by Bartłomiej Cieślar at 2023-08-14T13:46:33-04:00 Report deprecated fields bound by record wildcards when used This commit ensures that we emit the appropriate warnings when a deprecated record field bound by a record wildcard is used. For example: module A where data Foo = Foo {x :: Int, y :: Bool, z :: Char} {-# DEPRECATED x "Don't use x" #-} {-# WARNING y "Don't use y" #-} module B where import A foo (Foo {..}) = x This will cause us to emit a "Don't use x" warning, with location the location of the record wildcard. Note that we don't warn about `y`, because it is unused in the RHS of `foo`. Fixes #23382 - - - - - d6130065 by Matthew Pickering at 2023-08-14T13:47:11-04:00 Add zstd suffix to jobs which rely on zstd This was causing some confusion as the job was named simply "x86_64-linux-deb10-validate", which implies a standard configuration rather than any dependency on libzstd. - - - - - e24e44fc by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: Always run project-version job This is needed for the downstream test-primops pipeline to workout what the version of a bindist produced by a pipeline is. - - - - - f17b9d62 by Matthew Pickering at 2023-08-14T13:47:11-04:00 gen_ci: Rework how jobs-metadata.json is generated * We now represent a job group a triple of Maybes, which makes it easier to work out when jobs are enabled/disabled on certain pipelines. ``` data JobGroup a = StandardTriple { v :: Maybe (NamedJob a) , n :: Maybe (NamedJob a) , r :: Maybe (NamedJob a) } ``` * `jobs-metadata.json` generation is reworked using the following algorithm. - For each pipeline type, find all the platforms we are doing builds for. - Select one build per platform - Zip together the results This way we can choose different pipelines for validate/nightly/release which makes the metadata also useful for validate pipelines. This feature is used by the test-primops downstream CI in order to select the right bindist for testing validate pipelines. This makes it easier to inspect which jobs are going to be enabled on a particular pipeline. - - - - - f9a5563d by Matthew Pickering at 2023-08-14T13:47:11-04:00 gen_ci: Rules rework In particular we now distinguish between whether we are dealing with a Nightly/Release pipeline (which labels don't matter for) and a validate pipeline where labels do matter. The overall goal here is to allow a disjunction of labels for validate pipelines, for example, > Run a job if we have the full-ci label or test-primops label Therefore the "ValidateOnly" rules are treated as a set of disjunctions rather than conjunctions like before. What this means in particular is that if we want to ONLY run a job if a label is set, for example, "FreeBSD" label then we have to override the whole label set. Fixes #23772 - - - - - d54b0c1d by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: set -e for lint-ci-config scripts - - - - - 994a9b35 by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: Fix job metadata generation - - - - - e194ed2b by Ben Gamari at 2023-08-15T00:58:09-04:00 users-guide: Note that GHC2021 doesn't include ExplicitNamespaces As noted in #23801. - - - - - d814bda9 by Ben Gamari at 2023-08-15T05:43:53-04:00 users-guide: Support both distutils and packaging As noted in #23818, some old distributions (e.g. Debian 9) only include `distutils` while newer distributions only include `packaging`. Fixes #23818. - - - - - 1726db3f by Ben Gamari at 2023-08-15T05:43:53-04:00 users-guide: Ensure extlinks is compatible with Sphinx <4 The semantics of the `extlinks` attribute annoyingly changed in Sphinx 4. Reflect this in our configuration. See #22690. Fixes #23807. - - - - - 173338cf by Matthew Pickering at 2023-08-15T22:00:24-04:00 ci: Run full-ci on master and release branches Fixes #23737 - - - - - bdab6898 by Andrew Lelechenko at 2023-08-15T22:01:03-04:00 Add @since pragmas for Data.Ord.clamp and GHC.Float.clamp - - - - - 662d351b by Matthew Pickering at 2023-08-16T09:35:04-04:00 ghc-toolchain: Match CPP args with configure script At the moment we need ghc-toolchain to precisely match the output as provided by the normal configure script. The normal configure script (FP_HSCPP_CMD_WITH_ARGS) branches on whether we are using clang or gcc so we match that logic exactly in ghc-toolchain. The old implementation (which checks if certain flags are supported) is better but for now we have to match to catch any potential errors in the configuration. Ticket: #23720 - - - - - 09c6759e by Matthew Pickering at 2023-08-16T09:35:04-04:00 configure: Fix `-Wl,--no-as-needed` check The check was failing because the args supplied by $$1 were quoted which failed because then the C compiler thought they were an input file. Fixes #23720 - - - - - 2129678b by Matthew Pickering at 2023-08-16T09:35:04-04:00 configure: Add flag which turns ghc-toolchain check into error We want to catch these errors in CI, but first we need to a flag which turns this check into an error. - - - - - 6e2aa8e0 by Matthew Pickering at 2023-08-16T09:35:04-04:00 ci: Enable --enable-strict-ghc-toolchain-check for all CI jobs This will cause any CI job to fail if we have a mismatch between what ghc-toolchain reports and what ./configure natively reports. Fixing these kinds of issues is highest priority for 9.10 release. - - - - - 12d39e24 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 Pass user-specified options to ghc-toolchain The current user interface to configuring target toolchains is `./configure`. In !9263 we added a new tool to configure target toolchains called `ghc-toolchain`, but the blessed way of creating these toolchains is still through configure. However, we were not passing the user-specified options given with the `./configure` invocation to the ghc-toolchain tool. This commit remedies that by storing the user options and environment variables in USER_* variables, which then get passed to GHC-toolchain. The exception to the rule is the windows bundled toolchain, which overrides the USER_* variables with whatever flags the windows bundled toolchain requires to work. We consider the bundled toolchain to be effectively the user specifying options, since the actual user delegated that configuration work. Closes #23678 - - - - - f7b3c3a0 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 ghc-toolchain: Parse javascript and ghcjs as a Arch and OS - - - - - 8a0ae4ee by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 ghc-toolchain: Fix ranlib option - - - - - 31e9ec96 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 Check Link Works with -Werror - - - - - bc1998b3 by Matthew Pickering at 2023-08-16T09:35:04-04:00 Only check for no_compact_unwind support on darwin While writing ghc-toolchain we noticed that the FP_PROG_LD_NO_COMPACT_UNWIND check is subtly wrong. Specifically, we pass -Wl,-no_compact_unwind to cc. However, ld.gold interprets this as -n o_compact_unwind, which is a valid argument. Fixes #23676 - - - - - 0283f36e by Matthew Pickering at 2023-08-16T09:35:04-04:00 Add some javascript special cases to ghc-toolchain On javascript there isn't a choice of toolchain but some of the configure checks were not accurately providing the correct answer. 1. The linker was reported as gnu LD because the --version output mentioned gnu LD. 2. The --target flag makes no sense on javascript but it was just ignored by the linker, so we add a special case to stop ghc-toolchain thinking that emcc supports --target when used as a linker. - - - - - a48ec5f8 by Matthew Pickering at 2023-08-16T09:35:04-04:00 check for emcc in gnu_LD check - - - - - 50df2e69 by Matthew Pickering at 2023-08-16T09:35:04-04:00 Add ldOverrideWhitelist to only default to ldOverride on windows/linux On some platforms - ie darwin, javascript etc we really do not want to allow the user to use any linker other than the default one as this leads to all kinds of bugs. Therefore it is a bit more prudant to add a whitelist which specifies on which platforms it might be possible to use a different linker. - - - - - a669a39c by Matthew Pickering at 2023-08-16T09:35:04-04:00 Fix plaform glob in FPTOOLS_SET_C_LD_FLAGS A normal triple may look like x86_64-unknown-linux but when cross-compiling you get $target set to a quad such as.. aarch64-unknown-linux-gnu Which should also match this check. - - - - - c52b6769 by Matthew Pickering at 2023-08-16T09:35:04-04:00 ghc-toolchain: Pass ld-override onto ghc-toolchain - - - - - 039b484f by Matthew Pickering at 2023-08-16T09:35:04-04:00 ld override: Make whitelist override user given option - - - - - d2b63cbc by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: Add format mode to normalise differences before diffing. The "format" mode takes an "--input" and "--ouput" target file and formats it. This is intended to be useful on windows where the configure/ghc-toolchain target files can't be diffed very easily because the path separators are different. - - - - - f2b39e4a by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: Bump ci-images commit to get new ghc-wasm-meta We needed to remove -Wno-unused-command-line-argument from the arguments passed in order for the configure check to report correctly. See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10976#note_516335 - - - - - 92103830 by Matthew Pickering at 2023-08-16T09:35:05-04:00 configure: MergeObjsCmd - distinguish between empty string and unset variable If `MergeObjsCmd` is explicitly set to the empty string then we should assume that MergeObjs is just not supported. This is especially important for windows where we set MergeObjsCmd to "" in m4/fp_setup_windows_toolchain.m4. - - - - - 3500bb2c by Matthew Pickering at 2023-08-16T09:35:05-04:00 configure: Add proper check to see if object merging works - - - - - 08c9a014 by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: If MergeObjsCmd is not set, replace setting with Nothing If the user explicitly chooses to not set a MergeObjsCmd then it is correct to use Nothing for tgtMergeObjs field in the Target file. - - - - - c9071d94 by Matthew Pickering at 2023-08-16T09:35:05-04:00 HsCppArgs: Augment the HsCppOptions This is important when we pass -I when setting up the windows toolchain. - - - - - 294a6d80 by Matthew Pickering at 2023-08-16T09:35:05-04:00 Set USER_CPP_ARGS when setting up windows toolchain - - - - - bde4b5d4 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00 Improve handling of Cc as a fallback - - - - - f4c1c3a3 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00 ghc-toolchain: Configure Cpp and HsCpp correctly when user specifies flags In ghc-toolchain, we were only /not/ configuring required flags when the user specified any flags at all for the of the HsCpp and Cpp tools. Otherwise, the linker takes into consideration the user specified flags to determine whether to search for a better linker implementation, but already configured the remaining GHC and platform-specific flags regardless of the user options. Other Tools consider the user options as a baseline for further configuration (see `findProgram`), so #23689 is not applicable. Closes #23689 - - - - - bfe4ffac by Matthew Pickering at 2023-08-16T09:35:05-04:00 CPP_ARGS: Put new options after user specified options This matches up with the behaviour of ghc-toolchain, so that the output of both matches. - - - - - a6828173 by Gergő Érdi at 2023-08-16T09:35:41-04:00 If a defaulting plugin made progress, re-zonk wanteds before built-in defaulting Fixes #23821. - - - - - e2b38115 by Sylvain Henry at 2023-08-17T07:54:06-04:00 JS: implement openat(AT_FDCWD...) (#23697) Use `openSync` to implement `openat(AT_FDCWD...)`. - - - - - a975c663 by sheaf at 2023-08-17T07:54:47-04:00 Use unsatisfiable for missing methods w/ defaults When a class instance has an Unsatisfiable constraint in its context and the user has not explicitly provided an implementation of a method, we now always provide a RHS of the form `unsatisfiable @msg`, even if the method has a default definition available. This ensures that, when deferring type errors, users get the appropriate error message instead of a possible runtime loop, if class default methods were defined recursively. Fixes #23816 - - - - - 45ca51e5 by Ben Gamari at 2023-08-17T15:16:41-04:00 ghc-internal: Initial commit of the skeleton - - - - - 88bbf8c5 by Ben Gamari at 2023-08-17T15:16:41-04:00 ghc-experimental: Initial commit - - - - - 664468c0 by Ben Gamari at 2023-08-17T15:17:17-04:00 testsuite/cloneStackLib: Fix incorrect format specifiers - - - - - eaa835bb by Ben Gamari at 2023-08-17T15:17:17-04:00 rts/ipe: Fix const-correctness of IpeBufferListNode Both info tables and the string table should be `const` - - - - - 78f6f6fd by Ben Gamari at 2023-08-17T15:17:17-04:00 nonmoving: Drop dead debugging utilities These are largely superceded by support in the ghc-utils GDB extension. - - - - - 3f6e8f42 by Ben Gamari at 2023-08-17T15:17:17-04:00 nonmoving: Refactor management of mark thread Here we refactor that treatment of the worker thread used by the nonmoving GC for concurrent marking, avoiding creating a new thread with every major GC cycle. As well, the new scheme is considerably easier to reason about, consolidating all state in one place, accessed via a small set of accessors with clear semantics. - - - - - 88c32b7d by Ben Gamari at 2023-08-17T15:17:17-04:00 testsuite: Skip T23221 in nonmoving GC ways This test is very dependent upon GC behavior. - - - - - 381cfaed by Ben Gamari at 2023-08-17T15:17:17-04:00 ghc-heap: Don't expose stack dirty and marking fields These are GC metadata and are not relevant to the end-user. Moreover, they are unstable which makes ghc-heap harder to test than necessary. - - - - - 16828ca5 by Luite Stegeman at 2023-08-21T18:42:53-04:00 bump process submodule to include macOS fix and JS support - - - - - b4d5f6ed by Matthew Pickering at 2023-08-21T18:43:29-04:00 ci: Add support for triggering test-primops pipelines This commit adds 4 ways to trigger testing with test-primops. 1. Applying the ~test-primops label to a validate pipeline. 2. A manually triggered job on a validate pipeline 3. A nightly pipeline job 4. A release pipeline job Fixes #23695 - - - - - 32c50daa by Matthew Pickering at 2023-08-21T18:43:29-04:00 Add test-primops label support The test-primops CI job requires some additional builds in the validation pipeline, so we make sure to enable these jobs when test-primops label is set. - - - - - 73ca8340 by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "Aarch ncg: Optimize immediate use for address calculations" This reverts commit 8f3b3b78a8cce3bd463ed175ee933c2aabffc631. See #23793 - - - - - 5546ad9e by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "AArch NCG: Pure refactor" This reverts commit 00fb6e6b06598752414a0b9a92840fb6ca61338d. See #23793 - - - - - 02dfcdc2 by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "Aarch64 NCG: Use encoded immediates for literals." This reverts commit 40425c5021a9d8eb5e1c1046e2d5fa0a2918f96c. See #23793 ------------------------- Metric Increase: T4801 T5321FD T5321Fun ------------------------- - - - - - 7be4a272 by Matthew Pickering at 2023-08-22T08:55:20+01:00 ci: Remove manually triggered test-ci job This doesn't work on slimmed down pipelines as the needed jobs don't exist. If you want to run test-primops then apply the label. - - - - - 76a4d11b by Jaro Reinders at 2023-08-22T08:08:13-04:00 Remove Ptr example from roles docs - - - - - 069729d3 by Bryan Richter at 2023-08-22T08:08:49-04:00 Guard against duplicate pipelines in forks - - - - - f861423b by Rune K. Svendsen at 2023-08-22T08:09:35-04:00 dump-decls: fix "Ambiguous module name"-error Fixes errors of the following kind, which happen when dump-decls is run on a package that contains a module name that clashes with that of another package. ``` dump-decls: <no location info>: error: Ambiguous module name `System.Console.ANSI.Types': it was found in multiple packages: ansi-terminal-0.11.4 ansi-terminal-types-0.11.5 ``` - - - - - edd8bc43 by Krzysztof Gogolewski at 2023-08-22T12:31:20-04:00 Fix MultiWayIf linearity checking (#23814) Co-authored-by: Thomas BAGREL <thomas.bagrel at tweag.io> - - - - - 4ba088d1 by konsumlamm at 2023-08-22T12:32:02-04:00 Update `Control.Concurrent.*` documentation - - - - - 015886ec by ARATA Mizuki at 2023-08-22T15:13:13-04:00 Support 128-bit SIMD on AArch64 via LLVM backend - - - - - 52a6d868 by Krzysztof Gogolewski at 2023-08-22T15:13:51-04:00 Testsuite cleanup - Remove misleading help text in perf_notes, ways are not metrics - Remove no_print_summary - this was used for Phabricator - In linters tests, run 'git ls-files' just once. Previously, it was called on each has_ls_files() - Add ghc-prim.cabal to gitignore, noticed in #23726 - Remove ghc-prim.cabal, it was accidentally committed in 524c60c8cd - - - - - ab40aa52 by Alan Zimmerman at 2023-08-22T15:14:28-04:00 EPA: Use Introduce [DeclTag] in AnnSortKey The AnnSortKey is used to keep track of the order of declarations for printing when the container has split them apart. This applies to HsValBinds and ClassDecl, ClsInstDecl. When making modifications to the list of declarations, the new order must be captured for when it must be printed. For each list of declarations (binds and sigs for a HsValBind) we can just store the list in order. To recreate the list when printing, we must merge them, and this is what the AnnSortKey records. It used to be indexed by SrcSpan, we now simply index by a marker as to which list to take the next item from. - - - - - e7db36c1 by sheaf at 2023-08-23T08:41:28-04:00 Don't attempt pattern synonym error recovery This commit gets rid of the pattern synonym error recovery mechanism (recoverPSB). The rationale is that the fake pattern synonym binding that the recovery mechanism introduced could lead to undesirable knock-on errors, and it isn't really feasible to conjure up a satisfactory binding as pattern synonyms can be used both in expressions and patterns. See Note [Pattern synonym error recovery] in GHC.Tc.TyCl.PatSyn. It isn't such a big deal to eagerly fail compilation on a pattern synonym that doesn't typecheck anyway. Fixes #23467 - - - - - 6ccd9d65 by Ben Gamari at 2023-08-23T08:42:05-04:00 base: Don't use Data.ByteString.Internals.memcpy This function is now deprecated from `bytestring`. Use `Foreign.Marshal.Utils.copyBytes` instead. Fixes #23880. - - - - - 0bfa0031 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Uniformly pass buildOptions to all builders in runBuilder In Builder.hs, runBuilderWith mostly ignores the buildOptions in BuildInfo. This leads to hard to diagnose bugs as any build options you pass with runBuilderWithCmdOptions are ignored for many builders. Solution: Uniformly pass buildOptions to the invocation of cmd. Fixes #23845 - - - - - 9cac8f11 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Abstract windows toolchain setup This commit splits up the windows toolchain setup logic into two functions. * FP_INSTALL_WINDOWS_TOOLCHAIN - deals with downloading the toolchain if it isn't already downloaded * FP_SETUP_WINDOWS_TOOLCHAIN - sets the environment variables to point to the correct place FP_SETUP_WINDOWS_TOOLCHAIN is abstracted from the location of the mingw toolchain and also the eventual location where we will install the toolchain in the installed bindist. This is the first step towards #23608 - - - - - 6c043187 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Generate build.mk for bindists The config.mk.in script was relying on some variables which were supposed to be set by build.mk but therefore never were when used to install a bindist. Specifically * BUILD_PROF_LIBS to determine whether we had profiled libraries or not * DYNAMIC_GHC_PROGRAMS to determine whether we had shared libraries or not Not only were these never set but also not really accurate because you could have shared libaries but still statically linked ghc executable. In addition variables like GhcLibWays were just never used, so those have been deleted from the script. Now instead we generate a build.mk file which just directly specifies which RtsWays we have supplied in the bindist and whether we have DYNAMIC_GHC_PROGRAMS. - - - - - fe23629b by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add reloc-binary-dist-* targets This adds a command line option to build a "relocatable" bindist. The bindist is created by first creating a normal bindist and then installing it using the `RelocatableBuild=YES` option. This creates a bindist without any wrapper scripts pointing to the libdir. The motivation for this feature is that we want to ship relocatable bindists on windows and this method is more uniform than the ad-hoc method which lead to bugs such as #23608 and #23476 The relocatable bindist can be built with the "reloc-binary-dist" target and supports the same suffixes as the normal "binary-dist" command to specify the compression style. - - - - - 41cbaf44 by Matthew Pickering at 2023-08-23T13:43:48-04:00 packaging: Fix installation scripts on windows/RelocatableBuild case This includes quite a lot of small fixes which fix the installation makefile to work on windows properly. This also required fixing the RelocatableBuild variable which seemed to have been broken for a long while. Sam helped me a lot writing this patch by providing a windows machine to test the changes. Without him it would have taken ages to tweak everything. Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 03474456 by Matthew Pickering at 2023-08-23T13:43:48-04:00 ci: Build relocatable bindist on windows We now build the relocatable bindist target on windows, which means we test and distribute the new method of creating a relocatable bindist. - - - - - d0b48113 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add error when trying to build binary-dist target on windows The binary dist produced by `binary-dist` target doesn't work on windows because of the wrapper script the makefile installs. In order to not surprise any packagers we just give an error if someone tries to build the old binary-dist target rather than the reloc-binary-dist target. - - - - - 7cbf9361 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Remove query' logic to use tooldir - - - - - 03fad42e by Matthew Pickering at 2023-08-23T13:43:48-04:00 configure: Set WindresCmd directly and removed unused variables For some reason there was an indirection via the Windres variable before setting WindresCmd. That indirection led to #23855. I then also noticed that these other variables were just not used anywhere when trying to work out what the correct condition was for this bit of the configure script. - - - - - c82770f5 by sheaf at 2023-08-23T13:43:48-04:00 Apply shellcheck suggestion to SUBST_TOOLDIR - - - - - 896e35e5 by sheaf at 2023-08-23T13:44:34-04:00 Compute hints from TcSolverReportMsg This commit changes how hints are handled in conjunction with constraint solver report messages. Instead of storing `[GhcHint]` in the TcRnSolverReport error constructor, we compute the hints depending on the underlying TcSolverReportMsg. This disentangles the logic and makes it easier to add new hints for certain errors. - - - - - a05cdaf0 by Alexander Esgen at 2023-08-23T13:45:16-04:00 users-guide: remove note about fatal Haddock parse failures - - - - - 4908d798 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Introduce Data.Enum - - - - - f59707c7 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Integer - - - - - b1054053 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num - - - - - 6baa481d by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Natural - - - - - 2ac15233 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Float - - - - - f3c489de by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Real - - - - - 94f59eaa by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Eliminate module reexport in GHC.Exception The metric increase here isn't strictly due to this commit but it's a rather small, incidental change. Metric Increase: T8095 T13386 Metric Decrease: T8095 T13386 T18304 - - - - - be1fc7df by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add disclaimers in internal modules To warn users that these modules are internal and their interfaces may change with little warning. As proposed in Core Libraries Committee #146 [CLC146]. [CLC146]: https://github.com/haskell/core-libraries-committee/issues/146 - - - - - 0326f3f4 by sheaf at 2023-08-23T17:37:29-04:00 Bump Cabal submodule We need to bump the Cabal submodule to include commit ec75950 which fixes an issue with a dodgy import Rep(..) which relied on GHC bug #23570 - - - - - 0504cd08 by Facundo Domínguez at 2023-08-23T17:38:11-04:00 Fix typos in the documentation of Data.OldList.permutations - - - - - 1420b8cb by Antoine Leblanc at 2023-08-24T16:18:17-04:00 Be more eager in TyCon boot validity checking This commit performs boot-file consistency checking for TyCons into checkValidTyCl. This ensures that we eagerly catch any mismatches, which prevents the compiler from seeing these inconsistencies and panicking as a result. See Note [TyCon boot consistency checking] in GHC.Tc.TyCl. Fixes #16127 - - - - - d99c816f by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Refactor estimation of stack info table provenance This commit greatly refactors the way we compute estimated provenance for stack info tables. Previously, this process was done using an entirely separate traversal of the whole Cmm code stream to build the map from info tables to source locations. The separate traversal is now fused with the Cmm code generation pipeline in GHC.Driver.Main. This results in very significant code generation speed ups when -finfo-table-map is enabled. In testing, this patch reduces code generation times by almost 30% with -finfo-table-map and -O0, and 60% with -finfo-table-map and -O1 or -O2 . Fixes #23103 - - - - - d3e0124c by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Add a test checking overhead of -finfo-table-map We want to make sure we don't end up with poor codegen performance resulting from -finfo-table-map again as in #23103. This test adds a performance test tracking total allocations while compiling ExactPrint with -finfo-table-map. - - - - - fcfc1777 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Add export list to GHC.Llvm.MetaData - - - - - 5880fff6 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Allow LlvmLits in MetaExprs This omission appears to be an oversight. - - - - - 86ce92a2 by Ben Gamari at 2023-08-25T10:58:16-04:00 compiler: Move platform feature predicates to GHC.Driver.DynFlags These are useful in `GHC.Driver.Config.*`. - - - - - a6a38742 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Introduce infrastructure for module flag metadata - - - - - e9af2cf3 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Don't pass stack alignment via command line As of https://reviews.llvm.org/D103048 LLVM no longer supports the `-stack-alignment=...` flag. Instead this information is passed via a module flag metadata node. This requires dropping support for LLVM 11 and 12. Fixes #23870 - - - - - a936f244 by Alan Zimmerman at 2023-08-25T10:58:56-04:00 EPA: Keep track of "in" token for WarningTxt category A warning can now be written with a category, e.g. {-# WARNInG in "x-c" e "d" #-} Keep track of the location of the 'in' keyword and string, as well as the original SourceText of the label, in case it uses character escapes. - - - - - 3df8a653 by Matthew Pickering at 2023-08-25T17:42:18-04:00 Remove redundant import in InfoTableProv The copyBytes function is provided by the import of Foreign. Fixes #23889 - - - - - d6f807ec by Ben Gamari at 2023-08-25T17:42:54-04:00 gitlab/issue-template: Mention report-a-bug - - - - - 50b9f75d by Artin Ghasivand at 2023-08-26T20:02:50+03:30 Added StandaloneKindSignature examples to replace CUSKs ones - - - - - 2f6309a4 by Vladislav Zavialov at 2023-08-27T03:47:37-04:00 Remove outdated CPP in compiler/* and template-haskell/* The boot compiler was bumped to 9.4 in cebb5819b43. There is no point supporting older GHC versions with CPP. - - - - - 5248fdf7 by Zubin Duggal at 2023-08-28T15:01:09+05:30 testsuite: Add regression test for #23861 Simon says this was fixed by commit 8d68685468d0b6e922332a3ee8c7541efbe46137 Author: sheaf <sam.derbyshire at gmail.com> Date: Fri Aug 4 15:28:45 2023 +0200 Remove zonk in tcVTA - - - - - b6903f4d by Zubin Duggal at 2023-08-28T12:33:58-04:00 testsuite: Add regression test for #23864 Simon says this was fixed by commit 59202c800f2c97c16906120ab2561f6e1556e4af Author: Sebastian Graf <sebastian.graf at kit.edu> Date: Fri Mar 31 17:35:22 2023 +0200 CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now. The main reason is that it plays far better in conjunction with eta expansion (as we aim to do for arguments in CorePrep, #23083), because we can discard any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta` it's impossible to discard the argument. - - - - - 9eecdf33 by sheaf at 2023-08-28T18:54:06+00:00 Remove ScopedTypeVariables => TypeAbstractions This commit implements [amendment 604](https://github.com/ghc-proposals/ghc-proposals/pull/604/) to [GHC proposal 448](https://github.com/ghc-proposals/ghc-proposals/pull/448) by removing the implication of language extensions ScopedTypeVariables => TypeAbstractions To limit breakage, we now allow type arguments in constructor patterns when both ScopedTypeVariables and TypeApplications are enabled, but we emit a warning notifying the user that this is deprecated behaviour that will go away starting in GHC 9.12. Fixes #23776 - - - - - fadd5b4d by sheaf at 2023-08-28T18:54:06+00:00 .stderr: ScopedTypeVariables =/> TypeAbstractions This commit accepts testsuite changes for the changes in the previous commit, which mean that TypeAbstractions is no longer implied by ScopedTypeVariables. - - - - - 4f5fb500 by Greg Steuck at 2023-08-29T07:55:13-04:00 Repair `codes` test on OpenBSD by explicitly requesting extended RE - - - - - 6bbde581 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23540 `T23540.hs` makes use of `explainEv` from `HieQueries.hs`, so `explainEv` has been moved to `TestUtils.hs`. - - - - - 257bb3bd by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23120 - - - - - 4f192947 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Make some evidence uses reachable by toHie Resolves #23540, #23120 This adds spans to certain expressions in the typechecker and renamer, and lets 'toHie' make use of those spans. Therefore the relevant evidence uses for the following syntax will now show up under the expected nodes in 'HieAst's: - Overloaded literals ('IsString', 'Num', 'Fractional') - Natural patterns and N+k patterns ('Eq', 'Ord', and instances from the overloaded literals being matched on) - Arithmetic sequences ('Enum') - Monadic bind statements ('Monad') - Monadic body statements ('Monad', 'Alternative') - ApplicativeDo ('Applicative', 'Functor') - Overloaded lists ('IsList') Also see Note [Source locations for implicit function calls] In the process of handling overloaded lists I added an extra 'SrcSpan' field to 'VAExpansion' - this allows us to more accurately reconstruct the locations from the renamer in 'rebuildHsApps'. This also happens to fix #23120. See the additions to Note [Looking through HsExpanded] - - - - - fe9fcf9d by Sylvain Henry at 2023-08-29T12:07:50-04:00 ghc-heap: rename C file (fix #23898) - - - - - b60d6576 by Krzysztof Gogolewski at 2023-08-29T12:08:29-04:00 Misc cleanup - Builtin.PrimOps: ReturnsAlg was used only for unboxed tuples. Rename to ReturnsTuple. - Builtin.Utils: use SDoc for a panic message. The comment about <<details unavailable>> was obsoleted by e8d356773b56. - TagCheck: fix wrong logic. It was zipping a list 'args' with its version 'args_cmm' after filtering. - Core.Type: remove an outdated 1999 comment about unlifted polymorphic types - hadrian: remove leftover debugging print - - - - - 3054fd6d by Krzysztof Gogolewski at 2023-08-29T12:09:08-04:00 Add a regression test for #23903 The bug has been fixed by commit bad2f8b8aa8424. - - - - - 21584b12 by Ben Gamari at 2023-08-29T19:52:02-04:00 README: Refer to ghc-hq repository for contributor and governance information - - - - - e542d590 by sheaf at 2023-08-29T19:52:40-04:00 Export setInertSet from GHC.Tc.Solver.Monad We used to export getTcSInerts and setTcSInerts from GHC.Tc.Solver.Monad. These got renamed to getInertSet/setInertSet in e1590ddc. That commit also removed the export of setInertSet, but that function is useful for the GHC API. - - - - - 694ec5b1 by sheaf at 2023-08-30T10:18:32-04:00 Don't bundle children for non-parent Avails We used to bundle all children of the parent Avail with things that aren't the parent, e.g. with class C a where type T a meth :: .. we would bundle the whole Avail (C, T, meth) with all of C, T and meth, instead of only with C. Avoiding this fixes #23570 - - - - - d926380d by Krzysztof Gogolewski at 2023-08-30T10:19:08-04:00 Fix typos - - - - - d07080d2 by Josh Meredith at 2023-08-30T19:42:32-04:00 JS: Implement missing C functions `rename`, `realpath`, and `getcwd` (#23806) - - - - - e2940272 by David Binder at 2023-08-30T19:43:08-04:00 Bump submodules of hpc and hpc-bin to version 0.7.0.0 hpc 0.7.0.0 dropped SafeHaskell safety guarantees in order to simplify compatibility with newer versions of the directory package which dropped all SafeHaskell guarantees. - - - - - 5d56d05c by David Binder at 2023-08-30T19:43:08-04:00 Bump hpc bound in ghc.cabal.in - - - - - 99fff496 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 ghc classes documentation: rm redundant comment - - - - - fe021bab by Dominik Schrempf at 2023-08-31T00:04:46-04:00 prelude documentation: various nits - - - - - 48c84547 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 integer documentation: minor corrections - - - - - 20cd12f4 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 real documentation: nits - - - - - dd39bdc0 by sheaf at 2023-08-31T00:05:27-04:00 Add a test for #21765 This issue (of reporting a constraint as being redundant even though removing it causes typechecking to fail) was fixed in aed1974e. This commit simply adds a regression test. Fixes #21765 - - - - - f1ec3628 by Andrew Lelechenko at 2023-08-31T23:53:30-04:00 Export foldl' from Prelude and bump submodules See https://github.com/haskell/core-libraries-committee/issues/167 for discussion Metric Decrease: T8095 T13386 Metric Increase: T13386 T8095 T8095 ghc/alloc decreased on x86_64, but increased on aarch64. T13386 ghc/alloc decreased on x86_64-windows, but increased on other platforms. Neither has anything to do with `foldl'`, so I conclude that both are flaky. - - - - - 3181b97d by Gergő Érdi at 2023-08-31T23:54:06-04:00 Allow cross-tyvar defaulting proposals from plugins Fixes #23832. - - - - - e4af506e by Sebastian Graf at 2023-09-01T14:29:12-04:00 Clarify Note [GlobalId/LocalId] after CorePrep (#23797) Fixes #23797. - - - - - ac29787c by Sylvain Henry at 2023-09-01T14:30:02-04:00 Fix warning with UNPACK on sum type (#23921) - - - - - 9765ac7b by Zubin Duggal at 2023-09-05T00:37:45-04:00 hadrian: track python dependencies in doc rules - - - - - 1578215f by sheaf at 2023-09-05T00:38:26-04:00 Bump Haddock to fix #23616 This commit updates the Haddock submodule to include the fix to #23616. Fixes #23616 - - - - - 5a2fe35a by David Binder at 2023-09-05T00:39:07-04:00 Fix example in GHC user guide in SafeHaskell section The example given in the SafeHaskell section uses an implementation of Monad which no longer works. This MR removes the non-canonical return instance and adds the necessary instances of Functor and Applicative. - - - - - 291d81ae by Matthew Pickering at 2023-09-05T14:03:10-04:00 driver: Check transitive closure of haskell package dependencies when deciding whether to relink We were previously just checking whether direct package dependencies had been modified. This caused issues when compiling without optimisations as we wouldn't relink the direct dependency if one of its dependenices changed. Fixes #23724 - - - - - 35da0775 by Krzysztof Gogolewski at 2023-09-05T14:03:47-04:00 Re-export GHC.Utils.Panic.Plain from GHC.Utils.Panic Fixes #23930 - - - - - 3930d793 by Jaro Reinders at 2023-09-06T18:42:55-04:00 Make STG rewriter produce updatable closures - - - - - 0104221a by Krzysztof Gogolewski at 2023-09-06T18:43:32-04:00 configure: update message to use hadrian (#22616) - - - - - b34f8586 by Alan Zimmerman at 2023-09-07T10:58:38-04:00 EPA: Incorrect locations for UserTyVar with '@' In T13343.hs, the location for the @ is not within the span of the surrounding UserTyVar. type Bad @v = (forall (v1 :: RuntimeRep) (a1 :: TYPE v). a1) :: TYPE v Widen it so it is captured. Closes #23887 - - - - - 8046f020 by Finley McIlwaine at 2023-09-07T10:59:15-04:00 Bump haddock submodule to fix #23920 Removes the fake export of `FUN` from Prelude. Fixes #23920. Bumps haddock submodule. - - - - - e0aa8c6e by Krzysztof Gogolewski at 2023-09-07T11:00:03-04:00 Fix wrong role in mkSelCo_maybe In the Lint failure in #23938, we start with a coercion Refl :: T a ~R T a, and call mkSelCo (SelTyCon 1 nominal) Refl. The function incorrectly returned Refl :: a ~R a. The returned role should be nominal, according to the SelCo rule: co : (T s1..sn) ~r0 (T t1..tn) r = tyConRole tc r0 i ---------------------------------- SelCo (SelTyCon i r) : si ~r ti In this test case, r is nominal while r0 is representational. - - - - - 1d92f2df by Gergő Érdi at 2023-09-08T04:04:30-04:00 If we have multiple defaulting plugins, then we should zonk in between them after any defaulting has taken place, to avoid a defaulting plugin seeing a metavariable that has already been filled. Fixes #23821. - - - - - eaee4d29 by Gergő Érdi at 2023-09-08T04:04:30-04:00 Improvements to the documentation of defaulting plugins Based on @simonpj's draft and comments in !11117 - - - - - ede3df27 by Alan Zimmerman at 2023-09-08T04:05:06-04:00 EPA: Incorrect span for LWarnDec GhcPs The code (from T23465.hs) {-# WARNInG in "x-c" e "d" #-} e = e gives an incorrect span for the LWarnDecl GhcPs Closes #23892 It also fixes the Test23465/Test23464 mixup - - - - - a0ccef7a by Krzysztof Gogolewski at 2023-09-08T04:05:42-04:00 Valid hole fits: don't suggest unsafeCoerce (#17940) - - - - - 88b942c4 by Oleg Grenrus at 2023-09-08T19:58:42-04:00 Add warning for badly staged types. Resolves #23829. The stage violation results in out-of-bound names in splices. Technically this is an error, but someone might rely on this!? Internal changes: - we now track stages for TyVars. - thLevel (RunSplice _) = 0, instead of panic, as reifyInstances does in fact rename its argument type, and it can contain variables. - - - - - 9861f787 by Ben Gamari at 2023-09-08T19:59:19-04:00 rts: Fix invalid symbol type I suspect this code is dead since we haven't observed this failing despite the obviously incorrect macro name. - - - - - 03ed6a9a by Ben Gamari at 2023-09-08T19:59:19-04:00 testsuite: Add simple test exercising C11 atomics in GHCi See #22012. - - - - - 1aa5733a by Ben Gamari at 2023-09-08T19:59:19-04:00 rts/RtsSymbols: Add AArch64 outline atomic operations Fixes #22012 by adding the symbols described in https://github.com/llvm/llvm-project/blob/main/llvm/docs/Atomics.rst#libcalls-atomic. Ultimately this would be better addressed by #22011, but this is a first step in the right direction and fixes the immediate symptom. Note that we dropped the `__arch64_cas16` operations as these provided by all platforms's compilers. Also, we don't link directly against the libgcc/compiler-rt definitions but rather provide our own wrappers to work around broken toolchains (e.g. https://bugs.gentoo.org/868018). Generated via https://gitlab.haskell.org/ghc/ghc/-/snippets/5733. - - - - - 8f7d3041 by Matthew Pickering at 2023-09-08T19:59:55-04:00 ci: Build debian12 and fedora38 bindists This adds builds for the latest releases for fedora and debian We build these bindists in nightly and release pipelines. - - - - - a1f0d55c by Felix Leitz at 2023-09-08T20:00:37-04:00 Fix documentation around extension implication for MultiParamTypeClasses/ConstrainedClassMethods. - - - - - 98166389 by Teo Camarasu at 2023-09-12T04:30:54-04:00 docs: move -xn flag beside --nonmoving-gc It makes sense to have these beside each other as they are aliases. - - - - - f367835c by Teo Camarasu at 2023-09-12T04:30:55-04:00 nonmoving: introduce a family of dense allocators Supplement the existing power 2 sized nonmoving allocators with a family of dense allocators up to a configurable threshold. This should reduce waste from rounding up block sizes while keeping the amount of allocator sizes manageable. This patch: - Adds a new configuration option `--nonmoving-dense-allocator-count` to control the amount of these new dense allocators. - Adds some constants to `NonmovingAllocator` in order to keep marking fast with the new allocators. Resolves #23340 - - - - - 2b07bf2e by Teo Camarasu at 2023-09-12T04:30:55-04:00 Add changelog entry for #23340 - - - - - f96fe681 by sheaf at 2023-09-12T04:31:44-04:00 Use printGhciException in run{Stmt, Decls} When evaluating statements in GHCi, we need to use printGhciException instead of the printException function that GHC provides in order to get the appropriate error messages that are customised for ghci use. - - - - - d09b932b by psilospore at 2023-09-12T04:31:44-04:00 T23686: Suggest how to enable Language Extension when in ghci Fixes #23686 - - - - - da30f0be by Matthew Craven at 2023-09-12T04:32:24-04:00 Unarise: Split Rubbish literals in function args Fixes #23914. Also adds a check to STG lint that these args are properly unary or nullary after unarisation - - - - - 261b6747 by Matthew Pickering at 2023-09-12T04:33:04-04:00 darwin: Bump MAXOSX_DEPLOYMENT_TARGET to 10.13 This bumps the minumum supported version to 10.13 (High Sierra) which is 6 years old at this point. Fixes #22938 - - - - - f418f919 by Mario Blažević at 2023-09-12T04:33:45-04:00 Fix TH pretty-printing of nested GADTs, issue #23937 This commit fixes `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints GADTs declarations contained within data family instances. Fixes #23937 - - - - - d7a64753 by John Ericson at 2023-09-12T04:34:20-04:00 Put hadrian non-bootstrap plans through `jq` This makes it possible to review changes with conventional diffing tools. This is picking up where ad8cfed4195b1bbfc15b841f010e75e71f63157d left off. - - - - - ff0a709a by Sylvain Henry at 2023-09-12T08:46:28-04:00 JS: fix some tests - Tests using Setup programs need to pass --with-hc-pkg - Several other fixes See https://gitlab.haskell.org/ghc/ghc/-/wikis/javascript-backend/bug_triage for the current status - - - - - fc86f0e7 by Krzysztof Gogolewski at 2023-09-12T08:47:04-04:00 Fix in-scope set assertion failure (#23918) Patch by Simon - - - - - 21a906c2 by Matthew Pickering at 2023-09-12T17:21:04+02:00 Add -Winconsistent-flags warning The warning fires when inconsistent command line flags are passed. For example: * -dynamic-too and -dynamic * -dynamic-too on windows * -O and --interactive * etc This is on by default and allows users to control whether the warning is displayed and whether it should be an error or not. Fixes #22572 - - - - - dfc4f426 by Krzysztof Gogolewski at 2023-09-12T20:31:35-04:00 Avoid serializing BCOs with the internal interpreter Refs #23919 - - - - - 9217950b by Finley McIlwaine at 2023-09-13T08:06:03-04:00 Fix numa auto configure - - - - - 98e7c1cf by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Add -fno-cse to T15426 and T18964 This -fno-cse change is to avoid these performance tests depending on flukey CSE stuff. Each contains several independent tests, and we don't want them to interact. See #23925. By killing CSE we expect a 400% increase in T15426, and 100% in T18964. Metric Increase: T15426 T18964 - - - - - 236a134e by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Tiny refactor canEtaReduceToArity was only called internally, and always with two arguments equal to zero. This patch just specialises the function, and renames it to cantEtaReduceFun. No change in behaviour. - - - - - 56b403c9 by Ben Gamari at 2023-09-13T19:21:36-04:00 spec-constr: Lift argument limit for SPEC-marked functions When the user adds a SPEC argument to a function, they are informing us that they expect the function to be specialised. However, previously this instruction could be preempted by the specialised-argument limit (sc_max_args). Fix this. This fixes #14003. - - - - - 6840012e by Simon Peyton Jones at 2023-09-13T19:22:13-04:00 Fix eta reduction Issue #23922 showed that GHC was bogusly eta-reducing a join point. We should never eta-reduce (\x -> j x) to j, if j is a join point. It is extremly difficult to trigger this bug. It took me 45 mins of trying to make a small tests case, here immortalised as T23922a. - - - - - e5c00092 by Andreas Klebinger at 2023-09-14T08:57:43-04:00 Profiling: Properly escape characters when using `-pj`. There are some ways in which unusual characters like quotes or others can make it into cost centre names. So properly escape these. Fixes #23924 - - - - - ec490578 by Ellie Hermaszewska at 2023-09-14T08:58:24-04:00 Use clearer example variable names for bool eliminator - - - - - 5126a2fe by Sylvain Henry at 2023-09-15T11:18:02-04:00 Add missing int64/word64-to-double/float rules (#23907) CLC proposal: https://github.com/haskell/core-libraries-committee/issues/203 - - - - - 566ef411 by Mario Blažević at 2023-09-15T11:18:43-04:00 Fix and test TH pretty-printing of type operator role declarations This commit fixes and tests `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints `type role` declarations for operator names. Fixes #23954 - - - - - 8e05c54a by Simon Peyton Jones at 2023-09-16T01:42:33-04:00 Use correct FunTyFlag in adjustJoinPointType As the Lint error in #23952 showed, the function adjustJoinPointType was failing to adjust the FunTyFlag when adjusting the type. I don't think this caused the seg-fault reported in the ticket, but it is definitely. This patch fixes it. It is tricky to come up a small test case; Krzysztof came up with this one, but it only triggers a failure in GHC 9.6. - - - - - 778c84b6 by Pierre Le Marre at 2023-09-16T01:43:15-04:00 Update to Unicode 15.1.0 See: https://www.unicode.org/versions/Unicode15.1.0/ - - - - - f9d79a6c by Alan Zimmerman at 2023-09-18T00:00:14-04:00 EPA: track unicode version for unrestrictedFunTyCon Closes #23885 Updates haddock submodule - - - - - 9374f116 by Andrew Lelechenko at 2023-09-18T00:00:54-04:00 Bump parsec submodule to allow text-2.1 and bytestring-0.12 - - - - - 7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00 base: Advertise linear time of readFloat As noted in #23538, `readFloat` has runtime that scales nonlinearly in the size of its input. Consequently, its use on untrusted input can be exploited as a denial-of-service vector. Point this out and suggest use of `read` instead. See #23538. - - - - - f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00 Remove dead code GHC.CoreToStg.Prep.canFloat This function never fires, so we can delete it: #23965. - - - - - ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00 base/changelog: Move fix for #23907 to 9.8.1 section Since the fix was backported to 9.8.1 - - - - - 51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64 alpine bindist This is dynamically linked and makes creating statically linked executables more straightforward. Fixes #23482 - - - - - 02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64-deb11 bindist This adds a debian 11 release job for aarch64. Fixes #22005 - - - - - 8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00 Don’t store the async exception masking state in CATCH frames - - - - - 86d2971e by doyougnu at 2023-09-19T19:08:19-04:00 compiler,ghci: error codes link to HF error index closes: #23259 - adds -fprint-error-index-links={auto|always|never} flag - - - - - 5f826c18 by sheaf at 2023-09-19T19:09:03-04:00 Pass quantified tyvars in tcDefaultAssocDecl This commit passes the correct set of quantified type variables written by the user in associated type default declarations for validity checking. This ensures that validity checking of associated type defaults mirrors that of standalone type family instances. Fixes #23768 (see testcase T23734 in subsequent commit) - - - - - aba18424 by sheaf at 2023-09-19T19:09:03-04:00 Avoid panic in mkGADTVars This commit avoids panicking in mkGADTVars when we encounter a type variable as in #23784 that is bound by a user-written forall but not actually used. Fixes #23784 - - - - - a525a92a by sheaf at 2023-09-19T19:09:03-04:00 Adjust reporting of unused tyvars in data FamInsts This commit adjusts the validity checking of data family instances to improve the reporting of unused type variables. See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity. The problem was that, in a situation such as data family D :: Type data instance forall (d :: Type). D = MkD the RHS passed to 'checkFamPatBinders' would be the TyCon app R:D d which mentions the type variable 'd' quantified in the user-written forall. Thus, when computing the set of unused type variables in the RHS of the data family instance, we would find that 'd' is used, and report a strange error message that would say that 'd' is not bound on the LHS. To fix this, we special-case the data-family instance case, manually extracting all the type variables that appear in the arguments of all the data constructores of the data family instance. Fixes #23778 - - - - - 28dd52ee by sheaf at 2023-09-19T19:09:03-04:00 Unused tyvars in FamInst: only report user tyvars This commit changes how we perform some validity checking for coercion axioms to mirror how we handle default declarations for associated type families. This allows us to keep track of whether type variables in type and data family instances were user-written or not, in order to only report the user-written ones in "unused type variable" error messages. Consider for example: {-# LANGUAGE PolyKinds #-} type family F type instance forall a. F = () In this case, we get two quantified type variables, (k :: Type) and (a :: k); the second being user-written, but the first is introduced by the typechecker. We should only report 'a' as being unused, as the user has no idea what 'k' is. Fixes #23734 - - - - - 1eed645c by sheaf at 2023-09-19T19:09:03-04:00 Validity: refactor treatment of data families This commit refactors the reporting of unused type variables in type and data family instances to be more principled. This avoids ad-hoc logic in the treatment of data family instances. - - - - - 35bc506b by John Ericson at 2023-09-19T19:09:40-04:00 Remove `ghc-cabal` It is dead code since the Make build system was removed. I tried to go over every match of `git grep -i ghc-cabal` to find other stray bits. Some of those might be workarounds that can be further removed. - - - - - 665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00 Re-add unregisterised build support for sparc and sparc64 Closes #23959 - - - - - 142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00 Bump ci-images to use updated version of Alex Fixes #23977 - - - - - fa977034 by John Ericson at 2023-09-21T12:55:25-04:00 Use Cabal 3.10 for Hadrian We need the newer version for `CABAL_FLAG_*` env vars for #17191. - - - - - a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: `need` any `configure` script we will call When the script is changed, we should reconfigure. - - - - - db882b57 by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Make it easier to debug Cabal configure Right now, output is squashed. This make per-package configure scripts extremely hard to maintain, because we get vague "library is missing" errors when the actually probably is usually completely unrelated except for also involving the C/C++ toolchain. (I can always pass `-VVV` to Hadrian locally, but these errors are subtle and I often cannot reproduce them locally!) `--disable-option-checking` was added back in 75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill; if other flags are passed that are not recognized behind the two from Cabal mentioned in the former comment, we *do* want to know about it. - - - - - 7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Increase verbosity of certain cabal commands This is a hack to get around the cabal function we're calling *decreasing* the verbosity it passes to another function, which is the stuff we often actually care about. Sigh. Keeping this a separate commit so if this makes things too verbose it is easy to revert. - - - - - a4fde569 by John Ericson at 2023-09-21T12:55:25-04:00 rts: Move most external symbols logic to the configure script This is much more terse because we are programmatically handling the leading underscore. `findPtr` however is still handled in the Cabal file because we need a newer Cabal to pass flags to the configure script automatically. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump Cabal submodule to allow text-2.1 and bytestring-0.12 - - - - - 0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00 hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist - - - - - b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump hadrian's index-state to upgrade alex at least to 3.2.7.3 - - - - - 11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 - - - - - b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. - - - - - 37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Fix Windows line endings - - - - - 5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Use makefile_test - - - - - 15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00 system-cxx-std-lib: Add license and description - - - - - 0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00 gitlab/issue-templates: Rename bug.md -> default.md So that it is visible by default. - - - - - 23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00 Bump submodule text to 2.1 - - - - - b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00 Bump submodule unix to 2.8.2.1 - - - - - 54b2016e by John Ericson at 2023-09-23T11:40:41-04:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - 41130a65 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 58f3babf by John Ericson at 2023-10-11T16:02:48-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ - - - - - f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00 Modularity: pass TempDir instead of DynFlags (#17957) - - - - - 34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00 Do not check for the `mingwex` library in `/configure` See the recent discussion in !10360 --- Cabal will itself check for the library for the packages that need it, and while the autoconf check additionally does some other things like define a `HAS_LIBMINGWEX` C Preprocessor macro, those other things are also unused and unneeded. Progress towards #17191, which aims to get rid of `/configure` entirely. - - - - - 43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00 base: Introduce move modules into src The only non-move changes here are whitespace changes to pass the `whitespace` test and a few testsuite adaptations. - - - - - df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. - - - - - c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00 Move apple compat check to RTS configure - - - - - c80778ea by John Ericson at 2023-10-12T10:31:13-04:00 Move clock/timer fun checks to RTS configure Actual library check (which will set the Cabal flag) is left in the top-level configure for now. Progress towards #17191 - - - - - 7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00 Move visibility and "musttail" annotation checks to the RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00 Move leading underscore checks to RTS configure `CabalLeadingUnderscore` is done via Hadrian already, so we can stop `AC_SUBST`ing it completely. - - - - - 25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00 Move alloca, fork, const, and big endian checks to RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. - - - - - 5170f42a by John Ericson at 2023-10-12T10:31:13-04:00 Move libdl check to RTS configure - - - - - ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00 Adjust `FP_FIND_LIBFFI` Just set vars, and `AC_SUBST` in top-level configure. Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system). - - - - - f399812c by John Ericson at 2023-10-12T10:31:13-04:00 Split BFD support to RTS configure The flag is still in the top-level configure, but the other checks (which define various macros --- important) are in the RTS configure. - - - - - f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00 Split libm check between top level and RTS - - - - - dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. - - - - - 9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00 hadrian: Decrease verbosity of cabal commands In Normal, most tools do not produce output to stdout unless there are error conditions. Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217 - - - - - 08fc27af by John Ericson at 2023-10-12T20:35:36-04:00 Do not substitute `@...@` for stage-specific values in cabal files `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag defaults; instead manual choices are passed to configure in the usual way. The old way was fundamentally broken, because it meant we were baking these Cabal files for a specific stage. Now we only do stage-agnostic @...@ substitution in cabal files (the GHC version), and so all stage-specific configuration is properly confined to `_build` and the right stage dir. Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim` (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got rid of it. Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com> - - - - - a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - 257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Bignum: fix right shift of negative BigNat with native backend - - - - - cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - 72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - f9436990 by John Ericson at 2023-10-18T19:41:01-04:00 Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Fixes #24091 Progress on #23966 Issue #24091 reports that `@ProjectVersion@` is no longer being substituted in the GHC user's guide. I assume this is a recent issue, but I am not sure how it's worked since c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and configure are trying to substitute the same `.in` file! Now only Hadrian does. That is better anyways; already something that issue #23966 requested. It seems like we were missing some dependencies in Hadrian. (I really, really hate that this is possible!) Hopefully it is fixed now. - - - - - b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00 `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to be defined. (Guaranteed including a test in the testsuite.) - - - - - 0295375a by John Ericson at 2023-10-18T19:41:37-04:00 Generate `ghcversion.h` from a `.in` file Now that there are no conditional sections (see the previous commit), we can just a do simple substitution rather than pasting it together line by line. Progress on #23966 - - - - - 740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00 Add a regression test for #24064 - - - - - 921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00 CLC Proposal #182: Export List from Data.List Proposal link: https://github.com/haskell/core-libraries-committee/issues/182 - - - - - 4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00 rts: fix small argument passing on big-endian arch (fix #23387) - - - - - b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00 Interpreter: fix literal alignment on big-endian architectures (fix #19261) Literals weren't correctly aligned on big-endian, despite what the comment said. - - - - - a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00 Testsuite: recomp011 and recomp015 are fixed on powerpc These tests have been fixed but not tested and re-enabled on big-endian powerpc (see comments in #11260 and #11323) - - - - - fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00 CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102) - - - - - 02efc181 by John Ericson at 2023-10-22T02:48:55-04:00 Move function checks to RTS configure Some of these functions are used in `base` too, but we can copy the checks over to its configure if that's an issue. - - - - - 5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00 Move over a number of C-style checks to RTS configure - - - - - 5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00 Move/Copy more `AC_DEFINE` to RTS config Only exception is the LLVM version macros, which are used for GHC itself. - - - - - b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00 Define `TABLES_NEXT_TO_CODE` in the RTS configure We create a new cabal flag to facilitate this. - - - - - 4a40271e by John Ericson at 2023-10-22T02:48:55-04:00 Configure scripts: `checkOS`: Make a bit more robust `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This allows us to cope with configs/triples that we haven't normalized extra being what GNU `config.sub` does. - - - - - 16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00 Generate `ghcplatform.h` from RTS configure We create a new cabal flag to facilitate this. - - - - - 7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00 Get rid of all mention of `mk/config.h` The RTS configure script is now solely responsible for managing its headers; the top level configure script does not help. - - - - - c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00 rts: drop stale mentions of MIN_UPD_SIZE We used to have MIN_UPD_SIZE macro that describes the minimum reserved size for thunks, so that the thunk can be overwritten in place as indirections or blackholes. However, this macro has not been actually defined or used anywhere since a long time ago; StgThunkHeader already reserves a padding word for this purpose. Hence this patch which drops stale mentions of MIN_UPD_SIZE. - - - - - d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00 base changelog: move non-backported entries from 4.19 section to 4.20 Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational) nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip) were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section. Also minor stylistic changes to other entries, bringing them to a uniform form. - - - - - de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00 EPA Some tweaks to annotations - Fix span for GRHS - Move TrailingAnns from last match to FunBind - Fix GADT 'where' clause span - Capture full range for a CaseAlt Match - - - - - d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00 Update primitives.rst - - - - - 4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00 JS/userguide: add explanation of writing jsbits - - - - - 07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00 testsuite: increase timeout of ghc-api tests for wasm32 ghc-api tests for wasm32 are more likely to timeout due to the large wasm module sizes, especially when testing with wasm native tail calls, given wasmtime's handling of tail call opcodes are suboptimal at the moment. It makes sense to increase timeout specifically for these tests on wasm32. This doesn't affect other targets, and for wasm32 we don't increase timeout for all tests, so not to risk letting major performance regressions slip through the testsuite. - - - - - 0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00 Explicitly require RLIMIT_AS before use in OSMem.c This is done elsewhere in the source tree. It also suddenly is required on OpenBSD. - - - - - 9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00 Modularity: modularize external linker Decouple runLink from DynFlags to allow calling runLink more easily. This is preliminary work for calling Emscripten's linker (emcc) from our JavaScript linker. - - - - - e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00 js: add JStg IR, remove unsaturated constructor - Major step towards #22736 and adding the optimizer in #22261 - - - - - 35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00 Fix a bug in tail calls with ticks See #24078 for the diagnosis. The change affects only the Tick case of occurrence analysis. It's a bit hard to test, so no regression test (yet anyway). - - - - - 9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00 Teach tag-inference about SeqOp/seq# Fixes the STG/tag-inference analogue of #15226. Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00 [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra 48e391952c17ff7eab10b0b1456e3f2a2af28a9b introduced `SYM_TYPE_DUP_DISCARD` to the bitfield. The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value. Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions. - - - - - 5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00 Fix and test for issue #24111, TH.Ppr output of pattern synonyms - - - - - 723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00 EPA: print doc comments as normal comments And ignore the ones allocated in haddock processing. It does not guarantee that every original haddock-like comment appears in the output, as it discards ones that have no legal attachment point. closes #23459 - - - - - 21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00 Fix non-termination bug in equality solver constraint left-to-right then right to left, forever. Easily fixed. - - - - - 270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00 ghc-toolchain: build with `-package-env=-` (#24131) Otherwise globally installed libraries (via `cabal install --lib`) break the build. Fixes #24131. - - - - - 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - cc1c7c54 by Duncan Coutts at 2023-11-05T00:23:44-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 2e448f98 by Cheng Shao at 2023-11-05T00:23:44-04:00 Skip the IOManager test on wasm32 arch. The test relies on the sockets API which are not (yet) available. - - - - - fe50eb35 by Cheng Shao at 2023-11-05T00:24:20-04:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - af771148 by Cheng Shao at 2023-11-05T00:24:20-04:00 testsuite: fix optasm tests for wasm32 - - - - - 1b90735c by Matthew Pickering at 2023-11-05T00:24:20-04:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - db9a6496 by Alan Zimmerman at 2023-11-05T00:24:55-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 833e250c by Simon Peyton Jones at 2023-11-05T00:25:31-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - e451139f by Andreas Klebinger at 2023-11-05T00:26:07-04:00 Remove an accidental git conflict marker from a comment. - - - - - 30baac7a by Tobias Haslop at 2023-11-06T10:50:32+00:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - df626f00 by Tobias Haslop at 2023-11-07T02:20:37-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 8217acb8 by Alan Zimmerman at 2023-11-07T02:21:12-05:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - dd88a260 by Luite Stegeman at 2023-11-07T02:21:53-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - 455524a2 by Matthew Craven at 2023-11-09T08:41:59-05:00 Create specially-solved DataToTag class Closes #20532. This implements CLC proposal 104: https://github.com/haskell/core-libraries-committee/issues/104 The design is explained in Note [DataToTag overview] in GHC.Tc.Instance.Class. This replaces the existing `dataToTag#` primop. These metric changes are not "real"; they represent Unique-related flukes triggering on a different set of jobs than they did previously. See also #19414. Metric Decrease: T13386 T8095 Metric Increase: T13386 T8095 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - a05f4554 by Alan Zimmerman at 2023-11-09T08:42:35-05:00 EPA: get rid of glRR and friends in GHC/Parser.y With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead Metric Decrease: MultiLayerModulesTH_Make - - - - - 18498538 by Cheng Shao at 2023-11-09T16:58:12+00:00 ci: bump ci-images for wasi-sdk upgrade - - - - - 52c0fc69 by PHO at 2023-11-09T19:16:22-05:00 Don't assume the current locale is *.UTF-8, set the encoding explicitly primops.txt contains Unicode characters: > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226) Hadrian must also avoid using readFile' to read primops.txt because it tries to decode the file with a locale-specific encoding. - - - - - 7233b3b1 by PHO at 2023-11-09T19:17:01-05:00 Use '[' instead of '[[' because the latter is a Bash-ism It doesn't work on platforms where /bin/sh is something other than Bash. - - - - - 6dbab180 by Simon Peyton Jones at 2023-11-09T19:17:36-05:00 Add an extra check in kcCheckDeclHeader_sig Fix #24083 by checking for a implicitly-scoped type variable that is not actually bound. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures. Metric Decrease: MultiLayerModulesTH_Make - - - - - 22551364 by Sven Tennie at 2023-11-11T06:35:22-05:00 AArch64: Delete unused LDATA pseudo-instruction Though there were consuming functions for LDATA, there were no producers. Thus, the removed code was "dead". - - - - - 2a0ec8eb by Alan Zimmerman at 2023-11-11T06:35:59-05:00 EPA: harmonise acsa and acsA in GHC/Parser.y With the HasLoc class, we can remove the acsa helper function, using acsA instead. - - - - - 7ae517a0 by Teo Camarasu at 2023-11-12T08:04:12-05:00 nofib: bump submodule This includes changes that: - fix building a benchmark with HEAD - remove a Makefile-ism that causes errors in bash scripts Resolves #24178 - - - - - 3f0036ec by Alan Zimmerman at 2023-11-12T08:04:47-05:00 EPA: Replace Anchor with EpaLocation An Anchor has a location and an operation, which is either that it is unchanged or that it has moved with a DeltaPos data Anchor = Anchor { anchor :: RealSrcSpan , anchor_op :: AnchorOperation } An EpaLocation also has either a location or a DeltaPos data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] Now that we do not care about always having a location in the anchor, we remove Anchor and replace it with EpaLocation We do this with a type alias initially, to ease the transition. The alias will be removed in time. We also have helpers to reconstruct the AnchorOperation from an EpaLocation. This is also temporary. Updates Haddock submodule - - - - - a7492048 by Alan Zimmerman at 2023-11-12T13:43:07+00:00 EPA: get rid of AnchorOperation Now that the Anchor type is an alias for EpaLocation, remove AnchorOperation. Updates haddock submodule - - - - - 0745c34d by Andrew Lelechenko at 2023-11-13T16:25:07-05:00 Add since annotation for showHFloat - - - - - e98051a5 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 Suppress duplicate librares linker warning of new macOS linker Fixes #24167 XCode 15 introduced a new linker which warns on duplicate libraries being linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as suggested by Brad King in CMake issue #25297. This flag isn't necessarily available to other linkers on darwin, so we must only configure it into the CC linker arguments if valid. - - - - - c411c431 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Encoding test witnesses recent iconv bug is fragile A regression in the new iconv() distributed with XCode 15 and MacOS Sonoma causes the test 'encoding004' to fail in the CP936 roundrip. We mark this test as fragile until this is fixed upstream (rather than broken, since previous versions of iconv pass the test) See #24161 - - - - - ce7fe5a9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Update to LC_ALL=C no longer being ignored in darwin MacOS seems to have fixed an issue where it used to ignore the variable `LC_ALL` in program invocations and default to using Unicode. Since the behaviour seems to be fixed to account for the locale variable, we mark tests that were previously broken in spite of it as fragile (since they now pass in recent macOS distributions) See #24161 - - - - - e6c803f7 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 929ba2f9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Skip MultiLayerModulesTH_Make on darwin The recent toolchain upgrade on darwin machines resulted in the MultiLayerModulesTH_Make test metrics varying too much from the baseline, ultimately blocking the CI pipelines. This commit skips the test on darwin to temporarily avoid failures due to the environment change in the runners. However, the metrics divergence is being investigated still (tracked in #24177) - - - - - af261ccd by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 configure: check target (not build) understands -no_compact_unwind Previously, we were branching on whether the build system was darwin to shortcut this check, but we really want to branch on whether the target system (which is what we are configuring ld_prog for) is darwin. - - - - - 2125c176 by Luite Stegeman at 2023-11-15T13:19:38-05:00 JS: Fix missing variable declarations The JStg IR update was missing some local variable declarations that were present earlier, causing global variables to be used implicitly (or an error in JavaScript strict mode). This adds the local variable declarations again. - - - - - 99ced73b by Krzysztof Gogolewski at 2023-11-15T13:20:14-05:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - 2aff2361 by Zubin Duggal at 2023-11-15T13:20:50-05:00 users-guide: Fix links to libraries from the users-guide. The unit-ids generated in c1a3ecde720b3bddc2c8616daaa06ee324e602ab include the package name, so we don't need to explicitly add it to the links. Fixes #24151 - - - - - 27981fac by Alan Zimmerman at 2023-11-15T13:21:25-05:00 EPA: splitLHsForAllTyInvis does not return ann We did not use the annotations returned from splitLHsForAllTyInvis, so do not return them. - - - - - a6467834 by Krzysztof Gogolewski at 2023-11-15T22:22:59-05:00 Document defaulting of RuntimeReps Fixes #24099 - - - - - 2776920e by Simon Peyton Jones at 2023-11-15T22:23:35-05:00 Second fix to #24083 My earlier fix turns out to be too aggressive for data/type families See wrinkle (DTV1) in Note [Disconnected type variables] - - - - - cee81370 by Sylvain Henry at 2023-11-16T09:57:46-05:00 Fix unusable units and module reexport interaction (#21097) This commit fixes an issue with ModUnusable introduced in df0f148feae. In mkUnusableModuleNameProvidersMap we traverse the list of unusable units and generate ModUnusable origin for all the modules they contain: exposed modules, hidden modules, and also re-exported modules. To do this we have a two-level map: ModuleName -> Unit:ModuleName (aka Module) -> ModuleOrigin So for each module name "M" in broken unit "u" we have: "M" -> u:M -> ModUnusable reason However in the case of module reexports we were using the *target* module as a key. E.g. if "u:M" is a reexport for "X" from unit "o": "M" -> o:X -> ModUnusable reason Case 1: suppose a reexport without module renaming (u:M -> o:M) from unusable unit u: "M" -> o:M -> ModUnusable reason Here it's claiming that the import of M is unusable because a reexport from u is unusable. But if unit o isn't unusable we could also have in the map: "M" -> o:M -> ModOrigin ... Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModOrigin) Case 2: similarly we could have 2 unusable units reexporting the same module without renaming, say (u:M -> o:M) and (v:M -> o:M) with u and v unusable. It gives: "M" -> o:M -> ModUnusable ... (for u) "M" -> o:M -> ModUnusable ... (for v) Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModUnusable). This led to #21097, #16996, #11050. To fix this, in this commit we make ModUnusable track whether the module used as key is a reexport or not (for better error messages) and we use the re-export module as key. E.g. if "u:M" is a reexport for "o:X" and u is unusable, we now record: "M" -> u:M -> ModUnusable reason reexported=True So now, we have two cases for a reexport u:M -> o:X: - u unusable: "M" -> u:M -> ModUnusable ... reexported=True - u usable: "M" -> o:X -> ModOrigin ... reexportedFrom=u:M The second case is indexed with o:X because in this case the Semigroup instance of ModOrigin is used to combine valid expositions of a module (directly or via reexports). Note that module lookup functions select usable modules first (those who have a ModOrigin value), so it doesn't matter if we add new ModUnusable entries in the map like this: "M" -> { u:M -> ModUnusable ... reexported=True o:M -> ModOrigin ... } The ModOrigin one will be used. Only if there is no ModOrigin or ModHidden entry will the ModUnusable error be printed. See T21097 for an example printing several reasons why an import is unusable. - - - - - 3e606230 by Krzysztof Gogolewski at 2023-11-16T09:58:22-05:00 Fix IPE test A helper function was defined in a different module than used. To reproduce: ./hadrian/build test --test-root-dirs=testsuite/tests/rts/ipe - - - - - 49f5264b by Andreas Klebinger at 2023-11-16T20:52:11-05:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Use rep size rather than rep count to compute the size. Fixes #22309 - - - - - b4f84e4b by James Henri Haydon at 2023-11-16T20:52:53-05:00 Explicit methods for Alternative Compose Explicitly define some and many in Alternative instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/181 - - - - - 9bc0dd1f by Ignat Insarov at 2023-11-16T20:53:34-05:00 Add permutations for non-empty lists. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 5643ecf9 by Andrew Lelechenko at 2023-11-16T20:53:34-05:00 Update changelog and since annotations for Data.List.NonEmpty.permutations Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 94ff2134 by Oleg Alexander at 2023-11-16T20:54:15-05:00 Update doc string for traceShow Updated doc string for traceShow. - - - - - faff671a by Luite Stegeman at 2023-11-17T14:12:51+01:00 JS: clean up some foreign imports - - - - - 856e0a4e by Sven Tennie at 2023-11-18T06:54:11-05:00 AArch64: Remove unused instructions As these aren't ever emitted, we don't even know if they work or will ever be used. If one of them is needed in future, we may easily re-add it. Deleted instructions are: - CMN - ANDS - BIC - BICS - EON - ORN - ROR - TST - STP - LDP - DMBSY - - - - - 615441ef by Alan Zimmerman at 2023-11-18T06:54:46-05:00 EPA: Replace Monoid with NoAnn Remove the final Monoid instances in the exact print infrastructure. For Windows CI Metric Decrease: T5205 - - - - - 5a6c49d4 by David Feuer at 2023-11-20T18:53:18-05:00 Speed up stimes in instance Semigroup Endo As discussed at https://github.com/haskell/core-libraries-committee/issues/4 - - - - - cf9da4b3 by Andrew Lelechenko at 2023-11-20T18:53:18-05:00 base: reflect latest changes in the changelog - - - - - 48bf364e by Alan Zimmerman at 2023-11-20T18:53:54-05:00 EPA: Use SrcSpan in EpaSpan This is more natural, since we already need to deal with invalid RealSrcSpans, and that is exactly what SrcSpan.UnhelpfulSpan is for. Updates haddock submodule. - - - - - 97ec37cc by Sebastian Graf at 2023-11-20T18:54:31-05:00 Add regression test for #6070 Fixes #6070. - - - - - e9d5ae41 by Owen Shepherd at 2023-11-21T18:32:23-05:00 chore: Correct typo in the gitlab MR template [skip ci] - - - - - f158a8d0 by Rodrigo Mesquita at 2023-11-21T18:32:59-05:00 Improve error message when reading invalid `.target` files A `.target` file generated by ghc-toolchain or by configure can become invalid if the target representation (`Toolchain.Target`) is changed while the files are not re-generated by calling `./configure` or `ghc-toolchain` again. There is also the issue of hadrian caching the dependencies on `.target` files, which makes parsing fail when reading reading the cached value if the representation has been updated. This patch provides a better error message in both situations, moving away from a terrible `Prelude.read: no parse` error that you would get otherwise. Fixes #24199 - - - - - 955520c6 by Ben Gamari at 2023-11-21T18:33:34-05:00 users guide: Note that QuantifiedConstraints implies ExplicitForAll Fixes #24025. - - - - - 17ec3e97 by Owen Shepherd at 2023-11-22T09:37:28+01:00 fix: Change type signatures in NonEmpty export comments to reflect reality This fixes several typos in the comments of Data.List.NonEmpty export list items. - - - - - 2fd78f9f by Samuel Thibault at 2023-11-22T11:49:13-05:00 Fix the platform string for GNU/Hurd As commited in Cargo https://github.com/haskell/cabal/pull/9434 there is confusion between "gnu" and "hurd". This got fixed in Cargo, we need the converse in Hadrian. Fixes #24180 - - - - - a79960fe by Alan Zimmerman at 2023-11-22T11:49:48-05:00 EPA: Tuple Present no longer has annotation The Present constructor for a Tuple argument will never have an exact print annotation. So make this impossible. - - - - - 121c9ab7 by David Binder at 2023-11-22T21:12:29-05:00 Unify the hpc testsuites The hpc testsuite was split between testsuite/tests/hpc and the submodule libraries/hpc/test. This commit unifies the two testsuites in the GHC repository in the directory testsuite/tests/hpc. - - - - - d2733a05 by Alan Zimmerman at 2023-11-22T21:13:05-05:00 EPA: empty tup_tail has noAnn In Parser.y, the tup_tail rule had the following option | {- empty -} %shift { return [Left noAnn] } Once this works through PostProcess.hs, it means we add an extra Missing constructor if the last item was a comma. Change the annotation type to a Bool to indicate this, and use the EpAnn Anchor for the print location for the others. - - - - - fa576eb8 by Andreas Klebinger at 2023-11-24T08:29:13-05:00 Fix FMA primops generating broken assembly on x86. `genFMA3Code` assumed that we had to take extra precations to avoid overwriting the result of `getNonClobberedReg`. One of these special cases caused a bug resulting in broken assembly. I believe we don't need to hadle these cases specially at all, which means this MR simply deletes the special cases to fix the bug. Fixes #24160 - - - - - 34d86315 by Alan Zimmerman at 2023-11-24T08:29:49-05:00 EPA: Remove parenthesizeHsType This is called from PostProcess.hs, and adds spurious parens. With the looser version of exact printing we had before we could tolerate this, as they would be swallowed by the original at the same place. But with the next change (remove EpAnnNotUsed) they result in duplicates in the output. For Darwin build: Metric Increase: MultiLayerModulesTH_OneShot - - - - - 3ede659d by Vladislav Zavialov at 2023-11-26T06:43:32-05:00 Add name for -Wdeprecated-type-abstractions (#24154) This warning had no name or flag and was triggered unconditionally. Now it is part of -Wcompat. - - - - - 7902ebf8 by Alan Zimmerman at 2023-11-26T06:44:08-05:00 EPA: Remove EpAnnNotUsed We no longer need the EpAnnNotUsed constructor for EpAnn, as we can represent an unused annotation with an anchor having a EpaDelta of zero, and empty comments and annotations. This simplifies code handling annotations considerably. Updates haddock submodule Metric Increase: parsing001 - - - - - 471b2672 by Mario Blažević at 2023-11-26T06:44:48-05:00 Bumped the upper bound of text to <2.2 - - - - - d1bf25c7 by Vladislav Zavialov at 2023-11-26T11:45:49-05:00 Term variable capture (#23740) This patch changes type variable lookup rules (lookupTypeOccRn) and implicit quantification rules (filterInScope) so that variables bound in the term namespace can be captured at the type level {-# LANGUAGE RequiredTypeArguments #-} f1 x = g1 @x -- `x` used in a type application f2 x = g2 (undefined :: x) -- `x` used in a type annotation f3 x = g3 (type x) -- `x` used in an embedded type f4 x = ... where g4 :: x -> x -- `x` used in a type signature g4 = ... This change alone does not allow us to accept examples shown above, but at least it gets them past the renamer. - - - - - da863d15 by Vladislav Zavialov at 2023-11-26T11:46:26-05:00 Update Note [hsScopedTvs and visible foralls] The Note was written before GHC gained support for visible forall in types of terms. Rewrite a few sentences and use a better example. - - - - - b5213542 by Matthew Pickering at 2023-11-27T12:53:59-05:00 testsuite: Add mechanism to collect generic metrics * Generalise the metric logic by adding an additional field which allows you to specify how to query for the actual value. Previously the method of querying the baseline value was abstracted (but always set to the same thing). * This requires rejigging how the stat collection works slightly but now it's more uniform and hopefully simpler. * Introduce some new "generic" helper functions for writing generic stats tests. - collect_size ( deviation, path ) Record the size of the file as a metric - stat_from_file ( metric, deviation, path ) Read a value from the given path, and store that as a metric - collect_generic_stat ( metric, deviation, get_stat) Provide your own `get_stat` function, `lambda way: <Int>`, which can be used to establish the current value of the metric. - collect_generic_stats ( metric_info ): Like collect_generic_stat but provide the whole dictionary of metric definitions. { metric: { deviation: <Int> current: lambda way: <Int> } } * Introduce two new "size" metrics for keeping track of build products. - `size_hello_obj` - The size of `hello.o` from compiling hello.hs - `libdir` - The total size of the `libdir` folder. * Track the number of modules in the AST tests - CountDepsAst - CountDepsParser This lays the infrastructure for #24191 #22256 #17129 - - - - - 7d9a2e44 by ARATA Mizuki at 2023-11-27T12:54:39-05:00 x86: Don't require -mavx2 when using 256-bit floating-point SIMD primitives Fixes #24222 - - - - - 4e5ff6a4 by Alan Zimmerman at 2023-11-27T12:55:15-05:00 EPA: Remove SrcSpanAnn Now that we only have a single constructor for EpAnn, And it uses a SrcSpan for its location, we can do away with SrcSpanAnn completely. It only existed to wrap the original SrcSpan in a location, and provide a place for the exact print annotation. For darwin only: Metric Increase: MultiLayerModulesTH_OneShot Updates haddock submodule - - - - - e05bca39 by Krzysztof Gogolewski at 2023-11-28T08:00:55-05:00 testsuite: don't initialize testdir to '.' The test directory is removed during cleanup, if there's an interrupt that could remove the entire repository. Fixes #24219 - - - - - af881674 by Alan Zimmerman at 2023-11-28T08:01:30-05:00 EPA: Clean up mkScope in Ast.hs Now that we have HasLoc we can get rid of all the custom variants of mkScope For deb10-numa Metric Increase: libdir - - - - - 292983c8 by Ben Gamari at 2023-11-28T22:44:28-05:00 distrib: Rediscover otool and install_name_tool on Darwin In the bindist configure script we must rediscover the `otool` and `install_name_tool`s since they may be different from the build environment. Fixes #24211. - - - - - dfe1c354 by Stefan Schulze Frielinghaus at 2023-11-28T22:45:04-05:00 llvmGen: Align objects in the data section Objects in the data section may be referenced via tagged pointers. Thus, align those objects to a 4- or 8-byte boundary for 32- or 64-bit platforms, respectively. Note, this may need to be reconsidered if objects with a greater natural alignment requirement are emitted as e.g. 128-bit atomics. Fixes #24163. - - - - - f6c486c3 by Matthew Pickering at 2023-11-29T11:08:13-05:00 metrics: Widen libdir and size_hello_obj acceptance window af8816740d9b8759be1a22af8adcb5f13edeb61d shows that the libdir size can fluctuate quite significantly even when the change is quite small. Therefore we widen the acceptance window to 10%. - - - - - 99a6a49c by Alan Zimmerman at 2023-11-29T11:08:49-05:00 EPA: Clean up TC Monad Utils We no longer need the alternative variant of addLocM (addLocMA) nor wrapLocAM, wrapLocSndMA. aarch64-darwin Metric Increase: MultiLayerModulesTH_OneShot deb10-numa-slow Metric Decrease: libdir - - - - - cbc03fa0 by Sebastian Graf at 2023-11-30T12:37:21-05:00 perf tests: Move comments into new `Note [Sensitivity to unique increment]` (#19414) And additionally to T12545, link from T8095, T13386 to this new Note. - - - - - c7623b22 by Alan Zimmerman at 2023-11-30T12:37:56-05:00 EPA: EpaDelta for comment has no comments EpaLocation is used to position things. It has two constructors, EpaSpan holding a SrcSpan, and EpaDelta with a delta position and a possible list of comments. The comment list is needed because the location in EpaDelta has no absolute information to decide which comments should be emitted before them when printing. But it is also used for specifying the position of a comment. To prevent the absurdity of a comment position having a list of comments in it, we make EpaLocation parameterisable, using comments for the normal case and a constant for within comments. Updates haddock submodule. aarch64-darwin Metric Decrease: MultiLayerModulesTH_OneShot - - - - - bd8acc0c by Krzysztof Gogolewski at 2023-11-30T12:38:32-05:00 Kind-check body of a required forall We now require that in 'forall a -> ty', ty has kind TYPE r for some r. Fixes #24176 - - - - - 010fb784 by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Remove incorrect haddock link quotes in code block - - - - - cda9c12d by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Remove cycle from group haddock example - - - - - 495265b9 by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Use repl haddock syntax in group docs - - - - - d134d1de by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Use list [] notation in group haddock - - - - - dfcf629c by Owen Shepherd at 2023-12-03T00:10:10-05:00 docs(NonEmpty/group): Specify final property of group function in haddock - - - - - cad3b734 by Owen Shepherd at 2023-12-03T00:10:10-05:00 fix: Add missing property of List.group - - - - - bad37656 by Matthew Pickering at 2023-12-03T00:10:46-05:00 testsuite: Fix T21097b test with make 4.1 (deb9) cee81370cd6ef256f66035e3116878d4cb82e28b recently added a test which failed on deb9 because the version of make was emitting the recipe failure to stdout rather than stderr. One way to fix this is to be more precise in the test about which part of the output we care about inspecting. - - - - - 5efdf421 by Matthew Pickering at 2023-12-03T00:11:21-05:00 testsuite: Track size of libdir in bytes For consistency it's better if we track all size metrics in bytes. Metric Increase: libdir - - - - - f5eb0f29 by Matthew Pickering at 2023-12-03T00:11:22-05:00 testsuite: Remove rogue trace in testsuite I accidentally left a trace in the generics metric patch. - - - - - d5610737 by Claudio Bley at 2023-12-06T16:13:33-05:00 Only exit ghci in -e mode when :add command fails Previously, when running `ghci -e ':add Sample.hs'` the process would exit with exit code 1 if the file exists and could be loaded. Fixes #24115 - - - - - 0f0c53a5 by Vladislav Zavialov at 2023-12-06T16:14:09-05:00 T2T in Patterns (#23739) This patch implements the T2T (term-to-type) transformation in patterns. Patterns that are checked against a visible forall can now be written without the `type` keyword: \(type t) (x :: t) -> ... -- old \t (x :: t) -> ... -- new The `t` binder is parsed and renamed as a term pattern (Pat), but then undergoes a conversion to a type pattern (HsTyPat). See the new function pat_to_type_pat in compiler/GHC/Tc/Gen/Pat.hs - - - - - 10a1a6c6 by Sebastian Graf at 2023-12-06T16:14:45-05:00 Pmc: Fix SrcLoc and warning for incomplete irrefutable pats (#24234) Before, the source location would point at the surrounding function definition, causing the confusion in #24234. I also took the opportunity to introduce a new `LazyPatCtx :: HsMatchContext _` to make the warning message say "irrefutable pattern" instead of "pattern binding". - - - - - 36b9a38c by Matthew Pickering at 2023-12-06T16:15:21-05:00 libraries: Bump filepath to 1.4.200.1 and unix to 2.8.4.0 Updates filepath submodule Updates unix submodule Fixes #24240 - - - - - 91ff0971 by Matthew Pickering at 2023-12-06T16:15:21-05:00 Submodule linter: Allow references to tags We modify the submodule linter so that if the bumped commit is a specific tag then the commit is accepted. Fixes #24241 - - - - - 86f652dc by Zubin Duggal at 2023-12-06T16:15:21-05:00 hadrian: set -Wno-deprecations for directory and Win32 The filepath bump to 1.4.200.1 introduces a deprecation warning. See https://gitlab.haskell.org/ghc/ghc/-/issues/24240 https://github.com/haskell/filepath/pull/206 - - - - - 7ac6006e by Sylvain Henry at 2023-12-06T16:16:02-05:00 Zap OccInfo on case binders during StgCse #14895 #24233 StgCse can revive dead binders: case foo of dead { Foo x y -> Foo x y; ... } ===> case foo of dead { Foo x y -> dead; ... } -- dead is no longer dead So we must zap occurrence information on case binders. Fix #14895 and #24233 - - - - - 57c391c4 by Sebastian Graf at 2023-12-06T16:16:37-05:00 Cpr: Turn an assertion into a check to deal with some dead code (#23862) See the new `Note [Dead code may contain type confusions]`. Fixes #23862. - - - - - c1c8abf8 by Zubin Duggal at 2023-12-08T02:25:07-05:00 testsuite: add test for #23944 - - - - - 6329d308 by Zubin Duggal at 2023-12-08T02:25:07-05:00 driver: Only run a dynamic-too pipeline if object files are going to be generated Otherwise we run into a panic in hscMaybeWriteIface: "Unexpected DT_Dyn state when writing simple interface" when dynamic-too is enabled We could remove the panic and just write the interface even if the state is `DT_Dyn`, but it seems pointless to run the pipeline twice when `hscMaybeWriteIface` is already designed to write both `hi` and `dyn_hi` files if dynamic-too is enabled. Fixes #23944. - - - - - 28811f88 by Simon Peyton Jones at 2023-12-08T05:47:18-05:00 Improve duplicate elimination in SpecConstr This partially fixes #24229. See the new Note [Pattern duplicate elimination] in SpecConstr - - - - - fec7894f by Simon Peyton Jones at 2023-12-08T05:47:18-05:00 Make SpecConstr deal with casts better This patch does two things, to fix #23209: * It improves SpecConstr so that it no longer quantifies over coercion variables. See Note [SpecConstr and casts] * It improves the rule matcher to deal nicely with the case where the rule does not quantify over coercion variables, but the the template has a cast in it. See Note [Casts in the template] - - - - - 8db8d2fd by Zubin Duggal at 2023-12-08T05:47:54-05:00 driver: Don't lose track of nodes when we fail to resolve cycles The nodes that take part in a cycle should include both hs-boot and hs files, but when we fail to resolve a cycle, we were only counting the nodes from the graph without boot files. Fixes #24196 - - - - - c5b4efd3 by Zubin Duggal at 2023-12-08T05:48:30-05:00 testsuite: Skip MultiLayerModulesTH_OneShot on darwin See #24177 - - - - - fae472a9 by Wendao Lee at 2023-12-08T05:49:12-05:00 docs(Data.Char):Add more detailed descriptions for some functions Related changed function's docs: -GHC.Unicode.isAlpha -GHC.Unicode.isPrint -GHC.Unicode.isAlphaNum Add more details for what the function will return. Co-authored-by: Bodigrim <andrew.lelechenko at gmail.com> - - - - - ca7510e4 by Malik Ammar Faisal at 2023-12-08T05:49:55-05:00 Fix float parsing in GHC Cmm Lexer Add test case for bug #24224 - - - - - d8baa1bd by Simon Peyton Jones at 2023-12-08T15:40:37+00:00 Take care when simplifying unfoldings This MR fixes a very subtle bug exposed by #24242. See Note [Environment for simplLetUnfolding]. I also updated a bunch of Notes on shadowing - - - - - 03ca551d by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Comments only in FloatIn Relevant to #3458 - - - - - 50c78779 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Comments only in SpecConstr - - - - - 9431e195 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Add test for #22238 - - - - - d9e4c597 by Vladislav Zavialov at 2023-12-11T04:19:34-05:00 Make forall a keyword (#23719) Before this change, GHC used to accept `forall` as a term-level identifier: -- from constraints-0.13 forall :: forall p. (forall a. Dict (p a)) -> Dict (Forall p) forall d = ... Now it is a parse error. The -Wforall-identifier warning has served its purpose and is now a deprecated no-op. - - - - - 58d56644 by Zubin Duggal at 2023-12-11T04:20:10-05:00 driver: Ensure we actually clear the interactive context before reloading Previously we called discardIC, but immediately after set the session back to an old HscEnv that still contained the IC Partially addresses #24107 Fixes #23405 - - - - - 8e5745a0 by Zubin Duggal at 2023-12-11T04:20:10-05:00 driver: Ensure we force the lookup of old build artifacts before returning the build plan This prevents us from retaining all previous build artifacts in memory until a recompile finishes, instead only retaining the exact artifacts we need. Fixes #24118 - - - - - 105c370c by Zubin Duggal at 2023-12-11T04:20:10-05:00 testsuite: add test for #24118 and #24107 MultiLayerModulesDefsGhci was not able to catch the leak because it uses :l which discards the previous environment. Using :r catches both of these leaks - - - - - e822ff88 by Zubin Duggal at 2023-12-11T04:20:10-05:00 compiler: Add some strictness annotations to ImportSpec and related constructors This prevents us from retaining entire HscEnvs. Force these ImportSpecs when forcing the GlobalRdrEltX Adds an NFData instance for Bag Fixes #24107 - - - - - 522c12a4 by Zubin Duggal at 2023-12-11T04:20:10-05:00 compiler: Force IfGlobalRdrEnv in NFData instance. - - - - - 188b280d by Arnaud Spiwack at 2023-12-11T15:33:31+01:00 LinearTypes => MonoLocalBinds - - - - - 8e0446df by Arnaud Spiwack at 2023-12-11T15:44:28+01:00 Linear let and where bindings For expediency, the initial implementation of linear types in GHC made it so that let and where binders would always be considered unrestricted. This was rather unpleasant, and probably a big obstacle to adoption. At any rate, this was not how the proposal was designed. This patch fixes this infelicity. It was surprisingly difficult to build, which explains, in part, why it took so long to materialise. As of this patch, let or where bindings marked with %1 will be linear (respectively %p for an arbitrary multiplicity p). Unmarked let will infer their multiplicity. Here is a prototypical example of program that used to be rejected and is accepted with this patch: ```haskell f :: A %1 -> B g :: B %1 -> C h :: A %1 -> C h x = g y where y = f x ``` Exceptions: - Recursive let are unrestricted, as there isn't a clear semantics of what a linear recursive binding would be. - Destructive lets with lazy bindings are unrestricted, as their desugaring isn't linear (see also #23461). - (Strict) destructive lets with inferred polymorphic type are unrestricted. Because the desugaring isn't linear (See #18461 down-thread). Closes #18461 and #18739 Co-authored-by: @jackohughes - - - - - effa7e2d by Matthew Craven at 2023-12-12T04:37:20-05:00 Introduce `dataToTagSmall#` primop (closes #21710) ...and use it to generate slightly better code when dataToTag# is used at a "small data type" where there is no need to mess with "is_too_big_tag" or potentially look at an info table. Metric Decrease: T18304 - - - - - 35c7aef6 by Matthew Craven at 2023-12-12T04:37:20-05:00 Fix formatting of Note [alg-alt heap check] - - - - - 7397c784 by Oleg Grenrus at 2023-12-12T04:37:56-05:00 Allow untyped brackets in typed splices and vice versa. Resolves #24190 Apparently the check was essentially always (as far as I can trace back: d0d47ba76f8f0501cf3c4966bc83966ab38cac27), and while it does catch some mismatches, the type-checker will catch them too. OTOH, it prevents writing completely reasonable programs. - - - - - a3ee3b99 by Moritz Angermann at 2023-12-12T19:50:58-05:00 Drop hard Xcode dependency XCODE_VERSION calls out to `xcodebuild`, which is only available when having `Xcode` installed. The CommandLineTools are not sufficient. To install Xcode, you must have an apple id to download the Xcode.xip from apple. We do not use xcodebuild anywhere in our build explicilty. At best it appears to be a proxy for checking the linker or the compiler. These should rather be done with ``` xcrun ld -version ``` or similar, and not by proxy through Xcode. The CLR should be sufficient for building software on macOS. - - - - - 1c9496e0 by Vladislav Zavialov at 2023-12-12T19:51:34-05:00 docs: update information on RequiredTypeArguments Update the User's Guide and Release Notes to account for the recent progress in the implementation of RequiredTypeArguments. - - - - - d0b17576 by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Fix off-by-one in assertion Previously we failed to account for the NULL terminator `postString` asserted that there is enough room in the buffer for the string. - - - - - a10f9b9b by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Honor result of ensureRoomForVariableEvent is Previously we would keep plugging along, even if isn't enough room for the event. - - - - - 0e0f41c0 by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Avoid truncating event sizes Previously ensureRoomForVariableEvent would truncate the desired size to 16-bits, resulting in #24197. Fixes #24197. - - - - - 64e724c8 by Artin Ghasivand at 2023-12-13T06:34:20-05:00 Remove the "Derived Constraint" argument of TcPluginSolver, docs - - - - - fe6d97dd by Vladislav Zavialov at 2023-12-13T06:34:56-05:00 EPA: Move tokens into GhcPs extension fields (#23447) Summary of changes * Remove Language.Haskell.Syntax.Concrete * Move all tokens into GhcPs extension fields (LHsToken -> EpToken) * Create new TTG extension fields as needed * Drop the MultAnn wrapper Updates the haddock submodule. Co-authored-by: Alan Zimmerman <alan.zimm at gmail.com> - - - - - 8106e695 by Zubin Duggal at 2023-12-13T06:35:34-05:00 testsuite: use copy_files in T23405 This prevents the tree from being dirtied when the file is modified. - - - - - ed0e4099 by Bryan Richter at 2023-12-14T04:30:53-05:00 Document ghc package's PVP-noncompliance This changes nothing, it just makes the status quo explicit. - - - - - 8bef8d9f by Luite Stegeman at 2023-12-14T04:31:33-05:00 JS: Mark spurious CI failures js_fragile(24259) This marks the spurious test failures on the JS platform as js_fragile(24259), so we don't hold up merge requests while fixing the underlying issues. See #24259 - - - - - 1c79526a by Finley McIlwaine at 2023-12-15T12:24:40-08:00 Late plugins - - - - - 000c3302 by Finley McIlwaine at 2023-12-15T12:24:40-08:00 withTiming on LateCCs and late plugins - - - - - be4551ac by Finley McIlwaine at 2023-12-15T12:24:40-08:00 add test for late plugins - - - - - 7c29da9f by Finley McIlwaine at 2023-12-15T12:24:40-08:00 Document late plugins - - - - - 9a52ae46 by Ben Gamari at 2023-12-20T07:07:26-05:00 Fix thunk update ordering Previously we attempted to ensure soundness of concurrent thunk update by synchronizing on the access of the thunk's info table pointer field. This was believed to be sufficient since the indirectee (which may expose a closure allocated by another core) would not be examined until the info table pointer update is complete. However, it turns out that this can result in data races in the presence of multiple threads racing a update a single thunk. For instance, consider this interleaving under the old scheme: Thread A Thread B --------- --------- t=0 Enter t 1 Push update frame 2 Begin evaluation 4 Pause thread 5 t.indirectee=tso 6 Release t.info=BLACKHOLE 7 ... (e.g. GC) 8 Resume thread 9 Finish evaluation 10 Relaxed t.indirectee=x 11 Load t.info 12 Acquire fence 13 Inspect t.indirectee 14 Release t.info=BLACKHOLE Here Thread A enters thunk `t` but is soon paused, resulting in `t` being lazily blackholed at t=6. Then, at t=10 Thread A finishes evaluation and updates `t.indirectee` with a relaxed store. Meanwhile, Thread B enters the blackhole. Under the old scheme this would introduce an acquire-fence but this would only synchronize with Thread A at t=6. Consequently, the result of the evaluation, `x`, is not visible to Thread B, introducing a data race. We fix this by treating the `indirectee` field as we do all other mutable fields. This means we must always access this field with acquire-loads and release-stores. See #23185. - - - - - f4b53538 by Vladislav Zavialov at 2023-12-20T07:08:02-05:00 docs: Fix link to 051-ghc-base-libraries.rst The proposal is no longer available at the previous URL. - - - - - f7e21fab by Matthew Pickering at 2023-12-21T14:57:40+00:00 hadrian: Build all executables in bin/ folder In the end the bindist creation logic copies them all into the bin folder. There is no benefit to building a specific few binaries in the lib/bin folder anymore. This also removes the ad-hoc logic to copy the touchy and unlit executables from stage0 into stage1. It takes <1s to build so we might as well just build it. - - - - - 0038d052 by Zubin Duggal at 2023-12-22T23:28:00-05:00 testsuite: mark jspace as fragile on i386. This test has been flaky for some time and has been failing consistently on i386-linux since 8e0446df landed. See #24261 - - - - - dfd670a0 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 609e6225 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 865513b2 by Ömer Sinan Ağacan at 2023-12-24T10:11:13-05:00 Fix BNF in user manual 6.6.8.2: formal syntax for instance declarations - - - - - c247b6be by Zubin Duggal at 2023-12-25T16:01:23-05:00 docs: document permissibility of -XOverloadedLabels (#24249) Document the permissibility introduced by https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - e5b7eb59 by Ömer Sinan Ağacan at 2023-12-25T16:02:03-05:00 Fix a code block syntax in user manual sec. 6.8.8.6 - - - - - 2db11c08 by Ben Gamari at 2023-12-29T15:35:48-05:00 genSym: Reimplement via CAS on 32-bit platforms Previously the remaining use of the C implementation on 32-bit platforms resulted in a subtle bug, #24261. This was due to the C object (which used the RTS's `atomic_inc64` macro) being compiled without `-threaded` yet later being used in a threaded compiler. Side-step this issue by using the pure Haskell `genSym` implementation on all platforms. This required implementing `fetchAddWord64Addr#` in terms of CAS on 64-bit platforms. - - - - - 19328a8c by Xiaoyan Ren at 2023-12-29T15:36:30-05:00 Do not color the diagnostic code in error messages (#24172) - - - - - 685b467c by Krzysztof Gogolewski at 2023-12-29T15:37:06-05:00 Enforce that bindings of implicit parameters are lifted Fixes #24298 - - - - - bc4d67b7 by Matthew Craven at 2023-12-31T06:15:42-05:00 StgToCmm: Detect some no-op case-continuations ...and generate no code for them. Fixes #24264. - - - - - 5b603139 by Krzysztof Gogolewski at 2023-12-31T06:16:18-05:00 Revert "testsuite: mark jspace as fragile on i386." This reverts commit 0038d052c8c80b4b430bb2aa1c66d5280be1aa95. The atomicity bug should be fixed by !11802. - - - - - d55216ad by Krzysztof Gogolewski at 2024-01-01T12:05:49-05:00 Refactor: store [[PrimRep]] rather than [Type] in STG StgConApp stored a list of types. This list was used exclusively during unarisation of unboxed sums (mkUbxSum). However, this is at a wrong level of abstraction: STG shouldn't be concerned with Haskell types, only PrimReps. Update the code to store a [[PrimRep]]. Also, there's no point in storing this list when we're not dealing with an unboxed sum. - - - - - 8b340bc7 by Ömer Sinan Ağacan at 2024-01-01T12:06:29-05:00 Kind signatures docs: mention that they're allowed in newtypes - - - - - 989bf8e5 by Zubin Duggal at 2024-01-03T20:08:47-05:00 ci: Ensure we use the correct bindist name for the test artifact when generating release ghcup metadata Fixes #24268 - - - - - 89299a89 by Krzysztof Gogolewski at 2024-01-03T20:09:23-05:00 Refactor: remove calls to typePrimRepArgs The function typePrimRepArgs is just a thin wrapper around typePrimRep, adding a VoidRep if the list is empty. However, in StgToByteCode, we were discarding that VoidRep anyway, so there's no point in calling it. - - - - - c7be0c68 by mmzk1526 at 2024-01-03T20:10:07-05:00 Use "-V" for alex version check for better backward compatibility Fixes #24302. In recent versions of alex, "-v" is used for "--verbose" instead of "-version". - - - - - 67dbcc0a by Krzysztof Gogolewski at 2024-01-05T02:07:18-05:00 Fix VoidRep handling in ghci debugger 'go' inside extractSubTerms was giving a bad result given a VoidRep, attempting to round towards the next multiple of 0. I don't understand much about the debugger but the code should be better than it was. Fixes #24306 - - - - - 90ea574e by Krzysztof Gogolewski at 2024-01-05T02:07:54-05:00 VoidRep-related refactor * In GHC.StgToByteCode, replace bcIdPrimId with idPrimRep, bcIdArgRep with idArgRep, atomPrimRep with stgArgRep1. All of them were duplicates. * In GHC.Stg.Unarise, we were converting a PrimRep to a Type and back to PrimRep. Remove the calls to primRepToType and typePrimRep1 which cancel out. * In GHC.STG.Lint, GHC.StgToCmm, GHC.Types.RepType we were filtering out VoidRep from the result of typePrimRep. But typePrimRep never returns VoidRep - remove the filtering. - - - - - eaf72479 by brian at 2024-01-06T23:03:09-05:00 Add unaligned Addr# primops Implements CLC proposal #154: https://github.com/haskell/core-libraries-committee/issues/154 * add unaligned addr primops * add tests * accept tests * add documentation * fix js primops * uncomment in access ops * use Word64 in tests * apply suggestions * remove extra file * move docs * remove random options * use setByteArray# primop * better naming * update base-exports test * add base-exports for other architectures - - - - - d471d445 by Krzysztof Gogolewski at 2024-01-06T23:03:47-05:00 Remove VoidRep from PrimRep, introduce PrimOrVoidRep This introduces data PrimOrVoidRep = VoidRep | NVRep PrimRep changes typePrimRep1 to return PrimOrVoidRep, and adds a new function typePrimRepU to be used when the argument is definitely non-void. Details in Note [VoidRep] in GHC.Types.RepType. Fixes #19520 - - - - - 48720a07 by Matthew Craven at 2024-01-08T18:57:36-05:00 Apply Note [Sensitivity to unique increment] to LargeRecord - - - - - 9e2e180f by Sebastian Graf at 2024-01-08T18:58:13-05:00 Debugging: Add diffUFM for convenient diffing between UniqFMs - - - - - 948f3e35 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Rename Opt_D_dump_stranal to Opt_D_dump_dmdanal ... and Opt_D_dump_str_signatures to Opt_D_dump_dmd_signatures - - - - - 4e217e3e by Sebastian Graf at 2024-01-08T18:58:13-05:00 Deprecate -ddump-stranal and -ddump-str-signatures ... and suggest -ddump-dmdanal and -ddump-dmd-signatures instead - - - - - 6c613c90 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Move testsuite/tests/stranal to testsuite/tests/dmdanal A separate commit so that the rename is obvious to Git(Lab) - - - - - c929f02b by Sebastian Graf at 2024-01-08T18:58:13-05:00 CoreSubst: Stricten `substBndr` and `cloneBndr` Doing so reduced allocations of `cloneBndr` by about 25%. ``` T9233(normal) ghc/alloc 672,488,656 663,083,216 -1.4% GOOD T9675(optasm) ghc/alloc 423,029,256 415,812,200 -1.7% geo. mean -0.1% minimum -1.7% maximum +0.1% ``` Metric Decrease: T9233 - - - - - e3ca78f3 by Krzysztof Gogolewski at 2024-01-10T17:35:59-05:00 Deprecate -Wsemigroup This warning was used to prepare for Semigroup becoming a superclass of Monoid, and for (<>) being exported from Prelude. This happened in GHC 8.4 in 8ae263ceb3566 and feac0a3bc69fd3. The leftover logic for (<>) has been removed in GHC 9.8, 4d29ecdfcc79. Now the warning does nothing at all and can be deprecated. - - - - - 08d14925 by amesgen at 2024-01-10T17:36:42-05:00 WASM metadata: use correct GHC version - - - - - 7a808419 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Allow SCC declarations in TH (#24081) - - - - - 28827c51 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Fix prettyprinting of SCC pragmas - - - - - ae9cc1a8 by Matthew Craven at 2024-01-10T17:38:01-05:00 Fix loopification in the presence of void arguments This also removes Note [Void arguments in self-recursive tail calls], which was just misleading. It's important to count void args both in the function's arity and at the call site. Fixes #24295. - - - - - b718b145 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: Teach testsuite driver about c++ sources - - - - - 09cb57ad by Zubin Duggal at 2024-01-10T17:38:36-05:00 driver: Set -DPROFILING when compiling C++ sources with profiling Earlier, we used to pass all preprocessor flags to the c++ compiler. This meant that -DPROFILING was passed to the c++ compiler because it was a part of C++ flags However, this was incorrect and the behaviour was changed in 8ff3134ed4aa323b0199ad683f72165e51a59ab6. See #21291. But that commit exposed this bug where -DPROFILING was no longer being passed when compiling c++ sources. The fix is to explicitly include -DPROFILING in `opt_cxx` when profiling is enabled to ensure we pass the correct options for the way to both C and C++ compilers Fixes #24286 - - - - - 2cf9dd96 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: rename objcpp -> objcxx To avoid confusion with C Pre Processsor - - - - - af6932d6 by Simon Peyton Jones at 2024-01-10T17:39:12-05:00 Make TYPE and CONSTRAINT not-apart Issue #24279 showed up a bug in the logic in GHC.Core.Unify.unify_ty which is supposed to make TYPE and CONSTRAINT be not-apart. Easily fixed. - - - - - 4a39b5ff by Zubin Duggal at 2024-01-10T17:39:48-05:00 ci: Fix typo in mk_ghcup_metadata.py There was a missing colon in the fix to #24268 in 989bf8e53c08eb22de716901b914b3607bc8dd08 - - - - - 13503451 by Zubin Duggal at 2024-01-10T17:40:24-05:00 release-ci: remove release-x86_64-linux-deb11-release+boot_nonmoving_gc job There is no reason to have this release build or distribute this variation. This configuration is for testing purposes only. - - - - - afca46a4 by Sebastian Graf at 2024-01-10T17:41:00-05:00 Parser: Add a Note detailing why we need happy's `error` to implement layout - - - - - eaf8a06d by Krzysztof Gogolewski at 2024-01-11T00:43:17+01:00 Turn -Wtype-equality-out-of-scope on by default Also remove -Wnoncanonical-{monoid,monad}-instances from -Wcompat, since they are enabled by default. Refresh wcompat-warnings/ test with new -Wcompat warnings. Part of #24267 Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 42bee5aa by Sebastian Graf at 2024-01-12T21:16:21-05:00 Arity: Require called *exactly once* for eta exp with -fpedantic-bottoms (#24296) In #24296, we had a program in which we eta expanded away an error despite the presence of `-fpedantic-bottoms`. This was caused by turning called *at least once* lambdas into one-shot lambdas, while with `-fpedantic-bottoms` it is only sound to eta expand over lambdas that are called *exactly* once. An example can be found in `Note [Combining arity type with demand info]`. Fixes #24296. - - - - - 7e95f738 by Andreas Klebinger at 2024-01-12T21:16:57-05:00 Aarch64: Enable -mfma by default. Fixes #24311 - - - - - e43788d0 by Jason Shipman at 2024-01-14T12:47:38-05:00 Add more instances for Compose: Fractional, RealFrac, Floating, RealFloat CLC proposal #226 https://github.com/haskell/core-libraries-committee/issues/226 - - - - - ae6d8cd2 by Sebastian Graf at 2024-01-14T12:48:15-05:00 Pmc: COMPLETE pragmas associated with Family TyCons should apply to representation TyCons as well (#24326) Fixes #24326. - - - - - c5fc7304 by sheaf at 2024-01-15T14:15:29-05:00 Use lookupOccRn_maybe in TH.lookupName When looking up a value, we want to be able to find both variables and record fields. So we should not use the lookupSameOccRn_maybe function, as we can't know ahead of time which record field namespace a record field with the given textual name will belong to. Fixes #24293 - - - - - da908790 by Krzysztof Gogolewski at 2024-01-15T14:16:05-05:00 Make the build more strict on documentation errors * Detect undefined labels. This can be tested by adding :ref:`nonexistent` to a documentation rst file; attempting to build docs will fail. Fixed the undefined label in `9.8.1-notes.rst`. * Detect errors. While we have plenty of warnings, we can at least enforce that Sphinx does not report errors. Fixed the error in `required_type_arguments.rst`. Unrelated change: I have documented that the `-dlint` enables `-fcatch-nonexhaustive-cases`, as can be verified by checking `enableDLint`. - - - - - 5077416e by Javier Sagredo at 2024-01-16T15:40:06-05:00 Profiling: Adds an option to not start time profiling at startup Using the functionality provided by d89deeba47ce04a5198a71fa4cbc203fe2c90794, this patch creates a new rts flag `--no-automatic-time-samples` which disables the time profiling when starting a program. It is then expected that the user starts it whenever it is needed. Fixes #24337 - - - - - 5776008c by Matthew Pickering at 2024-01-16T15:40:42-05:00 eventlog: Fix off-by-one error in postIPE We were missing the extra_comma from the calculation of the size of the payload of postIPE. This was causing assertion failures when the event would overflow the buffer by one byte, as ensureRoomForVariable event would report there was enough space for `n` bytes but then we would write `n + 1` bytes into the buffer. Fixes #24287 - - - - - 66dc09b1 by Simon Peyton Jones at 2024-01-16T15:41:18-05:00 Improve SpecConstr (esp nofib/spectral/ansi) This MR makes three improvements to SpecConstr: see #24282 * It fixes an outright (and recently-introduced) bug in `betterPat`, which was wrongly forgetting to compare the lengths of the argument lists. * It enhances ConVal to inclue a boolean for work-free-ness, so that the envt can contain non-work-free constructor applications, so that we can do more: see Note [ConVal work-free-ness] * It rejigs `subsumePats` so that it doesn't reverse the list. This can make a difference because, when patterns overlap, we arbitrarily pick the first. There is no "right" way, but this retains the old pre-subsumePats behaviour, thereby "fixing" the regression in #24282. Nofib results +======================================== | spectral/ansi -21.14% | spectral/hartel/comp_lab_zift -0.12% | spectral/hartel/parstof +0.09% | spectral/last-piece -2.32% | spectral/multiplier +6.03% | spectral/para +0.60% | spectral/simple -0.26% +======================================== | geom mean -0.18% +---------------------------------------- The regression in `multiplier` is sad, but it simply replicates GHC's previous behaviour (e.g. GHC 9.6). - - - - - 65da79b3 by Matthew Pickering at 2024-01-16T15:41:54-05:00 hadrian: Reduce Cabal verbosity The comment claims that `simpleUserHooks` decrease verbosity, and it does, but only for the `postConf` phase. The other phases are too verbose with `-V`. At the moment > 5000 lines of the build log are devoted to output from `cabal copy`. So I take the simple approach and just decrease the verbosity level again. If the output of `postConf` is essential then it would be better to implement our own `UserHooks` which doesn't decrease the verbosity for `postConf`. Fixes #24338 - - - - - 16414d7d by Matthew Pickering at 2024-01-17T10:54:59-05:00 Stop retaining old ModGuts throughout subsequent simplifier phases Each phase of the simplifier typically rewrites the majority of ModGuts, so we want to be able to release the old ModGuts as soon as possible. `name_ppr_ctxt` lives throught the whole optimiser phase and it was retaining a reference to `ModGuts`, so we were failing to release the old `ModGuts` until the end of the phase (potentially doubling peak memory usage for that particular phase). This was discovered using eras profiling (#24332) Fixes #24328 - - - - - 7f0879e1 by Matthew Pickering at 2024-01-17T10:55:35-05:00 Update nofib submodule - - - - - 320454d3 by Cheng Shao at 2024-01-17T23:02:40+00:00 ci: bump ci-images for updated wasm image - - - - - 2eca52b4 by Cheng Shao at 2024-01-17T23:06:44+00:00 base: treat all FDs as "nonblocking" on wasm On posix platforms, when performing read/write on FDs, we check the nonblocking flag first. For FDs without this flag (e.g. stdout), we call fdReady() first, which in turn calls poll() to wait for I/O to be available on that FD. This is problematic for wasm32-wasi: although select()/poll() is supported via the poll_oneoff() wasi syscall, that syscall is rather heavyweight and runtime behavior differs in different wasi implementations. The issue is even worse when targeting browsers, given there's no satisfactory way to implement async I/O as a synchronous syscall, so existing JS polyfills for wasi often give up and simply return ENOSYS. Before we have a proper I/O manager that avoids poll_oneoff() for async I/O on wasm, this patch improves the status quo a lot by merely pretending all FDs are "nonblocking". Read/write on FDs will directly invoke read()/write(), which are much more reliably handled in existing wasi implementations, especially those in browsers. Fixes #23275 and the following test cases: T7773 isEOF001 openFile009 T4808 cgrun025 Approved by CLC proposal #234: https://github.com/haskell/core-libraries-committee/issues/234 - - - - - 83c6c710 by Andrew Lelechenko at 2024-01-18T05:21:49-05:00 base: clarify how to disable warnings about partiality of Data.List.{head,tail} - - - - - c4078f2f by Simon Peyton Jones at 2024-01-18T05:22:25-05:00 Fix four bug in handling of (forall cv. body_ty) These bugs are all described in #24335 It's not easy to provoke the bug, hence no test case. - - - - - 119586ea by Alexis King at 2024-01-19T00:08:00-05:00 Always refresh profiling CCSes after running pending initializers Fixes #24171. - - - - - 9718d970 by Oleg Grenrus at 2024-01-19T00:08:36-05:00 Set default-language: GHC2021 in ghc library Go through compiler/ sources, and remove all BangPatterns (and other GHC2021 enabled extensions in these files). - - - - - 3ef71669 by Matthew Pickering at 2024-01-19T21:55:16-05:00 testsuite: Remove unused have_library function Also remove the hence unused testsuite option `--test-package-db`. Fixes #24342 - - - - - 5b7fa20c by Jade at 2024-01-19T21:55:53-05:00 Fix Spelling in the compiler Tracking: #16591 - - - - - 09875f48 by Matthew Pickering at 2024-01-20T12:20:44-05:00 testsuite: Implement `isInTreeCompiler` in a more robust way Just a small refactoring to avoid redundantly specifying the same strings in two different places. - - - - - 0d12b987 by Jade at 2024-01-20T12:21:20-05:00 Change maintainer email from cvs-ghc at haskell.org to ghc-devs at haskell.org. Fixes #22142 - - - - - 1fa1c00c by Jade at 2024-01-23T19:17:03-05:00 Enhance Documentation of functions exported by Data.Function This patch aims to improve the documentation of functions exported in Data.Function Tracking: #17929 Fixes: #10065 - - - - - ab47a43d by Jade at 2024-01-23T19:17:39-05:00 Improve documentation of hGetLine. - Add explanation for whether a newline is returned - Add examples Fixes #14804 - - - - - dd4af0e5 by Cheng Shao at 2024-01-23T19:18:17-05:00 Fix genapply for cross-compilation by nuking fragile CPP logic This commit fixes incorrectly built genapply when cross compiling (#24347) by nuking all fragile CPP logic in it from the orbit. All target-specific info are now read from DerivedConstants.h at runtime, see added note for details. Also removes a legacy Makefile and adds haskell language server support for genapply. - - - - - 0cda2b8b by Cheng Shao at 2024-01-23T19:18:17-05:00 rts: enable wasm32 register mapping The wasm backend didn't properly make use of all Cmm global registers due to #24347. Now that it is fixed, this patch re-enables full register mapping for wasm32, and we can now generate smaller & faster wasm modules that doesn't always spill arguments onto the stack. Fixes #22460 #24152. - - - - - 0325a6e5 by Greg Steuck at 2024-01-24T01:29:44-05:00 Avoid utf8 in primops.txt.pp comments They don't make it through readFile' without explicitly setting the encoding. See https://gitlab.haskell.org/ghc/ghc/-/issues/17755 - - - - - 1aaf0bd8 by David Binder at 2024-01-24T01:30:20-05:00 Bump hpc and hpc-bin submodule Bump hpc to 0.7.0.1 Bump hpc-bin to commit d1780eb2 - - - - - e693a4e8 by Ben Gamari at 2024-01-24T01:30:56-05:00 testsuite: Ignore stderr in T8089 Otherwise spurious "Killed: 9" messages to stderr may cause the test to fail. Fixes #24361. - - - - - a40f4ab2 by sheaf at 2024-01-24T14:04:33-05:00 Fix FMA instruction on LLVM We were emitting the wrong instructions for fused multiply-add operations on LLVM: - the instruction name is "llvm.fma.f32" or "llvm.fma.f64", not "fmadd" - LLVM does not support other instructions such as "fmsub"; instead we implement these by flipping signs of some arguments - the instruction is an LLVM intrinsic, which requires handling it like a normal function call instead of a machine instruction Fixes #24223 - - - - - 69abc786 by Andrei Borzenkov at 2024-01-24T14:05:09-05:00 Add changelog entry for renaming tuples from (,,...,,) to Tuple<n> (24291) - - - - - 0ac8f385 by Cheng Shao at 2024-01-25T00:27:48-05:00 compiler: remove unused GHC.Linker module The GHC.Linker module is empty and unused, other than as a hack for the make build system. We can remove it now that make is long gone; the note is moved to GHC.Linker.Loader instead. - - - - - 699da01b by Hécate Moonlight at 2024-01-25T00:28:27-05:00 Clarification for newtype constructors when using `coerce` - - - - - b2d8cd85 by Matt Walker at 2024-01-26T09:50:08-05:00 Fix #24308 Add tests for semicolon separated where clauses - - - - - 0da490a1 by Ben Gamari at 2024-01-26T17:34:41-05:00 hsc2hs: Bump submodule - - - - - 3f442fd2 by Ben Gamari at 2024-01-26T17:34:41-05:00 Bump containers submodule to 0.7 - - - - - 82a1c656 by Sebastian Nagel at 2024-01-29T02:32:40-05:00 base: with{Binary}File{Blocking} only annotates own exceptions Fixes #20886 This ensures that inner, unrelated exceptions are not misleadingly annotated with the opened file. - - - - - 9294a086 by Andreas Klebinger at 2024-01-29T02:33:15-05:00 Fix fma warning when using llvm on aarch64. On aarch64 fma is always on so the +fma flag doesn't exist for that target. Hence no need to try and pass +fma to llvm. Fixes #24379 - - - - - ced2e731 by sheaf at 2024-01-29T17:27:12-05:00 No shadowing warnings for NoFieldSelector fields This commit ensures we don't emit shadowing warnings when a user shadows a field defined with NoFieldSelectors. Fixes #24381 - - - - - 8eeadfad by Patrick at 2024-01-29T17:27:51-05:00 Fix bug wrong span of nested_doc_comment #24378 close #24378 1. Update the start position of span in `nested_doc_comment` correctly. and hence the spans of identifiers of haddoc can be computed correctly. 2. add test `HaddockSpanIssueT24378`. - - - - - a557580f by Alexey Radkov at 2024-01-30T19:41:52-05:00 Fix irrelevant dodgy-foreign-imports warning on import f-pointers by value A test *сс018* is attached (not sure about the naming convention though). Note that without the fix, the test fails with the *dodgy-foreign-imports* warning passed to stderr. The warning disappears after the fix. GHC shouldn't warn on imports of natural function pointers from C by value (which is feasible with CApiFFI), such as ```haskell foreign import capi "cc018.h value f" f :: FunPtr (Int -> IO ()) ``` where ```c void (*f)(int); ``` See a related real-world use-case [here](https://gitlab.com/daniel-casanueva/pcre-light/-/merge_requests/17). There, GHC warns on import of C function pointer `pcre_free`. - - - - - ca99efaf by Alexey Radkov at 2024-01-30T19:41:53-05:00 Rename test cc018 -> T24034 - - - - - 88c38dd5 by Ben Gamari at 2024-01-30T19:42:28-05:00 rts/TraverseHeap.c: Ensure that PosixSource.h is included first - - - - - ca2e919e by Simon Peyton Jones at 2024-01-31T09:29:45+00:00 Make decomposeRuleLhs a bit more clever This fixes #24370 by making decomposeRuleLhs undertand dictionary /functions/ as well as plain /dictionaries/ - - - - - 94ce031d by Teo Camarasu at 2024-02-01T05:49:49-05:00 doc: Add -Dn flag to user guide Resolves #24394 - - - - - 31553b11 by Ben Gamari at 2024-02-01T12:21:29-05:00 cmm: Introduce MO_RelaxedRead In hand-written Cmm it can sometimes be necessary to atomically load from memory deep within an expression (e.g. see the `CHECK_GC` macro). This MachOp provides a convenient way to do so without breaking the expression into multiple statements. - - - - - 0785cf81 by Ben Gamari at 2024-02-01T12:21:29-05:00 codeGen: Use relaxed accesses in ticky bumping - - - - - be423dda by Ben Gamari at 2024-02-01T12:21:29-05:00 base: use atomic write when updating timer manager - - - - - 8a310e35 by Ben Gamari at 2024-02-01T12:21:29-05:00 Use relaxed atomics to manipulate TSO status fields - - - - - d6809ee4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Add necessary barriers when manipulating TSO owner - - - - - 39e3ac5d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Use `switch` to branch on why_blocked This is a semantics-preserving refactoring. - - - - - 515eb33d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix synchronization on thread blocking state We now use a release barrier whenever we update a thread's blocking state. This required widening StgTSO.why_blocked as AArch64 does not support atomic writes on 16-bit values. - - - - - eb38812e by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadPaused This only affects an assertion in the debug RTS and only needs relaxed ordering. - - - - - 26c48dd6 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadStatus# - - - - - 6af43ab4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in Interpreter's preemption check - - - - - 9502ad3c by Ben Gamari at 2024-02-01T12:21:29-05:00 rts/Messages: Fix data race - - - - - 60802db5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts/Prof: Fix data race - - - - - ef8ccef5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use relaxed ordering on dirty/clean info tables updates When changing the dirty/clean state of a mutable object we needn't have any particular ordering. - - - - - 76fe2b75 by Ben Gamari at 2024-02-01T12:21:30-05:00 codeGen: Use relaxed-read in closureInfoPtr - - - - - a6316eb4 by Ben Gamari at 2024-02-01T12:21:30-05:00 STM: Use acquire loads when possible Full sequential consistency is not needed here. - - - - - 6bddfd3d by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use fence rather than redundant load Previously we would use an atomic load to ensure acquire ordering. However, we now have `ACQUIRE_FENCE_ON`, which allows us to express this more directly. - - - - - 55c65dbc by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Fix data races in profiling timer - - - - - 856b5e75 by Ben Gamari at 2024-02-01T12:21:30-05:00 Add Note [C11 memory model] - - - - - 6534da24 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: move generic cmm optimization logic in NCG to a standalone module This commit moves GHC.CmmToAsm.cmmToCmm to a standalone module, GHC.Cmm.GenericOpt. The main motivation is enabling this logic to be run in the wasm backend NCG code, which is defined in other modules that's imported by GHC.CmmToAsm, causing a cyclic dependency issue. - - - - - 87e34888 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: explicitly disable PIC in wasm32 NCG This commit explicitly disables the ncgPIC flag for the wasm32 target. The wasm backend doesn't support PIC for the time being. - - - - - c6ce242e by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: enable generic cmm optimizations in wasm backend NCG This commit enables the generic cmm optimizations in other NCGs to be run in the wasm backend as well, followed by a late cmm control-flow optimization pass. The added optimizations do catch some corner cases not handled by the pre-NCG cmm pipeline and are useful in generating smaller CFGs. - - - - - 151dda4e by Andrei Borzenkov at 2024-02-01T12:22:43-05:00 Namespacing for WARNING/DEPRECATED pragmas (#24396) New syntax for WARNING and DEPRECATED pragmas was added, namely namespace specifierss: namespace_spec ::= 'type' | 'data' | {- empty -} warning ::= warning_category namespace_spec namelist strings deprecation ::= namespace_spec namelist strings A new data type was introduced to represent these namespace specifiers: data NamespaceSpecifier = NoSpecifier | TypeNamespaceSpecifier (EpToken "type") | DataNamespaceSpecifier (EpToken "data") Extension field XWarning now contains this NamespaceSpecifier. lookupBindGroupOcc function was changed: it now takes NamespaceSpecifier and checks that the namespace of the found names matches the passed flag. With this change {-# WARNING data D "..." #-} pragma will only affect value namespace and {-# WARNING type D "..." #-} will only affect type namespace. The same logic is applicable to DEPRECATED pragmas. Finding duplicated warnings inside rnSrcWarnDecls now takes into consideration NamespaceSpecifier flag to allow warnings with the same names that refer to different namespaces. - - - - - 38c3afb6 by Bryan Richter at 2024-02-01T12:23:19-05:00 CI: Disable the test-cabal-reinstall job Fixes #24363 - - - - - 27020458 by Matthew Craven at 2024-02-03T01:53:26-05:00 Bump bytestring submodule to something closer to 0.12.1 ...mostly so that 16d6b7e835ffdcf9b894e79f933dd52348dedd0c (which reworks unaligned writes in Builder) and the stuff in https://github.com/haskell/bytestring/pull/631 can see wider testing. The less-terrible code for unaligned writes used in Builder on hosts not known to be ulaigned-friendly also takes less effort for GHC to compile, resulting in a metric decrease for T21839c on some platforms. The metric increase on T21839r is caused by the unrelated commit 750dac33465e7b59100698a330b44de7049a345c. It perhaps warrants further analysis and discussion (see #23822) but is not critical. Metric Decrease: T21839c Metric Increase: T21839r - - - - - cdddeb0f by Rodrigo Mesquita at 2024-02-03T01:54:02-05:00 Work around autotools setting C11 standard in CC/CXX In autoconf >=2.70, C11 is set by default for $CC and $CXX via the -std=...11 flag. In this patch, we split the "-std" flag out of the $CC and $CXX variables, which we traditionally assume to be just the executable name/path, and move it to $CFLAGS/$CXXFLAGS instead. Fixes #24324 - - - - - 5ff7cc26 by Apoorv Ingle at 2024-02-03T13:14:46-06:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - The change is detailed in - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` - Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - Adds new datatypes: - `GHC.Hs.Expr.XXExprGhcRn`: new datatype makes this expansion work easier 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - Ensures warnings such as 1. Pattern match checks 2. Failable patterns 3. non-() return in body statements are preserved - Kill `HsMatchCtxt` in favor of `TcMatchAltChecker` - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) Also repoint haddock to the right submodule so that the test (haddockHypsrcTest) pass Metric Increase 'compile_time/bytes allocated': T9020 The testcase is a pathalogical example of a `do`-block with many statements that do nothing. Given that we are expanding the statements into function binds, we will have to bear a (small) 2% cost upfront in the compiler to unroll the statements. - - - - - 0df8ce27 by Vladislav Zavialov at 2024-02-04T03:55:14-05:00 Reduce parser allocations in allocateCommentsP In the most common case, the comment queue is empty, so we can skip the work of processing it. This reduces allocations by about 10% in the parsing001 test. Metric Decrease: MultiLayerModulesRecomp parsing001 - - - - - cfd68290 by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Stop dropping a case whose binder is demanded This MR fixes #24251. See Note [Case-to-let for strictly-used binders] in GHC.Core.Opt.Simplify.Iteration, plus #24251, for lots of discussion. Final Nofib changes over 0.1%: +----------------------------------------- | imaginary/digits-of-e2 -2.16% | imaginary/rfib -0.15% | real/fluid -0.10% | real/gamteb -1.47% | real/gg -0.20% | real/maillist +0.19% | real/pic -0.23% | real/scs -0.43% | shootout/n-body -0.41% | shootout/spectral-norm -0.12% +======================================== | geom mean -0.05% Pleasingly, overall executable size is down by just over 1%. Compile times (in perf/compiler) wobble around a bit +/- 0.5%, but the geometric mean is -0.1% which seems good. - - - - - e4d137bb by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Add Note [Bangs in Integer functions] ...to document the bangs in the functions in GHC.Num.Integer - - - - - ce90f12f by Andrei Borzenkov at 2024-02-05T17:59:09-05:00 Hide WARNING/DEPRECATED namespacing under -XExplicitNamespaces (#24396) - - - - - e2ea933f by Simon Peyton Jones at 2024-02-06T10:12:04-05:00 Refactoring in preparation for lazy skolemisation * Make HsMatchContext and HsStmtContext be parameterised over the function name itself, rather than over the pass. See [mc_fun field of FunRhs] in Language.Haskell.Syntax.Expr - Replace types HsMatchContext GhcPs --> HsMatchContextPs HsMatchContext GhcRn --> HsMatchContextRn HsMatchContext GhcTc --> HsMatchContextRn (sic! not Tc) HsStmtContext GhcRn --> HsStmtContextRn - Kill off convertHsMatchCtxt * Split GHC.Tc.Type.BasicTypes.TcSigInfo so that TcCompleteSig (describing a complete user-supplied signature) is its own data type. - Split TcIdSigInfo(CompleteSig, PartialSig) into TcCompleteSig(CSig) TcPartialSig(PSig) - Use TcCompleteSig in tcPolyCheck, CheckGen - Rename types and data constructors: TcIdSigInfo --> TcIdSig TcPatSynInfo(TPSI) --> TcPatSynSig(PatSig) - Shuffle around helper functions: tcSigInfoName (moved to GHC.Tc.Types.BasicTypes) completeSigPolyId_maybe (moved to GHC.Tc.Types.BasicTypes) tcIdSigName (inlined and removed) tcIdSigLoc (introduced) - Rearrange the pattern match in chooseInferredQuantifiers * Rename functions and types: tcMatchesCase --> tcCaseMatches tcMatchesFun --> tcFunBindMatches tcMatchLambda --> tcLambdaMatches tcPats --> tcMatchPats matchActualFunTysRho --> matchActualFunTys matchActualFunTySigma --> matchActualFunTy * Add HasDebugCallStack constraints to: mkBigCoreVarTupTy, mkBigCoreTupTy, boxTy, mkPiTy, mkPiTys, splitAppTys, splitTyConAppNoView_maybe * Use `penv` from the outer context in the inner loop of GHC.Tc.Gen.Pat.tcMultiple * Move tcMkVisFunTy, tcMkInvisFunTy, tcMkScaledFunTys down the file, factor out and export tcMkScaledFunTy. * Move isPatSigCtxt down the file. * Formatting and comments Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - f5d3e03c by Andrei Borzenkov at 2024-02-06T10:12:04-05:00 Lazy skolemisation for @a-binders (#17594) This patch is a preparation for @a-binders implementation. The main changes are: * Skolemisation is now prepared to deal with @binders. See Note [Skolemisation overview] in GHC.Tc.Utils.Unify. Most of the action is in - Utils.Unify.matchExpectedFunTys - Gen.Pat.tcMatchPats - Gen.Expr.tcPolyExprCheck - Gen.Binds.tcPolyCheck Some accompanying refactoring: * I found that funTyConAppTy_maybe was doing a lot of allocation, and rejigged userTypeError_maybe to avoid calling it. - - - - - 532993c8 by Zubin Duggal at 2024-02-06T10:12:41-05:00 driver: Really don't lose track of nodes when we fail to resolve cycles This fixes a bug in 8db8d2fd1c881032b1b360c032b6d9d072c11723, where we could lose track of acyclic components at the start of an unresolved cycle. We now ensure we never loose track of any of these components. As T24275 demonstrates, a "cyclic" SCC might not really be a true SCC: When viewed without boot files, we have a single SCC ``` [REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A [main:T24275A {-# SOURCE #-}]] ``` But with boot files this turns into ``` [NONREC main:T24275B {-# SOURCE #-} [], REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A {-# SOURCE #-} [main:T24275B], NONREC main:T24275A [main:T24275A {-# SOURCE #-}]] ``` Note that this is truly not an SCC, as no nodes are reachable from T24275B.hs-boot. However, we treat this entire group as a single "SCC" because it seems so when we analyse the graph without taking boot files into account. Indeed, we must return a single ResolvedCycle element in the BuildPlan for this as described in Note [Upsweep]. However, since after resolving this is not a true SCC anymore, `findCycle` fails to find a cycle and we have a sub-optimal error message as a result. To handle this, I extended `findCycle` to not assume its input is an SCC, and to try harder to find cycles in its input. Fixes #24275 - - - - - b35dd613 by Zubin Duggal at 2024-02-06T10:13:17-05:00 GHCi: Lookup breakpoint CCs in the correct module We need to look up breakpoint CCs in the module that the breakpoint points to, and not the current module. Fixes #24327 - - - - - b09e6958 by Zubin Duggal at 2024-02-06T10:13:17-05:00 testsuite: Add test for #24327 - - - - - 569b4c10 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add compile_artifact, ignore_extension flag In b521354216f2821e00d75f088d74081d8b236810 the testsuite gained the capability to collect generic metrics. But this assumed that the test was not linking and producing artifacts and we only wanted to track object files, interface files, or build artifacts from the compiler build. However, some backends, such as the JS backend, produce artifacts when compiling, such as the jsexe directory which we want to track. This patch: - tweaks the testsuite to collect generic metrics on any build artifact in the test directory. - expands the exe_extension function to consider windows and adds the ignore_extension flag. - Modifies certain tests to add the ignore_extension flag. Tests such as heaprof002 expect a .ps file, but on windows without ignore_extensions the testsuite will look for foo.exe.ps. Hence the flag. - adds the size_hello_artifact test - - - - - 75a31379 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add wasm_arch, heapprof002 wasm extension - - - - - c9731d6d by Rodrigo Mesquita at 2024-02-07T03:07:03-05:00 Synchronize bindist configure for #24324 In cdddeb0f1280b40cc194028bbaef36e127175c4c, we set up a workaround for #24324 in the in-tree configure script, but forgot to update the bindist configure script accordingly. This updates it. - - - - - d309f4e7 by Matthew Pickering at 2024-02-07T03:07:38-05:00 distrib/configure: Fix typo in CONF_GCC_LINKER_OPTS_STAGE2 variable Instead we were setting CONF_GCC_LINK_OPTS_STAGE2 which meant that we were missing passing `--target` when invoking the linker. Fixes #24414 - - - - - 77db84ab by Ben Gamari at 2024-02-08T00:35:22-05:00 llvmGen: Adapt to allow use of new pass manager. We now must use `-passes` in place of `-O<n>` due to #21936. Closes #21936. - - - - - 3c9ddf97 by Matthew Pickering at 2024-02-08T00:35:59-05:00 testsuite: Mark length001 as fragile on javascript Modifying the timeout multiplier is not a robust way to get this test to reliably fail. Therefore we mark it as fragile until/if javascript ever supports the stack limit. - - - - - 20b702b5 by Matthew Pickering at 2024-02-08T00:35:59-05:00 Javascript: Don't filter out rtsDeps list This logic appears to be incorrect as it would drop any dependency which was not in a direct dependency of the package being linked. In the ghc-internals split this started to cause errors because `ghc-internal` is not a direct dependency of most packages, and hence important symbols to keep which are hard coded into the js runtime were getting dropped. - - - - - 2df96366 by Ben Gamari at 2024-02-08T00:35:59-05:00 base: Cleanup whitespace in cbits - - - - - 44f6557a by Ben Gamari at 2024-02-08T00:35:59-05:00 Move `base` to `ghc-internal` Here we move a good deal of the implementation of `base` into a new package, `ghc-internal` such that it can be evolved independently from the user-visible interfaces of `base`. While we want to isolate implementation from interfaces, naturally, we would like to avoid turning `base` into a mere set of module re-exports. However, this is a non-trivial undertaking for a variety of reasons: * `base` contains numerous known-key and wired-in things, requiring corresponding changes in the compiler * `base` contains a significant amount of C code and corresponding autoconf logic, which is very fragile and difficult to break apart * `base` has numerous import cycles, which are currently dealt with via carefully balanced `hs-boot` files * We must not break existing users To accomplish this migration, I tried the following approaches: * [Split-GHC.Base]: Break apart the GHC.Base knot to allow incremental migration of modules into ghc-internal: this knot is simply too intertwined to be easily pulled apart, especially given the rather tricky import cycles that it contains) * [Move-Core]: Moving the "core" connected component of base (roughly 150 modules) into ghc-internal. While the Haskell side of this seems tractable, the C dependencies are very subtle to break apart. * [Move-Incrementally]: 1. Move all of base into ghc-internal 2. Examine the module structure and begin moving obvious modules (e.g. leaves of the import graph) back into base 3. Examine the modules remaining in ghc-internal, refactor as necessary to facilitate further moves 4. Go to (2) iterate until the cost/benefit of further moves is insufficient to justify continuing 5. Rename the modules moved into ghc-internal to ensure that they don't overlap with those in base 6. For each module moved into ghc-internal, add a shim module to base with the declarations which should be exposed and any requisite Haddocks (thus guaranteeing that base will be insulated from changes in the export lists of modules in ghc-internal Here I am using the [Move-Incrementally] approach, which is empirically the least painful of the unpleasant options above Bumps haddock submodule. Metric Decrease: haddock.Cabal haddock.base Metric Increase: MultiComponentModulesRecomp T16875 size_hello_artifact - - - - - e8fb2451 by Vladislav Zavialov at 2024-02-08T00:36:36-05:00 Haddock comments on infix constructors (#24221) Rewrite the `HasHaddock` instance for `ConDecl GhcPs` to account for infix constructors. This change fixes a Haddock regression (introduced in 19e80b9af252) that affected leading comments on infix data constructor declarations: -- | Docs for infix constructor | Int :* Bool The comment should be associated with the data constructor (:*), not with its left-hand side Int. - - - - - 9060d55b by Ben Gamari at 2024-02-08T00:37:13-05:00 Add os-string as a boot package Introduces `os-string` submodule. This will be necessary for `filepath-1.5`. - - - - - 9d65235a by Ben Gamari at 2024-02-08T00:37:13-05:00 gitignore: Ignore .hadrian_ghci_multi/ - - - - - d7ee12ea by Ben Gamari at 2024-02-08T00:37:13-05:00 hadrian: Set -this-package-name When constructing the GHC flags for a package Hadrian must take care to set `-this-package-name` in addition to `-this-unit-id`. This hasn't broken until now as we have not had any uses of qualified package imports. However, this will change with `filepath-1.5` and the corresponding `unix` bump, breaking `hadrian/multi-ghci`. - - - - - f2dffd2e by Ben Gamari at 2024-02-08T00:37:13-05:00 Bump filepath to 1.5.0.0 Required bumps of the following submodules: * `directory` * `filepath` * `haskeline` * `process` * `unix` * `hsc2hs` * `Win32` * `semaphore-compat` and the addition of `os-string` as a boot package. - - - - - ab533e71 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Use specific clang assembler when compiling with -fllvm There are situations where LLVM will produce assembly which older gcc toolchains can't handle. For example on Deb10, it seems that LLVM >= 13 produces assembly which the default gcc doesn't support. A more robust solution in the long term is to require a specific LLVM compatible assembler when using -fllvm. Fixes #16354 - - - - - c32b6426 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update CI images with LLVM 15, ghc-9.6.4 and cabal-install-3.10.2.0 - - - - - 5fcd58be by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update bootstrap plans for 9.4.8 and 9.6.4 - - - - - 707a32f5 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Add alpine 3_18 release job This is mainly experimental and future proofing to enable a smooth transition to newer alpine releases once 3_12 is too old. - - - - - c37931b3 by John Ericson at 2024-02-08T06:39:05-05:00 Generate LLVM min/max bound policy via Hadrian Per #23966, I want the top-level configure to only generate configuration data for Hadrian, not do any "real" tasks on its own. This is part of that effort --- one less file generated by it. (It is still done with a `.in` file, so in a future world non-Hadrian also can easily create this file.) Split modules: - GHC.CmmToLlvm.Config - GHC.CmmToLlvm.Version - GHC.CmmToLlvm.Version.Bounds - GHC.CmmToLlvm.Version.Type This also means we can get rid of the silly `unused.h` introduced in !6803 / 7dfcab2f4bcb7206174ea48857df1883d05e97a2 as temporary kludge. Part of #23966 - - - - - 9f987235 by Apoorv Ingle at 2024-02-08T06:39:42-05:00 Enable mdo statements to use HsExpansions Fixes: #24411 Added test T24411 for regression - - - - - 762b2120 by Jade at 2024-02-08T15:17:15+00:00 Improve Monad, Functor & Applicative docs This patch aims to improve the documentation of Functor, Applicative, Monad and related symbols. The main goal is to make it more consistent and make accessible. See also: !10979 (closed) and !10985 (closed) Ticket #17929 Updates haddock submodule - - - - - 151770ca by Josh Meredith at 2024-02-10T14:28:15-05:00 JavaScript codegen: Use GHC's tag inference where JS backend-specific evaluation inference was previously used (#24309) - - - - - 2e880635 by Zubin Duggal at 2024-02-10T14:28:51-05:00 ci: Allow release-hackage-lint to fail Otherwise it blocks the ghcup metadata pipeline from running. - - - - - b0293f78 by Matthew Pickering at 2024-02-10T14:29:28-05:00 rts: eras profiling mode The eras profiling mode is useful for tracking the life-time of closures. When a closure is written, the current era is recorded in the profiling header. This records the era in which the closure was created. * Enable with -he * User mode: Use functions ghc-experimental module GHC.Profiling.Eras to modify the era * Automatically: --automatic-era-increment, increases the user era on major collections * The first era is era 1 * -he<era> can be used with other profiling modes to select a specific era If you just want to record the era but not to perform heap profiling you can use `-he --no-automatic-heap-samples`. https://well-typed.com/blog/2024/01/ghc-eras-profiling/ Fixes #24332 - - - - - be674a2c by Jade at 2024-02-10T14:30:04-05:00 Adjust error message for trailing whitespace in as-pattern. Fixes #22524 - - - - - 53ef83f9 by doyougnu at 2024-02-10T14:30:47-05:00 gitlab: js: add codeowners Fixes: - #24409 Follow on from: - #21078 and MR !9133 - When we added the JS backend this was forgotten. This patch adds the rightful codeowners. - - - - - 8bbe12f2 by Matthew Pickering at 2024-02-10T14:31:23-05:00 Bump CI images so that alpine3_18 image includes clang15 The only changes here are that clang15 is now installed on the alpine-3_18 image. - - - - - df9fd9f7 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: handle stored null StablePtr Some Haskell codes unsafely cast StablePtr into ptr to compare against NULL. E.g. in direct-sqlite: if castStablePtrToPtr aggStPtr /= nullPtr then where `aggStPtr` is read (`peek`) from zeroed memory initially. We fix this by giving these StablePtr the same representation as other null pointers. It's safe because StablePtr at offset 0 is unused (for this exact reason). - - - - - 55346ede by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: disable MergeObjsMode test This isn't implemented for JS backend objects. - - - - - aef587f6 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: add support for linking C sources Support linking C sources with JS output of the JavaScript backend. See the added documentation in the users guide. The implementation simply extends the JS linker to use the objects (.o) that were already produced by the emcc compiler and which were filtered out previously. I've also added some options to control the link with C functions (see the documentation about pragmas). With this change I've successfully compiled the direct-sqlite package which embeds the sqlite.c database code. Some wrappers are still required (see the documentation about wrappers) but everything generic enough to be reused for other libraries have been integrated into rts/js/mem.js. - - - - - b71b392f by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: avoid EMCC logging spurious failure emcc would sometime output messages like: cache:INFO: generating system asset: symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json" for subsequent builds) cache:INFO: - ok Cf https://github.com/emscripten-core/emscripten/issues/18607 This breaks our tests matching the stderr output. We avoid this by setting EMCC_LOGGING=0 - - - - - ff2c0cc9 by Simon Peyton Jones at 2024-02-12T12:19:17-05:00 Remove a dead comment Just remove an out of date block of commented-out code, and tidy up the relevant Notes. See #8317. - - - - - bedb4f0d by Teo Camarasu at 2024-02-12T18:50:33-05:00 nonmoving: Add support for heap profiling Add support for heap profiling while using the nonmoving collector. We greatly simply the implementation by disabling concurrent collection for GCs when heap profiling is enabled. This entails that the marked objects on the nonmoving heap are exactly the live objects. Note that we match the behaviour for live bytes accounting by taking the size of objects on the nonmoving heap to be that of the segment's block rather than the object itself. Resolves #22221 - - - - - d0d5acb5 by Teo Camarasu at 2024-02-12T18:51:09-05:00 doc: Add requires prof annotation to options that require it Resolves #24421 - - - - - 57bb8c92 by Cheng Shao at 2024-02-13T14:07:49-05:00 deriveConstants: add needed constants for wasm backend This commit adds needed constants to deriveConstants. They are used by RTS code in the wasm backend to support the JSFFI logic. - - - - - 615eb855 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms The pure Haskell implementation causes i386 regression in unrelated work that can be fixed by using C-based atomic increment, see added comment for details. - - - - - a9918891 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow JSFFI for wasm32 This commit allows the javascript calling convention to be used when the target platform is wasm32. - - - - - 8771a53b by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow boxed JSVal as a foreign type This commit allows the boxed JSVal type to be used as a foreign argument/result type. - - - - - 053c92b3 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: ensure ctors have the right priority on wasm32 This commit fixes the priorities of ctors generated by GHC codegen on wasm32, see the referred note for details. - - - - - b7942e0a by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JSFFI desugar logic for wasm32 This commit adds JSFFI desugar logic for the wasm backend. - - - - - 2c1dca76 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JavaScriptFFI to supported extension list on wasm32 This commit adds JavaScriptFFI as a supported extension when the target platform is wasm32. - - - - - 9ad0e2b4 by Cheng Shao at 2024-02-13T14:07:49-05:00 rts/ghc-internal: add JSFFI support logic for wasm32 This commit adds rts/ghc-internal logic to support the wasm backend's JSFFI functionality. - - - - - e9ebea66 by Cheng Shao at 2024-02-13T14:07:49-05:00 ghc-internal: fix threadDelay for wasm in browsers This commit fixes broken threadDelay for wasm when it runs in browsers, see added note for detailed explanation. - - - - - f85f3fdb by Cheng Shao at 2024-02-13T14:07:49-05:00 utils: add JSFFI utility code This commit adds JavaScript util code to utils to support the wasm backend's JSFFI functionality: - jsffi/post-link.mjs, a post-linker to process the linked wasm module and emit a small complement JavaScript ESM module to be used with it at runtime - jsffi/prelude.js, a tiny bit of prelude code as the JavaScript side of runtime logic - jsffi/test-runner.mjs, run the jsffi test cases Co-authored-by: amesgen <amesgen at amesgen.de> - - - - - 77e91500 by Cheng Shao at 2024-02-13T14:07:49-05:00 hadrian: distribute jsbits needed for wasm backend's JSFFI support The post-linker.mjs/prelude.js files are now distributed in the bindist libdir, so when using the wasm backend's JSFFI feature, the user wouldn't need to fetch them from a ghc checkout manually. - - - - - c47ba1c3 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add opts.target_wrapper This commit adds opts.target_wrapper which allows overriding the target wrapper on a per test case basis when testing a cross target. This is used when testing the wasm backend's JSFFI functionality; the rest of the cases are tested using wasmtime, though the jsffi cases are tested using the node.js based test runner. - - - - - 8e048675 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: T22774 should work for wasm JSFFI T22774 works since the wasm backend now supports the JSFFI feature. - - - - - 1d07f9a6 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add JSFFI test cases for wasm backend This commit adds a few test cases for the wasm backend's JSFFI functionality, as well as a simple README to instruct future contributors to add new test cases. - - - - - b8997080 by Cheng Shao at 2024-02-13T14:07:49-05:00 docs: add documentation for wasm backend JSFFI This commit adds changelog and user facing documentation for the wasm backend's JSFFI feature. - - - - - ffeb000d by David Binder at 2024-02-13T14:08:30-05:00 Add tests from libraries/process/tests and libraries/Win32/tests to GHC These tests were previously part of the libraries, which themselves are submodules of the GHC repository. This commit moves the tests directly to the GHC repository. - - - - - 5a932cf2 by David Binder at 2024-02-13T14:08:30-05:00 Do not execute win32 tests on non-windows runners - - - - - 500d8cb8 by Jade at 2024-02-13T14:09:07-05:00 prevent GHCi (and runghc) from suggesting other symbols when not finding main Fixes: #23996 - - - - - b19ec331 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: update xxHash to v0.8.2 - - - - - 4a97bdb8 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: use XXH3_64bits hash on all 64-bit platforms This commit enables XXH3_64bits hash to be used on all 64-bit platforms. Previously it was only enabled on x86_64, so platforms like aarch64 silently falls back to using XXH32 which degrades the hashing function quality. - - - - - ee01de7d by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: define XXH_INLINE_ALL This commit cleans up how we include the xxhash.h header and only define XXH_INLINE_ALL, which is sufficient to inline the xxHash functions without symbol collision. - - - - - 0e01e1db by Alan Zimmerman at 2024-02-14T02:13:22-05:00 EPA: Move EpAnn out of extension points Leaving a few that are too tricky, maybe some other time. Also - remove some unneeded helpers from Parser.y - reduce allocations with strictness annotations Updates haddock submodule Metric Decrease: parsing001 - - - - - de589554 by Andreas Klebinger at 2024-02-14T02:13:59-05:00 Fix ffi callbacks with >6 args and non-64bit args. Check for ptr/int arguments rather than 64-bit width arguments when counting integer register arguments. The old approach broke when we stopped using exclusively W64-sized types to represent sub-word sized integers. Fixes #24314 - - - - - 325b7613 by Ben Gamari at 2024-02-14T14:27:45-05:00 rts/EventLog: Place eliminate duplicate strlens Previously many of the `post*` implementations would first compute the length of the event's strings in order to determine the event length. Later we would then end up computing the length yet again in `postString`. Now we instead pass the string length to `postStringLen`, avoiding the repeated work. - - - - - 8aafa51c by Ben Gamari at 2024-02-14T14:27:46-05:00 rts/eventlog: Place upper bound on IPE string field lengths The strings in IPE events may be of unbounded length. Limit the lengths of these fields to 64k characters to ensure that we don't exceed the maximum event length. - - - - - 0e60d52c by Zubin Duggal at 2024-02-14T14:27:46-05:00 rts: drop unused postString function - - - - - d8d1333a by Cheng Shao at 2024-02-14T14:28:23-05:00 compiler/rts: fix wasm unreg regression This commit fixes two wasm unreg regressions caught by a nightly pipeline: - Unknown stg_scheduler_loopzh symbol when compiling scheduler.cmm - Invalid _hs_constructor(101) function name when handling ctor - - - - - 264a4fa9 by Owen Shepherd at 2024-02-15T09:41:06-05:00 feat: Add sortOn to Data.List.NonEmpty Adds `sortOn` to `Data.List.NonEmpty`, and adds comments describing when to use it, compared to `sortWith` or `sortBy . comparing`. The aim is to smooth out the API between `Data.List`, and `Data.List.NonEmpty`. This change has been discussed in the [clc issue](https://github.com/haskell/core-libraries-committee/issues/227). - - - - - b57200de by Fendor at 2024-02-15T09:41:47-05:00 Prefer RdrName over OccName for looking up locations in doc renaming step Looking up by OccName only does not take into account when functions are only imported in a qualified way. Fixes issue #24294 Bump haddock submodule to include regression test - - - - - 8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00 JS: add simple optimizer The simple optimizer reduces the size of the code generated by the JavaScript backend without the complexity and performance penalty of the optimizer in GHCJS. Also see #22736 Metric Decrease: libdir size_hello_artifact - - - - - 20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00 base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and modifies the base API to reflect the new RTS flag. CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243 Fixes #24337 - - - - - 08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00 base: export System.Mem.performBlockingMajorGC The corresponding C function was introduced in ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264. Resolves #24228 The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230 Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00 Fix C output for modern C initiative GCC 14 on aarch64 rejects the C code written by GHC with this kind of error: error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion] 68 | *(ffi_arg*)resp = cret; | ^ Add the correct cast. For more information on this see: https://fedoraproject.org/wiki/Changes/PortingToModernC Tested-by: Richard W.M. Jones <rjones at redhat.com> - - - - - 5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00 Bump bytestring submodule to 0.12.1.0 - - - - - 902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00 Add missing BCO handling in scavenge_one. - - - - - 97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Make cast between words and floats real primops (#24331) First step towards fixing #24331. Replace foreign prim imports with real primops. - - - - - a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: add constant folding for bitcast between float and word (#24331) - - - - - 5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: replace stack checks with assertions in casting primops There are RESERVED_STACK_WORDS free words (currently 21) on the stack, so omit the checks. Suggested by Cheng Shao. - - - - - 401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00 Reexport primops from GHC.Float + add deprecation - - - - - 4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00 rts/Hash: Don't iterate over chunks if we don't need to free data When freeing a `HashTable` there is no reason to walk over the hash list before freeing it if the user has not given us a `dataFreeFun`. Noticed while looking at #24410. - - - - - bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00 compiler: add SEQ_CST fence support In addition to existing Acquire/Release fences, this commit adds SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a fence that enforces total memory ordering. The following logic is added: - The MO_SeqCstFence callish MachOp - The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h - MO_SeqCstFence lowering logic in every single GHC codegen backend - - - - - 2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00 testsuite: fix hs_try_putmvar002 for targets without pthread.h hs_try_putmvar002 includes pthread.h and doesn't work on targets without this header (e.g. wasm32). It doesn't need to include this header at all. This was previously unnoticed by wasm CI, though recent toolchain upgrade brought in upstream changes that completely removes pthread.h in the single-threaded wasm32-wasi sysroot, therefore we need to handle that change. - - - - - 1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00 ci: bump ci-images to use updated wasm image This commit bumps our ci-images revision to use updated wasm image. - - - - - 56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00 Bump submodule text to 2.1.1 T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a. Metric Decrease: T17123 - - - - - a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00 rts: remove redundant rCCCS initialization This commit removes the redundant logic of initializing each Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before initProfiling() is called during RTS startup, each Capability's rCCCS has already been assigned CCS_SYSTEM when they're first initialized. - - - - - 7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00 Parser, renamer, type checker for @a-binders (#17594) GHC Proposal 448 introduces binders for invisible type arguments (@a-binders) in various contexts. This patch implements @-binders in lambda patterns and function equations: {-# LANGUAGE TypeAbstractions #-} id1 :: a -> a id1 @t x = x :: t -- @t-binder on the LHS of a function equation higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16) higherRank f = (f 42, f 42) ex :: (Int8, Int16) ex = higherRank (\ @a x -> maxBound @a - x ) -- @a-binder in a lambda pattern in an argument -- to a higher-order function Syntax ------ To represent those @-binders in the AST, the list of patterns in Match now uses ArgPat instead of Pat: data Match p body = Match { ... - m_pats :: [LPat p], + m_pats :: [LArgPat p], ... } + data ArgPat pass + = VisPat (XVisPat pass) (LPat pass) + | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass)) + | XArgPat !(XXArgPat pass) The VisPat constructor represents patterns for visible arguments, which include ordinary value-level arguments and required type arguments (neither is prefixed with a @), while InvisPat represents invisible type arguments (prefixed with a @). Parser ------ In the grammar (Parser.y), the lambda and lambda-cases productions of aexp non-terminal were updated to accept argpats instead of apats: aexp : ... - | '\\' apats '->' exp + | '\\' argpats '->' exp ... - | '\\' 'lcases' altslist(apats) + | '\\' 'lcases' altslist(argpats) ... + argpat : apat + | PREFIX_AT atype Function left-hand sides did not require any changes to the grammar, as they were already parsed with productions capable of parsing @-binders. Those binders were being rejected in post-processing (isFunLhs), and now we accept them. In Parser.PostProcess, patterns are constructed with the help of PatBuilder, which is used as an intermediate data structure when disambiguating between FunBind and PatBind. In this patch we define ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived data structure produced in isFunLhs and consumed in checkFunBind. Renamer ------- Renaming of @-binders builds upon prior work on type patterns, implemented in 2afbddb0f24, which guarantees proper scoping and shadowing behavior of bound type variables. This patch merely defines rnLArgPatsAndThen to process a mix of visible and invisible patterns: + rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn] + rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where + rnArgPatAndThen (VisPat x p) = ... rnLPatAndThen ... + rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ... Common logic between rnArgPats and rnPats is factored out into the rn_pats_general helper. Type checker ------------ Type-checking of @-binders builds upon prior work on lazy skolemisation, implemented in f5d3e03c56f. This patch extends tcMatchPats to handle @-binders. Now it takes and returns a list of LArgPat rather than LPat: tcMatchPats :: ... - -> [LPat GhcRn] + -> [LArgPat GhcRn] ... - -> TcM ([LPat GhcTc], a) + -> TcM ([LArgPat GhcTc], a) Invisible binders in the Match are matched up with invisible (Specified) foralls in the type. This is done with a new clause in the `loop` worker of tcMatchPats: loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a) loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys) ... -- NEW CLAUSE: | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis = ... In addition to that, tcMatchPats no longer discards type patterns. This is done by filterOutErasedPats in the desugarer instead. x86_64-linux-deb10-validate+debug_info Metric Increase: MultiLayerModulesTH_OneShot - - - - - 486979b0 by Jade at 2024-02-19T07:12:13-05:00 Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246 Fixes: #24346 - - - - - 17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00 Fix reST in users guide It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax. - - - - - 35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00 Fix searching for errors in sphinx build - - - - - 4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00 hadrian: fix wasm backend post linker script permissions The post-link.mjs script was incorrectly copied and installed as a regular data file without executable permission, this commit fixes it. - - - - - a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00 testsuite: mark T23540 as fragile on i386 See #24449 for details. - - - - - 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 8a8ac65a by Matthew Craven at 2024-03-23T00:20:52-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 0c48f2b9 by Apoorv Ingle at 2024-03-23T00:21:28-04:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - b72705e9 by Simon Peyton Jones at 2024-03-23T00:22:04-04:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 8f7cfc7e by Tristan Cacqueray at 2024-03-23T00:22:44-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - 5bd8ed53 by Andreas Klebinger at 2024-03-23T16:18:33-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8d67f247 by Ben Gamari at 2024-03-23T16:19:09-04:00 docs: Drop old release notes, add for 9.12.1 - - - - - 7db8c992 by Cheng Shao at 2024-03-25T13:45:46-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. - - - - - 237194ce by Sylvain Henry at 2024-03-25T13:46:27-04:00 Lexer: fix imports for Alex 3.5.1 (#24583) - - - - - 810660b7 by Cheng Shao at 2024-03-25T22:19:16-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - d2ba41e8 by Alan Zimmerman at 2024-03-25T22:19:51-04:00 EPA: do not duplicate comments in signature RHS - - - - - 32a8103f by Rodrigo Mesquita at 2024-03-26T21:16:12-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. - - - - - bf65a7c3 by Rodrigo Mesquita at 2024-03-26T21:16:48-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 - - - - - cfeb70d3 by Rodrigo Mesquita at 2024-03-26T21:17:24-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 13223f6d by Serge S. Gulin at 2024-03-27T07:28:51-04:00 JS: `h$rts_isProfiled` is removed from `profiling` and left its version at `rts/js/config.js` - - - - - 0acfe391 by Alan Zimmerman at 2024-03-27T07:29:27-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. - - - - - cd0fb82f by Alan Zimmerman at 2024-03-27T19:33:08+00:00 EPA: Fix FamDecl range The span was incorrect if opt_datafam_kind_sig was empty - - - - - f8f384a8 by Ben Gamari at 2024-03-29T01:23:03-04:00 Fix type of _get_osfhandle foreign import Fixes #24601. - - - - - 00d3ecf0 by Alan Zimmerman at 2024-03-29T12:19:10+00:00 EPA: Extend StringLiteral range to include trailing commas This goes slightly against the exact printing philosophy where trailing decorations should be in an annotation, but the practicalities of adding it to the WarningTxt environment, and the problems caused by deviating do not make a more principles approach worthwhile. - - - - - efab3649 by brandon s allbery kf8nh at 2024-03-31T20:04:01-04:00 clarify Note [Preproccesing invocations] - - - - - c8a4c050 by Ben Gamari at 2024-04-02T12:50:35-04:00 rts: Fix TSAN_ENABLED CPP guard This should be `#if defined(TSAN_ENABLED)`, not `#if TSAN_ENABLED`, lest we suffer warnings. - - - - - e91dad93 by Cheng Shao at 2024-04-02T12:50:35-04:00 rts: fix errors when compiling with TSAN This commit fixes rts compilation errors when compiling with TSAN: - xxx_FENCE macros are redefined and trigger CPP warnings. - Use SIZEOF_W. WORD_SIZE_IN_BITS is provided by MachDeps.h which Cmm.h doesn't include by default. - - - - - a9ab9455 by Cheng Shao at 2024-04-02T12:50:35-04:00 rts: fix clang-specific errors when compiling with TSAN This commit fixes clang-specific rts compilation errors when compiling with TSAN: - clang doesn't have -Wtsan flag - Fix prototype of ghc_tsan_* helper functions - __tsan_atomic_* functions aren't clang built-ins and sanitizer/tsan_interface_atomic.h needs to be included - On macOS, TSAN runtime library is libclang_rt.tsan_osx_dynamic.dylib, not libtsan. -fsanitize-thread as a link-time flag will take care of linking the TSAN runtime library anyway so remove tsan as an rts extra library - - - - - 865bd717 by Cheng Shao at 2024-04-02T12:50:35-04:00 compiler: fix github link to __tsan_memory_order in a comment - - - - - 07cb627c by Cheng Shao at 2024-04-02T12:50:35-04:00 ci: improve TSAN CI jobs - Run TSAN jobs with +thread_sanitizer_cmm which enables Cmm instrumentation as well. - Run TSAN jobs in deb12 which ships gcc-12, a reasonably recent gcc that @bgamari confirms he's using in #GHC:matrix.org. Ideally we should be using latest clang release for latest improvements in sanitizers, though that's left as future work. - Mark TSAN jobs as manual+allow_failure in validate pipelines. The purpose is to demonstrate that we have indeed at least fixed building of TSAN mode in CI without blocking the patch to land, and once merged other people can begin playing with TSAN using their own dev setups and feature branches. - - - - - a1c18c7b by Andrei Borzenkov at 2024-04-02T12:51:11-04:00 Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy (#24299, #23639) This patch implements refactoring which is a prerequisite to updating kind checking of type patterns. This is a huge simplification of the main worker that checks kind of HsType. It also fixes the issues caused by previous code duplication, e.g. that we didn't add module finalizers from splices in inference mode. - - - - - 817e8936 by Rodrigo Mesquita at 2024-04-02T20:13:05-04:00 th: Hide the Language.Haskell.TH.Lib.Internal module from haddock Fixes #24562 - - - - - b36ee57b by Sylvain Henry at 2024-04-02T20:13:46-04:00 JS: reenable h$appendToHsString optimization (#24495) The optimization introducing h$appendToHsString wasn't kicking in anymore (while it did in 9.8.1) because of the changes introduced in #23270 (7e0c8b3bab30). This patch reenables the optimization by matching on case-expression, as done in Cmm for unpackCString# standard thunks. The test is also T24495 added in the next commits (two commits for ease of backporting to 9.8). - - - - - 527616e9 by Sylvain Henry at 2024-04-02T20:13:46-04:00 JS: fix h$appendToHsString implementation (#24495) h$appendToHsString needs to wrap its argument in an updatable thunk to behave like unpackAppendCString#. Otherwise if a SingleEntry thunk is passed, it is stored as-is in a CONS cell, making the resulting list impossible to deepseq (forcing the thunk doesn't update the contents of the CONS cell)! The added test checks that the optimization kicks in and that h$appendToHsString works as intended. Fix #24495 - - - - - faa30b41 by Simon Peyton Jones at 2024-04-02T20:14:22-04:00 Deal with duplicate tyvars in type declarations GHC was outright crashing before this fix: #24604 - - - - - e0b0c717 by Simon Peyton Jones at 2024-04-02T20:14:58-04:00 Try using MCoercion in exprIsConApp_maybe This is just a simple refactor that makes exprIsConApp_maybe a little bit more direct, simple, and efficient. Metrics: compile_time/bytes allocated geo. mean -0.1% minimum -2.0% maximum -0.0% Not a big gain, but worthwhile given that the code is, if anything, easier to grok. - - - - - 15f4d867 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Initial ./configure support for selecting I/O managers In this patch we just define new CPP vars, but don't yet use them or replace the existing approach. That will follow. The intention here is that every I/O manager can be enabled/disabled at GHC build time (subject to some constraints). More than one I/O manager can be enabled to be built. At least one I/O manager supporting the non-threaded RTS must be enabled as well as at least one supporting the non-threaded RTS. The I/O managers enabled here will become the choices available at runtime at RTS startup (in later patches). The choice can be made with RTS flags. There are separate sets of choices for the threaded and non-threaded RTS ways, because most I/O managers are specific to these ways. Furthermore we must establish a default I/O manager for the threaded and non-threaded RTS. Most I/O managers are platform-specific so there are checks to ensure each one can be enabled on the platform. Such checks are also where (in future) any system dependencies (e.g. libraries) can be checked. The output is a set of CPP flags (in the mk/config.h file), with one flag per named I/O manager: * IOMGR_BUILD_<name> : which ones should be built (some) * IOMGR_DEFAULT_NON_THREADED_<name> : which one is default (exactly one) * IOMGR_DEFAULT_THREADED_<name> : which one is default (exactly one) and a set of derived flags in IOManager.h * IOMGR_ENABLED_<name> : enabled for the current RTS way Note that IOMGR_BUILD_<name> just says that an I/O manager will be built for _some_ RTS way (i.e. threaded or non-threaded). The derived flags IOMGR_ENABLED_<name> in IOManager.h say if each I/O manager is enabled in the "current" RTS way. These are the ones that can be used for conditional compilation of the I/O manager code. Co-authored-by: Pi Delport <pi at well-typed.com> - - - - - 85b0f87a by Duncan Coutts at 2024-04-03T01:27:17-04:00 Change the handling of the RTS flag --io-manager= Now instead of it being just used on Windows to select between the WinIO vs the MIO or Win32-legacy I/O managers, it is now used on all platforms for selecting the I/O manager to use. Right now it remains the case that there is only an actual choice on Windows, but that will change later. Document the --io-manager flag in the user guide. This change is also reflected in the RTS flags types in the base library. Deprecate the export of IoSubSystem from GHC.RTS.Flags with a message to import it from GHC.IO.Subsystem. The way the 'IoSubSystem' is detected also changes. Instead of looking at the RTS flag, there is now a C bool global var in the RTS which gets set on startup when the I/O manager is selected. This bool var says whether the selected I/O manager classifies as "native" on Windows, which in practice means the WinIO I/O manager has been selected. Similarly, the is_io_mng_native_p RTS helper function is re-implemented in terms of the selected I/O manager, rather than based on the RTS flags. We do however remove the ./configure --native-io-manager flag because we're bringing the WinIO/MIO/Win32-legacy choice under the new general scheme for selecting I/O managers, and that new scheme involves no ./configure time user choices, just runtime RTS flag choices. - - - - - 1a8f020f by Duncan Coutts at 2024-04-03T01:27:17-04:00 Convert {init,stop,exit}IOManager to switch style Rather than ad-hoc cpp conitionals on THREADED_RTS and mingw32_HOST_OS, we use a style where we switch on the I/O manager impl, with cases for each I/O manager impl. - - - - - a5bad3d2 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Split up the CapIOManager content by I/O manager Using the new IOMGR_ENABLED_<name> CPP defines. - - - - - 1d36e609 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Convert initIOManagerAfterFork and wakeupIOManager to switch style - - - - - c2f26f36 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move most of waitRead#/Write# from cmm to C Moves it into the IOManager.c where we can follow the new pattern of switching on the selected I/O manager. - - - - - 457705a8 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move most of the delay# impl from cmm to C Moves it into the IOManager.c where we can follow the new pattern of switching on the selected I/O manager. Uses a new IOManager API: syncDelay, following the naming convention of sync* for thread-synchronous I/O & timer/delay operations. As part of porting from cmm to C, we maintain the rule that the why_blocked gets accessed using load acquire and store release atomic memory operations. There was one exception to this rule: in the delay# primop cmm code on posix (not win32), the why_blocked was being updated using a store relaxed, not a store release. I've no idea why. In this convesion I'm playing it safe here and using store release consistently. - - - - - e93058e0 by Duncan Coutts at 2024-04-03T01:27:18-04:00 insertIntoSleepingQueue is no longer public No longer defined in IOManager.h, just a private function in IOManager.c. Since it is no longer called from cmm code, just from syncDelay. It ought to get moved further into the select() I/O manager impl, rather than living in IOManager.c. On the other hand appendToIOBlockedQueue is still called from cmm code in the win32-legacy I/O manager primops async{Read,Write}#, and it is also used by the select() I/O manager. Update the CPP and comments to reflect this. - - - - - 60ce9910 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move anyPendingTimeoutsOrIO impl from .h to .c The implementation is eventually going to need to use more private things, which will drag in unwanted includes into IOManager.h, so it's better to move the impl out of the header file and into the .c file, at the slight cost of it no longer being inline. At the same time, change to the "switch (iomgr_type)" style. - - - - - f70b8108 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Take a simpler approach to gcc warnings in IOManager.c We have lots of functions with conditional implementations for different I/O managers. Some functions, for some I/O managers, naturally have implementations that do nothing or barf. When only one such I/O manager is enabled then the whole function implementation will have an implementation that does nothing or barfs. This then results in warnings from gcc that parameters are unused, or that the function should be marked with attribute noreturn (since barf does not return). The USED_IF_THREADS trick for fine-grained warning supression is fine for just two cases, but an equivalent here would need USED_IF_THE_ONLY_ENABLED_IOMGR_IS_X_OR_Y which would have combinitorial blowup. So we take a coarse grained approach and simply disable these two warnings for the whole file. So we use a GCC pragma, with its handy push/pop support: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsuggest-attribute=noreturn" #pragma GCC diagnostic ignored "-Wunused-parameter" ... #pragma GCC diagnostic pop - - - - - b48805b9 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add a new trace class for the iomanager It makes sense now for it to be separate from the scheduler class of tracers. Enabled with +RTS -Do. Document the -Do debug flag in the user guide. - - - - - f0c1f862 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Have the throwTo impl go via (new) IOManager APIs rather than directly operating on the IO manager's data structures. Specifically, when thowing an async exception to a thread that is blocked waiting for I/O or waiting for a timer, then we want to cancel that I/O waiting or cancel the timer. Currently this is done directly in removeFromQueues() in RaiseAsync.c. We want it to go via proper APIs both for modularity but also to let us support multiple I/O managers. So add sync{IO,Delay}Cancel, which is the cancellation for the corresponding sync{IO,Delay}. The implementations of these use the usual "switch (iomgr_type)" style. - - - - - 4f9e9c4e by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move awaitEvent into a proper IOManager API and have the scheduler use it. Previously the scheduler calls awaitEvent directly, and awaitEvent is implemented directly in the RTS I/O managers (select, win32). This relies on the old scheme where there's a single active I/O manager for each platform and RTS way. We want to move that to go via an API in IOManager.{h,c} which can then call out to the active I/O manager. Also take the opportunity to split awaitEvent into two. The existing awaitEvent has a bool wait parameter, to say if the call should be blocking or non-blocking. We split this into two separate functions: pollCompletedTimeoutsOrIO and awaitCompletedTimeoutsOrIO. We split them for a few reasons: they have different post-conditions (specifically the await version is supposed to guarantee that there are threads runnable when it completes). Secondly, it is also anticipated that in future I/O managers the implementations of the two cases will be simpler if they are separated. - - - - - 5ad4b30f by Duncan Coutts at 2024-04-03T01:27:18-04:00 Rename awaitEvent in select and win32 I/O managers These are now just called from IOManager.c and are the per-I/O manager backend impls (whereas previously awaitEvent was the entry point). Follow the new naming convention in the IOManager.{h,c} of awaitCompletedTimeoutsOrIO, with the I/O manager's name as a suffix: so awaitCompletedTimeoutsOrIO{Select,Win32}. - - - - - d30c6bc6 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Tidy up a couple things in Select.{h,c} Use the standard #include {Begin,End}Private.h style rather than RTS_PRIVATE on individual decls. And conditionally build the code for the select I/O manager based on the new CPP IOMGR_ENABLED_SELECT rather than on THREADED_RTS. - - - - - 4161f516 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add an IOManager API for scavenging TSO blocked_info When the GC scavenges a TSO it needs to scavenge the tso->blocked_info but the blocked_info is a big union and what lives there depends on the two->why_blocked, which for I/O-related reasons is something that in principle is the responsibility of the I/O manager and not the GC. So the right thing to do is for the GC to ask the I/O manager to sscavenge the blocked_info if it encounters any I/O-related why_blocked reasons. So we add scavengeTSOIOManager in IOManager.{h,c} with the usual style. Now as it happens, right now, there is no special scavenging to do, so the implementation of scavengeTSOIOManager is a fancy no-op. That's because the select I/O manager uses only the fd and target members, which are not GC pointers, and the win32-legacy I/O manager _ought_ to be using GC-managed heap objects for the StgAsyncIOResult but it is actually usingthe C heap, so again no GC pointers. If the win32-legacy were doing this more sensibly, then scavengeTSOIOManager would be the right place to do the GC magic. Future I/O managers will need GC heap objects in the tso->blocked_info and will make use of this functionality. - - - - - 94a87d21 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add I/O manager API notifyIOManagerCapabilitiesChanged Used in setNumCapabilities. It only does anything for MIO on Posix. Previously it always invoked Haskell code, but that code only did anything on non-Windows (and non-JS), and only threaded. That currently effectively means the MIO I/O manager on Posix. So now it only invokes it for the MIO Posix case. - - - - - 3be6d591 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Select an I/O manager early in RTS startup We need to select the I/O manager to use during startup before the per-cap I/O manager initialisation. - - - - - aaa294d0 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Make struct CapIOManager be fully opaque Provide an opaque (forward) definition in Capability.h (since the cap contains a *CapIOManager) and then only provide a full definition in a new file IOManagerInternals.h. This new file is only supposed to be included by the IOManager implementation, not by its users. So that means IOManager.c and individual I/O manager implementations. The posix/Signals.c still needs direct access, but that should be eliminated. Anything that needs direct access either needs to be clearly part of an I/O manager (e.g. the sleect() one) or go via a proper API. - - - - - 877a2a80 by Duncan Coutts at 2024-04-03T01:27:18-04:00 The select() I/O manager does have some global initialisation It's just to make sure an exception CAF is a GC root. - - - - - 9c51473b by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add tracing for the main I/O manager actions Using the new tracer class. Note: The unconditional definition of showIOManager should be compatible with the debugTrace change in 7c7d1f6. Co-authored-by: Pi Delport <pi at well-typed.com> - - - - - c7d3e3a3 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Include the default I/O manager in the +RTS --info output Document the extra +RTS --info output in the user guide - - - - - 8023bad4 by Duncan Coutts at 2024-04-03T01:27:18-04:00 waitRead# / waitWrite# do not work for win32-legacy I/O manager Previously it was unclear that they did not work because the code path was shared with other I/O managers (in particular select()). Following the code carefully shows that what actually happens is that the calling thread would block forever: the thread will be put into the blocked queue, but no other action is scheduled that will ever result in it getting unblocked. It's better to just fail loudly in case anyone accidentally calls it, also it's less confusing code. - - - - - 83a74d20 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Conditionally ignore some GCC warnings Some GCC versions don't know about some warnings, and they complain that we're ignoring unknown warnings. So we try to ignore the warning based on the GCC version. - - - - - 1adc6fa4 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Accept changes to base-exports All the changes are in fact not changes at all. Previously, the IoSubSystem data type was defined in GHC.RTS.Flags and exported from both GHC.RTS.Flags and GHC.IO.SubSystem. Now, the data type is defined in GHC.IO.SubSystem and still exported from both modules. Therefore, the same exports and same instances are still available from both modules. But the base-exports records only the defining module, and so it looks like a change when it is fully compatible. Related: we do add a deprecation to the export of the type via GHC.RTS.Flags, telling people to use the export from GHC.IO.SubSystem. Also the sort order for some unrelated Show instances changed. No idea why. The same changes apply in the other versions, with a few more changes due to sort order weirdness. - - - - - 8d950968 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Accept metric decrease in T12227 I can't think of any good reason that anything in this MR should have changed the number of allocations, up or down. (Yes this is an empty commit.) Metric Decrease: T12227 - - - - - e869605e by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Several improvements to the handling of coercions * Make `mkSymCo` and `mkInstCo` smarter Fixes #23642 * Fix return role of `SelCo` in the coercion optimiser. Fixes #23617 * Make the coercion optimiser `opt_trans_rule` work better for newtypes Fixes #23619 - - - - - 1efd0714 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 FloatOut: improve floating for join point See the new Note [Floating join point bindings]. * Completely get rid of the complicated join_ceiling nonsense, which I have never understood. * Do not float join points at all, except perhaps to top level. * Some refactoring around wantToFloat, to treat Rec and NonRec more uniformly - - - - - 9c00154d by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Improve eta-expansion through call stacks See Note [Eta expanding through CallStacks] in GHC.Core.Opt.Arity This is a one-line change, that fixes an inconsistency - || isCallStackPredTy ty + || isCallStackPredTy ty || isCallStackTy ty - - - - - 95a9a172 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Spelling, layout, pretty-printing only - - - - - bdf1660f by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Improve exprIsConApp_maybe a little Eliminate a redundant case at birth. This sometimes reduces Simplifier iterations. See Note [Case elim in exprIsConApp_maybe]. - - - - - 609cd32c by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Inline GHC.HsToCore.Pmc.Solver.Types.trvVarInfo When exploring compile-time regressions after meddling with the Simplifier, I discovered that GHC.HsToCore.Pmc.Solver.Types.trvVarInfo was very delicately balanced. It's a small, heavily used, overloaded function and it's important that it inlines. By a fluke it was before, but at various times in my journey it stopped doing so. So I just added an INLINE pragma to it; no sense in depending on a delicately-balanced fluke. - - - - - ae24c9bc by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Slight improvement in WorkWrap Ensure that WorkWrap preserves lambda binders, in case of join points. Sadly I have forgotten why I made this change (it was while I was doing a lot of meddling in the Simplifier, but * it does no harm, * it is slightly more efficient, and * presumably it made something better! Anyway I have kept it in a separate commit. - - - - - e9297181 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Use named record fields for the CastIt { ... } data constructor This is a pure refactor - - - - - b4581e23 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Remove a long-commented-out line Pure refactoring - - - - - e026bdf2 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The main changes are below. There are also many new or rewritten Notes. Avoiding simplifying repeatedly ~~~~~~~~~~~~~~~ See Note [Avoiding simplifying repeatedly] * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env. Currently used only for the next point: avoiding repeatedly simplifying coercions. * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] * Improve the case-merge transformation: - Move the main code to `GHC.Core.Utils.mergeCaseAlts`, to join `filterAlts` and friends. See Note [Merge Nested Cases] in GHC.Core.Utils. - Add a new case for `tagToEnum#`; see wrinkle (MC3). - Add a new case to look through join points: see wrinkle (MC4) postInlineUnconditionally ~~~~~~~~~~~~~~~~~~~~~~~~~ * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. * Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. * Improve occurrence analyis for bottoming function calls, to help postInlineUnconditionally. See Note [Bottoming function calls] in GHC.Core.Opt.OccurAnal Inlining generally ~~~~~~~~~~~~~~~~~~ * In GHC.Core.Opt.Simplify.Utils.interestingCallContext, use RhsCtxt NonRecursive (not BoringCtxt) for a plain-seq case. See Note [Seq is boring] Also, wrinkle (SB1), inline in that `seq` context only for INLINE functions (UnfWhen guidance). * In GHC.Core.Opt.Simplify.Utils.interestingArg, - return ValueArg for OtherCon [c1,c2, ...], but - return NonTrivArg for OtherCon [] This makes a function a little less likely to inline if all we know is that the argument is evaluated, but nothing else. * isConLikeUnfolding is no longer true for OtherCon {}. This propagates to exprIsConLike. Con-like-ness has /positive/ information. Join points ~~~~~~~~~~~ * Be very careful about inlining join points. See these two long Notes Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline * When making join points, don't do so if the join point is so small it will immediately be inlined; check uncondInlineJoin. * In GHC.Core.Opt.Simplify.Inline.tryUnfolding, improve the inlining heuristics for join points. In general we /do not/ want to inline join points /even if they are small/. See Note [Duplicating join points] GHC.Core.Opt.Simplify.Iteration. But sometimes we do: see Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline; and the new `isBetterUnfoldingThan` function. * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * In GHC.Core.Unfold.sizeExpr, make jumps small, so that we don't penalise having a non-inlined join point. Performance changes ~~~~~~~~~~~~~~~~~~~ * Binary sizes fall by around 2.6%, according to nofib. * Compile times improve slightly. Here are the figures over 1%. I investiate the biggest differnce in T18304. It's a very small module, just a few hundred nodes. The large percentage difffence is due to a single function that didn't quite inline before, and does now, making code size a bit bigger. I decided gains outweighed the losses. Metrics: compile_time/bytes allocated (changes over +/- 1%) ------------------------------------------------ CoOpt_Singletons(normal) -9.2% GOOD LargeRecord(normal) -23.5% GOOD MultiComponentModulesRecomp(normal) +1.2% MultiLayerModulesTH_OneShot(normal) +4.1% BAD PmSeriesS(normal) -3.8% PmSeriesV(normal) -1.5% T11195(normal) -1.3% T12227(normal) -20.4% GOOD T12545(normal) -3.2% T12707(normal) -2.1% GOOD T13253(normal) -1.2% T13253-spj(normal) +8.1% BAD T13386(normal) -3.1% GOOD T14766(normal) -2.6% GOOD T15164(normal) -1.4% T15304(normal) +1.2% T15630(normal) -8.2% T15630a(normal) NEW T15703(normal) -14.7% GOOD T16577(normal) -2.3% GOOD T17516(normal) -39.7% GOOD T18140(normal) +1.2% T18223(normal) -17.1% GOOD T18282(normal) -5.0% GOOD T18304(normal) +10.8% BAD T18923(normal) -2.9% GOOD T1969(normal) +1.0% T19695(normal) -1.5% T20049(normal) -12.7% GOOD T21839c(normal) -4.1% GOOD T3064(normal) -1.5% T3294(normal) +1.2% BAD T4801(normal) +1.2% T5030(normal) -15.2% GOOD T5321Fun(normal) -2.2% GOOD T6048(optasm) -16.8% GOOD T783(normal) -1.2% T8095(normal) -6.0% GOOD T9630(normal) -4.7% GOOD T9961(normal) +1.9% BAD WWRec(normal) -1.4% info_table_map_perf(normal) -1.3% parsing001(normal) +1.5% geo. mean -2.0% minimum -39.7% maximum +10.8% * Runtimes generally improve. In the testsuite perf/should_run gives: Metrics: runtime/bytes allocated ------------------------------------------ Conversions(normal) -0.3% T13536a(optasm) -41.7% GOOD T4830(normal) -0.1% haddock.Cabal(normal) -0.1% haddock.base(normal) -0.1% haddock.compiler(normal) -0.1% geo. mean -0.8% minimum -41.7% maximum +0.0% * For runtime, nofib is a better test. The news is mostly good. Here are the number more than +/- 0.1%: # bytes allocated ==========================++========== imaginary/digits-of-e1 || -14.40% imaginary/digits-of-e2 || -4.41% imaginary/paraffins || -0.17% imaginary/rfib || -0.15% imaginary/wheel-sieve2 || -0.10% real/compress || -0.47% real/fluid || -0.10% real/fulsom || +0.14% real/gamteb || -1.47% real/gg || -0.20% real/infer || +0.24% real/pic || -0.23% real/prolog || -0.36% real/scs || -0.46% real/smallpt || +4.03% shootout/k-nucleotide || -20.23% shootout/n-body || -0.42% shootout/spectral-norm || -0.13% spectral/boyer2 || -3.80% spectral/constraints || -0.27% spectral/hartel/ida || -0.82% spectral/mate || -20.34% spectral/para || +0.46% spectral/rewrite || +1.30% spectral/sphere || -0.14% ==========================++========== geom mean || -0.59% real/smallpt has a huge nest of local definitions, and I could not pin down a reason for a regression. But there are three big wins! Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12707 T13386 T13536a T14766 T15703 T16577 T17516 T18223 T18282 T18923 T21839c T20049 T5321Fun T5030 T6048 T8095 T9630 T783 Metric Increase: MultiLayerModulesTH_OneShot T13253-spj T18304 T18698a T9961 T3294 - - - - - 27db3c5e by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Testsuite message changes from simplifier improvements - - - - - 271a7812 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Account for bottoming functions in OccurAnal This fixes #24582, a small but long-standing bug - - - - - 0fde229f by Ben Gamari at 2024-04-04T07:04:58-04:00 testsuite: Introduce template-haskell-exports test - - - - - 0c4a9686 by Luite Stegeman at 2024-04-04T07:05:39-04:00 Update correct counter in bumpTickyAllocd - - - - - 5f085d3a by Fendor at 2024-04-04T14:47:33-04:00 Replace `SizedSeq` with `FlatBag` for flattened structure LinkedLists are notoriously memory ineffiecient when all we do is traversing a structure. As 'UnlinkedBCO' has been identified as a data structure that impacts the overall memory usage of GHCi sessions, we avoid linked lists and prefer flattened structure for storing. We introduce a new memory efficient representation of sequential elements that has special support for the cases: * Empty * Singleton * Tuple Elements This improves sharing in the 'Empty' case and avoids the overhead of 'Array' until its constant overhead is justified. - - - - - 82cfe10c by Fendor at 2024-04-04T14:47:33-04:00 Compact FlatBag array representation `Array` contains three additional `Word`'s we do not need in `FlatBag`. Move `FlatBag` to `SmallArray`. Expand the API of SmallArray by `sizeofSmallArray` and add common traversal functions, such as `mapSmallArray` and `foldMapSmallArray`. Additionally, allow users to force the elements of a `SmallArray` via `rnfSmallArray`. - - - - - 36a75b80 by Andrei Borzenkov at 2024-04-04T14:48:10-04:00 Change how invisible patterns represented in haskell syntax and TH AST (#24557) Before this patch: data ArgPat p = InvisPat (LHsType p) | VisPat (LPat p) With this patch: data Pat p = ... | InvisPat (LHsType p) ... And the same transformation in the TH land. The rest of the changes is just updating code to handle new AST and writing tests to check if it is possible to create invalid states using TH. Metric Increase: MultiLayerModulesTH_OneShot - - - - - 28009fbc by Matthew Pickering at 2024-04-04T14:48:46-04:00 Fix off by one error in seekBinNoExpand and seekBin - - - - - 9b9e031b by Ben Gamari at 2024-04-04T21:30:08-04:00 compiler: Allow more types in GHCForeignImportPrim For many, many years `GHCForeignImportPrim` has suffered from the rather restrictive limitation of not allowing any non-trivial types in arguments or results. This limitation was justified by the code generator allegely barfing in the presence of such types. However, this restriction appears to originate well before the NCG rewrite and the new NCG does not appear to have any trouble with such types (see the added `T24598` test). Lift this restriction. Fixes #24598. - - - - - 1324b862 by Alan Zimmerman at 2024-04-04T21:30:44-04:00 EPA: Use EpaLocation not SrcSpan in ForeignDecls This allows us to update them for makeDeltaAst in ghc-exactprint - - - - - 19883a23 by Alan Zimmerman at 2024-04-05T16:58:17-04:00 EPA: Use EpaLocation for RecFieldsDotDot So we can update it to a delta position in makeDeltaAst if needed. - - - - - e8724327 by Matthew Pickering at 2024-04-05T16:58:53-04:00 Remove accidentally committed test.hs - - - - - 88cb3e10 by Fendor at 2024-04-08T09:03:34-04:00 Avoid UArray when indexing is not required `UnlinkedBCO`'s can occur many times in the heap. Each `UnlinkedBCO` references two `UArray`'s but never indexes them. They are only needed to encode the elements into a `ByteArray#`. The three words for the lower bound, upper bound and number of elements are essentially unused, thus we replace `UArray` with a wrapper around `ByteArray#`. This saves us up to three words for each `UnlinkedBCO`. Further, to avoid re-allocating these words for `ResolvedBCO`, we repeat the procedure for `ResolvedBCO` and add custom `Binary` and `Show` instances. For example, agda's repl session has around 360_000 UnlinkedBCO's, so avoiding these three words is already saving us around 8MB residency. - - - - - f2cc1107 by Fendor at 2024-04-08T09:04:11-04:00 Never UNPACK `FastMutInt` for counting z-encoded `FastString`s In `FastStringTable`, we count the number of z-encoded FastStrings that exist in a GHC session. We used to UNPACK the counters to not waste memory, but live retainer analysis showed that we allocate a lot of `FastMutInt`s, retained by `mkFastZString`. We lazily compute the `FastZString`, only incrementing the counter when the `FastZString` is forced. The function `mkFastStringWith` calls `mkZFastString` and boxes the `FastMutInt`, leading to the following core: mkFastStringWith = \ mk_fs _ -> = case stringTable of { FastStringTable _ n_zencs segments# _ -> ... case ((mk_fs (I# ...) (FastMutInt n_zencs)) `cast` <Co:2> :: ...) ... Marking this field as `NOUNPACK` avoids this reboxing, eliminating the allocation of a fresh `FastMutInt` on every `FastString` allocation. - - - - - c6def949 by Matthew Pickering at 2024-04-08T16:06:51-04:00 Force in_multi to avoid retaining entire hsc_env - - - - - fbb91a63 by Fendor at 2024-04-08T16:06:51-04:00 Eliminate name thunk in declaration fingerprinting Thunk analysis showed that we have about 100_000 thunks (in agda and `-fwrite-simplified-core`) pointing to the name of the name decl. Forcing this thunk fixes this issue. The thunk created here is retained by the thunk created by forkM, it is better to eagerly force this because the result (a `Name`) is already retained indirectly via the `IfaceDecl`. - - - - - 3b7b0c1c by Alan Zimmerman at 2024-04-08T16:07:27-04:00 EPA: Use EpaLocation in WarningTxt This allows us to use an EpDelta if needed when using makeDeltaAst. - - - - - 12b997df by Alan Zimmerman at 2024-04-08T16:07:27-04:00 EPA: Move DeltaPos and EpaLocation' into GHC.Types.SrcLoc This allows us to use a NoCommentsLocation for the possibly trailing comma location in a StringLiteral. This in turn allows us to correctly roundtrip via makeDeltaAst. - - - - - 868c8a78 by Fendor at 2024-04-09T08:51:50-04:00 Prefer packed representation for CompiledByteCode As there are many 'CompiledByteCode' objects alive during a GHCi session, representing its element in a more packed manner improves space behaviour at a minimal cost. When running GHCi on the agda codebase, we find around 380 live 'CompiledByteCode' objects. Packing their respective 'UnlinkedByteCode' can save quite some pointers. - - - - - be3bddde by Alan Zimmerman at 2024-04-09T08:52:26-04:00 EPA: Capture all comments in a ClassDecl Hopefully the final fix needed for #24533 - - - - - 3d0806fc by Jade at 2024-04-10T05:39:53-04:00 Validate -main-is flag using parseIdentifier Fixes #24368 - - - - - dd530bb7 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: free error message before returning Fixes a memory leak in rts/linker/PEi386.c - - - - - e008a19a by Alexis King at 2024-04-10T05:40:29-04:00 linker: Avoid linear search when looking up Haskell symbols via dlsym See the primary Note [Looking up symbols in the relevant objects] for a more in-depth explanation. When dynamically loading a Haskell symbol (typical when running a splice or GHCi expression), before this commit we would search for the symbol in all dynamic libraries that were loaded. However, this could be very inefficient when too many packages are loaded (which can happen if there are many package dependencies) because the time to lookup the would be linear in the number of packages loaded. This commit drastically improves symbol loading performance by introducing a mapping from units to the handles of corresponding loaded dlls. These handles are returned by dlopen when we load a dll, and can then be used to look up in a specific dynamic library. Looking up a given Name is now much more precise because we can get lookup its unit in the mapping and lookup the symbol solely in the handles of the dynamic libraries loaded for that unit. In one measurement, the wait time before the expression was executed went from +-38 seconds down to +-2s. This commit also includes Note [Symbols may not be found in pkgs_loaded], explaining the fallback to the old behaviour in case no dll can be found in the unit mapping for a given Name. Fixes #23415 Co-authored-by: Rodrigo Mesquita (@alt-romes) - - - - - dcfaa190 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: Make addDLL a wrapper around loadNativeObj Rewrite the implementation of `addDLL` as a wrapper around the more principled `loadNativeObj` rts linker function. The latter should be preferred while the former is preserved for backwards compatibility. `loadNativeObj` was previously only available on ELF platforms, so this commit further refactors the rts linker to transform loadNativeObj_ELF into loadNativeObj_POSIX, which is available in ELF and MachO platforms. The refactor made it possible to remove the `dl_mutex` mutex in favour of always using `linker_mutex` (rather than a combination of both). Lastly, we implement `loadNativeObj` for Windows too. - - - - - 12931698 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 Use symbol cache in internal interpreter too This commit makes the symbol cache that was used by the external interpreter available for the internal interpreter too. This follows from the analysis in #23415 that suggests the internal interpreter could benefit from this cache too, and that there is no good reason not to have the cache for it too. It also makes it a bit more uniform to have the symbol cache range over both the internal and external interpreter. This commit also refactors the cache into a function which is used by both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the caching logic to `lookupSymbolInDLL` too. - - - - - dccd3ea1 by Ben Gamari at 2024-04-10T05:40:29-04:00 testsuite: Add test for lookupSymbolInNativeObj - - - - - 1b1a92bd by Alan Zimmerman at 2024-04-10T05:41:05-04:00 EPA: Remove unnecessary XRec in CompleteMatchSig The XRec for [LIdP pass] is not needed for exact printing, remove it. - - - - - 6e18ce2b by Ben Gamari at 2024-04-12T08:16:09-04:00 users-guide: Clarify language extension documentation Over the years the users guide's language extension documentation has gone through quite a few refactorings. In the process some of the descriptions have been rendered non-sensical. For instance, the description of `NoImplicitPrelude` actually describes the semantics of `ImplicitPrelude`. To fix this we: * ensure that all extensions are named in their "positive" sense (e.g. `ImplicitPrelude` rather than `NoImplicitPrelude`). * rework the documentation to avoid flag-oriented wording like "enable" and "disable" * ensure that the polarity of the documentation is consistent with reality. Fixes #23895. - - - - - a933aff3 by Zubin Duggal at 2024-04-12T08:16:45-04:00 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - 23c3e624 by Andreas Klebinger at 2024-04-12T08:17:21-04:00 RTS: Emit warning when -M < -H Fixes #24487 - - - - - d23afb8c by Ben Gamari at 2024-04-12T08:17:56-04:00 testsuite: Add broken test for CApiFFI with -fprefer-bytecode See #24634. - - - - - a4bb3a51 by Ben Gamari at 2024-04-12T08:18:32-04:00 base: Deprecate GHC.Pack As proposed in #21461. Closes #21540. - - - - - 55eb8c98 by Ben Gamari at 2024-04-12T08:19:08-04:00 ghc-internal: Fix mentions of ghc-internal in deprecation warnings Closes #24609. - - - - - b0fbd181 by Ben Gamari at 2024-04-12T08:19:44-04:00 rts: Implement set_initial_registers for AArch64 Fixes #23680. - - - - - 14c9ec62 by Ben Gamari at 2024-04-12T08:20:20-04:00 ghcup-metadata: Use Debian 9 binaries on Ubuntu 16, 17 Closes #24646. - - - - - 35a1621e by Ben Gamari at 2024-04-12T08:20:55-04:00 Bump unix submodule to 2.8.5.1 Closes #24640. - - - - - a1c24df0 by Finley McIlwaine at 2024-04-12T08:21:31-04:00 Correct default -funfolding-use-threshold in docs - - - - - 0255d03c by Oleg Grenrus at 2024-04-12T08:22:07-04:00 FastString is a __Modified__ UTF-8 - - - - - c3489547 by Matthew Pickering at 2024-04-12T13:13:44-04:00 rts: Improve tracing message when nursery is resized It is sometimes more useful to know how much bigger or smaller the nursery got when it is resized. In particular I am trying to investigate situations where we end up with fragmentation due to the nursery (#24577) - - - - - 5e4f4ba8 by Simon Peyton Jones at 2024-04-12T13:14:20-04:00 Don't generate wrappers for `type data` constructors with StrictData Previously, the logic for checking if a data constructor needs a wrapper or not would take into account whether the constructor's fields have explicit strictness (e.g., `data T = MkT !Int`), but the logic would _not_ take into account whether `StrictData` was enabled. This meant that something like `type data T = MkT Int` would incorrectly generate a wrapper for `MkT` if `StrictData` was enabled, leading to the horrible errors seen in #24620. To fix this, we disable generating wrappers for `type data` constructors altogether. Fixes #24620. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - dbdf1995 by Alex Mason at 2024-04-15T15:28:26+10:00 Implements MO_S_Mul2 and MO_U_Mul2 using the UMULH, UMULL and SMULH instructions for AArch64 Also adds a test for MO_S_Mul2 - - - - - 42bd0407 by Teo Camarasu at 2024-04-16T20:06:39-04:00 Make template-haskell a stage1 package Promoting template-haskell from a stage0 to a stage1 package means that we can much more easily refactor template-haskell. We implement this by duplicating the in-tree `template-haskell`. A new `template-haskell-next` library is autogenerated to mirror `template-haskell` `stage1:ghc` to depend on the new interface of the library including the `Binary` instances without adding an explicit dependency on `template-haskell`. This is controlled by the `bootstrap-th` cabal flag When building `template-haskell` modules as part of this vendoring we do not have access to quote syntax, so we cannot use variable quote notation (`'Just`). So we either replace these with hand-written `Name`s or hide the code behind CPP. We can remove the `th_hack` from hadrian, which was required when building stage0 packages using the in-tree `template-haskell` library. For more details see Note [Bootstrapping Template Haskell]. Resolves #23536 Co-Authored-By: Sebastian Graf <sgraf1337 at gmail.com> Co-Authored-By: Matthew Craven <5086-clyring at users.noreply.gitlab.haskell.org> - - - - - 3d973e47 by Ben Gamari at 2024-04-16T20:07:15-04:00 Bump parsec submodule to 3.1.17.0 - - - - - 9d38bfa0 by Simon Peyton Jones at 2024-04-16T20:07:51-04:00 Clone CoVars in CorePrep This MR addresses #24463. It's all explained in the new Note [Cloning CoVars and TyVars] - - - - - 0fe2b410 by Andreas Klebinger at 2024-04-16T20:08:27-04:00 NCG: Fix a bug where we errounously removed a required jump instruction. Add a new method to the Instruction class to check if we can eliminate a jump in favour of fallthrough control flow. Fixes #24507 - - - - - 9f99126a by Teo Camarasu at 2024-04-16T20:09:04-04:00 Fix documentation preview from doc-tarball job - Include all the .html files and assets in the job artefacts - Include all the .pdf files in the job artefacts - Mark the artefact as an "exposed" artefact meaning it turns up in the UI. Resolves #24651 - - - - - 3a0642ea by Ben Gamari at 2024-04-16T20:09:39-04:00 rts: Ignore EINTR while polling in timerfd itimer implementation While the RTS does attempt to mask signals, it may be that a foreign library unmasks them. This previously caused benign warnings which we now ignore. See #24610. - - - - - 9a53cd3f by Alan Zimmerman at 2024-04-16T20:10:15-04:00 EPA: Add additional comments field to AnnsModule This is used in exact printing to store comments coming after the `where` keyword but before any comments allocated to imports or decls. It is used in ghc-exactprint, see https://github.com/alanz/ghc-exactprint/commit/44bbed311fd8f0d053053fef195bf47c17d34fa7 - - - - - e5c43259 by Bryan Richter at 2024-04-16T20:10:51-04:00 Remove unrunnable FreeBSD CI jobs FreeBSD runner supply is inelastic. Currently there is only one, and it's unavailable because of a hardware issue. - - - - - 914eb49a by Ben Gamari at 2024-04-16T20:11:27-04:00 rel-eng: Fix mktemp usage in recompress-all We need a temporary directory, not a file. - - - - - f30e4984 by Teo Camarasu at 2024-04-16T20:12:03-04:00 Fix ghc API link in docs/index.html This was missing part of the unit ID meaning it would 404. Resolves #24674 - - - - - d7a3d6b5 by Ben Gamari at 2024-04-16T20:12:39-04:00 template-haskell: Declare TH.Lib.Internal as not-home Rather than `hide`. Closes #24659. - - - - - 5eaa46e7 by Matthew Pickering at 2024-04-19T02:14:55-04:00 testsuite: Rename isCross() predicate to needsTargetWrapper() isCross() was a misnamed because it assumed that all cross targets would provide a target wrapper, but the two most common cross targets (javascript, wasm) don't need a target wrapper. Therefore we rename this predicate to `needsTargetWrapper()` so situations in the testsuite where we can check whether running executables requires a target wrapper or not. - - - - - 55a9d699 by Simon Peyton Jones at 2024-04-19T02:15:32-04:00 Do not float HNFs out of lambdas This MR adjusts SetLevels so that it is less eager to float a HNF (lambda or constructor application) out of a lambda, unless it gets to top level. Data suggests that this change is a small net win: * nofib bytes-allocated falls by -0.09% (but a couple go up) * perf/should_compile bytes-allocated falls by -0.5% * perf/should_run bytes-allocated falls by -0.1% See !12410 for more detail. When fiddling elsewhere, I also found that this patch had a huge positive effect on the (very delicate) test perf/should_run/T21839r But that improvement doesn't show up in this MR by itself. Metric Decrease: MultiLayerModulesRecomp T15703 parsing001 - - - - - f0701585 by Alan Zimmerman at 2024-04-19T02:16:08-04:00 EPA: Fix comments in mkListSyntaxTy0 Also extend the test to confirm. Addresses #24669, 1 of 4 - - - - - b01c01d4 by Serge S. Gulin at 2024-04-19T02:16:51-04:00 JS: set image `x86_64-linux-deb11-emsdk-closure` for build - - - - - c90c6039 by Alan Zimmerman at 2024-04-19T02:17:27-04:00 EPA: Provide correct span for PatBind And remove unused parameter in checkPatBind Contributes to #24669 - - - - - 26036f96 by Alan Zimmerman at 2024-04-19T13:11:08-04:00 EPA: Fix span for PatBuilderAppType Include the location of the prefix @ in the span for InVisPat. Also removes unnecessary annotations from HsTP. Contributes to #24669 - - - - - dba03aab by Matthew Craven at 2024-04-19T13:11:44-04:00 testsuite: Give the pre_cmd for mhu-perf more time - - - - - d31fbf6c by Krzysztof Gogolewski at 2024-04-19T21:04:09-04:00 Fix quantification order for a `op` b and a %m -> b Fixes #23764 Implements https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0640-tyop-quantification-order.rst Updates haddock submodule. - - - - - 385cd1c4 by Sebastian Graf at 2024-04-19T21:04:45-04:00 Make `seq#` a magic Id and inline it in CorePrep (#24124) We can save much code and explanation in Tag Inference and StgToCmm by making `seq#` a known-key Magic Id in `GHC.Internal.IO` and inline this definition in CorePrep. See the updated `Note [seq# magic]`. I also implemented a new `Note [Flatten case-bind]` to get better code for otherwise nested case scrutinees. I renamed the contructors of `ArgInfo` to use an `AI` prefix in order to resolve the clash between `type CpeApp = CoreExpr` and the data constructor of `ArgInfo`, as well as fixed typos in `Note [CorePrep invariants]`. Fixes #24252 and #24124. - - - - - 275e41a9 by Jade at 2024-04-20T11:10:40-04:00 Put the newline after errors instead of before them This mainly has consequences for GHCi but also slightly alters how the output of GHC on the commandline looks. Fixes: #22499 - - - - - dd339c7a by Teo Camarasu at 2024-04-20T11:11:16-04:00 Remove unecessary stage0 packages Historically quite a few packages had to be stage0 as they depended on `template-haskell` and that was stage0. In #23536 we made it so that was no longer the case. This allows us to remove a bunch of packages from this list. A few still remain. A new version of `Win32` is required by `semaphore-compat`. Including `Win32` in the stage0 set requires also including `filepath` because otherwise Hadrian's dependency logic gets confused. Once our boot compiler has a newer version of `Win32` all of these will be able to be dropped. Resolves #24652 - - - - - 2f8e3a25 by Alan Zimmerman at 2024-04-20T11:11:52-04:00 EPA: Avoid duplicated comments in splice decls Contributes to #24669 - - - - - c70b9ddb by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fix typos and namings (fixes #24602) You may noted that I've also changed term of ``` , global "h$vt_double" ||= toJExpr IntV ``` See "IntV" and ``` WaitReadOp -> \[] [fd] -> pure $ PRPrimCall $ returnS (app "h$waidRead" [fd]) ``` See "h$waidRead" - - - - - 3db54f9b by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: trivial checks for variable presence (fixes #24602) - - - - - 777f108f by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fs module imported twice (by emscripten and by ghc-internal). ghc-internal import wrapped in a closure to prevent conflict with emscripten (fixes #24602) Better solution is to use some JavaScript module system like AMD, CommonJS or even UMD. It will be investigated at other issues. At first glance we should try UMD (See https://github.com/umdjs/umd) - - - - - a45a5712 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: thread.js requires h$fds and h$fdReady to be declared for static code analysis, minimal code copied from GHCJS (fixes #24602) I've just copied some old pieces of GHCJS from publicly available sources (See https://github.com/Taneb/shims/blob/a6dd0202dcdb86ad63201495b8b5d9763483eb35/src/io.js#L607). Also I didn't put details to h$fds. I took minimal and left only its object initialization: `var h$fds = {};` - - - - - ad90bf12 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: heap and stack overflows reporting defined as js hard failure (fixes #24602) These errors were treated as a hard failure for browser application. The fix is trivial: just throw error. - - - - - 5962fa52 by Serge S. Gulin at 2024-04-21T16:33:44+03:00 JS: Stubs for code without actual implementation detected by Google Closure Compiler (fixes #24602) These errors were fixed just by introducing stubbed functions with throw for further implementation. - - - - - a0694298 by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add externs to linker (fixes #24602) After enabling jsdoc and built-in google closure compiler types I was needed to deal with the following: 1. Define NodeJS-environment types. I've just copied minimal set of externs from semi-official repo (see https://github.com/externs/nodejs/blob/6c6882c73efcdceecf42e7ba11f1e3e5c9c041f0/v8/nodejs.js#L8). 2. Define Emscripten-environment types: `HEAP8`. Emscripten already provides some externs in our code but it supposed to be run in some module system. And its definitions do not work well in plain bundle. 3. We have some functions which purpose is to add to functions some contextual information via function properties. These functions should be marked as `modifies` to let google closure compiler remove calls if these functions are not used actually by call graph. Such functions are: `h$o`, `h$sti`, `h$init_closure`, `h$setObjInfo`. 4. STG primitives such as registries and stuff from `GHC.StgToJS`. `dXX` properties were already present at externs generator function but they are started from `7`, not from `1`. This message is related: `// fixme does closure compiler bite us here?` - - - - - e58bb29f by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: added both tests: for size and for correctness (fixes #24602) By some reason MacOS builds add to stderr messages like: Ignoring unexpected archive entry: __.SYMDEF ... However I left stderr to `/dev/null` for compatibility with linux CI builds. - - - - - 909f3a9c by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Disable js linker warning for empty symbol table to make js tests running consistent across environments - - - - - 83eb10da by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add special preprocessor for js files due of needing to keep jsdoc comments (fixes #24602) Our js files have defined google closure compiler types at jsdoc entries but these jsdoc entries are removed by cpp preprocessor. I considered that reusing them in javascript-backend would be a nice thing. Right now haskell processor uses `-traditional` option to deal with comments and `//` operators. But now there are following compiler options: `-C` and `-CC`. You can read about them at GCC (see https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#index-CC) and CLang (see https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-CC). It seems that `-CC` works better for javascript jsdoc than `-traditional`. At least it leaves `/* ... */` comments w/o changes. - - - - - e1cf8dc2 by brandon s allbery kf8nh at 2024-04-22T03:48:26-04:00 fix link in CODEOWNERS It seems that our local Gitlab no longer has documentation for the `CODEOWNERS` file, but the master documentation still does. Use that instead. - - - - - 593f4e04 by Fendor at 2024-04-23T10:19:14-04:00 Add performance regression test for '-fwrite-simplified-core' - - - - - 1ba39b05 by Fendor at 2024-04-23T10:19:14-04:00 Typecheck corebindings lazily during bytecode generation This delays typechecking the corebindings until the bytecode generation happens. We also avoid allocating a thunk that is retained by `unsafeInterleaveIO`. In general, we shouldn't retain values of the hydrated `Type`, as not evaluating the bytecode object keeps it alive. It is better if we retain the unhydrated `IfaceType`. See Note [Hydrating Modules] - - - - - e916fc92 by Alan Zimmerman at 2024-04-23T10:19:50-04:00 EPA: Keep comments in a CaseAlt match The comments now live in the surrounding location, not inside the Match. Make sure we keep them. Closes #24707 - - - - - d2b17f32 by Cheng Shao at 2024-04-23T15:01:22-04:00 driver: force merge objects when building dynamic objects This patch forces the driver to always merge objects when building dynamic objects even when ar -L is supported. It is an oversight of !8887: original rationale of that patch is favoring the relatively cheap ar -L operation over object merging when ar -L is supported, which makes sense but only if we are building static objects! Omitting check for whether we are building dynamic objects will result in broken .so files with undefined reference errors at executable link time when building GHC with llvm-ar. Fixes #22210. - - - - - 209d09f5 by Julian Ospald at 2024-04-23T15:02:03-04:00 Allow non-absolute values for bootstrap GHC variable Fixes #24682 - - - - - 3fff0977 by Matthew Pickering at 2024-04-23T15:02:38-04:00 Don't depend on registerPackage function in Cabal More recent versions of Cabal modify the behaviour of libAbiHash which breaks our usage of registerPackage. It is simpler to inline the part of registerPackage that we need and avoid any additional dependency and complication using the higher-level function introduces. - - - - - c62dc317 by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: remove obsolete ln script This commit removes an obsolete ln script in ghc-bignum/gmp. See 060251c24ad160264ae8553efecbb8bed2f06360 for its original intention, but it's been obsolete for a long time, especially since the removal of the make build system. Hence the house cleaning. - - - - - 6399d52b by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: update gmp to 6.3.0 This patch bumps the gmp-tarballs submodule and updates gmp to 6.3.0. The tarball format is now xz, and gmpsrc.patch has been patched into the tarball so hadrian no longer needs to deal with patching logic when building in-tree GMP. - - - - - 65b4b92f by Cheng Shao at 2024-04-25T01:32:02-04:00 hadrian: remove obsolete Patch logic This commit removes obsolete Patch logic from hadrian, given we no longer need to patch the gmp tarball when building in-tree GMP. - - - - - 71f28958 by Cheng Shao at 2024-04-25T01:32:02-04:00 autoconf: remove obsolete patch detection This commit removes obsolete deletection logic of the patch command from autoconf scripts, given we no longer need to patch anything in the GHC build process. - - - - - daeda834 by Sylvain Henry at 2024-04-25T01:32:43-04:00 JS: correctly handle RUBBISH literals (#24664) - - - - - 8a06ddf6 by Matthew Pickering at 2024-04-25T11:16:16-04:00 Linearise ghc-internal and base build This is achieved by requesting the final package database for ghc-internal, which mandates it is fully built as a dependency of configuring the `base` package. This is at the expense of cross-package parrallelism between ghc-internal and the base package. Fixes #24436 - - - - - 94da9365 by Andrei Borzenkov at 2024-04-25T11:16:54-04:00 Fix tuple puns renaming (24702) Move tuple renaming short cutter from `isBuiltInOcc_maybe` to `isPunOcc_maybe`, so we consider incoming module. I also fixed some hidden bugs that raised after the change was done. - - - - - fa03b1fb by Fendor at 2024-04-26T18:03:13-04:00 Refactor the Binary serialisation interface The goal is simplifiy adding deduplication tables to `ModIface` interface serialisation. We identify two main points of interest that make this difficult: 1. UserData hardcodes what `Binary` instances can have deduplication tables. Moreover, it heavily uses partial functions. 2. GHC.Iface.Binary hardcodes the deduplication tables for 'Name' and 'FastString', making it difficult to add more deduplication. Instead of having a single `UserData` record with fields for all the types that can have deduplication tables, we allow to provide custom serialisers for any `Typeable`. These are wrapped in existentials and stored in a `Map` indexed by their respective `TypeRep`. The `Binary` instance of the type to deduplicate still needs to explicitly look up the decoder via `findUserDataReader` and `findUserDataWriter`, which is no worse than the status-quo. `Map` was chosen as microbenchmarks indicate it is the fastest for a small number of keys (< 10). To generalise the deduplication table serialisation mechanism, we introduce the types `ReaderTable` and `WriterTable` which provide a simple interface that is sufficient to implement a general purpose deduplication mechanism for `writeBinIface` and `readBinIface`. This allows us to provide a list of deduplication tables for serialisation that can be extended more easily, for example for `IfaceTyCon`, see the issue https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for more motivation. In addition to this refactoring, we split `UserData` into `ReaderUserData` and `WriterUserData`, to avoid partial functions and reduce overall memory usage, as we need fewer mutable variables. Bump haddock submodule to accomodate for `UserData` split. ------------------------- Metric Increase: MultiLayerModulesTH_Make MultiLayerModulesRecomp T21839c ------------------------- - - - - - bac57298 by Fendor at 2024-04-26T18:03:13-04:00 Split `BinHandle` into `ReadBinHandle` and `WriteBinHandle` A `BinHandle` contains too much information for reading data. For example, it needs to keep a `FastMutInt` and a `IORef BinData`, when the non-mutable variants would suffice. Additionally, this change has the benefit that anyone can immediately tell whether the `BinHandle` is used for reading or writing. Bump haddock submodule BinHandle split. - - - - - 4d6394dd by Simon Peyton Jones at 2024-04-26T18:03:49-04:00 Fix missing escaping-kind check in tcPatSynSig Note [Escaping kind in type signatures] explains how we deal with escaping kinds in type signatures, e.g. f :: forall r (a :: TYPE r). a where the kind of the body is (TYPE r), but `r` is not in scope outside the forall-type. I had missed this subtlety in tcPatSynSig, leading to #24686. This MR fixes it; and a similar bug in tc_top_lhs_type. (The latter is tested by T24686a.) - - - - - 981c2c2c by Alan Zimmerman at 2024-04-26T18:04:25-04:00 EPA: check-exact: check that the roundtrip reproduces the source Closes #24670 - - - - - a8616747 by Andrew Lelechenko at 2024-04-26T18:05:01-04:00 Document that setEnv is not thread-safe - - - - - 1e41de83 by Bryan Richter at 2024-04-26T18:05:37-04:00 CI: Work around frequent Signal 9 errors - - - - - a6d5f9da by Naïm Favier at 2024-04-27T17:52:40-04:00 ghc-internal: add MonadFix instance for (,) Closes https://gitlab.haskell.org/ghc/ghc/-/issues/24288, implements CLC proposal https://github.com/haskell/core-libraries-committee/issues/238. Adds a MonadFix instance for tuples, permitting value recursion in the "native" writer monad and bringing consistency with the existing instance for transformers's WriterT (and, to a lesser extent, for Solo). - - - - - 64feadcd by Rodrigo Mesquita at 2024-04-27T17:53:16-04:00 bindist: Fix xattr cleaning The original fix (725343aa) was incorrect because it used the shell bracket syntax which is the quoting syntax in autoconf, making the test for existence be incorrect and therefore `xattr` was never run. Fixes #24554 - - - - - e2094df3 by damhiya at 2024-04-28T23:52:00+09:00 Make read accepts binary integer formats CLC proposal : https://github.com/haskell/core-libraries-committee/issues/177 - - - - - 1c2fd963 by Alan Zimmerman at 2024-04-29T23:17:00-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 - - - - - 4189d17e by Sylvain Henry at 2024-04-29T23:17:42-04:00 LLVM: better unreachable default destination in Switch (#24717) See added note. Co-authored-by: Siddharth Bhat <siddu.druid at gmail.com> - - - - - a3725c88 by Cheng Shao at 2024-04-29T23:18:20-04:00 ci: enable wasm jobs for MRs with wasm label This patch enables wasm jobs for MRs with wasm label. Previously the wasm label didn't actually have any effect on the CI pipeline, and full-ci needed to be applied to run wasm jobs which was a waste of runners when working on the wasm backend, hence the fix here. - - - - - 702f7964 by Matthew Pickering at 2024-04-29T23:18:56-04:00 Make interface files and object files depend on inplace .conf file A potential fix for #24737 - - - - - 728af21e by Cheng Shao at 2024-04-30T05:30:23-04:00 utils: remove obsolete vagrant scripts Vagrantfile has long been removed in !5288. This commit further removes the obsolete vagrant scripts in the tree. - - - - - 36f2c342 by Cheng Shao at 2024-04-30T05:31:00-04:00 Update autoconf scripts Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 - - - - - ecbf22a6 by Ben Gamari at 2024-04-30T05:31:36-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 7eab4e01 by Alan Zimmerman at 2024-05-04T16:14:55+01:00 EPA: Widen stmtslist to include last semicolon Closes #24754 - - - - - 06f7db40 by Teo Camarasu at 2024-05-05T00:19:38-04:00 doc: Fix type error in hs_try_putmvar example - - - - - af000532 by Moritz Schuler at 2024-05-05T06:30:58-04:00 Fix parsing of module names in CLI arguments closes issue #24732 - - - - - da74e9c9 by Ben Gamari at 2024-05-05T06:31:34-04:00 ghc-platform: Add Setup.hs The Hadrian bootstrapping script relies upon `Setup.hs` to drive its build. Addresses #24761. - - - - - 936a9a71 by Peter Trommler at 2024-05-05T14:04:04+00:00 PPC: Support ELF v2 on powerpc64 big-endian Detect ELF v2 on PowerPC 64-bit systems. Check for `_CALL_ELF` preprocessor macro. Fixes #21191 - - - - - 03ca1154 by Sylvain Henry at 2024-05-05T14:04:04+00:00 Fix copy-paste - - - - - 20 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - − .gitlab/circle-ci-job.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - − .gitlab/gen-ci.cabal - + .gitlab/generate-ci/LICENSE - + .gitlab/generate-ci/README.mkd - + .gitlab/generate-ci/flake.lock - + .gitlab/generate-ci/flake.nix - .gitlab/gen_ci.hs → .gitlab/generate-ci/gen_ci.hs - + .gitlab/generate-ci/generate-ci.cabal - + .gitlab/generate-ci/generate-job-metadata - + .gitlab/generate-ci/generate-jobs - .gitlab/hie.yaml → .gitlab/generate-ci/hie.yaml - − .gitlab/generate_job_metadata - − .gitlab/generate_jobs - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fcb79fa7121865a33ed2a52912499884ce842d6b...03ca1154238fb8429adc0ed6060b68198b81a26d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fcb79fa7121865a33ed2a52912499884ce842d6b...03ca1154238fb8429adc0ed6060b68198b81a26d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun May 5 16:53:16 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 05 May 2024 12:53:16 -0400 Subject: [Git][ghc/ghc][master] EPA: preserve comments in class and data decls Message-ID: <6637b97c5e047_53c461597ddc42829@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 35d34fde by Alan Zimmerman at 2024-05-05T12:52:40-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 - - - - - 4 changed files: - compiler/GHC/Parser/PostProcess.hs - testsuite/tests/printer/Makefile - + testsuite/tests/printer/Test24755.hs - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -204,11 +204,11 @@ mkClassDecl :: SrcSpan -> P (LTyClDecl GhcPs) mkClassDecl loc' (L _ (mcxt, tycl_hdr)) fds where_cls layout annsIn - = do { let loc = noAnnSrcSpan loc' - ; (binds, sigs, ats, at_defs, _, docs) <- cvBindsAndSigs where_cls - ; (cls, tparams, fixity, ann) <- checkTyClHdr True tycl_hdr + = do { (binds, sigs, ats, at_defs, _, docs) <- cvBindsAndSigs where_cls + ; (cls, tparams, fixity, ann, cs) <- checkTyClHdr True tycl_hdr ; tyvars <- checkTyVars (text "class") whereDots cls tparams ; let anns' = annsIn Semi.<> ann + ; let loc = EpAnn (spanAsAnchor loc') noAnn cs ; return (L loc (ClassDecl { tcdCExt = (anns', layout, NoAnnSortKey) , tcdCtxt = mcxt , tcdLName = cls, tcdTyVars = tyvars @@ -231,12 +231,12 @@ mkTyData :: SrcSpan -> P (LTyClDecl GhcPs) mkTyData loc' is_type_data new_or_data cType (L _ (mcxt, tycl_hdr)) ksig data_cons (L _ maybe_deriv) annsIn - = do { let loc = noAnnSrcSpan loc' - ; (tc, tparams, fixity, ann) <- checkTyClHdr False tycl_hdr + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False tycl_hdr ; tyvars <- checkTyVars (ppr new_or_data) equalsDots tc tparams ; let anns' = annsIn Semi.<> ann - ; data_cons <- checkNewOrData (locA loc) (unLoc tc) is_type_data new_or_data data_cons + ; data_cons <- checkNewOrData loc' (unLoc tc) is_type_data new_or_data data_cons ; defn <- mkDataDefn cType mcxt ksig data_cons maybe_deriv + ; let loc = EpAnn (spanAsAnchor loc') noAnn cs ; return (L loc (DataDecl { tcdDExt = anns', tcdLName = tc, tcdTyVars = tyvars, tcdFixity = fixity, @@ -263,14 +263,14 @@ mkTySynonym :: SrcSpan -> [AddEpAnn] -> P (LTyClDecl GhcPs) mkTySynonym loc lhs rhs annsIn - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs ; tyvars <- checkTyVars (text "type") equalsDots tc tparams ; let anns' = annsIn Semi.<> ann - ; return (L (noAnnSrcSpan loc) (SynDecl - { tcdSExt = anns' - , tcdLName = tc, tcdTyVars = tyvars - , tcdFixity = fixity - , tcdRhs = rhs })) } + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (SynDecl { tcdSExt = anns' + , tcdLName = tc, tcdTyVars = tyvars + , tcdFixity = fixity + , tcdRhs = rhs })) } mkStandaloneKindSig :: SrcSpan @@ -303,8 +303,9 @@ mkTyFamInstEqn :: SrcSpan -> [AddEpAnn] -> P (LTyFamInstEqn GhcPs) mkTyFamInstEqn loc bndrs lhs rhs anns - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs - ; return (L (noAnnSrcSpan loc) $ FamEqn + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' $ FamEqn { feqn_ext = anns `mappend` ann , feqn_tycon = tc , feqn_bndrs = bndrs @@ -324,10 +325,11 @@ mkDataFamInst :: SrcSpan -> P (LInstDecl GhcPs) mkDataFamInst loc new_or_data cType (mcxt, bndrs, tycl_hdr) ksig data_cons (L _ maybe_deriv) anns - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False tycl_hdr + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False tycl_hdr ; data_cons <- checkNewOrData loc (unLoc tc) False new_or_data data_cons ; defn <- mkDataDefn cType mcxt ksig data_cons maybe_deriv - ; return (L (noAnnSrcSpan loc) (DataFamInstD noExtField (DataFamInstDecl + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (DataFamInstD noExtField (DataFamInstDecl (FamEqn { feqn_ext = ann Semi.<> anns , feqn_tycon = tc , feqn_bndrs = bndrs @@ -368,10 +370,10 @@ mkFamDecl :: SrcSpan -> [AddEpAnn] -> P (LTyClDecl GhcPs) mkFamDecl loc info topLevel lhs ksig injAnn annsIn - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs ; tyvars <- checkTyVars (ppr info) equals_or_where tc tparams - ; return (L (noAnnSrcSpan loc) (FamDecl noExtField - (FamilyDecl + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (FamDecl noExtField (FamilyDecl { fdExt = annsIn Semi.<> ann , fdTopLevel = topLevel , fdInfo = info, fdLName = tc @@ -1040,45 +1042,46 @@ checkTyClHdr :: Bool -- True <=> class header -> P (LocatedN RdrName, -- the head symbol (type or class name) [LHsTypeArg GhcPs], -- parameters of head symbol LexicalFixity, -- the declaration is in infix format - [AddEpAnn]) -- API Annotation for HsParTy + [AddEpAnn], -- API Annotation for HsParTy -- when stripping parens + EpAnnComments) -- Accumulated comments from re-arranging -- Well-formedness check and decomposition of type and class heads. -- Decomposes T ty1 .. tyn into (T, [ty1, ..., tyn]) -- Int :*: Bool into (:*:, [Int, Bool]) -- returning the pieces checkTyClHdr is_cls ty - = goL ty [] [] [] Prefix + = goL emptyComments ty [] [] [] Prefix where - goL (L l ty) acc ops cps fix = go l ty acc ops cps fix + goL cs (L l ty) acc ops cps fix = go cs l ty acc ops cps fix -- workaround to define '*' despite StarIsType - go ll (HsParTy an (L l (HsStarTy _ isUni))) acc ops' cps' fix + go cs ll (HsParTy an (L l (HsStarTy _ isUni))) acc ops' cps' fix = do { addPsMessage (locA l) PsWarnStarBinder ; let name = mkOccNameFS tcClsName (starSym isUni) ; let a' = newAnns ll l an ; return (L a' (Unqual name), acc, fix - , (reverse ops') ++ cps') } + , (reverse ops') ++ cps', cs) } - go _ (HsTyVar _ _ ltc@(L _ tc)) acc ops cps fix - | isRdrTc tc = return (ltc, acc, fix, (reverse ops) ++ cps) - go _ (HsOpTy _ _ t1 ltc@(L _ tc) t2) acc ops cps _fix - | isRdrTc tc = return (ltc, lhs:rhs:acc, Infix, (reverse ops) ++ cps) + go cs l (HsTyVar _ _ ltc@(L _ tc)) acc ops cps fix + | isRdrTc tc = return (ltc, acc, fix, (reverse ops) ++ cps, cs Semi.<> comments l) + go cs l (HsOpTy _ _ t1 ltc@(L _ tc) t2) acc ops cps _fix + | isRdrTc tc = return (ltc, lhs:rhs:acc, Infix, (reverse ops) ++ cps, cs Semi.<> comments l) where lhs = HsValArg noExtField t1 rhs = HsValArg noExtField t2 - go l (HsParTy _ ty) acc ops cps fix = goL ty acc (o:ops) (c:cps) fix + go cs l (HsParTy _ ty) acc ops cps fix = goL (cs Semi.<> comments l) ty acc (o:ops) (c:cps) fix where (o,c) = mkParensEpAnn (realSrcSpan (locA l)) - go _ (HsAppTy _ t1 t2) acc ops cps fix = goL t1 (HsValArg noExtField t2:acc) ops cps fix - go _ (HsAppKindTy at ty ki) acc ops cps fix = goL ty (HsTypeArg at ki:acc) ops cps fix - go l (HsTupleTy _ HsBoxedOrConstraintTuple ts) [] ops cps fix + go cs l (HsAppTy _ t1 t2) acc ops cps fix = goL (cs Semi.<> comments l) t1 (HsValArg noExtField t2:acc) ops cps fix + go cs l (HsAppKindTy at ty ki) acc ops cps fix = goL (cs Semi.<> comments l) ty (HsTypeArg at ki:acc) ops cps fix + go cs l (HsTupleTy _ HsBoxedOrConstraintTuple ts) [] ops cps fix = return (L (l2l l) (nameRdrName tup_name) - , map (HsValArg noExtField) ts, fix, (reverse ops)++cps) + , map (HsValArg noExtField) ts, fix, (reverse ops)++cps, cs Semi.<> comments l) where arity = length ts tup_name | is_cls = cTupleTyConName arity | otherwise = getName (tupleTyCon Boxed arity) -- See Note [Unit tuples] in GHC.Hs.Type (TODO: is this still relevant?) - go l _ _ _ _ _ + go _ l _ _ _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope (locA l) $ (PsErrMalformedTyOrClDecl ty) ===================================== testsuite/tests/printer/Makefile ===================================== @@ -856,3 +856,8 @@ Test24749: Test24754: $(CHECK_PPR) $(LIBDIR) Test24754.hs $(CHECK_EXACT) $(LIBDIR) Test24754.hs + +.PHONY: Test24755 +Test24755: + $(CHECK_PPR) $(LIBDIR) Test24755.hs + $(CHECK_EXACT) $(LIBDIR) Test24755.hs ===================================== testsuite/tests/printer/Test24755.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeOperators #-} +module Test24755 where + +class + a -- Before operator + :+ + b -- After operator ===================================== testsuite/tests/printer/all.T ===================================== @@ -204,3 +204,4 @@ test('Test24748', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24748']) test('DataDeclShort', [ignore_stderr, req_ppr_deps], makefile_test, ['DataDeclShort']) test('Test24749', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24749']) test('Test24754', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24754']) +test('Test24755', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24755']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/35d34fde62cd9e0002ac42f10bf705552f5c654e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/35d34fde62cd9e0002ac42f10bf705552f5c654e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun May 5 16:53:48 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 05 May 2024 12:53:48 -0400 Subject: [Git][ghc/ghc][master] Fix a float-out error Message-ID: <6637b99c1918a_53c461717fcc4571f@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 03c5dfbf by Simon Peyton Jones at 2024-05-05T12:53:15-04:00 Fix a float-out error Ticket #24768 showed that the Simplifier was accidentally destroying a join point. It turned out to be that we were sending a bottoming join point to the top, accidentally abstracting over /other/ join points. Easily fixed. - - - - - 3 changed files: - compiler/GHC/Core/Opt/SetLevels.hs - + testsuite/tests/simplCore/should_compile/T24768.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -1088,6 +1088,11 @@ But, as ever, we need to be careful: as /another/ MFE, so we tell lvlFloatRhs not to do that, via the is_bot argument. + Do /not/ do this for bottoming /join-point/ bindings. They may call other + join points (#24768), and floating to the top would abstract over those join + points, which we should never do. + + See Maessen's paper 1999 "Bottom extraction: factoring error handling out of functional programs" (unpublished I think). @@ -1252,9 +1257,11 @@ lvlBind env (AnnNonRec bndr rhs) deann_rhs = deAnnotate rhs mb_bot_str = exprBotStrictness_maybe deann_rhs - is_bot_lam = isJust mb_bot_str + is_bot_lam = not is_join && isJust mb_bot_str -- is_bot_lam: looks like (\xy. bot), maybe zero lams - -- NB: not isBottomThunk! See Note [Bottoming floats] point (3) + -- NB: not isBottomThunk! + -- NB: not is_join: don't send bottoming join points to the top. + -- See Note [Bottoming floats] point (3) is_top_bindable = exprIsTopLevelBindable deann_rhs bndr_ty n_extra = count isId abs_vars ===================================== testsuite/tests/simplCore/should_compile/T24768.hs ===================================== @@ -0,0 +1,56 @@ +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TupleSections #-} +{-# LANGUAGE TypeApplications #-} + +-- In this example the simplifer destroyed a join point, +-- namely the `loop` inside `detectLeaks` + +module T24768 (detectLeaks) where + +import Control.Monad (zipWithM_) +import Control.Monad.Reader (ReaderT(..)) +import Control.Monad.State (StateT, evalStateT) +import qualified Data.Map as M +import qualified Data.Set as S + +data Debuggee + +newtype DebugM a = DebugM (ReaderT Debuggee IO a) + deriving (Functor, Applicative, Monad) + +runSimple :: Debuggee -> DebugM a -> IO a +runSimple d (DebugM a) = runReaderT a d + +cands :: [a] +cands = [] +{-# NOINLINE cands #-} + +detectLeaks :: Debuggee -> IO () +detectLeaks e = loop M.empty + where + loop :: M.Map () RankInfo -> IO () + loop rm = do + gs <- runSimple e $ mapM (findSlice rm) cands + zipWithM_ (\n _g -> writeFile + ("slices/" ++ show @Int n ++ ".dot") + "abcd") + [0..] gs + loop rm + +data RankInfo = RankInfo !Double !Int + +lookupRM :: () -> M.Map () RankInfo -> [((), RankInfo)] +lookupRM k m = M.assocs filtered_map + where + (res_map, _) = M.partitionWithKey (\e _ -> e == k) m + filtered_map = M.filter (\(RankInfo r _) -> r > 0) res_map + +findSlice :: forall m a. Monad m => M.Map () RankInfo -> () -> m [a] +findSlice rm _k = evalStateT go S.empty + where + go :: StateT s m [a] + go = do + let next_edges = lookupRM () rm + _ss <- concat <$> mapM (\_ -> go) next_edges + return [] ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -515,3 +515,4 @@ test('T24229b', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typea test('T24370', normal, compile, ['-O']) test('T24551', normal, compile, ['-O -dcore-lint']) test('T24726', normal, compile, ['-dcore-lint -dsuppress-uniques']) +test('T24768', normal, compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/03c5dfbf52969504ca3473cb2eb7b3f7cf96d4b3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/03c5dfbf52969504ca3473cb2eb7b3f7cf96d4b3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun May 5 16:57:15 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sun, 05 May 2024 12:57:15 -0400 Subject: [Git][ghc/ghc][wip/az/T24753-epa-mkhsoptypv-dup-comments] 5 commits: Fix parsing of module names in CLI arguments Message-ID: <6637ba6bea374_53c4618234c04602b@gitlab.mail> Alan Zimmerman pushed to branch wip/az/T24753-epa-mkhsoptypv-dup-comments at Glasgow Haskell Compiler / GHC Commits: af000532 by Moritz Schuler at 2024-05-05T06:30:58-04:00 Fix parsing of module names in CLI arguments closes issue #24732 - - - - - da74e9c9 by Ben Gamari at 2024-05-05T06:31:34-04:00 ghc-platform: Add Setup.hs The Hadrian bootstrapping script relies upon `Setup.hs` to drive its build. Addresses #24761. - - - - - 35d34fde by Alan Zimmerman at 2024-05-05T12:52:40-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 - - - - - 03c5dfbf by Simon Peyton Jones at 2024-05-05T12:53:15-04:00 Fix a float-out error Ticket #24768 showed that the Simplifier was accidentally destroying a join point. It turned out to be that we were sending a bottoming join point to the top, accidentally abstracting over /other/ join points. Easily fixed. - - - - - eb401582 by Alan Zimmerman at 2024-05-05T17:56:07+01:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 - - - - - 13 changed files: - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Parser/PostProcess.hs - compiler/Language/Haskell/Syntax/Module/Name.hs - + libraries/ghc-platform/Setup.hs - testsuite/tests/printer/Makefile - + testsuite/tests/printer/Test24753.hs - + testsuite/tests/printer/Test24755.hs - testsuite/tests/printer/all.T - + testsuite/tests/rename/should_compile/T24732.hs - + testsuite/tests/rename/should_compile/T24732.stdout - testsuite/tests/rename/should_compile/all.T - + testsuite/tests/simplCore/should_compile/T24768.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -1088,6 +1088,11 @@ But, as ever, we need to be careful: as /another/ MFE, so we tell lvlFloatRhs not to do that, via the is_bot argument. + Do /not/ do this for bottoming /join-point/ bindings. They may call other + join points (#24768), and floating to the top would abstract over those join + points, which we should never do. + + See Maessen's paper 1999 "Bottom extraction: factoring error handling out of functional programs" (unpublished I think). @@ -1252,9 +1257,11 @@ lvlBind env (AnnNonRec bndr rhs) deann_rhs = deAnnotate rhs mb_bot_str = exprBotStrictness_maybe deann_rhs - is_bot_lam = isJust mb_bot_str + is_bot_lam = not is_join && isJust mb_bot_str -- is_bot_lam: looks like (\xy. bot), maybe zero lams - -- NB: not isBottomThunk! See Note [Bottoming floats] point (3) + -- NB: not isBottomThunk! + -- NB: not is_join: don't send bottoming join points to the top. + -- See Note [Bottoming floats] point (3) is_top_bindable = exprIsTopLevelBindable deann_rhs bndr_ty n_extra = count isId abs_vars ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -204,11 +204,11 @@ mkClassDecl :: SrcSpan -> P (LTyClDecl GhcPs) mkClassDecl loc' (L _ (mcxt, tycl_hdr)) fds where_cls layout annsIn - = do { let loc = noAnnSrcSpan loc' - ; (binds, sigs, ats, at_defs, _, docs) <- cvBindsAndSigs where_cls - ; (cls, tparams, fixity, ann) <- checkTyClHdr True tycl_hdr + = do { (binds, sigs, ats, at_defs, _, docs) <- cvBindsAndSigs where_cls + ; (cls, tparams, fixity, ann, cs) <- checkTyClHdr True tycl_hdr ; tyvars <- checkTyVars (text "class") whereDots cls tparams ; let anns' = annsIn Semi.<> ann + ; let loc = EpAnn (spanAsAnchor loc') noAnn cs ; return (L loc (ClassDecl { tcdCExt = (anns', layout, NoAnnSortKey) , tcdCtxt = mcxt , tcdLName = cls, tcdTyVars = tyvars @@ -231,12 +231,12 @@ mkTyData :: SrcSpan -> P (LTyClDecl GhcPs) mkTyData loc' is_type_data new_or_data cType (L _ (mcxt, tycl_hdr)) ksig data_cons (L _ maybe_deriv) annsIn - = do { let loc = noAnnSrcSpan loc' - ; (tc, tparams, fixity, ann) <- checkTyClHdr False tycl_hdr + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False tycl_hdr ; tyvars <- checkTyVars (ppr new_or_data) equalsDots tc tparams ; let anns' = annsIn Semi.<> ann - ; data_cons <- checkNewOrData (locA loc) (unLoc tc) is_type_data new_or_data data_cons + ; data_cons <- checkNewOrData loc' (unLoc tc) is_type_data new_or_data data_cons ; defn <- mkDataDefn cType mcxt ksig data_cons maybe_deriv + ; let loc = EpAnn (spanAsAnchor loc') noAnn cs ; return (L loc (DataDecl { tcdDExt = anns', tcdLName = tc, tcdTyVars = tyvars, tcdFixity = fixity, @@ -263,14 +263,14 @@ mkTySynonym :: SrcSpan -> [AddEpAnn] -> P (LTyClDecl GhcPs) mkTySynonym loc lhs rhs annsIn - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs ; tyvars <- checkTyVars (text "type") equalsDots tc tparams ; let anns' = annsIn Semi.<> ann - ; return (L (noAnnSrcSpan loc) (SynDecl - { tcdSExt = anns' - , tcdLName = tc, tcdTyVars = tyvars - , tcdFixity = fixity - , tcdRhs = rhs })) } + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (SynDecl { tcdSExt = anns' + , tcdLName = tc, tcdTyVars = tyvars + , tcdFixity = fixity + , tcdRhs = rhs })) } mkStandaloneKindSig :: SrcSpan @@ -303,8 +303,9 @@ mkTyFamInstEqn :: SrcSpan -> [AddEpAnn] -> P (LTyFamInstEqn GhcPs) mkTyFamInstEqn loc bndrs lhs rhs anns - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs - ; return (L (noAnnSrcSpan loc) $ FamEqn + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' $ FamEqn { feqn_ext = anns `mappend` ann , feqn_tycon = tc , feqn_bndrs = bndrs @@ -324,10 +325,11 @@ mkDataFamInst :: SrcSpan -> P (LInstDecl GhcPs) mkDataFamInst loc new_or_data cType (mcxt, bndrs, tycl_hdr) ksig data_cons (L _ maybe_deriv) anns - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False tycl_hdr + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False tycl_hdr ; data_cons <- checkNewOrData loc (unLoc tc) False new_or_data data_cons ; defn <- mkDataDefn cType mcxt ksig data_cons maybe_deriv - ; return (L (noAnnSrcSpan loc) (DataFamInstD noExtField (DataFamInstDecl + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (DataFamInstD noExtField (DataFamInstDecl (FamEqn { feqn_ext = ann Semi.<> anns , feqn_tycon = tc , feqn_bndrs = bndrs @@ -368,10 +370,10 @@ mkFamDecl :: SrcSpan -> [AddEpAnn] -> P (LTyClDecl GhcPs) mkFamDecl loc info topLevel lhs ksig injAnn annsIn - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs ; tyvars <- checkTyVars (ppr info) equals_or_where tc tparams - ; return (L (noAnnSrcSpan loc) (FamDecl noExtField - (FamilyDecl + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (FamDecl noExtField (FamilyDecl { fdExt = annsIn Semi.<> ann , fdTopLevel = topLevel , fdInfo = info, fdLName = tc @@ -1040,45 +1042,46 @@ checkTyClHdr :: Bool -- True <=> class header -> P (LocatedN RdrName, -- the head symbol (type or class name) [LHsTypeArg GhcPs], -- parameters of head symbol LexicalFixity, -- the declaration is in infix format - [AddEpAnn]) -- API Annotation for HsParTy + [AddEpAnn], -- API Annotation for HsParTy -- when stripping parens + EpAnnComments) -- Accumulated comments from re-arranging -- Well-formedness check and decomposition of type and class heads. -- Decomposes T ty1 .. tyn into (T, [ty1, ..., tyn]) -- Int :*: Bool into (:*:, [Int, Bool]) -- returning the pieces checkTyClHdr is_cls ty - = goL ty [] [] [] Prefix + = goL emptyComments ty [] [] [] Prefix where - goL (L l ty) acc ops cps fix = go l ty acc ops cps fix + goL cs (L l ty) acc ops cps fix = go cs l ty acc ops cps fix -- workaround to define '*' despite StarIsType - go ll (HsParTy an (L l (HsStarTy _ isUni))) acc ops' cps' fix + go cs ll (HsParTy an (L l (HsStarTy _ isUni))) acc ops' cps' fix = do { addPsMessage (locA l) PsWarnStarBinder ; let name = mkOccNameFS tcClsName (starSym isUni) ; let a' = newAnns ll l an ; return (L a' (Unqual name), acc, fix - , (reverse ops') ++ cps') } + , (reverse ops') ++ cps', cs) } - go _ (HsTyVar _ _ ltc@(L _ tc)) acc ops cps fix - | isRdrTc tc = return (ltc, acc, fix, (reverse ops) ++ cps) - go _ (HsOpTy _ _ t1 ltc@(L _ tc) t2) acc ops cps _fix - | isRdrTc tc = return (ltc, lhs:rhs:acc, Infix, (reverse ops) ++ cps) + go cs l (HsTyVar _ _ ltc@(L _ tc)) acc ops cps fix + | isRdrTc tc = return (ltc, acc, fix, (reverse ops) ++ cps, cs Semi.<> comments l) + go cs l (HsOpTy _ _ t1 ltc@(L _ tc) t2) acc ops cps _fix + | isRdrTc tc = return (ltc, lhs:rhs:acc, Infix, (reverse ops) ++ cps, cs Semi.<> comments l) where lhs = HsValArg noExtField t1 rhs = HsValArg noExtField t2 - go l (HsParTy _ ty) acc ops cps fix = goL ty acc (o:ops) (c:cps) fix + go cs l (HsParTy _ ty) acc ops cps fix = goL (cs Semi.<> comments l) ty acc (o:ops) (c:cps) fix where (o,c) = mkParensEpAnn (realSrcSpan (locA l)) - go _ (HsAppTy _ t1 t2) acc ops cps fix = goL t1 (HsValArg noExtField t2:acc) ops cps fix - go _ (HsAppKindTy at ty ki) acc ops cps fix = goL ty (HsTypeArg at ki:acc) ops cps fix - go l (HsTupleTy _ HsBoxedOrConstraintTuple ts) [] ops cps fix + go cs l (HsAppTy _ t1 t2) acc ops cps fix = goL (cs Semi.<> comments l) t1 (HsValArg noExtField t2:acc) ops cps fix + go cs l (HsAppKindTy at ty ki) acc ops cps fix = goL (cs Semi.<> comments l) ty (HsTypeArg at ki:acc) ops cps fix + go cs l (HsTupleTy _ HsBoxedOrConstraintTuple ts) [] ops cps fix = return (L (l2l l) (nameRdrName tup_name) - , map (HsValArg noExtField) ts, fix, (reverse ops)++cps) + , map (HsValArg noExtField) ts, fix, (reverse ops)++cps, cs Semi.<> comments l) where arity = length ts tup_name | is_cls = cTupleTyConName arity | otherwise = getName (tupleTyCon Boxed arity) -- See Note [Unit tuples] in GHC.Hs.Type (TODO: is this still relevant?) - go l _ _ _ _ _ + go _ l _ _ _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope (locA l) $ (PsErrMalformedTyOrClDecl ty) @@ -2056,7 +2059,10 @@ instance DisambTD (HsType GhcPs) where mkHsAppTyHeadPV = return mkHsAppTyPV t1 t2 = return (mkHsAppTy t1 t2) mkHsAppKindTyPV t at ki = return (mkHsAppKindTy at t ki) - mkHsOpTyPV prom t1 op t2 = return (mkLHsOpTy prom t1 op t2) + mkHsOpTyPV prom t1 op t2 = do + let (L l ty) = mkLHsOpTy prom t1 op t2 + !cs <- getCommentsFor (locA l) + return (L (addCommentsToEpAnn l cs) ty) mkUnpackednessPV = addUnpackednessP dataConBuilderCon :: DataConBuilder -> LocatedN RdrName @@ -2098,8 +2104,9 @@ instance DisambTD DataConBuilder where mkHsOpTyPV prom lhs tc rhs = do check_no_ops (unLoc rhs) -- check the RHS because parsing type operators is right-associative data_con <- eitherToP $ tyConToDataCon tc + !cs <- getCommentsFor (locA l) checkNotPromotedDataCon prom data_con - return $ L l (InfixDataConBuilder lhs data_con rhs) + return $ L (addCommentsToEpAnn l cs) (InfixDataConBuilder lhs data_con rhs) where l = combineLocsA lhs rhs check_no_ops (HsBangTy _ _ t) = check_no_ops (unLoc t) @@ -3220,8 +3227,8 @@ mkSumOrTuplePat l Boxed a at Sum{} _ = mkLHsOpTy :: PromotionFlag -> LHsType GhcPs -> LocatedN RdrName -> LHsType GhcPs -> LHsType GhcPs mkLHsOpTy prom x op y = - let loc = getLoc x `combineSrcSpansA` (noAnnSrcSpan $ getLocA op) `combineSrcSpansA` getLoc y - in L loc (mkHsOpTy prom x op y) + let loc = locA x `combineSrcSpans` locA op `combineSrcSpans` locA y + in L (noAnnSrcSpan loc) (mkHsOpTy prom x op y) mkMultTy :: EpToken "%" -> LHsType GhcPs -> EpUniToken "->" "→" -> HsArrow GhcPs mkMultTy pct t@(L _ (HsTyLit _ (HsNumTy (SourceText (unpackFS -> "1")) 1))) arr ===================================== compiler/Language/Haskell/Syntax/Module/Name.hs ===================================== @@ -56,5 +56,5 @@ moduleNameColons = dots_to_colons . moduleNameString parseModuleName :: Parse.ReadP ModuleName parseModuleName = fmap mkModuleName - $ Parse.munch1 (\c -> isAlphaNum c || c `elem` "_.") + $ Parse.munch1 (\c -> isAlphaNum c || c `elem` "_.'") ===================================== libraries/ghc-platform/Setup.hs ===================================== @@ -0,0 +1,6 @@ +module Main (main) where + +import Distribution.Simple + +main :: IO () +main = defaultMain ===================================== testsuite/tests/printer/Makefile ===================================== @@ -856,3 +856,13 @@ Test24749: Test24754: $(CHECK_PPR) $(LIBDIR) Test24754.hs $(CHECK_EXACT) $(LIBDIR) Test24754.hs + +.PHONY: Test24755 +Test24755: + $(CHECK_PPR) $(LIBDIR) Test24755.hs + $(CHECK_EXACT) $(LIBDIR) Test24755.hs + +.PHONY: Test24753 +Test24753: + $(CHECK_PPR) $(LIBDIR) Test24753.hs + $(CHECK_EXACT) $(LIBDIR) Test24753.hs ===================================== testsuite/tests/printer/Test24753.hs ===================================== @@ -0,0 +1,8 @@ +module Test24753 where + +type ErrorChoiceApi + = "path0" :> Get '[JSON] Int -- c0 + :<|> "path4" :> (ReqBody '[PlainText] Int :> Post '[PlainText] Int -- c4 + :<|> ReqBody '[PlainText] Int :> Post '[JSON] Int) -- c5 + :<|> "path5" :> (ReqBody '[JSON] Int :> Post '[PlainText] Int -- c6 + :<|> ReqBody '[PlainText] Int :> Post '[PlainText] Int) -- c7 ===================================== testsuite/tests/printer/Test24755.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeOperators #-} +module Test24755 where + +class + a -- Before operator + :+ + b -- After operator ===================================== testsuite/tests/printer/all.T ===================================== @@ -204,3 +204,5 @@ test('Test24748', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24748']) test('DataDeclShort', [ignore_stderr, req_ppr_deps], makefile_test, ['DataDeclShort']) test('Test24749', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24749']) test('Test24754', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24754']) +test('Test24755', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24755']) +test('Test24753', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24753']) ===================================== testsuite/tests/rename/should_compile/T24732.hs ===================================== @@ -0,0 +1,4 @@ +import P' + +main :: IO () +main = printf "Hello World\n" \ No newline at end of file ===================================== testsuite/tests/rename/should_compile/T24732.stdout ===================================== @@ -0,0 +1 @@ +Hello World ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -223,3 +223,4 @@ test('T22478a', req_th, compile, ['']) test('RecordWildCardDeprecation', normal, multimod_compile, ['RecordWildCardDeprecation', '-Wno-duplicate-exports']) test('T14032b', normal, compile_and_run, ['']) test('T14032d', normal, compile, ['']) +test('T24732', normal, compile_and_run, ['-package "base(Prelude, Text.Printf as P\')"']) ===================================== testsuite/tests/simplCore/should_compile/T24768.hs ===================================== @@ -0,0 +1,56 @@ +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TupleSections #-} +{-# LANGUAGE TypeApplications #-} + +-- In this example the simplifer destroyed a join point, +-- namely the `loop` inside `detectLeaks` + +module T24768 (detectLeaks) where + +import Control.Monad (zipWithM_) +import Control.Monad.Reader (ReaderT(..)) +import Control.Monad.State (StateT, evalStateT) +import qualified Data.Map as M +import qualified Data.Set as S + +data Debuggee + +newtype DebugM a = DebugM (ReaderT Debuggee IO a) + deriving (Functor, Applicative, Monad) + +runSimple :: Debuggee -> DebugM a -> IO a +runSimple d (DebugM a) = runReaderT a d + +cands :: [a] +cands = [] +{-# NOINLINE cands #-} + +detectLeaks :: Debuggee -> IO () +detectLeaks e = loop M.empty + where + loop :: M.Map () RankInfo -> IO () + loop rm = do + gs <- runSimple e $ mapM (findSlice rm) cands + zipWithM_ (\n _g -> writeFile + ("slices/" ++ show @Int n ++ ".dot") + "abcd") + [0..] gs + loop rm + +data RankInfo = RankInfo !Double !Int + +lookupRM :: () -> M.Map () RankInfo -> [((), RankInfo)] +lookupRM k m = M.assocs filtered_map + where + (res_map, _) = M.partitionWithKey (\e _ -> e == k) m + filtered_map = M.filter (\(RankInfo r _) -> r > 0) res_map + +findSlice :: forall m a. Monad m => M.Map () RankInfo -> () -> m [a] +findSlice rm _k = evalStateT go S.empty + where + go :: StateT s m [a] + go = do + let next_edges = lookupRM () rm + _ss <- concat <$> mapM (\_ -> go) next_edges + return [] ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -515,3 +515,4 @@ test('T24229b', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typea test('T24370', normal, compile, ['-O']) test('T24551', normal, compile, ['-O -dcore-lint']) test('T24726', normal, compile, ['-dcore-lint -dsuppress-uniques']) +test('T24768', normal, compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0367a1902a4092945e0dce74416cbdb96ac40e8f...eb4015828fe3f2a0e3f2c71afb96e3f6a02ea1db -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0367a1902a4092945e0dce74416cbdb96ac40e8f...eb4015828fe3f2a0e3f2c71afb96e3f6a02ea1db You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun May 5 19:49:11 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Sun, 05 May 2024 15:49:11 -0400 Subject: [Git][ghc/ghc][wip/T24359] 211 commits: rts: fix clang compilation on aarch64 Message-ID: <6637e2b7e1b48_53c462b6ff38652ab@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24359 at Glasgow Haskell Compiler / GHC Commits: 7db8c992 by Cheng Shao at 2024-03-25T13:45:46-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. - - - - - 237194ce by Sylvain Henry at 2024-03-25T13:46:27-04:00 Lexer: fix imports for Alex 3.5.1 (#24583) - - - - - 810660b7 by Cheng Shao at 2024-03-25T22:19:16-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - d2ba41e8 by Alan Zimmerman at 2024-03-25T22:19:51-04:00 EPA: do not duplicate comments in signature RHS - - - - - 32a8103f by Rodrigo Mesquita at 2024-03-26T21:16:12-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. - - - - - bf65a7c3 by Rodrigo Mesquita at 2024-03-26T21:16:48-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 - - - - - cfeb70d3 by Rodrigo Mesquita at 2024-03-26T21:17:24-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 13223f6d by Serge S. Gulin at 2024-03-27T07:28:51-04:00 JS: `h$rts_isProfiled` is removed from `profiling` and left its version at `rts/js/config.js` - - - - - 0acfe391 by Alan Zimmerman at 2024-03-27T07:29:27-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. - - - - - cd0fb82f by Alan Zimmerman at 2024-03-27T19:33:08+00:00 EPA: Fix FamDecl range The span was incorrect if opt_datafam_kind_sig was empty - - - - - f8f384a8 by Ben Gamari at 2024-03-29T01:23:03-04:00 Fix type of _get_osfhandle foreign import Fixes #24601. - - - - - 00d3ecf0 by Alan Zimmerman at 2024-03-29T12:19:10+00:00 EPA: Extend StringLiteral range to include trailing commas This goes slightly against the exact printing philosophy where trailing decorations should be in an annotation, but the practicalities of adding it to the WarningTxt environment, and the problems caused by deviating do not make a more principles approach worthwhile. - - - - - efab3649 by brandon s allbery kf8nh at 2024-03-31T20:04:01-04:00 clarify Note [Preproccesing invocations] - - - - - c8a4c050 by Ben Gamari at 2024-04-02T12:50:35-04:00 rts: Fix TSAN_ENABLED CPP guard This should be `#if defined(TSAN_ENABLED)`, not `#if TSAN_ENABLED`, lest we suffer warnings. - - - - - e91dad93 by Cheng Shao at 2024-04-02T12:50:35-04:00 rts: fix errors when compiling with TSAN This commit fixes rts compilation errors when compiling with TSAN: - xxx_FENCE macros are redefined and trigger CPP warnings. - Use SIZEOF_W. WORD_SIZE_IN_BITS is provided by MachDeps.h which Cmm.h doesn't include by default. - - - - - a9ab9455 by Cheng Shao at 2024-04-02T12:50:35-04:00 rts: fix clang-specific errors when compiling with TSAN This commit fixes clang-specific rts compilation errors when compiling with TSAN: - clang doesn't have -Wtsan flag - Fix prototype of ghc_tsan_* helper functions - __tsan_atomic_* functions aren't clang built-ins and sanitizer/tsan_interface_atomic.h needs to be included - On macOS, TSAN runtime library is libclang_rt.tsan_osx_dynamic.dylib, not libtsan. -fsanitize-thread as a link-time flag will take care of linking the TSAN runtime library anyway so remove tsan as an rts extra library - - - - - 865bd717 by Cheng Shao at 2024-04-02T12:50:35-04:00 compiler: fix github link to __tsan_memory_order in a comment - - - - - 07cb627c by Cheng Shao at 2024-04-02T12:50:35-04:00 ci: improve TSAN CI jobs - Run TSAN jobs with +thread_sanitizer_cmm which enables Cmm instrumentation as well. - Run TSAN jobs in deb12 which ships gcc-12, a reasonably recent gcc that @bgamari confirms he's using in #GHC:matrix.org. Ideally we should be using latest clang release for latest improvements in sanitizers, though that's left as future work. - Mark TSAN jobs as manual+allow_failure in validate pipelines. The purpose is to demonstrate that we have indeed at least fixed building of TSAN mode in CI without blocking the patch to land, and once merged other people can begin playing with TSAN using their own dev setups and feature branches. - - - - - a1c18c7b by Andrei Borzenkov at 2024-04-02T12:51:11-04:00 Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy (#24299, #23639) This patch implements refactoring which is a prerequisite to updating kind checking of type patterns. This is a huge simplification of the main worker that checks kind of HsType. It also fixes the issues caused by previous code duplication, e.g. that we didn't add module finalizers from splices in inference mode. - - - - - 817e8936 by Rodrigo Mesquita at 2024-04-02T20:13:05-04:00 th: Hide the Language.Haskell.TH.Lib.Internal module from haddock Fixes #24562 - - - - - b36ee57b by Sylvain Henry at 2024-04-02T20:13:46-04:00 JS: reenable h$appendToHsString optimization (#24495) The optimization introducing h$appendToHsString wasn't kicking in anymore (while it did in 9.8.1) because of the changes introduced in #23270 (7e0c8b3bab30). This patch reenables the optimization by matching on case-expression, as done in Cmm for unpackCString# standard thunks. The test is also T24495 added in the next commits (two commits for ease of backporting to 9.8). - - - - - 527616e9 by Sylvain Henry at 2024-04-02T20:13:46-04:00 JS: fix h$appendToHsString implementation (#24495) h$appendToHsString needs to wrap its argument in an updatable thunk to behave like unpackAppendCString#. Otherwise if a SingleEntry thunk is passed, it is stored as-is in a CONS cell, making the resulting list impossible to deepseq (forcing the thunk doesn't update the contents of the CONS cell)! The added test checks that the optimization kicks in and that h$appendToHsString works as intended. Fix #24495 - - - - - faa30b41 by Simon Peyton Jones at 2024-04-02T20:14:22-04:00 Deal with duplicate tyvars in type declarations GHC was outright crashing before this fix: #24604 - - - - - e0b0c717 by Simon Peyton Jones at 2024-04-02T20:14:58-04:00 Try using MCoercion in exprIsConApp_maybe This is just a simple refactor that makes exprIsConApp_maybe a little bit more direct, simple, and efficient. Metrics: compile_time/bytes allocated geo. mean -0.1% minimum -2.0% maximum -0.0% Not a big gain, but worthwhile given that the code is, if anything, easier to grok. - - - - - 15f4d867 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Initial ./configure support for selecting I/O managers In this patch we just define new CPP vars, but don't yet use them or replace the existing approach. That will follow. The intention here is that every I/O manager can be enabled/disabled at GHC build time (subject to some constraints). More than one I/O manager can be enabled to be built. At least one I/O manager supporting the non-threaded RTS must be enabled as well as at least one supporting the non-threaded RTS. The I/O managers enabled here will become the choices available at runtime at RTS startup (in later patches). The choice can be made with RTS flags. There are separate sets of choices for the threaded and non-threaded RTS ways, because most I/O managers are specific to these ways. Furthermore we must establish a default I/O manager for the threaded and non-threaded RTS. Most I/O managers are platform-specific so there are checks to ensure each one can be enabled on the platform. Such checks are also where (in future) any system dependencies (e.g. libraries) can be checked. The output is a set of CPP flags (in the mk/config.h file), with one flag per named I/O manager: * IOMGR_BUILD_<name> : which ones should be built (some) * IOMGR_DEFAULT_NON_THREADED_<name> : which one is default (exactly one) * IOMGR_DEFAULT_THREADED_<name> : which one is default (exactly one) and a set of derived flags in IOManager.h * IOMGR_ENABLED_<name> : enabled for the current RTS way Note that IOMGR_BUILD_<name> just says that an I/O manager will be built for _some_ RTS way (i.e. threaded or non-threaded). The derived flags IOMGR_ENABLED_<name> in IOManager.h say if each I/O manager is enabled in the "current" RTS way. These are the ones that can be used for conditional compilation of the I/O manager code. Co-authored-by: Pi Delport <pi at well-typed.com> - - - - - 85b0f87a by Duncan Coutts at 2024-04-03T01:27:17-04:00 Change the handling of the RTS flag --io-manager= Now instead of it being just used on Windows to select between the WinIO vs the MIO or Win32-legacy I/O managers, it is now used on all platforms for selecting the I/O manager to use. Right now it remains the case that there is only an actual choice on Windows, but that will change later. Document the --io-manager flag in the user guide. This change is also reflected in the RTS flags types in the base library. Deprecate the export of IoSubSystem from GHC.RTS.Flags with a message to import it from GHC.IO.Subsystem. The way the 'IoSubSystem' is detected also changes. Instead of looking at the RTS flag, there is now a C bool global var in the RTS which gets set on startup when the I/O manager is selected. This bool var says whether the selected I/O manager classifies as "native" on Windows, which in practice means the WinIO I/O manager has been selected. Similarly, the is_io_mng_native_p RTS helper function is re-implemented in terms of the selected I/O manager, rather than based on the RTS flags. We do however remove the ./configure --native-io-manager flag because we're bringing the WinIO/MIO/Win32-legacy choice under the new general scheme for selecting I/O managers, and that new scheme involves no ./configure time user choices, just runtime RTS flag choices. - - - - - 1a8f020f by Duncan Coutts at 2024-04-03T01:27:17-04:00 Convert {init,stop,exit}IOManager to switch style Rather than ad-hoc cpp conitionals on THREADED_RTS and mingw32_HOST_OS, we use a style where we switch on the I/O manager impl, with cases for each I/O manager impl. - - - - - a5bad3d2 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Split up the CapIOManager content by I/O manager Using the new IOMGR_ENABLED_<name> CPP defines. - - - - - 1d36e609 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Convert initIOManagerAfterFork and wakeupIOManager to switch style - - - - - c2f26f36 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move most of waitRead#/Write# from cmm to C Moves it into the IOManager.c where we can follow the new pattern of switching on the selected I/O manager. - - - - - 457705a8 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move most of the delay# impl from cmm to C Moves it into the IOManager.c where we can follow the new pattern of switching on the selected I/O manager. Uses a new IOManager API: syncDelay, following the naming convention of sync* for thread-synchronous I/O & timer/delay operations. As part of porting from cmm to C, we maintain the rule that the why_blocked gets accessed using load acquire and store release atomic memory operations. There was one exception to this rule: in the delay# primop cmm code on posix (not win32), the why_blocked was being updated using a store relaxed, not a store release. I've no idea why. In this convesion I'm playing it safe here and using store release consistently. - - - - - e93058e0 by Duncan Coutts at 2024-04-03T01:27:18-04:00 insertIntoSleepingQueue is no longer public No longer defined in IOManager.h, just a private function in IOManager.c. Since it is no longer called from cmm code, just from syncDelay. It ought to get moved further into the select() I/O manager impl, rather than living in IOManager.c. On the other hand appendToIOBlockedQueue is still called from cmm code in the win32-legacy I/O manager primops async{Read,Write}#, and it is also used by the select() I/O manager. Update the CPP and comments to reflect this. - - - - - 60ce9910 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move anyPendingTimeoutsOrIO impl from .h to .c The implementation is eventually going to need to use more private things, which will drag in unwanted includes into IOManager.h, so it's better to move the impl out of the header file and into the .c file, at the slight cost of it no longer being inline. At the same time, change to the "switch (iomgr_type)" style. - - - - - f70b8108 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Take a simpler approach to gcc warnings in IOManager.c We have lots of functions with conditional implementations for different I/O managers. Some functions, for some I/O managers, naturally have implementations that do nothing or barf. When only one such I/O manager is enabled then the whole function implementation will have an implementation that does nothing or barfs. This then results in warnings from gcc that parameters are unused, or that the function should be marked with attribute noreturn (since barf does not return). The USED_IF_THREADS trick for fine-grained warning supression is fine for just two cases, but an equivalent here would need USED_IF_THE_ONLY_ENABLED_IOMGR_IS_X_OR_Y which would have combinitorial blowup. So we take a coarse grained approach and simply disable these two warnings for the whole file. So we use a GCC pragma, with its handy push/pop support: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsuggest-attribute=noreturn" #pragma GCC diagnostic ignored "-Wunused-parameter" ... #pragma GCC diagnostic pop - - - - - b48805b9 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add a new trace class for the iomanager It makes sense now for it to be separate from the scheduler class of tracers. Enabled with +RTS -Do. Document the -Do debug flag in the user guide. - - - - - f0c1f862 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Have the throwTo impl go via (new) IOManager APIs rather than directly operating on the IO manager's data structures. Specifically, when thowing an async exception to a thread that is blocked waiting for I/O or waiting for a timer, then we want to cancel that I/O waiting or cancel the timer. Currently this is done directly in removeFromQueues() in RaiseAsync.c. We want it to go via proper APIs both for modularity but also to let us support multiple I/O managers. So add sync{IO,Delay}Cancel, which is the cancellation for the corresponding sync{IO,Delay}. The implementations of these use the usual "switch (iomgr_type)" style. - - - - - 4f9e9c4e by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move awaitEvent into a proper IOManager API and have the scheduler use it. Previously the scheduler calls awaitEvent directly, and awaitEvent is implemented directly in the RTS I/O managers (select, win32). This relies on the old scheme where there's a single active I/O manager for each platform and RTS way. We want to move that to go via an API in IOManager.{h,c} which can then call out to the active I/O manager. Also take the opportunity to split awaitEvent into two. The existing awaitEvent has a bool wait parameter, to say if the call should be blocking or non-blocking. We split this into two separate functions: pollCompletedTimeoutsOrIO and awaitCompletedTimeoutsOrIO. We split them for a few reasons: they have different post-conditions (specifically the await version is supposed to guarantee that there are threads runnable when it completes). Secondly, it is also anticipated that in future I/O managers the implementations of the two cases will be simpler if they are separated. - - - - - 5ad4b30f by Duncan Coutts at 2024-04-03T01:27:18-04:00 Rename awaitEvent in select and win32 I/O managers These are now just called from IOManager.c and are the per-I/O manager backend impls (whereas previously awaitEvent was the entry point). Follow the new naming convention in the IOManager.{h,c} of awaitCompletedTimeoutsOrIO, with the I/O manager's name as a suffix: so awaitCompletedTimeoutsOrIO{Select,Win32}. - - - - - d30c6bc6 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Tidy up a couple things in Select.{h,c} Use the standard #include {Begin,End}Private.h style rather than RTS_PRIVATE on individual decls. And conditionally build the code for the select I/O manager based on the new CPP IOMGR_ENABLED_SELECT rather than on THREADED_RTS. - - - - - 4161f516 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add an IOManager API for scavenging TSO blocked_info When the GC scavenges a TSO it needs to scavenge the tso->blocked_info but the blocked_info is a big union and what lives there depends on the two->why_blocked, which for I/O-related reasons is something that in principle is the responsibility of the I/O manager and not the GC. So the right thing to do is for the GC to ask the I/O manager to sscavenge the blocked_info if it encounters any I/O-related why_blocked reasons. So we add scavengeTSOIOManager in IOManager.{h,c} with the usual style. Now as it happens, right now, there is no special scavenging to do, so the implementation of scavengeTSOIOManager is a fancy no-op. That's because the select I/O manager uses only the fd and target members, which are not GC pointers, and the win32-legacy I/O manager _ought_ to be using GC-managed heap objects for the StgAsyncIOResult but it is actually usingthe C heap, so again no GC pointers. If the win32-legacy were doing this more sensibly, then scavengeTSOIOManager would be the right place to do the GC magic. Future I/O managers will need GC heap objects in the tso->blocked_info and will make use of this functionality. - - - - - 94a87d21 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add I/O manager API notifyIOManagerCapabilitiesChanged Used in setNumCapabilities. It only does anything for MIO on Posix. Previously it always invoked Haskell code, but that code only did anything on non-Windows (and non-JS), and only threaded. That currently effectively means the MIO I/O manager on Posix. So now it only invokes it for the MIO Posix case. - - - - - 3be6d591 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Select an I/O manager early in RTS startup We need to select the I/O manager to use during startup before the per-cap I/O manager initialisation. - - - - - aaa294d0 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Make struct CapIOManager be fully opaque Provide an opaque (forward) definition in Capability.h (since the cap contains a *CapIOManager) and then only provide a full definition in a new file IOManagerInternals.h. This new file is only supposed to be included by the IOManager implementation, not by its users. So that means IOManager.c and individual I/O manager implementations. The posix/Signals.c still needs direct access, but that should be eliminated. Anything that needs direct access either needs to be clearly part of an I/O manager (e.g. the sleect() one) or go via a proper API. - - - - - 877a2a80 by Duncan Coutts at 2024-04-03T01:27:18-04:00 The select() I/O manager does have some global initialisation It's just to make sure an exception CAF is a GC root. - - - - - 9c51473b by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add tracing for the main I/O manager actions Using the new tracer class. Note: The unconditional definition of showIOManager should be compatible with the debugTrace change in 7c7d1f6. Co-authored-by: Pi Delport <pi at well-typed.com> - - - - - c7d3e3a3 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Include the default I/O manager in the +RTS --info output Document the extra +RTS --info output in the user guide - - - - - 8023bad4 by Duncan Coutts at 2024-04-03T01:27:18-04:00 waitRead# / waitWrite# do not work for win32-legacy I/O manager Previously it was unclear that they did not work because the code path was shared with other I/O managers (in particular select()). Following the code carefully shows that what actually happens is that the calling thread would block forever: the thread will be put into the blocked queue, but no other action is scheduled that will ever result in it getting unblocked. It's better to just fail loudly in case anyone accidentally calls it, also it's less confusing code. - - - - - 83a74d20 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Conditionally ignore some GCC warnings Some GCC versions don't know about some warnings, and they complain that we're ignoring unknown warnings. So we try to ignore the warning based on the GCC version. - - - - - 1adc6fa4 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Accept changes to base-exports All the changes are in fact not changes at all. Previously, the IoSubSystem data type was defined in GHC.RTS.Flags and exported from both GHC.RTS.Flags and GHC.IO.SubSystem. Now, the data type is defined in GHC.IO.SubSystem and still exported from both modules. Therefore, the same exports and same instances are still available from both modules. But the base-exports records only the defining module, and so it looks like a change when it is fully compatible. Related: we do add a deprecation to the export of the type via GHC.RTS.Flags, telling people to use the export from GHC.IO.SubSystem. Also the sort order for some unrelated Show instances changed. No idea why. The same changes apply in the other versions, with a few more changes due to sort order weirdness. - - - - - 8d950968 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Accept metric decrease in T12227 I can't think of any good reason that anything in this MR should have changed the number of allocations, up or down. (Yes this is an empty commit.) Metric Decrease: T12227 - - - - - e869605e by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Several improvements to the handling of coercions * Make `mkSymCo` and `mkInstCo` smarter Fixes #23642 * Fix return role of `SelCo` in the coercion optimiser. Fixes #23617 * Make the coercion optimiser `opt_trans_rule` work better for newtypes Fixes #23619 - - - - - 1efd0714 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 FloatOut: improve floating for join point See the new Note [Floating join point bindings]. * Completely get rid of the complicated join_ceiling nonsense, which I have never understood. * Do not float join points at all, except perhaps to top level. * Some refactoring around wantToFloat, to treat Rec and NonRec more uniformly - - - - - 9c00154d by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Improve eta-expansion through call stacks See Note [Eta expanding through CallStacks] in GHC.Core.Opt.Arity This is a one-line change, that fixes an inconsistency - || isCallStackPredTy ty + || isCallStackPredTy ty || isCallStackTy ty - - - - - 95a9a172 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Spelling, layout, pretty-printing only - - - - - bdf1660f by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Improve exprIsConApp_maybe a little Eliminate a redundant case at birth. This sometimes reduces Simplifier iterations. See Note [Case elim in exprIsConApp_maybe]. - - - - - 609cd32c by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Inline GHC.HsToCore.Pmc.Solver.Types.trvVarInfo When exploring compile-time regressions after meddling with the Simplifier, I discovered that GHC.HsToCore.Pmc.Solver.Types.trvVarInfo was very delicately balanced. It's a small, heavily used, overloaded function and it's important that it inlines. By a fluke it was before, but at various times in my journey it stopped doing so. So I just added an INLINE pragma to it; no sense in depending on a delicately-balanced fluke. - - - - - ae24c9bc by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Slight improvement in WorkWrap Ensure that WorkWrap preserves lambda binders, in case of join points. Sadly I have forgotten why I made this change (it was while I was doing a lot of meddling in the Simplifier, but * it does no harm, * it is slightly more efficient, and * presumably it made something better! Anyway I have kept it in a separate commit. - - - - - e9297181 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Use named record fields for the CastIt { ... } data constructor This is a pure refactor - - - - - b4581e23 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Remove a long-commented-out line Pure refactoring - - - - - e026bdf2 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The main changes are below. There are also many new or rewritten Notes. Avoiding simplifying repeatedly ~~~~~~~~~~~~~~~ See Note [Avoiding simplifying repeatedly] * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env. Currently used only for the next point: avoiding repeatedly simplifying coercions. * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] * Improve the case-merge transformation: - Move the main code to `GHC.Core.Utils.mergeCaseAlts`, to join `filterAlts` and friends. See Note [Merge Nested Cases] in GHC.Core.Utils. - Add a new case for `tagToEnum#`; see wrinkle (MC3). - Add a new case to look through join points: see wrinkle (MC4) postInlineUnconditionally ~~~~~~~~~~~~~~~~~~~~~~~~~ * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. * Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. * Improve occurrence analyis for bottoming function calls, to help postInlineUnconditionally. See Note [Bottoming function calls] in GHC.Core.Opt.OccurAnal Inlining generally ~~~~~~~~~~~~~~~~~~ * In GHC.Core.Opt.Simplify.Utils.interestingCallContext, use RhsCtxt NonRecursive (not BoringCtxt) for a plain-seq case. See Note [Seq is boring] Also, wrinkle (SB1), inline in that `seq` context only for INLINE functions (UnfWhen guidance). * In GHC.Core.Opt.Simplify.Utils.interestingArg, - return ValueArg for OtherCon [c1,c2, ...], but - return NonTrivArg for OtherCon [] This makes a function a little less likely to inline if all we know is that the argument is evaluated, but nothing else. * isConLikeUnfolding is no longer true for OtherCon {}. This propagates to exprIsConLike. Con-like-ness has /positive/ information. Join points ~~~~~~~~~~~ * Be very careful about inlining join points. See these two long Notes Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline * When making join points, don't do so if the join point is so small it will immediately be inlined; check uncondInlineJoin. * In GHC.Core.Opt.Simplify.Inline.tryUnfolding, improve the inlining heuristics for join points. In general we /do not/ want to inline join points /even if they are small/. See Note [Duplicating join points] GHC.Core.Opt.Simplify.Iteration. But sometimes we do: see Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline; and the new `isBetterUnfoldingThan` function. * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * In GHC.Core.Unfold.sizeExpr, make jumps small, so that we don't penalise having a non-inlined join point. Performance changes ~~~~~~~~~~~~~~~~~~~ * Binary sizes fall by around 2.6%, according to nofib. * Compile times improve slightly. Here are the figures over 1%. I investiate the biggest differnce in T18304. It's a very small module, just a few hundred nodes. The large percentage difffence is due to a single function that didn't quite inline before, and does now, making code size a bit bigger. I decided gains outweighed the losses. Metrics: compile_time/bytes allocated (changes over +/- 1%) ------------------------------------------------ CoOpt_Singletons(normal) -9.2% GOOD LargeRecord(normal) -23.5% GOOD MultiComponentModulesRecomp(normal) +1.2% MultiLayerModulesTH_OneShot(normal) +4.1% BAD PmSeriesS(normal) -3.8% PmSeriesV(normal) -1.5% T11195(normal) -1.3% T12227(normal) -20.4% GOOD T12545(normal) -3.2% T12707(normal) -2.1% GOOD T13253(normal) -1.2% T13253-spj(normal) +8.1% BAD T13386(normal) -3.1% GOOD T14766(normal) -2.6% GOOD T15164(normal) -1.4% T15304(normal) +1.2% T15630(normal) -8.2% T15630a(normal) NEW T15703(normal) -14.7% GOOD T16577(normal) -2.3% GOOD T17516(normal) -39.7% GOOD T18140(normal) +1.2% T18223(normal) -17.1% GOOD T18282(normal) -5.0% GOOD T18304(normal) +10.8% BAD T18923(normal) -2.9% GOOD T1969(normal) +1.0% T19695(normal) -1.5% T20049(normal) -12.7% GOOD T21839c(normal) -4.1% GOOD T3064(normal) -1.5% T3294(normal) +1.2% BAD T4801(normal) +1.2% T5030(normal) -15.2% GOOD T5321Fun(normal) -2.2% GOOD T6048(optasm) -16.8% GOOD T783(normal) -1.2% T8095(normal) -6.0% GOOD T9630(normal) -4.7% GOOD T9961(normal) +1.9% BAD WWRec(normal) -1.4% info_table_map_perf(normal) -1.3% parsing001(normal) +1.5% geo. mean -2.0% minimum -39.7% maximum +10.8% * Runtimes generally improve. In the testsuite perf/should_run gives: Metrics: runtime/bytes allocated ------------------------------------------ Conversions(normal) -0.3% T13536a(optasm) -41.7% GOOD T4830(normal) -0.1% haddock.Cabal(normal) -0.1% haddock.base(normal) -0.1% haddock.compiler(normal) -0.1% geo. mean -0.8% minimum -41.7% maximum +0.0% * For runtime, nofib is a better test. The news is mostly good. Here are the number more than +/- 0.1%: # bytes allocated ==========================++========== imaginary/digits-of-e1 || -14.40% imaginary/digits-of-e2 || -4.41% imaginary/paraffins || -0.17% imaginary/rfib || -0.15% imaginary/wheel-sieve2 || -0.10% real/compress || -0.47% real/fluid || -0.10% real/fulsom || +0.14% real/gamteb || -1.47% real/gg || -0.20% real/infer || +0.24% real/pic || -0.23% real/prolog || -0.36% real/scs || -0.46% real/smallpt || +4.03% shootout/k-nucleotide || -20.23% shootout/n-body || -0.42% shootout/spectral-norm || -0.13% spectral/boyer2 || -3.80% spectral/constraints || -0.27% spectral/hartel/ida || -0.82% spectral/mate || -20.34% spectral/para || +0.46% spectral/rewrite || +1.30% spectral/sphere || -0.14% ==========================++========== geom mean || -0.59% real/smallpt has a huge nest of local definitions, and I could not pin down a reason for a regression. But there are three big wins! Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12707 T13386 T13536a T14766 T15703 T16577 T17516 T18223 T18282 T18923 T21839c T20049 T5321Fun T5030 T6048 T8095 T9630 T783 Metric Increase: MultiLayerModulesTH_OneShot T13253-spj T18304 T18698a T9961 T3294 - - - - - 27db3c5e by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Testsuite message changes from simplifier improvements - - - - - 271a7812 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Account for bottoming functions in OccurAnal This fixes #24582, a small but long-standing bug - - - - - 0fde229f by Ben Gamari at 2024-04-04T07:04:58-04:00 testsuite: Introduce template-haskell-exports test - - - - - 0c4a9686 by Luite Stegeman at 2024-04-04T07:05:39-04:00 Update correct counter in bumpTickyAllocd - - - - - 5f085d3a by Fendor at 2024-04-04T14:47:33-04:00 Replace `SizedSeq` with `FlatBag` for flattened structure LinkedLists are notoriously memory ineffiecient when all we do is traversing a structure. As 'UnlinkedBCO' has been identified as a data structure that impacts the overall memory usage of GHCi sessions, we avoid linked lists and prefer flattened structure for storing. We introduce a new memory efficient representation of sequential elements that has special support for the cases: * Empty * Singleton * Tuple Elements This improves sharing in the 'Empty' case and avoids the overhead of 'Array' until its constant overhead is justified. - - - - - 82cfe10c by Fendor at 2024-04-04T14:47:33-04:00 Compact FlatBag array representation `Array` contains three additional `Word`'s we do not need in `FlatBag`. Move `FlatBag` to `SmallArray`. Expand the API of SmallArray by `sizeofSmallArray` and add common traversal functions, such as `mapSmallArray` and `foldMapSmallArray`. Additionally, allow users to force the elements of a `SmallArray` via `rnfSmallArray`. - - - - - 36a75b80 by Andrei Borzenkov at 2024-04-04T14:48:10-04:00 Change how invisible patterns represented in haskell syntax and TH AST (#24557) Before this patch: data ArgPat p = InvisPat (LHsType p) | VisPat (LPat p) With this patch: data Pat p = ... | InvisPat (LHsType p) ... And the same transformation in the TH land. The rest of the changes is just updating code to handle new AST and writing tests to check if it is possible to create invalid states using TH. Metric Increase: MultiLayerModulesTH_OneShot - - - - - 28009fbc by Matthew Pickering at 2024-04-04T14:48:46-04:00 Fix off by one error in seekBinNoExpand and seekBin - - - - - 9b9e031b by Ben Gamari at 2024-04-04T21:30:08-04:00 compiler: Allow more types in GHCForeignImportPrim For many, many years `GHCForeignImportPrim` has suffered from the rather restrictive limitation of not allowing any non-trivial types in arguments or results. This limitation was justified by the code generator allegely barfing in the presence of such types. However, this restriction appears to originate well before the NCG rewrite and the new NCG does not appear to have any trouble with such types (see the added `T24598` test). Lift this restriction. Fixes #24598. - - - - - 1324b862 by Alan Zimmerman at 2024-04-04T21:30:44-04:00 EPA: Use EpaLocation not SrcSpan in ForeignDecls This allows us to update them for makeDeltaAst in ghc-exactprint - - - - - 19883a23 by Alan Zimmerman at 2024-04-05T16:58:17-04:00 EPA: Use EpaLocation for RecFieldsDotDot So we can update it to a delta position in makeDeltaAst if needed. - - - - - e8724327 by Matthew Pickering at 2024-04-05T16:58:53-04:00 Remove accidentally committed test.hs - - - - - 88cb3e10 by Fendor at 2024-04-08T09:03:34-04:00 Avoid UArray when indexing is not required `UnlinkedBCO`'s can occur many times in the heap. Each `UnlinkedBCO` references two `UArray`'s but never indexes them. They are only needed to encode the elements into a `ByteArray#`. The three words for the lower bound, upper bound and number of elements are essentially unused, thus we replace `UArray` with a wrapper around `ByteArray#`. This saves us up to three words for each `UnlinkedBCO`. Further, to avoid re-allocating these words for `ResolvedBCO`, we repeat the procedure for `ResolvedBCO` and add custom `Binary` and `Show` instances. For example, agda's repl session has around 360_000 UnlinkedBCO's, so avoiding these three words is already saving us around 8MB residency. - - - - - f2cc1107 by Fendor at 2024-04-08T09:04:11-04:00 Never UNPACK `FastMutInt` for counting z-encoded `FastString`s In `FastStringTable`, we count the number of z-encoded FastStrings that exist in a GHC session. We used to UNPACK the counters to not waste memory, but live retainer analysis showed that we allocate a lot of `FastMutInt`s, retained by `mkFastZString`. We lazily compute the `FastZString`, only incrementing the counter when the `FastZString` is forced. The function `mkFastStringWith` calls `mkZFastString` and boxes the `FastMutInt`, leading to the following core: mkFastStringWith = \ mk_fs _ -> = case stringTable of { FastStringTable _ n_zencs segments# _ -> ... case ((mk_fs (I# ...) (FastMutInt n_zencs)) `cast` <Co:2> :: ...) ... Marking this field as `NOUNPACK` avoids this reboxing, eliminating the allocation of a fresh `FastMutInt` on every `FastString` allocation. - - - - - c6def949 by Matthew Pickering at 2024-04-08T16:06:51-04:00 Force in_multi to avoid retaining entire hsc_env - - - - - fbb91a63 by Fendor at 2024-04-08T16:06:51-04:00 Eliminate name thunk in declaration fingerprinting Thunk analysis showed that we have about 100_000 thunks (in agda and `-fwrite-simplified-core`) pointing to the name of the name decl. Forcing this thunk fixes this issue. The thunk created here is retained by the thunk created by forkM, it is better to eagerly force this because the result (a `Name`) is already retained indirectly via the `IfaceDecl`. - - - - - 3b7b0c1c by Alan Zimmerman at 2024-04-08T16:07:27-04:00 EPA: Use EpaLocation in WarningTxt This allows us to use an EpDelta if needed when using makeDeltaAst. - - - - - 12b997df by Alan Zimmerman at 2024-04-08T16:07:27-04:00 EPA: Move DeltaPos and EpaLocation' into GHC.Types.SrcLoc This allows us to use a NoCommentsLocation for the possibly trailing comma location in a StringLiteral. This in turn allows us to correctly roundtrip via makeDeltaAst. - - - - - 868c8a78 by Fendor at 2024-04-09T08:51:50-04:00 Prefer packed representation for CompiledByteCode As there are many 'CompiledByteCode' objects alive during a GHCi session, representing its element in a more packed manner improves space behaviour at a minimal cost. When running GHCi on the agda codebase, we find around 380 live 'CompiledByteCode' objects. Packing their respective 'UnlinkedByteCode' can save quite some pointers. - - - - - be3bddde by Alan Zimmerman at 2024-04-09T08:52:26-04:00 EPA: Capture all comments in a ClassDecl Hopefully the final fix needed for #24533 - - - - - 3d0806fc by Jade at 2024-04-10T05:39:53-04:00 Validate -main-is flag using parseIdentifier Fixes #24368 - - - - - dd530bb7 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: free error message before returning Fixes a memory leak in rts/linker/PEi386.c - - - - - e008a19a by Alexis King at 2024-04-10T05:40:29-04:00 linker: Avoid linear search when looking up Haskell symbols via dlsym See the primary Note [Looking up symbols in the relevant objects] for a more in-depth explanation. When dynamically loading a Haskell symbol (typical when running a splice or GHCi expression), before this commit we would search for the symbol in all dynamic libraries that were loaded. However, this could be very inefficient when too many packages are loaded (which can happen if there are many package dependencies) because the time to lookup the would be linear in the number of packages loaded. This commit drastically improves symbol loading performance by introducing a mapping from units to the handles of corresponding loaded dlls. These handles are returned by dlopen when we load a dll, and can then be used to look up in a specific dynamic library. Looking up a given Name is now much more precise because we can get lookup its unit in the mapping and lookup the symbol solely in the handles of the dynamic libraries loaded for that unit. In one measurement, the wait time before the expression was executed went from +-38 seconds down to +-2s. This commit also includes Note [Symbols may not be found in pkgs_loaded], explaining the fallback to the old behaviour in case no dll can be found in the unit mapping for a given Name. Fixes #23415 Co-authored-by: Rodrigo Mesquita (@alt-romes) - - - - - dcfaa190 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: Make addDLL a wrapper around loadNativeObj Rewrite the implementation of `addDLL` as a wrapper around the more principled `loadNativeObj` rts linker function. The latter should be preferred while the former is preserved for backwards compatibility. `loadNativeObj` was previously only available on ELF platforms, so this commit further refactors the rts linker to transform loadNativeObj_ELF into loadNativeObj_POSIX, which is available in ELF and MachO platforms. The refactor made it possible to remove the `dl_mutex` mutex in favour of always using `linker_mutex` (rather than a combination of both). Lastly, we implement `loadNativeObj` for Windows too. - - - - - 12931698 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 Use symbol cache in internal interpreter too This commit makes the symbol cache that was used by the external interpreter available for the internal interpreter too. This follows from the analysis in #23415 that suggests the internal interpreter could benefit from this cache too, and that there is no good reason not to have the cache for it too. It also makes it a bit more uniform to have the symbol cache range over both the internal and external interpreter. This commit also refactors the cache into a function which is used by both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the caching logic to `lookupSymbolInDLL` too. - - - - - dccd3ea1 by Ben Gamari at 2024-04-10T05:40:29-04:00 testsuite: Add test for lookupSymbolInNativeObj - - - - - 1b1a92bd by Alan Zimmerman at 2024-04-10T05:41:05-04:00 EPA: Remove unnecessary XRec in CompleteMatchSig The XRec for [LIdP pass] is not needed for exact printing, remove it. - - - - - 6e18ce2b by Ben Gamari at 2024-04-12T08:16:09-04:00 users-guide: Clarify language extension documentation Over the years the users guide's language extension documentation has gone through quite a few refactorings. In the process some of the descriptions have been rendered non-sensical. For instance, the description of `NoImplicitPrelude` actually describes the semantics of `ImplicitPrelude`. To fix this we: * ensure that all extensions are named in their "positive" sense (e.g. `ImplicitPrelude` rather than `NoImplicitPrelude`). * rework the documentation to avoid flag-oriented wording like "enable" and "disable" * ensure that the polarity of the documentation is consistent with reality. Fixes #23895. - - - - - a933aff3 by Zubin Duggal at 2024-04-12T08:16:45-04:00 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - 23c3e624 by Andreas Klebinger at 2024-04-12T08:17:21-04:00 RTS: Emit warning when -M < -H Fixes #24487 - - - - - d23afb8c by Ben Gamari at 2024-04-12T08:17:56-04:00 testsuite: Add broken test for CApiFFI with -fprefer-bytecode See #24634. - - - - - a4bb3a51 by Ben Gamari at 2024-04-12T08:18:32-04:00 base: Deprecate GHC.Pack As proposed in #21461. Closes #21540. - - - - - 55eb8c98 by Ben Gamari at 2024-04-12T08:19:08-04:00 ghc-internal: Fix mentions of ghc-internal in deprecation warnings Closes #24609. - - - - - b0fbd181 by Ben Gamari at 2024-04-12T08:19:44-04:00 rts: Implement set_initial_registers for AArch64 Fixes #23680. - - - - - 14c9ec62 by Ben Gamari at 2024-04-12T08:20:20-04:00 ghcup-metadata: Use Debian 9 binaries on Ubuntu 16, 17 Closes #24646. - - - - - 35a1621e by Ben Gamari at 2024-04-12T08:20:55-04:00 Bump unix submodule to 2.8.5.1 Closes #24640. - - - - - a1c24df0 by Finley McIlwaine at 2024-04-12T08:21:31-04:00 Correct default -funfolding-use-threshold in docs - - - - - 0255d03c by Oleg Grenrus at 2024-04-12T08:22:07-04:00 FastString is a __Modified__ UTF-8 - - - - - c3489547 by Matthew Pickering at 2024-04-12T13:13:44-04:00 rts: Improve tracing message when nursery is resized It is sometimes more useful to know how much bigger or smaller the nursery got when it is resized. In particular I am trying to investigate situations where we end up with fragmentation due to the nursery (#24577) - - - - - 5e4f4ba8 by Simon Peyton Jones at 2024-04-12T13:14:20-04:00 Don't generate wrappers for `type data` constructors with StrictData Previously, the logic for checking if a data constructor needs a wrapper or not would take into account whether the constructor's fields have explicit strictness (e.g., `data T = MkT !Int`), but the logic would _not_ take into account whether `StrictData` was enabled. This meant that something like `type data T = MkT Int` would incorrectly generate a wrapper for `MkT` if `StrictData` was enabled, leading to the horrible errors seen in #24620. To fix this, we disable generating wrappers for `type data` constructors altogether. Fixes #24620. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - dbdf1995 by Alex Mason at 2024-04-15T15:28:26+10:00 Implements MO_S_Mul2 and MO_U_Mul2 using the UMULH, UMULL and SMULH instructions for AArch64 Also adds a test for MO_S_Mul2 - - - - - 42bd0407 by Teo Camarasu at 2024-04-16T20:06:39-04:00 Make template-haskell a stage1 package Promoting template-haskell from a stage0 to a stage1 package means that we can much more easily refactor template-haskell. We implement this by duplicating the in-tree `template-haskell`. A new `template-haskell-next` library is autogenerated to mirror `template-haskell` `stage1:ghc` to depend on the new interface of the library including the `Binary` instances without adding an explicit dependency on `template-haskell`. This is controlled by the `bootstrap-th` cabal flag When building `template-haskell` modules as part of this vendoring we do not have access to quote syntax, so we cannot use variable quote notation (`'Just`). So we either replace these with hand-written `Name`s or hide the code behind CPP. We can remove the `th_hack` from hadrian, which was required when building stage0 packages using the in-tree `template-haskell` library. For more details see Note [Bootstrapping Template Haskell]. Resolves #23536 Co-Authored-By: Sebastian Graf <sgraf1337 at gmail.com> Co-Authored-By: Matthew Craven <5086-clyring at users.noreply.gitlab.haskell.org> - - - - - 3d973e47 by Ben Gamari at 2024-04-16T20:07:15-04:00 Bump parsec submodule to 3.1.17.0 - - - - - 9d38bfa0 by Simon Peyton Jones at 2024-04-16T20:07:51-04:00 Clone CoVars in CorePrep This MR addresses #24463. It's all explained in the new Note [Cloning CoVars and TyVars] - - - - - 0fe2b410 by Andreas Klebinger at 2024-04-16T20:08:27-04:00 NCG: Fix a bug where we errounously removed a required jump instruction. Add a new method to the Instruction class to check if we can eliminate a jump in favour of fallthrough control flow. Fixes #24507 - - - - - 9f99126a by Teo Camarasu at 2024-04-16T20:09:04-04:00 Fix documentation preview from doc-tarball job - Include all the .html files and assets in the job artefacts - Include all the .pdf files in the job artefacts - Mark the artefact as an "exposed" artefact meaning it turns up in the UI. Resolves #24651 - - - - - 3a0642ea by Ben Gamari at 2024-04-16T20:09:39-04:00 rts: Ignore EINTR while polling in timerfd itimer implementation While the RTS does attempt to mask signals, it may be that a foreign library unmasks them. This previously caused benign warnings which we now ignore. See #24610. - - - - - 9a53cd3f by Alan Zimmerman at 2024-04-16T20:10:15-04:00 EPA: Add additional comments field to AnnsModule This is used in exact printing to store comments coming after the `where` keyword but before any comments allocated to imports or decls. It is used in ghc-exactprint, see https://github.com/alanz/ghc-exactprint/commit/44bbed311fd8f0d053053fef195bf47c17d34fa7 - - - - - e5c43259 by Bryan Richter at 2024-04-16T20:10:51-04:00 Remove unrunnable FreeBSD CI jobs FreeBSD runner supply is inelastic. Currently there is only one, and it's unavailable because of a hardware issue. - - - - - 914eb49a by Ben Gamari at 2024-04-16T20:11:27-04:00 rel-eng: Fix mktemp usage in recompress-all We need a temporary directory, not a file. - - - - - f30e4984 by Teo Camarasu at 2024-04-16T20:12:03-04:00 Fix ghc API link in docs/index.html This was missing part of the unit ID meaning it would 404. Resolves #24674 - - - - - d7a3d6b5 by Ben Gamari at 2024-04-16T20:12:39-04:00 template-haskell: Declare TH.Lib.Internal as not-home Rather than `hide`. Closes #24659. - - - - - 5eaa46e7 by Matthew Pickering at 2024-04-19T02:14:55-04:00 testsuite: Rename isCross() predicate to needsTargetWrapper() isCross() was a misnamed because it assumed that all cross targets would provide a target wrapper, but the two most common cross targets (javascript, wasm) don't need a target wrapper. Therefore we rename this predicate to `needsTargetWrapper()` so situations in the testsuite where we can check whether running executables requires a target wrapper or not. - - - - - 55a9d699 by Simon Peyton Jones at 2024-04-19T02:15:32-04:00 Do not float HNFs out of lambdas This MR adjusts SetLevels so that it is less eager to float a HNF (lambda or constructor application) out of a lambda, unless it gets to top level. Data suggests that this change is a small net win: * nofib bytes-allocated falls by -0.09% (but a couple go up) * perf/should_compile bytes-allocated falls by -0.5% * perf/should_run bytes-allocated falls by -0.1% See !12410 for more detail. When fiddling elsewhere, I also found that this patch had a huge positive effect on the (very delicate) test perf/should_run/T21839r But that improvement doesn't show up in this MR by itself. Metric Decrease: MultiLayerModulesRecomp T15703 parsing001 - - - - - f0701585 by Alan Zimmerman at 2024-04-19T02:16:08-04:00 EPA: Fix comments in mkListSyntaxTy0 Also extend the test to confirm. Addresses #24669, 1 of 4 - - - - - b01c01d4 by Serge S. Gulin at 2024-04-19T02:16:51-04:00 JS: set image `x86_64-linux-deb11-emsdk-closure` for build - - - - - c90c6039 by Alan Zimmerman at 2024-04-19T02:17:27-04:00 EPA: Provide correct span for PatBind And remove unused parameter in checkPatBind Contributes to #24669 - - - - - 26036f96 by Alan Zimmerman at 2024-04-19T13:11:08-04:00 EPA: Fix span for PatBuilderAppType Include the location of the prefix @ in the span for InVisPat. Also removes unnecessary annotations from HsTP. Contributes to #24669 - - - - - dba03aab by Matthew Craven at 2024-04-19T13:11:44-04:00 testsuite: Give the pre_cmd for mhu-perf more time - - - - - d31fbf6c by Krzysztof Gogolewski at 2024-04-19T21:04:09-04:00 Fix quantification order for a `op` b and a %m -> b Fixes #23764 Implements https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0640-tyop-quantification-order.rst Updates haddock submodule. - - - - - 385cd1c4 by Sebastian Graf at 2024-04-19T21:04:45-04:00 Make `seq#` a magic Id and inline it in CorePrep (#24124) We can save much code and explanation in Tag Inference and StgToCmm by making `seq#` a known-key Magic Id in `GHC.Internal.IO` and inline this definition in CorePrep. See the updated `Note [seq# magic]`. I also implemented a new `Note [Flatten case-bind]` to get better code for otherwise nested case scrutinees. I renamed the contructors of `ArgInfo` to use an `AI` prefix in order to resolve the clash between `type CpeApp = CoreExpr` and the data constructor of `ArgInfo`, as well as fixed typos in `Note [CorePrep invariants]`. Fixes #24252 and #24124. - - - - - 275e41a9 by Jade at 2024-04-20T11:10:40-04:00 Put the newline after errors instead of before them This mainly has consequences for GHCi but also slightly alters how the output of GHC on the commandline looks. Fixes: #22499 - - - - - dd339c7a by Teo Camarasu at 2024-04-20T11:11:16-04:00 Remove unecessary stage0 packages Historically quite a few packages had to be stage0 as they depended on `template-haskell` and that was stage0. In #23536 we made it so that was no longer the case. This allows us to remove a bunch of packages from this list. A few still remain. A new version of `Win32` is required by `semaphore-compat`. Including `Win32` in the stage0 set requires also including `filepath` because otherwise Hadrian's dependency logic gets confused. Once our boot compiler has a newer version of `Win32` all of these will be able to be dropped. Resolves #24652 - - - - - 2f8e3a25 by Alan Zimmerman at 2024-04-20T11:11:52-04:00 EPA: Avoid duplicated comments in splice decls Contributes to #24669 - - - - - c70b9ddb by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fix typos and namings (fixes #24602) You may noted that I've also changed term of ``` , global "h$vt_double" ||= toJExpr IntV ``` See "IntV" and ``` WaitReadOp -> \[] [fd] -> pure $ PRPrimCall $ returnS (app "h$waidRead" [fd]) ``` See "h$waidRead" - - - - - 3db54f9b by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: trivial checks for variable presence (fixes #24602) - - - - - 777f108f by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fs module imported twice (by emscripten and by ghc-internal). ghc-internal import wrapped in a closure to prevent conflict with emscripten (fixes #24602) Better solution is to use some JavaScript module system like AMD, CommonJS or even UMD. It will be investigated at other issues. At first glance we should try UMD (See https://github.com/umdjs/umd) - - - - - a45a5712 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: thread.js requires h$fds and h$fdReady to be declared for static code analysis, minimal code copied from GHCJS (fixes #24602) I've just copied some old pieces of GHCJS from publicly available sources (See https://github.com/Taneb/shims/blob/a6dd0202dcdb86ad63201495b8b5d9763483eb35/src/io.js#L607). Also I didn't put details to h$fds. I took minimal and left only its object initialization: `var h$fds = {};` - - - - - ad90bf12 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: heap and stack overflows reporting defined as js hard failure (fixes #24602) These errors were treated as a hard failure for browser application. The fix is trivial: just throw error. - - - - - 5962fa52 by Serge S. Gulin at 2024-04-21T16:33:44+03:00 JS: Stubs for code without actual implementation detected by Google Closure Compiler (fixes #24602) These errors were fixed just by introducing stubbed functions with throw for further implementation. - - - - - a0694298 by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add externs to linker (fixes #24602) After enabling jsdoc and built-in google closure compiler types I was needed to deal with the following: 1. Define NodeJS-environment types. I've just copied minimal set of externs from semi-official repo (see https://github.com/externs/nodejs/blob/6c6882c73efcdceecf42e7ba11f1e3e5c9c041f0/v8/nodejs.js#L8). 2. Define Emscripten-environment types: `HEAP8`. Emscripten already provides some externs in our code but it supposed to be run in some module system. And its definitions do not work well in plain bundle. 3. We have some functions which purpose is to add to functions some contextual information via function properties. These functions should be marked as `modifies` to let google closure compiler remove calls if these functions are not used actually by call graph. Such functions are: `h$o`, `h$sti`, `h$init_closure`, `h$setObjInfo`. 4. STG primitives such as registries and stuff from `GHC.StgToJS`. `dXX` properties were already present at externs generator function but they are started from `7`, not from `1`. This message is related: `// fixme does closure compiler bite us here?` - - - - - e58bb29f by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: added both tests: for size and for correctness (fixes #24602) By some reason MacOS builds add to stderr messages like: Ignoring unexpected archive entry: __.SYMDEF ... However I left stderr to `/dev/null` for compatibility with linux CI builds. - - - - - 909f3a9c by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Disable js linker warning for empty symbol table to make js tests running consistent across environments - - - - - 83eb10da by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add special preprocessor for js files due of needing to keep jsdoc comments (fixes #24602) Our js files have defined google closure compiler types at jsdoc entries but these jsdoc entries are removed by cpp preprocessor. I considered that reusing them in javascript-backend would be a nice thing. Right now haskell processor uses `-traditional` option to deal with comments and `//` operators. But now there are following compiler options: `-C` and `-CC`. You can read about them at GCC (see https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#index-CC) and CLang (see https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-CC). It seems that `-CC` works better for javascript jsdoc than `-traditional`. At least it leaves `/* ... */` comments w/o changes. - - - - - e1cf8dc2 by brandon s allbery kf8nh at 2024-04-22T03:48:26-04:00 fix link in CODEOWNERS It seems that our local Gitlab no longer has documentation for the `CODEOWNERS` file, but the master documentation still does. Use that instead. - - - - - 593f4e04 by Fendor at 2024-04-23T10:19:14-04:00 Add performance regression test for '-fwrite-simplified-core' - - - - - 1ba39b05 by Fendor at 2024-04-23T10:19:14-04:00 Typecheck corebindings lazily during bytecode generation This delays typechecking the corebindings until the bytecode generation happens. We also avoid allocating a thunk that is retained by `unsafeInterleaveIO`. In general, we shouldn't retain values of the hydrated `Type`, as not evaluating the bytecode object keeps it alive. It is better if we retain the unhydrated `IfaceType`. See Note [Hydrating Modules] - - - - - e916fc92 by Alan Zimmerman at 2024-04-23T10:19:50-04:00 EPA: Keep comments in a CaseAlt match The comments now live in the surrounding location, not inside the Match. Make sure we keep them. Closes #24707 - - - - - d2b17f32 by Cheng Shao at 2024-04-23T15:01:22-04:00 driver: force merge objects when building dynamic objects This patch forces the driver to always merge objects when building dynamic objects even when ar -L is supported. It is an oversight of !8887: original rationale of that patch is favoring the relatively cheap ar -L operation over object merging when ar -L is supported, which makes sense but only if we are building static objects! Omitting check for whether we are building dynamic objects will result in broken .so files with undefined reference errors at executable link time when building GHC with llvm-ar. Fixes #22210. - - - - - 209d09f5 by Julian Ospald at 2024-04-23T15:02:03-04:00 Allow non-absolute values for bootstrap GHC variable Fixes #24682 - - - - - 3fff0977 by Matthew Pickering at 2024-04-23T15:02:38-04:00 Don't depend on registerPackage function in Cabal More recent versions of Cabal modify the behaviour of libAbiHash which breaks our usage of registerPackage. It is simpler to inline the part of registerPackage that we need and avoid any additional dependency and complication using the higher-level function introduces. - - - - - c62dc317 by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: remove obsolete ln script This commit removes an obsolete ln script in ghc-bignum/gmp. See 060251c24ad160264ae8553efecbb8bed2f06360 for its original intention, but it's been obsolete for a long time, especially since the removal of the make build system. Hence the house cleaning. - - - - - 6399d52b by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: update gmp to 6.3.0 This patch bumps the gmp-tarballs submodule and updates gmp to 6.3.0. The tarball format is now xz, and gmpsrc.patch has been patched into the tarball so hadrian no longer needs to deal with patching logic when building in-tree GMP. - - - - - 65b4b92f by Cheng Shao at 2024-04-25T01:32:02-04:00 hadrian: remove obsolete Patch logic This commit removes obsolete Patch logic from hadrian, given we no longer need to patch the gmp tarball when building in-tree GMP. - - - - - 71f28958 by Cheng Shao at 2024-04-25T01:32:02-04:00 autoconf: remove obsolete patch detection This commit removes obsolete deletection logic of the patch command from autoconf scripts, given we no longer need to patch anything in the GHC build process. - - - - - daeda834 by Sylvain Henry at 2024-04-25T01:32:43-04:00 JS: correctly handle RUBBISH literals (#24664) - - - - - 8a06ddf6 by Matthew Pickering at 2024-04-25T11:16:16-04:00 Linearise ghc-internal and base build This is achieved by requesting the final package database for ghc-internal, which mandates it is fully built as a dependency of configuring the `base` package. This is at the expense of cross-package parrallelism between ghc-internal and the base package. Fixes #24436 - - - - - 94da9365 by Andrei Borzenkov at 2024-04-25T11:16:54-04:00 Fix tuple puns renaming (24702) Move tuple renaming short cutter from `isBuiltInOcc_maybe` to `isPunOcc_maybe`, so we consider incoming module. I also fixed some hidden bugs that raised after the change was done. - - - - - fa03b1fb by Fendor at 2024-04-26T18:03:13-04:00 Refactor the Binary serialisation interface The goal is simplifiy adding deduplication tables to `ModIface` interface serialisation. We identify two main points of interest that make this difficult: 1. UserData hardcodes what `Binary` instances can have deduplication tables. Moreover, it heavily uses partial functions. 2. GHC.Iface.Binary hardcodes the deduplication tables for 'Name' and 'FastString', making it difficult to add more deduplication. Instead of having a single `UserData` record with fields for all the types that can have deduplication tables, we allow to provide custom serialisers for any `Typeable`. These are wrapped in existentials and stored in a `Map` indexed by their respective `TypeRep`. The `Binary` instance of the type to deduplicate still needs to explicitly look up the decoder via `findUserDataReader` and `findUserDataWriter`, which is no worse than the status-quo. `Map` was chosen as microbenchmarks indicate it is the fastest for a small number of keys (< 10). To generalise the deduplication table serialisation mechanism, we introduce the types `ReaderTable` and `WriterTable` which provide a simple interface that is sufficient to implement a general purpose deduplication mechanism for `writeBinIface` and `readBinIface`. This allows us to provide a list of deduplication tables for serialisation that can be extended more easily, for example for `IfaceTyCon`, see the issue https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for more motivation. In addition to this refactoring, we split `UserData` into `ReaderUserData` and `WriterUserData`, to avoid partial functions and reduce overall memory usage, as we need fewer mutable variables. Bump haddock submodule to accomodate for `UserData` split. ------------------------- Metric Increase: MultiLayerModulesTH_Make MultiLayerModulesRecomp T21839c ------------------------- - - - - - bac57298 by Fendor at 2024-04-26T18:03:13-04:00 Split `BinHandle` into `ReadBinHandle` and `WriteBinHandle` A `BinHandle` contains too much information for reading data. For example, it needs to keep a `FastMutInt` and a `IORef BinData`, when the non-mutable variants would suffice. Additionally, this change has the benefit that anyone can immediately tell whether the `BinHandle` is used for reading or writing. Bump haddock submodule BinHandle split. - - - - - 4d6394dd by Simon Peyton Jones at 2024-04-26T18:03:49-04:00 Fix missing escaping-kind check in tcPatSynSig Note [Escaping kind in type signatures] explains how we deal with escaping kinds in type signatures, e.g. f :: forall r (a :: TYPE r). a where the kind of the body is (TYPE r), but `r` is not in scope outside the forall-type. I had missed this subtlety in tcPatSynSig, leading to #24686. This MR fixes it; and a similar bug in tc_top_lhs_type. (The latter is tested by T24686a.) - - - - - 981c2c2c by Alan Zimmerman at 2024-04-26T18:04:25-04:00 EPA: check-exact: check that the roundtrip reproduces the source Closes #24670 - - - - - a8616747 by Andrew Lelechenko at 2024-04-26T18:05:01-04:00 Document that setEnv is not thread-safe - - - - - 1e41de83 by Bryan Richter at 2024-04-26T18:05:37-04:00 CI: Work around frequent Signal 9 errors - - - - - a6d5f9da by Naïm Favier at 2024-04-27T17:52:40-04:00 ghc-internal: add MonadFix instance for (,) Closes https://gitlab.haskell.org/ghc/ghc/-/issues/24288, implements CLC proposal https://github.com/haskell/core-libraries-committee/issues/238. Adds a MonadFix instance for tuples, permitting value recursion in the "native" writer monad and bringing consistency with the existing instance for transformers's WriterT (and, to a lesser extent, for Solo). - - - - - 64feadcd by Rodrigo Mesquita at 2024-04-27T17:53:16-04:00 bindist: Fix xattr cleaning The original fix (725343aa) was incorrect because it used the shell bracket syntax which is the quoting syntax in autoconf, making the test for existence be incorrect and therefore `xattr` was never run. Fixes #24554 - - - - - e2094df3 by damhiya at 2024-04-28T23:52:00+09:00 Make read accepts binary integer formats CLC proposal : https://github.com/haskell/core-libraries-committee/issues/177 - - - - - 1c2fd963 by Alan Zimmerman at 2024-04-29T23:17:00-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 - - - - - 4189d17e by Sylvain Henry at 2024-04-29T23:17:42-04:00 LLVM: better unreachable default destination in Switch (#24717) See added note. Co-authored-by: Siddharth Bhat <siddu.druid at gmail.com> - - - - - a3725c88 by Cheng Shao at 2024-04-29T23:18:20-04:00 ci: enable wasm jobs for MRs with wasm label This patch enables wasm jobs for MRs with wasm label. Previously the wasm label didn't actually have any effect on the CI pipeline, and full-ci needed to be applied to run wasm jobs which was a waste of runners when working on the wasm backend, hence the fix here. - - - - - 702f7964 by Matthew Pickering at 2024-04-29T23:18:56-04:00 Make interface files and object files depend on inplace .conf file A potential fix for #24737 - - - - - 728af21e by Cheng Shao at 2024-04-30T05:30:23-04:00 utils: remove obsolete vagrant scripts Vagrantfile has long been removed in !5288. This commit further removes the obsolete vagrant scripts in the tree. - - - - - 36f2c342 by Cheng Shao at 2024-04-30T05:31:00-04:00 Update autoconf scripts Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 - - - - - ecbf22a6 by Ben Gamari at 2024-04-30T05:31:36-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 7eab4e01 by Alan Zimmerman at 2024-05-04T16:14:55+01:00 EPA: Widen stmtslist to include last semicolon Closes #24754 - - - - - 06f7db40 by Teo Camarasu at 2024-05-05T00:19:38-04:00 doc: Fix type error in hs_try_putmvar example - - - - - af000532 by Moritz Schuler at 2024-05-05T06:30:58-04:00 Fix parsing of module names in CLI arguments closes issue #24732 - - - - - da74e9c9 by Ben Gamari at 2024-05-05T06:31:34-04:00 ghc-platform: Add Setup.hs The Hadrian bootstrapping script relies upon `Setup.hs` to drive its build. Addresses #24761. - - - - - 35d34fde by Alan Zimmerman at 2024-05-05T12:52:40-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 - - - - - 03c5dfbf by Simon Peyton Jones at 2024-05-05T12:53:15-04:00 Fix a float-out error Ticket #24768 showed that the Simplifier was accidentally destroying a join point. It turned out to be that we were sending a bottoming join point to the top, accidentally abstracting over /other/ join points. Easily fixed. - - - - - 21fb9916 by Simon Peyton Jones at 2024-05-05T20:22:58+01:00 Just a start on specialising expressions Addresses #24359. Just a start, does not compile. - - - - - 32f0649f by Simon Peyton Jones at 2024-05-05T20:22:58+01:00 More progress (Still does not compile.) - - - - - ad469cdd by Simon Peyton Jones at 2024-05-05T20:24:26+01:00 More progress - - - - - 8743ab52 by Simon Peyton Jones at 2024-05-05T20:24:26+01:00 Wibble - - - - - 8f17e118 by Simon Peyton Jones at 2024-05-05T20:26:08+01:00 More progress - - - - - def8b747 by Simon Peyton Jones at 2024-05-05T20:26:08+01:00 More progress - - - - - cdad64a7 by Simon Peyton Jones at 2024-05-05T20:27:00+01:00 Finally runnable! - - - - - 175373a5 by Simon Peyton Jones at 2024-05-05T20:27:00+01:00 Progress - - - - - f01e83ab by Simon Peyton Jones at 2024-05-05T20:27:00+01:00 Working I think - - - - - c3197867 by Andrei Borzenkov at 2024-05-05T20:27:00+01:00 Fix derivations conflict in parser, disambiguate them in post-process - - - - - 6e124a22 by Alan Zimmerman at 2024-05-05T20:27:00+01:00 Fix exact printing for RuleBndrs This puts the exact print annotations inside a TTG extension point in RuleBndrs. It also adds an exact print case for SpecSigE - - - - - bc543b65 by Simon Peyton Jones at 2024-05-05T20:48:12+01:00 Wibble imports - - - - - 30 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - .gitlab/rel_eng/recompress-all - CODEOWNERS - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b984c23304fb6a82255e88504302cd1ea8d1273a...bc543b65f3cc34c78b84d0f701bf99bf4e675c76 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b984c23304fb6a82255e88504302cd1ea8d1273a...bc543b65f3cc34c78b84d0f701bf99bf4e675c76 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun May 5 20:56:06 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 05 May 2024 16:56:06 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: EPA: preserve comments in class and data decls Message-ID: <6637f266142f4_53c46335976c75732@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 35d34fde by Alan Zimmerman at 2024-05-05T12:52:40-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 - - - - - 03c5dfbf by Simon Peyton Jones at 2024-05-05T12:53:15-04:00 Fix a float-out error Ticket #24768 showed that the Simplifier was accidentally destroying a join point. It turned out to be that we were sending a bottoming join point to the top, accidentally abstracting over /other/ join points. Easily fixed. - - - - - 3371b3a1 by John Ericson at 2024-05-05T16:55:50-04:00 Substitute bindist files with Hadrian not configure The `ghc-toolchain` overhaul will eventually replace all this stuff with something much more cleaned up, but I think it is still worth making this sort of cleanup in the meantime so other untanglings and dead code cleaning can procede. I was able to delete a fair amount of dead code doing this too. `LLVMTarget_CPP` is renamed to / merged with `LLVMTarget` because it wasn't actually turned into a valid CPP identifier. (Original to 1345c7cc42c45e63ab1726a8fd24a7e4d4222467, actually.) Progress on #23966 Co-Authored-By: Sylvain Henry <hsyl20 at gmail.com> - - - - - 0f74e544 by Alan Zimmerman at 2024-05-05T16:55:51-04:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 - - - - - 17 changed files: - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Parser/PostProcess.hs - configure.ac - distrib/configure.ac.in - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cfg/system.config.in - hadrian/src/Oracles/Setting.hs - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Rules/Generate.hs - mk/project.mk.in - testsuite/tests/printer/Makefile - + testsuite/tests/printer/Test24753.hs - + testsuite/tests/printer/Test24755.hs - testsuite/tests/printer/all.T - + testsuite/tests/simplCore/should_compile/T24768.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -1088,6 +1088,11 @@ But, as ever, we need to be careful: as /another/ MFE, so we tell lvlFloatRhs not to do that, via the is_bot argument. + Do /not/ do this for bottoming /join-point/ bindings. They may call other + join points (#24768), and floating to the top would abstract over those join + points, which we should never do. + + See Maessen's paper 1999 "Bottom extraction: factoring error handling out of functional programs" (unpublished I think). @@ -1252,9 +1257,11 @@ lvlBind env (AnnNonRec bndr rhs) deann_rhs = deAnnotate rhs mb_bot_str = exprBotStrictness_maybe deann_rhs - is_bot_lam = isJust mb_bot_str + is_bot_lam = not is_join && isJust mb_bot_str -- is_bot_lam: looks like (\xy. bot), maybe zero lams - -- NB: not isBottomThunk! See Note [Bottoming floats] point (3) + -- NB: not isBottomThunk! + -- NB: not is_join: don't send bottoming join points to the top. + -- See Note [Bottoming floats] point (3) is_top_bindable = exprIsTopLevelBindable deann_rhs bndr_ty n_extra = count isId abs_vars ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -204,11 +204,11 @@ mkClassDecl :: SrcSpan -> P (LTyClDecl GhcPs) mkClassDecl loc' (L _ (mcxt, tycl_hdr)) fds where_cls layout annsIn - = do { let loc = noAnnSrcSpan loc' - ; (binds, sigs, ats, at_defs, _, docs) <- cvBindsAndSigs where_cls - ; (cls, tparams, fixity, ann) <- checkTyClHdr True tycl_hdr + = do { (binds, sigs, ats, at_defs, _, docs) <- cvBindsAndSigs where_cls + ; (cls, tparams, fixity, ann, cs) <- checkTyClHdr True tycl_hdr ; tyvars <- checkTyVars (text "class") whereDots cls tparams ; let anns' = annsIn Semi.<> ann + ; let loc = EpAnn (spanAsAnchor loc') noAnn cs ; return (L loc (ClassDecl { tcdCExt = (anns', layout, NoAnnSortKey) , tcdCtxt = mcxt , tcdLName = cls, tcdTyVars = tyvars @@ -231,12 +231,12 @@ mkTyData :: SrcSpan -> P (LTyClDecl GhcPs) mkTyData loc' is_type_data new_or_data cType (L _ (mcxt, tycl_hdr)) ksig data_cons (L _ maybe_deriv) annsIn - = do { let loc = noAnnSrcSpan loc' - ; (tc, tparams, fixity, ann) <- checkTyClHdr False tycl_hdr + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False tycl_hdr ; tyvars <- checkTyVars (ppr new_or_data) equalsDots tc tparams ; let anns' = annsIn Semi.<> ann - ; data_cons <- checkNewOrData (locA loc) (unLoc tc) is_type_data new_or_data data_cons + ; data_cons <- checkNewOrData loc' (unLoc tc) is_type_data new_or_data data_cons ; defn <- mkDataDefn cType mcxt ksig data_cons maybe_deriv + ; let loc = EpAnn (spanAsAnchor loc') noAnn cs ; return (L loc (DataDecl { tcdDExt = anns', tcdLName = tc, tcdTyVars = tyvars, tcdFixity = fixity, @@ -263,14 +263,14 @@ mkTySynonym :: SrcSpan -> [AddEpAnn] -> P (LTyClDecl GhcPs) mkTySynonym loc lhs rhs annsIn - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs ; tyvars <- checkTyVars (text "type") equalsDots tc tparams ; let anns' = annsIn Semi.<> ann - ; return (L (noAnnSrcSpan loc) (SynDecl - { tcdSExt = anns' - , tcdLName = tc, tcdTyVars = tyvars - , tcdFixity = fixity - , tcdRhs = rhs })) } + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (SynDecl { tcdSExt = anns' + , tcdLName = tc, tcdTyVars = tyvars + , tcdFixity = fixity + , tcdRhs = rhs })) } mkStandaloneKindSig :: SrcSpan @@ -303,8 +303,9 @@ mkTyFamInstEqn :: SrcSpan -> [AddEpAnn] -> P (LTyFamInstEqn GhcPs) mkTyFamInstEqn loc bndrs lhs rhs anns - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs - ; return (L (noAnnSrcSpan loc) $ FamEqn + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' $ FamEqn { feqn_ext = anns `mappend` ann , feqn_tycon = tc , feqn_bndrs = bndrs @@ -324,10 +325,11 @@ mkDataFamInst :: SrcSpan -> P (LInstDecl GhcPs) mkDataFamInst loc new_or_data cType (mcxt, bndrs, tycl_hdr) ksig data_cons (L _ maybe_deriv) anns - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False tycl_hdr + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False tycl_hdr ; data_cons <- checkNewOrData loc (unLoc tc) False new_or_data data_cons ; defn <- mkDataDefn cType mcxt ksig data_cons maybe_deriv - ; return (L (noAnnSrcSpan loc) (DataFamInstD noExtField (DataFamInstDecl + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (DataFamInstD noExtField (DataFamInstDecl (FamEqn { feqn_ext = ann Semi.<> anns , feqn_tycon = tc , feqn_bndrs = bndrs @@ -368,10 +370,10 @@ mkFamDecl :: SrcSpan -> [AddEpAnn] -> P (LTyClDecl GhcPs) mkFamDecl loc info topLevel lhs ksig injAnn annsIn - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs ; tyvars <- checkTyVars (ppr info) equals_or_where tc tparams - ; return (L (noAnnSrcSpan loc) (FamDecl noExtField - (FamilyDecl + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (FamDecl noExtField (FamilyDecl { fdExt = annsIn Semi.<> ann , fdTopLevel = topLevel , fdInfo = info, fdLName = tc @@ -1040,45 +1042,46 @@ checkTyClHdr :: Bool -- True <=> class header -> P (LocatedN RdrName, -- the head symbol (type or class name) [LHsTypeArg GhcPs], -- parameters of head symbol LexicalFixity, -- the declaration is in infix format - [AddEpAnn]) -- API Annotation for HsParTy + [AddEpAnn], -- API Annotation for HsParTy -- when stripping parens + EpAnnComments) -- Accumulated comments from re-arranging -- Well-formedness check and decomposition of type and class heads. -- Decomposes T ty1 .. tyn into (T, [ty1, ..., tyn]) -- Int :*: Bool into (:*:, [Int, Bool]) -- returning the pieces checkTyClHdr is_cls ty - = goL ty [] [] [] Prefix + = goL emptyComments ty [] [] [] Prefix where - goL (L l ty) acc ops cps fix = go l ty acc ops cps fix + goL cs (L l ty) acc ops cps fix = go cs l ty acc ops cps fix -- workaround to define '*' despite StarIsType - go ll (HsParTy an (L l (HsStarTy _ isUni))) acc ops' cps' fix + go cs ll (HsParTy an (L l (HsStarTy _ isUni))) acc ops' cps' fix = do { addPsMessage (locA l) PsWarnStarBinder ; let name = mkOccNameFS tcClsName (starSym isUni) ; let a' = newAnns ll l an ; return (L a' (Unqual name), acc, fix - , (reverse ops') ++ cps') } + , (reverse ops') ++ cps', cs) } - go _ (HsTyVar _ _ ltc@(L _ tc)) acc ops cps fix - | isRdrTc tc = return (ltc, acc, fix, (reverse ops) ++ cps) - go _ (HsOpTy _ _ t1 ltc@(L _ tc) t2) acc ops cps _fix - | isRdrTc tc = return (ltc, lhs:rhs:acc, Infix, (reverse ops) ++ cps) + go cs l (HsTyVar _ _ ltc@(L _ tc)) acc ops cps fix + | isRdrTc tc = return (ltc, acc, fix, (reverse ops) ++ cps, cs Semi.<> comments l) + go cs l (HsOpTy _ _ t1 ltc@(L _ tc) t2) acc ops cps _fix + | isRdrTc tc = return (ltc, lhs:rhs:acc, Infix, (reverse ops) ++ cps, cs Semi.<> comments l) where lhs = HsValArg noExtField t1 rhs = HsValArg noExtField t2 - go l (HsParTy _ ty) acc ops cps fix = goL ty acc (o:ops) (c:cps) fix + go cs l (HsParTy _ ty) acc ops cps fix = goL (cs Semi.<> comments l) ty acc (o:ops) (c:cps) fix where (o,c) = mkParensEpAnn (realSrcSpan (locA l)) - go _ (HsAppTy _ t1 t2) acc ops cps fix = goL t1 (HsValArg noExtField t2:acc) ops cps fix - go _ (HsAppKindTy at ty ki) acc ops cps fix = goL ty (HsTypeArg at ki:acc) ops cps fix - go l (HsTupleTy _ HsBoxedOrConstraintTuple ts) [] ops cps fix + go cs l (HsAppTy _ t1 t2) acc ops cps fix = goL (cs Semi.<> comments l) t1 (HsValArg noExtField t2:acc) ops cps fix + go cs l (HsAppKindTy at ty ki) acc ops cps fix = goL (cs Semi.<> comments l) ty (HsTypeArg at ki:acc) ops cps fix + go cs l (HsTupleTy _ HsBoxedOrConstraintTuple ts) [] ops cps fix = return (L (l2l l) (nameRdrName tup_name) - , map (HsValArg noExtField) ts, fix, (reverse ops)++cps) + , map (HsValArg noExtField) ts, fix, (reverse ops)++cps, cs Semi.<> comments l) where arity = length ts tup_name | is_cls = cTupleTyConName arity | otherwise = getName (tupleTyCon Boxed arity) -- See Note [Unit tuples] in GHC.Hs.Type (TODO: is this still relevant?) - go l _ _ _ _ _ + go _ l _ _ _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope (locA l) $ (PsErrMalformedTyOrClDecl ty) @@ -2056,7 +2059,10 @@ instance DisambTD (HsType GhcPs) where mkHsAppTyHeadPV = return mkHsAppTyPV t1 t2 = return (mkHsAppTy t1 t2) mkHsAppKindTyPV t at ki = return (mkHsAppKindTy at t ki) - mkHsOpTyPV prom t1 op t2 = return (mkLHsOpTy prom t1 op t2) + mkHsOpTyPV prom t1 op t2 = do + let (L l ty) = mkLHsOpTy prom t1 op t2 + !cs <- getCommentsFor (locA l) + return (L (addCommentsToEpAnn l cs) ty) mkUnpackednessPV = addUnpackednessP dataConBuilderCon :: DataConBuilder -> LocatedN RdrName @@ -2098,8 +2104,9 @@ instance DisambTD DataConBuilder where mkHsOpTyPV prom lhs tc rhs = do check_no_ops (unLoc rhs) -- check the RHS because parsing type operators is right-associative data_con <- eitherToP $ tyConToDataCon tc + !cs <- getCommentsFor (locA l) checkNotPromotedDataCon prom data_con - return $ L l (InfixDataConBuilder lhs data_con rhs) + return $ L (addCommentsToEpAnn l cs) (InfixDataConBuilder lhs data_con rhs) where l = combineLocsA lhs rhs check_no_ops (HsBangTy _ _ t) = check_no_ops (unLoc t) @@ -3220,8 +3227,8 @@ mkSumOrTuplePat l Boxed a at Sum{} _ = mkLHsOpTy :: PromotionFlag -> LHsType GhcPs -> LocatedN RdrName -> LHsType GhcPs -> LHsType GhcPs mkLHsOpTy prom x op y = - let loc = getLoc x `combineSrcSpansA` (noAnnSrcSpan $ getLocA op) `combineSrcSpansA` getLoc y - in L loc (mkHsOpTy prom x op y) + let loc = locA x `combineSrcSpans` locA op `combineSrcSpans` locA y + in L (noAnnSrcSpan loc) (mkHsOpTy prom x op y) mkMultTy :: EpToken "%" -> LHsType GhcPs -> EpUniToken "->" "→" -> HsArrow GhcPs mkMultTy pct t@(L _ (HsTyLit _ (HsNumTy (SourceText (unpackFS -> "1")) 1))) arr ===================================== configure.ac ===================================== @@ -379,15 +379,7 @@ then else TargetPlatformFull="${target_alias}" fi -if test "$CrossCompiling" = "YES" -then - # Use value passed by user from --target= - CrossCompilePrefix="${TargetPlatformFull}-" -else - CrossCompilePrefix="" -fi AC_SUBST(CrossCompiling) -AC_SUBST(CrossCompilePrefix) AC_SUBST(TargetPlatformFull) dnl ** Which gcc to use? @@ -623,9 +615,6 @@ FP_LD_NO_WARN_DUPLICATE_LIBRARIES([target], [CONF_GCC_LINKER_OPTS_STAGE2]) FP_MERGE_OBJECTS_SUPPORTS_RESPONSE_FILES GHC_LLVM_TARGET_SET_VAR -# we intend to pass trough --targets to llvm as is. -LLVMTarget_CPP=` echo "$LlvmTarget"` -AC_SUBST(LLVMTarget_CPP) # The target is substituted into the distrib/configure.ac file AC_SUBST(LlvmTarget) @@ -951,12 +940,10 @@ PREP_TARGET_FILE FIND_GHC_TOOLCHAIN([hadrian/cfg]) AC_CONFIG_FILES( -[ mk/project.mk - hadrian/cfg/system.config +[ hadrian/cfg/system.config hadrian/ghci-cabal hadrian/ghci-multi-cabal hadrian/ghci-stack - distrib/configure.ac hadrian/cfg/default.host.target hadrian/cfg/default.target ]) ===================================== distrib/configure.ac.in ===================================== @@ -23,19 +23,12 @@ bootstrap_llvm_target=@LlvmTarget@ TargetHasLibm=@TargetHasLibm@ AC_SUBST(TargetHasLibm) -FFIIncludeDir=@FFIIncludeDir@ -FFILibDir=@FFILibDir@ -AC_SUBST(FFILibDir) -AC_SUBST(FFIIncludeDir) - -LibdwIncludeDir=@LibdwIncludeDir@ -LibdwLibDir=@LibdwLibDir@ -AC_SUBST(LibdwLibDir) -AC_SUBST(LibdwIncludeDir) - UseLibffiForAdjustors=@UseLibffiForAdjustors@ AC_SUBST(UseLibffiForAdjustors) +GhcWithSMP=@GhcWithSMP@ +AC_SUBST(GhcWithSMP) + # We have to run these unconditionally as FPTOOLS_SET_PLATFORMS_VARS wants the # values it computes. AC_CANONICAL_BUILD @@ -59,13 +52,11 @@ if test "$target" != "$host" ; then fi LeadingUnderscore="@LeadingUnderscore@" CrossCompilePrefix="@CrossCompilePrefix@" -TargetPlatformFull="${target}" TablesNextToCode="@TablesNextToCode@" AC_SUBST(LeadingUnderscore) AC_SUBST(CrossCompiling) AC_SUBST(CrossCompilePrefix) -AC_SUBST(TargetPlatformFull) AC_SUBST(TablesNextToCode) Unregisterised="@Unregisterised@" ===================================== hadrian/bindist/Makefile ===================================== @@ -123,7 +123,7 @@ lib/settings : config.mk @echo ',("target has subsections via symbols", "$(TargetHasSubsectionsViaSymbols)")' >> $@ @echo ',("target has libm", "$(TargetHasLibm)")' >> $@ @echo ',("Unregisterised", "$(GhcUnregisterised)")' >> $@ - @echo ',("LLVM target", "$(LLVMTarget_CPP)")' >> $@ + @echo ',("LLVM target", "$(LLVMTarget)")' >> $@ @echo ',("LLVM llc command", "$(SettingsLlcCommand)")' >> $@ @echo ',("LLVM opt command", "$(SettingsOptCommand)")' >> $@ @echo ',("LLVM llvm-as command", "$(SettingsLlvmAsCommand)")' >> $@ ===================================== hadrian/bindist/config.mk.in ===================================== @@ -134,20 +134,9 @@ CrossCompiling = @CrossCompiling@ CrossCompilePrefix = @CrossCompilePrefix@ GhcUnregisterised = @Unregisterised@ -# ArchSupportsSMP should be set iff there is support for that arch in -# rts/include/stg/SMP.h -ifeq "$(TargetArch_CPP)" "arm" -# We don't support load/store barriers pre-ARMv7. See #10433. -ArchSupportsSMP=$(if $(filter $(ARM_ISA),ARMv5 ARMv6),NO,YES) -else ifeq "$(TargetArch_CPP)" "javascript" -ArchSupportsSMP=NO -else -ArchSupportsSMP=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(TargetArch_CPP), i386 x86_64 sparc powerpc powerpc64 powerpc64le s390x aarch64 riscv64))) -endif - # The THREADED_RTS requires `BaseReg` to be in a register and the # `GhcUnregisterised` mode doesn't allow that. -GhcWithSMP := $(strip $(if $(filter YESNO, $(ArchSupportsSMP)$(GhcUnregisterised)),YES,NO)) +GhcWithSMP := @GhcWithSMP@ # Whether to include GHCi in the compiler. Depends on whether the RTS linker # has support for this OS/ARCH combination. ===================================== hadrian/cfg/system.config.in ===================================== @@ -128,3 +128,5 @@ use-lib-dl = @UseLibdl@ use-lib-bfd = @UseLibbfd@ use-lib-pthread = @UseLibpthread@ need-libatomic = @NeedLibatomic@ + +emsdk-version = @ConfiguredEmsdkVersion@ ===================================== hadrian/src/Oracles/Setting.hs ===================================== @@ -72,6 +72,7 @@ data Setting = CursesIncludeDir | SystemGhc | TargetPlatformFull | BourneShell + | EmsdkVersion -- TODO compute solely in Hadrian, removing these variables' definitions -- from aclocal.m4 whenever they can be calculated from other variables @@ -128,6 +129,7 @@ setting key = lookupSystemConfig $ case key of SystemGhc -> "system-ghc" TargetPlatformFull -> "target-platform-full" BourneShell -> "bourne-shell" + EmsdkVersion -> "emsdk-version" -- | Look up the value of a 'SettingList' in @cfg/system.config@, tracking the -- result. ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -337,6 +337,7 @@ bindistRules = do -- Prepare binary distribution configure script -- (generated under /distrib/configure by 'autoreconf') root -/- "bindist" -/- "ghc-*" -/- "configure" %> \configurePath -> do + need ["distrib" -/- "configure.ac"] ghcRoot <- topDirectory copyFile (ghcRoot -/- "aclocal.m4") (ghcRoot -/- "distrib" -/- "aclocal.m4") copyDirectory (ghcRoot -/- "m4") (ghcRoot -/- "distrib") @@ -360,8 +361,7 @@ bindistRules = do -- creating the archive). forM_ bindistInstallFiles $ \file -> root -/- "bindist" -/- "ghc-*" -/- file %> \dest -> do - ghcRoot <- topDirectory - copyFile (ghcRoot -/- fixup file) dest + copyFile (fixup file) dest where fixup f | f `elem` ["INSTALL", "README"] = "distrib" -/- f ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -371,6 +371,57 @@ templateRules = do [ interpolateVar "LlvmMinVersion" $ replaceEq '.' ',' <$> setting LlvmMinVersion , interpolateVar "LlvmMaxVersion" $ replaceEq '.' ',' <$> setting LlvmMaxVersion ] + bindistRules + +bindistRules :: Rules () +bindistRules = do + templateRule ("mk" -/- "project.mk") $ mconcat + [ interpolateSetting "ProjectName" ProjectName + , interpolateSetting "ProjectVersion" ProjectVersion + , interpolateSetting "ProjectVersionInt" ProjectVersionInt + , interpolateSetting "ProjectPatchLevel" ProjectPatchLevel + , interpolateSetting "ProjectPatchLevel1" ProjectPatchLevel1 + , interpolateSetting "ProjectPatchLevel2" ProjectPatchLevel2 + , interpolateSetting "ProjectGitCommitId" ProjectGitCommitId + + , interpolateVar "HostOS_CPP" $ fmap cppify $ interp $ queryHost queryOS + + , interpolateVar "TargetPlatform" $ getTarget targetPlatformTriple + , interpolateVar "TargetPlatform_CPP" $ cppify <$> getTarget targetPlatformTriple + , interpolateVar "TargetArch_CPP" $ cppify <$> getTarget queryArch + , interpolateVar "TargetOS_CPP" $ cppify <$> getTarget queryOS + , interpolateVar "LLVMTarget" $ getTarget tgtLlvmTarget + ] + templateRule ("distrib" -/- "configure.ac") $ mconcat + [ interpolateSetting "ConfiguredEmsdkVersion" EmsdkVersion + , interpolateVar "CrossCompilePrefix" $ do + crossCompiling <- interp $ getFlag CrossCompiling + tpf <- setting TargetPlatformFull + pure $ if crossCompiling then tpf <> "-" else "" + , interpolateVar "LeadingUnderscore" $ yesNo <$> getTarget tgtSymbolsHaveLeadingUnderscore + , interpolateSetting "LlvmMaxVersion" LlvmMaxVersion + , interpolateSetting "LlvmMinVersion" LlvmMinVersion + , interpolateVar "LlvmTarget" $ getTarget tgtLlvmTarget + , interpolateSetting "ProjectVersion" ProjectVersion + , interpolateVar "SettingsUseDistroMINGW" $ settingsFileSetting ToolchainSetting_DistroMinGW + , interpolateVar "TablesNextToCode" $ yesNo <$> getTarget tgtTablesNextToCode + , interpolateVar "TargetHasLibm" $ lookupSystemConfig "target-has-libm" + , interpolateVar "TargetPlatform" $ getTarget targetPlatformTriple + , interpolateVar "TargetWordBigEndian" $ getTarget isBigEndian + , interpolateVar "TargetWordSize" $ getTarget wordSize + , interpolateVar "Unregisterised" $ yesNo <$> getTarget tgtUnregisterised + , interpolateVar "UseLibdw" $ fmap yesNo $ interp $ getFlag UseLibdw + , interpolateVar "UseLibffiForAdjustors" $ yesNo <$> getTarget tgtUseLibffiForAdjustors + , interpolateVar "GhcWithSMP" $ yesNo <$> targetSupportsSMP + ] + where + interp = interpretInContext (semiEmptyTarget Stage2) + getTarget = interp . queryTarget + +-- | Given a 'String' replace characters '.' and '-' by underscores ('_') so that +-- the resulting 'String' is a valid C preprocessor identifier. +cppify :: String -> String +cppify = replaceEq '-' '_' . replaceEq '.' '_' -- Generators @@ -486,10 +537,11 @@ generateSettings settingsFile = do arSupportsAtFile' = yesNo . arSupportsAtFile . tgtAr arSupportsDashL' = yesNo . arSupportsDashL . tgtAr ranlibPath = maybe "" (prgPath . ranlibProgram) . tgtRanlib - isBigEndian = yesNo . (\case BigEndian -> True; LittleEndian -> False) . tgtEndianness - wordSize = show . wordSize2Bytes . tgtWordSize mergeObjsSupportsResponseFiles' = maybe "NO" (yesNo . mergeObjsSupportsResponseFiles) . tgtMergeObjs +isBigEndian, wordSize :: Toolchain.Target -> String +isBigEndian = yesNo . (\case BigEndian -> True; LittleEndian -> False) . tgtEndianness +wordSize = show . wordSize2Bytes . tgtWordSize -- | Generate @Config.hs@ files. generateConfigHs :: Expr String ===================================== mk/project.mk.in ===================================== @@ -1,5 +1,5 @@ # WARNING: mk/project.mk is automatically generated from mk/project.mk.in by -# ./configure. Make sure you are editing mk/project.mk.in, not mk/project.mk. +# Hadrian. Make sure you are editing mk/project.mk.in, not mk/project.mk. ################################################################################ # @@ -25,8 +25,7 @@ # random .o-file stuff might change even if the .hi syntax doesn't ProjectName = @ProjectName@ -ProjectTags = -ProjectVersion = @ProjectVersion@$(ProjectTags) +ProjectVersion = @ProjectVersion@ ProjectVersionInt = @ProjectVersionInt@ ProjectPatchLevel = @ProjectPatchLevel@ ProjectPatchLevel1 = @ProjectPatchLevel1@ @@ -81,41 +80,14 @@ ProjectGitCommitId = @ProjectGitCommitId@ # You have to do a lot of work by hand to cross compile: see the # section on "Porting GHC" in the Building Guide. -HOSTPLATFORM = @HostPlatform@ TARGETPLATFORM = @TargetPlatform@ -BUILDPLATFORM = @BuildPlatform@ -HostPlatform_CPP = @HostPlatform_CPP@ -HostArch_CPP = @HostArch_CPP@ HostOS_CPP = @HostOS_CPP@ -HostVendor_CPP = @HostVendor_CPP@ TargetPlatform_CPP = @TargetPlatform_CPP@ TargetArch_CPP = @TargetArch_CPP@ TargetOS_CPP = @TargetOS_CPP@ -TargetVendor_CPP = @TargetVendor_CPP@ -LLVMTarget_CPP = @LLVMTarget_CPP@ - -BuildPlatform_CPP = @BuildPlatform_CPP@ -BuildArch_CPP = @BuildArch_CPP@ -BuildOS_CPP = @BuildOS_CPP@ -BuildVendor_CPP = @BuildVendor_CPP@ - - at HostPlatform_CPP@_HOST = 1 - at TargetPlatform_CPP@_TARGET = 1 - at BuildPlatform_CPP@_BUILD = 1 - - at HostArch_CPP@_HOST_ARCH = 1 - at TargetArch_CPP@_TARGET_ARCH = 1 - at BuildArch_CPP@_BUILD_ARCH = 1 - - at HostOS_CPP@_HOST_OS = 1 - at TargetOS_CPP@_TARGET_OS = 1 - at BuildOS_CPP@_BUILD_OS = 1 - - at HostVendor_CPP@_HOST_VENDOR = 1 - at TargetVendor_CPP@_TARGET_VENDOR = 1 - at BuildVendor_CPP@_BUILD_VENDOR = 1 +LLVMTarget = @LLVMTarget@ ################################################################################ # @@ -123,13 +95,6 @@ BuildVendor_CPP = @BuildVendor_CPP@ # ################################################################################ -# Pin a suffix on executables? If so, what (Windows only). -exeext0=@exeext_host@ -exeext1=@exeext_target@ -exeext2=@exeext_target@ -exeext3=@exeext_target@ -soext=@soext_target@ - # Windows_Host=YES if on a Windows platform ifneq "$(findstring $(HostOS_CPP), mingw32)" "" Windows_Host=YES @@ -143,17 +108,3 @@ Darwin_Host=YES else Darwin_Host=NO endif - -# Windows_Target=YES if we are targeting a Windows platform -ifneq "$(findstring $(TargetOS_CPP), mingw32)" "" -Windows_Target=YES -else -Windows_Target=NO -endif - -# Is the stage0 compiler affected by Bug #9439? -GHC_LLVM_AFFECTED_BY_9439 = @GHC_LLVM_AFFECTED_BY_9439@ - -ifeq "$(TargetArch_CPP)" "arm" -ARM_ISA=@ARM_ISA@ -endif ===================================== testsuite/tests/printer/Makefile ===================================== @@ -856,3 +856,13 @@ Test24749: Test24754: $(CHECK_PPR) $(LIBDIR) Test24754.hs $(CHECK_EXACT) $(LIBDIR) Test24754.hs + +.PHONY: Test24755 +Test24755: + $(CHECK_PPR) $(LIBDIR) Test24755.hs + $(CHECK_EXACT) $(LIBDIR) Test24755.hs + +.PHONY: Test24753 +Test24753: + $(CHECK_PPR) $(LIBDIR) Test24753.hs + $(CHECK_EXACT) $(LIBDIR) Test24753.hs ===================================== testsuite/tests/printer/Test24753.hs ===================================== @@ -0,0 +1,8 @@ +module Test24753 where + +type ErrorChoiceApi + = "path0" :> Get '[JSON] Int -- c0 + :<|> "path4" :> (ReqBody '[PlainText] Int :> Post '[PlainText] Int -- c4 + :<|> ReqBody '[PlainText] Int :> Post '[JSON] Int) -- c5 + :<|> "path5" :> (ReqBody '[JSON] Int :> Post '[PlainText] Int -- c6 + :<|> ReqBody '[PlainText] Int :> Post '[PlainText] Int) -- c7 ===================================== testsuite/tests/printer/Test24755.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeOperators #-} +module Test24755 where + +class + a -- Before operator + :+ + b -- After operator ===================================== testsuite/tests/printer/all.T ===================================== @@ -204,3 +204,5 @@ test('Test24748', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24748']) test('DataDeclShort', [ignore_stderr, req_ppr_deps], makefile_test, ['DataDeclShort']) test('Test24749', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24749']) test('Test24754', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24754']) +test('Test24755', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24755']) +test('Test24753', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24753']) ===================================== testsuite/tests/simplCore/should_compile/T24768.hs ===================================== @@ -0,0 +1,56 @@ +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TupleSections #-} +{-# LANGUAGE TypeApplications #-} + +-- In this example the simplifer destroyed a join point, +-- namely the `loop` inside `detectLeaks` + +module T24768 (detectLeaks) where + +import Control.Monad (zipWithM_) +import Control.Monad.Reader (ReaderT(..)) +import Control.Monad.State (StateT, evalStateT) +import qualified Data.Map as M +import qualified Data.Set as S + +data Debuggee + +newtype DebugM a = DebugM (ReaderT Debuggee IO a) + deriving (Functor, Applicative, Monad) + +runSimple :: Debuggee -> DebugM a -> IO a +runSimple d (DebugM a) = runReaderT a d + +cands :: [a] +cands = [] +{-# NOINLINE cands #-} + +detectLeaks :: Debuggee -> IO () +detectLeaks e = loop M.empty + where + loop :: M.Map () RankInfo -> IO () + loop rm = do + gs <- runSimple e $ mapM (findSlice rm) cands + zipWithM_ (\n _g -> writeFile + ("slices/" ++ show @Int n ++ ".dot") + "abcd") + [0..] gs + loop rm + +data RankInfo = RankInfo !Double !Int + +lookupRM :: () -> M.Map () RankInfo -> [((), RankInfo)] +lookupRM k m = M.assocs filtered_map + where + (res_map, _) = M.partitionWithKey (\e _ -> e == k) m + filtered_map = M.filter (\(RankInfo r _) -> r > 0) res_map + +findSlice :: forall m a. Monad m => M.Map () RankInfo -> () -> m [a] +findSlice rm _k = evalStateT go S.empty + where + go :: StateT s m [a] + go = do + let next_edges = lookupRM () rm + _ss <- concat <$> mapM (\_ -> go) next_edges + return [] ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -515,3 +515,4 @@ test('T24229b', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typea test('T24370', normal, compile, ['-O']) test('T24551', normal, compile, ['-O -dcore-lint']) test('T24726', normal, compile, ['-dcore-lint -dsuppress-uniques']) +test('T24768', normal, compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5a02a27cf93add1a80ec6404da928848bbae9fb4...0f74e54459ec7838c4f8954929b9f29fb35b73b3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5a02a27cf93add1a80ec6404da928848bbae9fb4...0f74e54459ec7838c4f8954929b9f29fb35b73b3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun May 5 23:36:30 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 05 May 2024 19:36:30 -0400 Subject: [Git][ghc/ghc][master] Substitute bindist files with Hadrian not configure Message-ID: <663817fe8edb9_53c4647835bc8706a@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: adba68e7 by John Ericson at 2024-05-05T19:35:56-04:00 Substitute bindist files with Hadrian not configure The `ghc-toolchain` overhaul will eventually replace all this stuff with something much more cleaned up, but I think it is still worth making this sort of cleanup in the meantime so other untanglings and dead code cleaning can procede. I was able to delete a fair amount of dead code doing this too. `LLVMTarget_CPP` is renamed to / merged with `LLVMTarget` because it wasn't actually turned into a valid CPP identifier. (Original to 1345c7cc42c45e63ab1726a8fd24a7e4d4222467, actually.) Progress on #23966 Co-Authored-By: Sylvain Henry <hsyl20 at gmail.com> - - - - - 9 changed files: - configure.ac - distrib/configure.ac.in - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cfg/system.config.in - hadrian/src/Oracles/Setting.hs - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Rules/Generate.hs - mk/project.mk.in Changes: ===================================== configure.ac ===================================== @@ -379,15 +379,7 @@ then else TargetPlatformFull="${target_alias}" fi -if test "$CrossCompiling" = "YES" -then - # Use value passed by user from --target= - CrossCompilePrefix="${TargetPlatformFull}-" -else - CrossCompilePrefix="" -fi AC_SUBST(CrossCompiling) -AC_SUBST(CrossCompilePrefix) AC_SUBST(TargetPlatformFull) dnl ** Which gcc to use? @@ -623,9 +615,6 @@ FP_LD_NO_WARN_DUPLICATE_LIBRARIES([target], [CONF_GCC_LINKER_OPTS_STAGE2]) FP_MERGE_OBJECTS_SUPPORTS_RESPONSE_FILES GHC_LLVM_TARGET_SET_VAR -# we intend to pass trough --targets to llvm as is. -LLVMTarget_CPP=` echo "$LlvmTarget"` -AC_SUBST(LLVMTarget_CPP) # The target is substituted into the distrib/configure.ac file AC_SUBST(LlvmTarget) @@ -951,12 +940,10 @@ PREP_TARGET_FILE FIND_GHC_TOOLCHAIN([hadrian/cfg]) AC_CONFIG_FILES( -[ mk/project.mk - hadrian/cfg/system.config +[ hadrian/cfg/system.config hadrian/ghci-cabal hadrian/ghci-multi-cabal hadrian/ghci-stack - distrib/configure.ac hadrian/cfg/default.host.target hadrian/cfg/default.target ]) ===================================== distrib/configure.ac.in ===================================== @@ -23,19 +23,12 @@ bootstrap_llvm_target=@LlvmTarget@ TargetHasLibm=@TargetHasLibm@ AC_SUBST(TargetHasLibm) -FFIIncludeDir=@FFIIncludeDir@ -FFILibDir=@FFILibDir@ -AC_SUBST(FFILibDir) -AC_SUBST(FFIIncludeDir) - -LibdwIncludeDir=@LibdwIncludeDir@ -LibdwLibDir=@LibdwLibDir@ -AC_SUBST(LibdwLibDir) -AC_SUBST(LibdwIncludeDir) - UseLibffiForAdjustors=@UseLibffiForAdjustors@ AC_SUBST(UseLibffiForAdjustors) +GhcWithSMP=@GhcWithSMP@ +AC_SUBST(GhcWithSMP) + # We have to run these unconditionally as FPTOOLS_SET_PLATFORMS_VARS wants the # values it computes. AC_CANONICAL_BUILD @@ -59,13 +52,11 @@ if test "$target" != "$host" ; then fi LeadingUnderscore="@LeadingUnderscore@" CrossCompilePrefix="@CrossCompilePrefix@" -TargetPlatformFull="${target}" TablesNextToCode="@TablesNextToCode@" AC_SUBST(LeadingUnderscore) AC_SUBST(CrossCompiling) AC_SUBST(CrossCompilePrefix) -AC_SUBST(TargetPlatformFull) AC_SUBST(TablesNextToCode) Unregisterised="@Unregisterised@" ===================================== hadrian/bindist/Makefile ===================================== @@ -123,7 +123,7 @@ lib/settings : config.mk @echo ',("target has subsections via symbols", "$(TargetHasSubsectionsViaSymbols)")' >> $@ @echo ',("target has libm", "$(TargetHasLibm)")' >> $@ @echo ',("Unregisterised", "$(GhcUnregisterised)")' >> $@ - @echo ',("LLVM target", "$(LLVMTarget_CPP)")' >> $@ + @echo ',("LLVM target", "$(LLVMTarget)")' >> $@ @echo ',("LLVM llc command", "$(SettingsLlcCommand)")' >> $@ @echo ',("LLVM opt command", "$(SettingsOptCommand)")' >> $@ @echo ',("LLVM llvm-as command", "$(SettingsLlvmAsCommand)")' >> $@ ===================================== hadrian/bindist/config.mk.in ===================================== @@ -134,20 +134,9 @@ CrossCompiling = @CrossCompiling@ CrossCompilePrefix = @CrossCompilePrefix@ GhcUnregisterised = @Unregisterised@ -# ArchSupportsSMP should be set iff there is support for that arch in -# rts/include/stg/SMP.h -ifeq "$(TargetArch_CPP)" "arm" -# We don't support load/store barriers pre-ARMv7. See #10433. -ArchSupportsSMP=$(if $(filter $(ARM_ISA),ARMv5 ARMv6),NO,YES) -else ifeq "$(TargetArch_CPP)" "javascript" -ArchSupportsSMP=NO -else -ArchSupportsSMP=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(TargetArch_CPP), i386 x86_64 sparc powerpc powerpc64 powerpc64le s390x aarch64 riscv64))) -endif - # The THREADED_RTS requires `BaseReg` to be in a register and the # `GhcUnregisterised` mode doesn't allow that. -GhcWithSMP := $(strip $(if $(filter YESNO, $(ArchSupportsSMP)$(GhcUnregisterised)),YES,NO)) +GhcWithSMP := @GhcWithSMP@ # Whether to include GHCi in the compiler. Depends on whether the RTS linker # has support for this OS/ARCH combination. ===================================== hadrian/cfg/system.config.in ===================================== @@ -128,3 +128,5 @@ use-lib-dl = @UseLibdl@ use-lib-bfd = @UseLibbfd@ use-lib-pthread = @UseLibpthread@ need-libatomic = @NeedLibatomic@ + +emsdk-version = @ConfiguredEmsdkVersion@ ===================================== hadrian/src/Oracles/Setting.hs ===================================== @@ -72,6 +72,7 @@ data Setting = CursesIncludeDir | SystemGhc | TargetPlatformFull | BourneShell + | EmsdkVersion -- TODO compute solely in Hadrian, removing these variables' definitions -- from aclocal.m4 whenever they can be calculated from other variables @@ -128,6 +129,7 @@ setting key = lookupSystemConfig $ case key of SystemGhc -> "system-ghc" TargetPlatformFull -> "target-platform-full" BourneShell -> "bourne-shell" + EmsdkVersion -> "emsdk-version" -- | Look up the value of a 'SettingList' in @cfg/system.config@, tracking the -- result. ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -337,6 +337,7 @@ bindistRules = do -- Prepare binary distribution configure script -- (generated under /distrib/configure by 'autoreconf') root -/- "bindist" -/- "ghc-*" -/- "configure" %> \configurePath -> do + need ["distrib" -/- "configure.ac"] ghcRoot <- topDirectory copyFile (ghcRoot -/- "aclocal.m4") (ghcRoot -/- "distrib" -/- "aclocal.m4") copyDirectory (ghcRoot -/- "m4") (ghcRoot -/- "distrib") @@ -360,8 +361,7 @@ bindistRules = do -- creating the archive). forM_ bindistInstallFiles $ \file -> root -/- "bindist" -/- "ghc-*" -/- file %> \dest -> do - ghcRoot <- topDirectory - copyFile (ghcRoot -/- fixup file) dest + copyFile (fixup file) dest where fixup f | f `elem` ["INSTALL", "README"] = "distrib" -/- f ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -371,6 +371,57 @@ templateRules = do [ interpolateVar "LlvmMinVersion" $ replaceEq '.' ',' <$> setting LlvmMinVersion , interpolateVar "LlvmMaxVersion" $ replaceEq '.' ',' <$> setting LlvmMaxVersion ] + bindistRules + +bindistRules :: Rules () +bindistRules = do + templateRule ("mk" -/- "project.mk") $ mconcat + [ interpolateSetting "ProjectName" ProjectName + , interpolateSetting "ProjectVersion" ProjectVersion + , interpolateSetting "ProjectVersionInt" ProjectVersionInt + , interpolateSetting "ProjectPatchLevel" ProjectPatchLevel + , interpolateSetting "ProjectPatchLevel1" ProjectPatchLevel1 + , interpolateSetting "ProjectPatchLevel2" ProjectPatchLevel2 + , interpolateSetting "ProjectGitCommitId" ProjectGitCommitId + + , interpolateVar "HostOS_CPP" $ fmap cppify $ interp $ queryHost queryOS + + , interpolateVar "TargetPlatform" $ getTarget targetPlatformTriple + , interpolateVar "TargetPlatform_CPP" $ cppify <$> getTarget targetPlatformTriple + , interpolateVar "TargetArch_CPP" $ cppify <$> getTarget queryArch + , interpolateVar "TargetOS_CPP" $ cppify <$> getTarget queryOS + , interpolateVar "LLVMTarget" $ getTarget tgtLlvmTarget + ] + templateRule ("distrib" -/- "configure.ac") $ mconcat + [ interpolateSetting "ConfiguredEmsdkVersion" EmsdkVersion + , interpolateVar "CrossCompilePrefix" $ do + crossCompiling <- interp $ getFlag CrossCompiling + tpf <- setting TargetPlatformFull + pure $ if crossCompiling then tpf <> "-" else "" + , interpolateVar "LeadingUnderscore" $ yesNo <$> getTarget tgtSymbolsHaveLeadingUnderscore + , interpolateSetting "LlvmMaxVersion" LlvmMaxVersion + , interpolateSetting "LlvmMinVersion" LlvmMinVersion + , interpolateVar "LlvmTarget" $ getTarget tgtLlvmTarget + , interpolateSetting "ProjectVersion" ProjectVersion + , interpolateVar "SettingsUseDistroMINGW" $ settingsFileSetting ToolchainSetting_DistroMinGW + , interpolateVar "TablesNextToCode" $ yesNo <$> getTarget tgtTablesNextToCode + , interpolateVar "TargetHasLibm" $ lookupSystemConfig "target-has-libm" + , interpolateVar "TargetPlatform" $ getTarget targetPlatformTriple + , interpolateVar "TargetWordBigEndian" $ getTarget isBigEndian + , interpolateVar "TargetWordSize" $ getTarget wordSize + , interpolateVar "Unregisterised" $ yesNo <$> getTarget tgtUnregisterised + , interpolateVar "UseLibdw" $ fmap yesNo $ interp $ getFlag UseLibdw + , interpolateVar "UseLibffiForAdjustors" $ yesNo <$> getTarget tgtUseLibffiForAdjustors + , interpolateVar "GhcWithSMP" $ yesNo <$> targetSupportsSMP + ] + where + interp = interpretInContext (semiEmptyTarget Stage2) + getTarget = interp . queryTarget + +-- | Given a 'String' replace characters '.' and '-' by underscores ('_') so that +-- the resulting 'String' is a valid C preprocessor identifier. +cppify :: String -> String +cppify = replaceEq '-' '_' . replaceEq '.' '_' -- Generators @@ -486,10 +537,11 @@ generateSettings settingsFile = do arSupportsAtFile' = yesNo . arSupportsAtFile . tgtAr arSupportsDashL' = yesNo . arSupportsDashL . tgtAr ranlibPath = maybe "" (prgPath . ranlibProgram) . tgtRanlib - isBigEndian = yesNo . (\case BigEndian -> True; LittleEndian -> False) . tgtEndianness - wordSize = show . wordSize2Bytes . tgtWordSize mergeObjsSupportsResponseFiles' = maybe "NO" (yesNo . mergeObjsSupportsResponseFiles) . tgtMergeObjs +isBigEndian, wordSize :: Toolchain.Target -> String +isBigEndian = yesNo . (\case BigEndian -> True; LittleEndian -> False) . tgtEndianness +wordSize = show . wordSize2Bytes . tgtWordSize -- | Generate @Config.hs@ files. generateConfigHs :: Expr String ===================================== mk/project.mk.in ===================================== @@ -1,5 +1,5 @@ # WARNING: mk/project.mk is automatically generated from mk/project.mk.in by -# ./configure. Make sure you are editing mk/project.mk.in, not mk/project.mk. +# Hadrian. Make sure you are editing mk/project.mk.in, not mk/project.mk. ################################################################################ # @@ -25,8 +25,7 @@ # random .o-file stuff might change even if the .hi syntax doesn't ProjectName = @ProjectName@ -ProjectTags = -ProjectVersion = @ProjectVersion@$(ProjectTags) +ProjectVersion = @ProjectVersion@ ProjectVersionInt = @ProjectVersionInt@ ProjectPatchLevel = @ProjectPatchLevel@ ProjectPatchLevel1 = @ProjectPatchLevel1@ @@ -81,41 +80,14 @@ ProjectGitCommitId = @ProjectGitCommitId@ # You have to do a lot of work by hand to cross compile: see the # section on "Porting GHC" in the Building Guide. -HOSTPLATFORM = @HostPlatform@ TARGETPLATFORM = @TargetPlatform@ -BUILDPLATFORM = @BuildPlatform@ -HostPlatform_CPP = @HostPlatform_CPP@ -HostArch_CPP = @HostArch_CPP@ HostOS_CPP = @HostOS_CPP@ -HostVendor_CPP = @HostVendor_CPP@ TargetPlatform_CPP = @TargetPlatform_CPP@ TargetArch_CPP = @TargetArch_CPP@ TargetOS_CPP = @TargetOS_CPP@ -TargetVendor_CPP = @TargetVendor_CPP@ -LLVMTarget_CPP = @LLVMTarget_CPP@ - -BuildPlatform_CPP = @BuildPlatform_CPP@ -BuildArch_CPP = @BuildArch_CPP@ -BuildOS_CPP = @BuildOS_CPP@ -BuildVendor_CPP = @BuildVendor_CPP@ - - at HostPlatform_CPP@_HOST = 1 - at TargetPlatform_CPP@_TARGET = 1 - at BuildPlatform_CPP@_BUILD = 1 - - at HostArch_CPP@_HOST_ARCH = 1 - at TargetArch_CPP@_TARGET_ARCH = 1 - at BuildArch_CPP@_BUILD_ARCH = 1 - - at HostOS_CPP@_HOST_OS = 1 - at TargetOS_CPP@_TARGET_OS = 1 - at BuildOS_CPP@_BUILD_OS = 1 - - at HostVendor_CPP@_HOST_VENDOR = 1 - at TargetVendor_CPP@_TARGET_VENDOR = 1 - at BuildVendor_CPP@_BUILD_VENDOR = 1 +LLVMTarget = @LLVMTarget@ ################################################################################ # @@ -123,13 +95,6 @@ BuildVendor_CPP = @BuildVendor_CPP@ # ################################################################################ -# Pin a suffix on executables? If so, what (Windows only). -exeext0=@exeext_host@ -exeext1=@exeext_target@ -exeext2=@exeext_target@ -exeext3=@exeext_target@ -soext=@soext_target@ - # Windows_Host=YES if on a Windows platform ifneq "$(findstring $(HostOS_CPP), mingw32)" "" Windows_Host=YES @@ -143,17 +108,3 @@ Darwin_Host=YES else Darwin_Host=NO endif - -# Windows_Target=YES if we are targeting a Windows platform -ifneq "$(findstring $(TargetOS_CPP), mingw32)" "" -Windows_Target=YES -else -Windows_Target=NO -endif - -# Is the stage0 compiler affected by Bug #9439? -GHC_LLVM_AFFECTED_BY_9439 = @GHC_LLVM_AFFECTED_BY_9439@ - -ifeq "$(TargetArch_CPP)" "arm" -ARM_ISA=@ARM_ISA@ -endif View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/adba68e73d6a8b68d56567da52d591a6dad1f9ab -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/adba68e73d6a8b68d56567da52d591a6dad1f9ab You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun May 5 23:37:10 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 05 May 2024 19:37:10 -0400 Subject: [Git][ghc/ghc][master] EPA: fix mkHsOpTyPV duplicating comments Message-ID: <663818267ce91_53c46491f4e8916d2@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 18f4ff84 by Alan Zimmerman at 2024-05-05T19:36:32-04:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 - - - - - 4 changed files: - compiler/GHC/Parser/PostProcess.hs - testsuite/tests/printer/Makefile - + testsuite/tests/printer/Test24753.hs - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -2059,7 +2059,10 @@ instance DisambTD (HsType GhcPs) where mkHsAppTyHeadPV = return mkHsAppTyPV t1 t2 = return (mkHsAppTy t1 t2) mkHsAppKindTyPV t at ki = return (mkHsAppKindTy at t ki) - mkHsOpTyPV prom t1 op t2 = return (mkLHsOpTy prom t1 op t2) + mkHsOpTyPV prom t1 op t2 = do + let (L l ty) = mkLHsOpTy prom t1 op t2 + !cs <- getCommentsFor (locA l) + return (L (addCommentsToEpAnn l cs) ty) mkUnpackednessPV = addUnpackednessP dataConBuilderCon :: DataConBuilder -> LocatedN RdrName @@ -2101,8 +2104,9 @@ instance DisambTD DataConBuilder where mkHsOpTyPV prom lhs tc rhs = do check_no_ops (unLoc rhs) -- check the RHS because parsing type operators is right-associative data_con <- eitherToP $ tyConToDataCon tc + !cs <- getCommentsFor (locA l) checkNotPromotedDataCon prom data_con - return $ L l (InfixDataConBuilder lhs data_con rhs) + return $ L (addCommentsToEpAnn l cs) (InfixDataConBuilder lhs data_con rhs) where l = combineLocsA lhs rhs check_no_ops (HsBangTy _ _ t) = check_no_ops (unLoc t) @@ -3223,8 +3227,8 @@ mkSumOrTuplePat l Boxed a at Sum{} _ = mkLHsOpTy :: PromotionFlag -> LHsType GhcPs -> LocatedN RdrName -> LHsType GhcPs -> LHsType GhcPs mkLHsOpTy prom x op y = - let loc = getLoc x `combineSrcSpansA` (noAnnSrcSpan $ getLocA op) `combineSrcSpansA` getLoc y - in L loc (mkHsOpTy prom x op y) + let loc = locA x `combineSrcSpans` locA op `combineSrcSpans` locA y + in L (noAnnSrcSpan loc) (mkHsOpTy prom x op y) mkMultTy :: EpToken "%" -> LHsType GhcPs -> EpUniToken "->" "→" -> HsArrow GhcPs mkMultTy pct t@(L _ (HsTyLit _ (HsNumTy (SourceText (unpackFS -> "1")) 1))) arr ===================================== testsuite/tests/printer/Makefile ===================================== @@ -861,3 +861,8 @@ Test24754: Test24755: $(CHECK_PPR) $(LIBDIR) Test24755.hs $(CHECK_EXACT) $(LIBDIR) Test24755.hs + +.PHONY: Test24753 +Test24753: + $(CHECK_PPR) $(LIBDIR) Test24753.hs + $(CHECK_EXACT) $(LIBDIR) Test24753.hs ===================================== testsuite/tests/printer/Test24753.hs ===================================== @@ -0,0 +1,8 @@ +module Test24753 where + +type ErrorChoiceApi + = "path0" :> Get '[JSON] Int -- c0 + :<|> "path4" :> (ReqBody '[PlainText] Int :> Post '[PlainText] Int -- c4 + :<|> ReqBody '[PlainText] Int :> Post '[JSON] Int) -- c5 + :<|> "path5" :> (ReqBody '[JSON] Int :> Post '[PlainText] Int -- c6 + :<|> ReqBody '[PlainText] Int :> Post '[PlainText] Int) -- c7 ===================================== testsuite/tests/printer/all.T ===================================== @@ -205,3 +205,4 @@ test('DataDeclShort', [ignore_stderr, req_ppr_deps], makefile_test, ['DataDeclSh test('Test24749', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24749']) test('Test24754', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24754']) test('Test24755', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24755']) +test('Test24753', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24753']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/18f4ff84b323236f6dfd07f3bbc2842308a01e91 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/18f4ff84b323236f6dfd07f3bbc2842308a01e91 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 07:53:31 2024 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Mon, 06 May 2024 03:53:31 -0400 Subject: [Git][ghc/ghc][wip/expansions-appdo] some pesky appdo testcases remain Message-ID: <66388c7b98355_2b15841ebabe4768a1@gitlab.mail> Apoorv Ingle pushed to branch wip/expansions-appdo at Glasgow Haskell Compiler / GHC Commits: 7c2ea776 by Apoorv Ingle at 2024-05-06T02:53:03-05:00 some pesky appdo testcases remain - - - - - 4 changed files: - compiler/GHC/Tc/Gen/Do.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Head.hs - testsuite/tests/ado/ado002.stderr Changes: ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -203,6 +203,7 @@ expand_do_stmts doFlavour ((L _ (ApplicativeStmt _ args mb_join)): lstmts) = -- args are [(<$>, e1), (<*>, e2), .., ] do { expr' <- expand_do_stmts doFlavour lstmts -- extracts pats and arg bodies (rhss) from args + ; (pats_can_fail, rhss) <- unzip <$> mapM (do_arg . snd) args -- add blocks for failable patterns @@ -231,7 +232,7 @@ expand_do_stmts doFlavour ((L _ (ApplicativeStmt _ args mb_join)): lstmts) = , is_body_stmt = is_body_stmt }) = do let xx_stmt = mkExpandedStmtAt rhs_loc stmt doFlavour rhs - traceTc "do_arg" (text "OneArg" <+> ppr xx_stmt) + traceTc "do_arg" (text "OneArg" <+> vcat [ppr pat, ppr xx_stmt]) return ((pat, mb_fail_op) , xx_stmt) where stmt = if is_body_stmt @@ -239,7 +240,7 @@ expand_do_stmts doFlavour ((L _ (ApplicativeStmt _ args mb_join)): lstmts) = else (L rhs_loc (BindStmt xbsn pat (L rhs_loc rhs))) do_arg (ApplicativeArgMany _ stmts ret@(L ret_loc _) pat ctxt) = do { expr <- expand_do_stmts ctxt $ stmts ++ [L ret_loc $ mkLastStmt ret] - ; traceTc "do_arg" (text "ManyArg" <+> ppr expr) + ; traceTc "do_arg" (text "ManyArg" <+> vcat [ppr pat, ppr expr]) ; return ((pat, Nothing) , expr) } @@ -252,12 +253,7 @@ expand_do_stmts doFlavour ((L _ (ApplicativeStmt _ args mb_join)): lstmts) = mk_apps :: LHsExpr GhcRn -> (SyntaxExprRn, LHsExpr GhcRn) -> LHsExpr GhcRn mk_apps l_expr (op, r_expr) = case op of - SyntaxExprRn op -> case r_expr of - L loc (XExpr (ExpandedThingRn (OrigStmt (L l s) flav) e)) - -> wrapGenSpan $ XExpr (ExpandedThingRn (OrigStmt (L l s) flav) - (genHsExpApps op [ l_expr - , L loc e ])) - _ -> wrapGenSpan $ genHsExpApps op [ l_expr, r_expr ] + SyntaxExprRn op -> wrapGenSpan $ genHsExpApps op [ l_expr, r_expr ] NoSyntaxExprRn -> pprPanic "expand_do_stmts applicative op:" (ppr op) xbsn :: XBindStmtRn ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -90,6 +90,7 @@ import GHC.Utils.Panic import Control.Monad import qualified Data.List.NonEmpty as NE +import qualified GHC.LanguageExtensions as LangExt {- ************************************************************************ @@ -728,9 +729,14 @@ tcXExpr xe@(ExpandedThingRn o e') res_ty -- `e` is the last statement's body expression -- and not a HsApp of a generated (>>) or (>>=) -- This improves error messages e.g. tests: DoExpansion1, DoExpansion2, DoExpansion3 - | OrigStmt ls@(L loc _) flav <- o + | OrigStmt ls@(L loc s) flav <- o = setSrcSpanA loc $ - mkExpandedStmtTc ls flav <$> tcApp (XExpr xe) res_ty + do appDo <- xoptM LangExt.ApplicativeDo + if appDo + then addStmtCtxt s flav $ + mkExpandedStmtTc ls flav <$> tcExpr e' res_ty + + else mkExpandedStmtTc ls flav <$> tcApp (XExpr xe) res_ty tcXExpr xe res_ty = tcApp (XExpr xe) res_ty ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -243,7 +243,8 @@ appCtxtLoc (VACall _ _ l) = l insideExpansion :: AppCtxt -> Bool insideExpansion (VAExpansion {}) = True -insideExpansion (VACall {}) = False -- but what if the VACall has a generated context? +insideExpansion (VACall _ _ src) = isGeneratedSrcSpan src +-- insideExpansion (VACall {}) = False -- but what if the VACall has a generated context? instance Outputable AppCtxt where ppr (VAExpansion e l _) = text "VAExpansion" <+> ppr e <+> ppr l ===================================== testsuite/tests/ado/ado002.stderr ===================================== @@ -96,4 +96,3 @@ ado002.hs:23:9: error: [GHC-83865] • The function ‘getChar’ is applied to one visible argument, but its type ‘IO Char’ has none In a stmt of a 'do' block: x5 <- getChar x4 - In a stmt of a 'do' block: x4 <- getChar View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7c2ea7768df91c5374d8e08d0a408d82c079682a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7c2ea7768df91c5374d8e08d0a408d82c079682a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 10:00:35 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Mon, 06 May 2024 06:00:35 -0400 Subject: [Git][ghc/ghc][wip/fendor/ghc-iface-sharing-avoid-reserialisation] 6 commits: Add run-time configurability of .hi file compression Message-ID: <6638aa43ee8c8_2b15842d8f7b48515f@gitlab.mail> Hannes Siebenhandl pushed to branch wip/fendor/ghc-iface-sharing-avoid-reserialisation at Glasgow Haskell Compiler / GHC Commits: 5abb60f3 by Matthew Pickering at 2024-04-30T15:51:23+02:00 Add run-time configurability of .hi file compression Introduce the flag `-fwrite-if-compression=<n>` which allows to configure the compression level of writing .hi files. The motivation is that some deduplication operations are too expensive for the average use case. Hence, we introduce multiple compression levels that have a minimal impact on performance, but still reduce the memory residency and `.hi` file size on disk considerably. We introduce three compression levels: * `1`: `Normal` mode. This is the least amount of compression. It deduplicates only `Name` and `FastString`s, and is naturally the fastest compression mode. * `2`: `Safe` mode. It has a noticeable impact on .hi file size and is marginally slower than `Normal` mode. In general, it should be safe to always use `Safe` mode. * `3`: `Full` deduplication mode. Deduplicate as much as we can, resulting in minimal .hi files, but at the cost of additional compilation time. Reading .hi files doesn't need to know the initial compression level, and can always deserialise a `ModIface`. This allows users to experiment with different compression levels for packages, without recompilation of dependencies. Note, the deduplication also has an additional side effect of reduced memory consumption to implicit sharing of deduplicated elements. See https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for example where that matters. ------------------------- Metric Decrease: MultiLayerModulesDefsGhciWithCore T16875 T21839c T24471 hard_hole_fits ------------------------- - - - - - 1b91e077 by Matthew Pickering at 2024-04-30T15:53:05+02:00 Introduce regression tests for `.hi` file sizes Add regression tests to track how `-fwrite-if-compression` levels affect the size of `.hi` files. - - - - - 53880781 by Fendor at 2024-04-30T15:53:05+02:00 Implement TrieMap for IfaceType - - - - - 3134b745 by Fendor at 2024-05-06T12:00:04+02:00 Improve sharing of duplicated values in `ModIface` As a `ModIface` contains often duplicated values that are not necessarily shared, we improve sharing by serialising the `ModIface` to an in-memory byte array. Serialisation uses deduplication tables, and deserialisation implicitly shares duplicated values. This helps reducing the peak memory usage while compiling in `--make` mode. The peak memory usage is especially reduced when generating interface files with core expressions (`-fwrite-if-simplified-core`). On agda, this reduces the peak memory usage: * `2.2 GB` to `1.9 GB` for a ghci session. On `lib:Cabal`, we report: * `570 MB` to `500 MB` for a ghci session * `790 MB` to `667 MB` for compiling `lib:Cabal` with ghc The execution time is not affected. - - - - - be433156 by Fendor at 2024-05-06T12:00:04+02:00 FullBinData Commit - - - - - cbd79025 by Fendor at 2024-05-06T12:00:04+02:00 Avoid unneccessarily re-serialising the `ModIface` To reduce memory usage of `ModIface`, we serialise `ModIface` to an in-memory byte array, which implicitly shares duplicated values. This serailised byte array can be reused to avoid work when we actually write the `ModIface` to disk. We introduce a new field to `ModIface` which allows us to save the byte array, and write it to disk if the `ModIface` wasn't changed after the initial serialisation. This requires us to change absolute offsets, for example to jump to the deduplication table for `Name` or `FastString` with relative offsets, as the deduplication byte array doesn't contain header information, such as fingerprints. To allow us to dump the binary blob to disk, we need to replace all absolute offsets with relative ones. This leads to new primitives for `ModIface`, which help to construct relative offsets. - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Core/Map/Expr.hs - compiler/GHC/Data/TrieMap.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Ext/Fields.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Type.hs - + compiler/GHC/Iface/Type/Map.hs - compiler/GHC/Stg/CSE.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Unit/Module/ModIface.hs - compiler/GHC/Utils/Binary.hs - compiler/ghc.cabal.in - docs/users_guide/using-optimisation.rst - + testsuite/tests/iface/IfaceSharingIfaceType.hs - + testsuite/tests/iface/IfaceSharingName.hs - + testsuite/tests/iface/Lib.hs - + testsuite/tests/iface/Makefile - + testsuite/tests/iface/all.T - + testsuite/tests/iface/if_faststring.hs - + testsuite/tests/iface/if_ifacetype.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4bcd2b69c92d8ea2cb465a0d3188a669abdfefde...cbd7902510ffeb80e96d23afcf693b684c63fa09 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4bcd2b69c92d8ea2cb465a0d3188a669abdfefde...cbd7902510ffeb80e96d23afcf693b684c63fa09 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 10:15:33 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Mon, 06 May 2024 06:15:33 -0400 Subject: [Git][ghc/ghc][wip/T24359] Typo in comments Message-ID: <6638adc59240c_2b15842fd475492389@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24359 at Glasgow Haskell Compiler / GHC Commits: 7d2bc16d by Simon Peyton Jones at 2024-05-06T11:15:21+01:00 Typo in comments - - - - - 1 changed file: - compiler/GHC/Tc/Gen/Sig.hs Changes: ===================================== compiler/GHC/Tc/Gen/Sig.hs ===================================== @@ -665,7 +665,7 @@ should add the arity later for all binders. But it works fine like this. * * ************************************************************************ -Note [Handling SPoECIALISE pragmas] +Note [Handling SPECIALISE pragmas] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The basic idea is this: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7d2bc16deada0a0a800618a07d592b513d0c5a47 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7d2bc16deada0a0a800618a07d592b513d0c5a47 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 10:22:15 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Mon, 06 May 2024 06:22:15 -0400 Subject: [Git][ghc/ghc][wip/fendor/ghc-iface-sharing-avoid-reserialisation] 2 commits: Improve sharing of duplicated values in `ModIface` Message-ID: <6638af5758780_2b1584314ea6c930ad@gitlab.mail> Hannes Siebenhandl pushed to branch wip/fendor/ghc-iface-sharing-avoid-reserialisation at Glasgow Haskell Compiler / GHC Commits: b1aec332 by Fendor at 2024-05-06T12:21:29+02:00 Improve sharing of duplicated values in `ModIface` As a `ModIface` contains often duplicated values that are not necessarily shared, we improve sharing by serialising the `ModIface` to an in-memory byte array. Serialisation uses deduplication tables, and deserialisation implicitly shares duplicated values. This helps reducing the peak memory usage while compiling in `--make` mode. The peak memory usage is especially reduced when generating interface files with core expressions (`-fwrite-if-simplified-core`). On agda, this reduces the peak memory usage: * `2.2 GB` to `1.9 GB` for a ghci session. On `lib:Cabal`, we report: * `570 MB` to `500 MB` for a ghci session * `790 MB` to `667 MB` for compiling `lib:Cabal` with ghc There is a small impact on execution time, around 2% on the agda code base. - - - - - a2fbe8ff by Fendor at 2024-05-06T12:21:55+02:00 Avoid unneccessarily re-serialising the `ModIface` To reduce memory usage of `ModIface`, we serialise `ModIface` to an in-memory byte array, which implicitly shares duplicated values. This serailised byte array can be reused to avoid work when we actually write the `ModIface` to disk. We introduce a new field to `ModIface` which allows us to save the byte array, and write it to disk if the `ModIface` wasn't changed after the initial serialisation. This requires us to change absolute offsets, for example to jump to the deduplication table for `Name` or `FastString` with relative offsets, as the deduplication byte array doesn't contain header information, such as fingerprints. To allow us to dump the binary blob to disk, we need to replace all absolute offsets with relative ones. This leads to new primitives for `ModIface`, which help to construct relative offsets. - - - - - 15 changed files: - compiler/GHC.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Ext/Fields.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Unit/Module/ModIface.hs - compiler/GHC/Utils/Binary.hs - utils/haddock Changes: ===================================== compiler/GHC.hs ===================================== @@ -98,7 +98,32 @@ module GHC ( lookupGlobalName, findGlobalAnns, mkNamePprCtxForModule, - ModIface, ModIface_(..), + ModIface, + mi_module, + mi_sig_of, + mi_hsc_src, + mi_src_hash, + mi_hi_bytes, + mi_deps, + mi_usages, + mi_exports, + mi_used_th, + mi_fixities, + mi_warns, + mi_anns, + mi_insts, + mi_fam_insts, + mi_rules, + mi_decls, + mi_extra_decls, + mi_globals, + mi_hpc, + mi_trust, + mi_trust_pkg, + mi_complete_matches, + mi_docs, + mi_final_exts, + mi_ext_fields, SafeHaskellMode(..), -- * Printing ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -966,10 +966,11 @@ loadByteCode iface mod_sum = do -------------------------------------------------------------- + -- Knot tying! See Note [Knot-tying typecheckIface] -- See Note [ModDetails and --make mode] initModDetails :: HscEnv -> ModIface -> IO ModDetails -initModDetails hsc_env iface = +initModDetails hsc_env iface = do fixIO $ \details' -> do let act hpt = addToHpt hpt (moduleName $ mi_module iface) (HomeModInfo iface details' emptyHomeModInfoLinkable) ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -18,6 +18,8 @@ module GHC.Iface.Binary ( getSymtabName, CheckHiWay(..), TraceBinIFace(..), + getIfaceWithExtFields, + putIfaceWithExtFields, getWithUserData, putWithUserData, @@ -61,6 +63,8 @@ import Data.Map.Strict (Map) import Data.Word import System.IO.Unsafe import Data.Typeable (Typeable) +import qualified GHC.Data.Strict as Strict +import Data.Function ((&)) -- --------------------------------------------------------------------------- @@ -156,17 +160,27 @@ readBinIface readBinIface profile name_cache checkHiWay traceBinIface hi_path = do (src_hash, bh) <- readBinIfaceHeader profile name_cache checkHiWay traceBinIface hi_path - extFields_p <- get bh + mod_iface <- getIfaceWithExtFields name_cache bh - mod_iface <- getWithUserData name_cache bh + return $ mod_iface + & addSourceFingerprint src_hash - seekBinReader bh extFields_p - extFields <- get bh - return mod_iface - { mi_ext_fields = extFields - , mi_src_hash = src_hash - } +getIfaceWithExtFields :: NameCache -> ReadBinHandle -> IO ModIface +getIfaceWithExtFields name_cache bh = do + start <- tellBinReader bh + extFields_p_rel <- getRelBin bh + + mod_iface <- getWithUserData name_cache bh + + seekBinReader bh start + seekBinReaderRel bh extFields_p_rel + extFields <- get bh + modIfaceData <- freezeBinHandle2 bh start + pure $ mod_iface + & set_mi_ext_fields extFields + & set_mi_hi_bytes (FullIfaceBinHandle $ Strict.Just modIfaceData) + -- | This performs a get action after reading the dictionary and symbol -- table. It is necessary to run this before trying to deserialise any @@ -195,7 +209,7 @@ getTables name_cache bh = do -- add it to the 'ReaderUserData' of 'ReadBinHandle'. decodeReaderTable :: Typeable a => ReaderTable a -> ReadBinHandle -> IO ReadBinHandle decodeReaderTable tbl bh0 = do - table <- Binary.forwardGet bh (getTable tbl bh0) + table <- Binary.forwardGetRel bh (getTable tbl bh0) let binaryReader = mkReaderFromTable tbl table pure $ addReaderToUserData binaryReader bh0 @@ -227,19 +241,24 @@ writeBinIface profile traceBinIface compressionLevel hi_path mod_iface = do put_ bh tag put_ bh (mi_src_hash mod_iface) - extFields_p_p <- tellBinWriter bh - put_ bh extFields_p_p - - putWithUserData traceBinIface compressionLevel bh mod_iface - - extFields_p <- tellBinWriter bh - putAt bh extFields_p_p extFields_p - seekBinWriter bh extFields_p - put_ bh (mi_ext_fields mod_iface) + putIfaceWithExtFields traceBinIface compressionLevel bh mod_iface -- And send the result to the file writeBinMem bh hi_path +-- | Puts the 'ModIface' to the 'WriteBinHandle'. +-- +-- This avoids serialisation of the 'ModIface' if the fields 'mi_hi_bytes' contains a +-- 'Just' value. This fields can only be populated by reading the 'ModIface' using +-- 'getIfaceWithExtFields' and not modifying it in any way afterwards. +putIfaceWithExtFields :: TraceBinIFace -> CompressionIFace -> WriteBinHandle -> ModIface -> IO () +putIfaceWithExtFields traceBinIface compressionLevel bh mod_iface = + case mi_hi_bytes mod_iface of + FullIfaceBinHandle Strict.Nothing -> do + forwardPutRel_ bh (\_ -> put_ bh (mi_ext_fields mod_iface)) $ do + putWithUserData traceBinIface compressionLevel bh mod_iface + FullIfaceBinHandle (Strict.Just binData) -> putFullBinData bh binData + -- | Put a piece of data with an initialised `UserData` field. This -- is necessary if you want to serialise Names or FastStrings. -- It also writes a symbol table and the dictionary. @@ -309,7 +328,7 @@ putAllTables _ [] act = do a <- act pure ([], a) putAllTables bh (x : xs) act = do - (r, (res, a)) <- forwardPut bh (const $ putTable x bh) $ do + (r, (res, a)) <- forwardPutRel bh (const $ putTable x bh) $ do putAllTables bh xs act pure (r : res, a) @@ -461,7 +480,7 @@ to the table we need to deserialise first. What deduplication tables exist and the order of serialisation is currently statically specified in 'putWithTables'. 'putWithTables' also takes care of the serialisation of used deduplication tables. The deserialisation of the deduplication tables happens 'getTables', using 'Binary' utility -functions such as 'forwardGet'. +functions such as 'forwardGetRel'. Here, a visualisation of the table structure we currently have (ignoring 'ExtensibleFields'): @@ -522,7 +541,6 @@ initWriteIfaceType compressionLevel = do putGenericSymTab sym_tab bh ty _ -> putIfaceType bh ty - fullIfaceTypeSerialiser sym_tab bh ty = do put_ bh ifaceTypeSharedByte putGenericSymTab sym_tab bh ty ===================================== compiler/GHC/Iface/Ext/Binary.hs ===================================== @@ -235,7 +235,7 @@ readHieFileContents bh0 name_cache = do get bh1 where get_dictionary tbl bin_handle = do - fsTable <- Binary.forwardGet bin_handle (getTable tbl bin_handle) + fsTable <- Binary.forwardGetRel bin_handle (getTable tbl bin_handle) let fsReader = mkReaderFromTable tbl fsTable bhFs = addReaderToUserData fsReader bin_handle ===================================== compiler/GHC/Iface/Ext/Fields.hs ===================================== @@ -41,7 +41,7 @@ instance Binary ExtensibleFields where -- to point to the start of each payload: forM_ header_entries $ \(field_p_p, dat) -> do field_p <- tellBinWriter bh - putAt bh field_p_p field_p + putAtRel bh field_p_p field_p seekBinWriter bh field_p put_ bh dat @@ -50,11 +50,11 @@ instance Binary ExtensibleFields where -- Get the names and field pointers: header_entries <- replicateM n $ - (,) <$> get bh <*> get bh + (,) <$> get bh <*> getRelBin bh -- Seek to and get each field's payload: fields <- forM header_entries $ \(name, field_p) -> do - seekBinReader bh field_p + seekBinReaderRel bh field_p dat <- get bh return (name, dat) ===================================== compiler/GHC/Iface/Load.hs ===================================== @@ -117,6 +117,7 @@ import System.FilePath import System.Directory import GHC.Driver.Env.KnotVars import GHC.Iface.Errors.Types +import Data.Function ((&)) {- ************************************************************************ @@ -515,14 +516,12 @@ loadInterface doc_str mod from ; new_eps_anns <- tcIfaceAnnotations (mi_anns iface) ; new_eps_complete_matches <- tcIfaceCompleteMatches (mi_complete_matches iface) - ; let { final_iface = iface { - mi_decls = panic "No mi_decls in PIT", - mi_insts = panic "No mi_insts in PIT", - mi_fam_insts = panic "No mi_fam_insts in PIT", - mi_rules = panic "No mi_rules in PIT", - mi_anns = panic "No mi_anns in PIT" - } - } + ; let final_iface = iface + & set_mi_decls (panic "No mi_decls in PIT") + & set_mi_insts (panic "No mi_insts in PIT") + & set_mi_fam_insts (panic "No mi_fam_insts in PIT") + & set_mi_rules (panic "No mi_rules in PIT") + & set_mi_anns (panic "No mi_anns in PIT") ; let bad_boot = mi_boot iface == IsBoot && isJust (lookupKnotVars (if_rec_types gbl_env) mod) @@ -1017,13 +1016,13 @@ readIface dflags name_cache wanted_mod file_path = do -- See Note [GHC.Prim] in primops.txt.pp. ghcPrimIface :: ModIface ghcPrimIface - = empty_iface { - mi_exports = ghcPrimExports, - mi_decls = [], - mi_fixities = fixities, - mi_final_exts = (mi_final_exts empty_iface){ mi_fix_fn = mkIfaceFixCache fixities }, - mi_docs = Just ghcPrimDeclDocs -- See Note [GHC.Prim Docs] - } + = empty_iface + & set_mi_exports ghcPrimExports + & set_mi_decls [] + & set_mi_fixities fixities + & set_mi_final_exts ((mi_final_exts empty_iface){ mi_fix_fn = mkIfaceFixCache fixities }) + & set_mi_docs (Just ghcPrimDeclDocs) -- See Note [GHC.Prim Docs] + where empty_iface = emptyFullModIface gHC_PRIM @@ -1107,7 +1106,7 @@ pprModIfaceSimple unit_state iface = -- -- The UnitState is used to pretty-print units pprModIface :: UnitState -> ModIface -> SDoc -pprModIface unit_state iface at ModIface{ mi_final_exts = exts } +pprModIface unit_state iface = vcat [ text "interface" <+> ppr (mi_module iface) <+> pp_hsc_src (mi_hsc_src iface) <+> (if mi_orphan exts then text "[orphan module]" else Outputable.empty) @@ -1148,6 +1147,7 @@ pprModIface unit_state iface at ModIface{ mi_final_exts = exts } , text "extensible fields:" $$ nest 2 (pprExtensibleFields (mi_ext_fields iface)) ] where + exts = mi_final_exts iface pp_hsc_src HsBootFile = text "[boot]" pp_hsc_src HsigFile = text "[hsig]" pp_hsc_src HsSrcFile = Outputable.empty ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -69,10 +69,13 @@ import GHC.Types.HpcInfo import GHC.Types.CompleteMatch import GHC.Types.SourceText import GHC.Types.SrcLoc ( unLoc ) +import GHC.Types.Name.Cache import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Logger +import GHC.Utils.Binary +import GHC.Iface.Binary import GHC.Data.FastString import GHC.Data.Maybe @@ -141,14 +144,44 @@ mkFullIface hsc_env partial_iface mb_stg_infos mb_cmm_infos = do full_iface <- {-# SCC "addFingerprints" #-} - addFingerprints hsc_env partial_iface{ mi_decls = decls } + addFingerprints hsc_env (set_mi_decls decls partial_iface) -- Debug printing let unit_state = hsc_units hsc_env putDumpFileMaybe (hsc_logger hsc_env) Opt_D_dump_hi "FINAL INTERFACE" FormatText (pprModIface unit_state full_iface) + final_iface <- shareIface (hsc_NC hsc_env) (flagsToIfCompression $ hsc_dflags hsc_env) full_iface + return final_iface + +-- | Compress an 'ModIface' and share as many values as possible, depending on the 'CompressionIFace' level. +-- See Note [Sharing of ModIface]. +-- +-- We compress the 'ModIface' by serialising the 'ModIface' to an in-memory byte array, and then deserialising it. +-- The deserialisation will deduplicate certain values depending on the 'CompressionIFace' level. +-- See Note [Deduplication during iface binary serialisation] for how we do that. +-- +-- Additionally, we cache the serialised byte array, so if the 'ModIface' is not modified +-- after calling 'shareIface', 'writeBinIface' will reuse that buffer without serialising the 'ModIface' again. +-- Modifying the 'ModIface' forces us to re-serialise it again. +shareIface :: NameCache -> CompressionIFace -> ModIface -> IO ModIface +shareIface _ NormalCompression mi = do + -- In 'NormalCompression', the sharing isn't reducing the memory usage, as 'Name's and 'FastString's are + -- already shared, and at this compression level, we don't compress/share anything else. + -- Thus, for a brief moment we simply double the memory residency for no reason. + -- Therefore, we only try to share expensive values if the compression mode is higher than + -- 'NormalCompression' + pure mi +shareIface nc compressionLevel mi = do + bh <- openBinMem (1024 * 1024) + start <- tellBinWriter bh + putIfaceWithExtFields QuietBinIFace compressionLevel bh mi + rbh <- shrinkBinBuffer bh + seekBinReader rbh start + res <- getIfaceWithExtFields nc rbh + let resiface = restoreFromOldModIface mi res + forceModIface resiface + return resiface - return full_iface updateDecl :: [IfaceDecl] -> Maybe StgCgInfos -> Maybe CmmCgInfos -> [IfaceDecl] updateDecl decls Nothing Nothing = decls @@ -302,40 +335,40 @@ mkIface_ hsc_env icomplete_matches = map mkIfaceCompleteMatch complete_matches !rdrs = maybeGlobalRdrEnv rdr_env - ModIface { - mi_module = this_mod, + emptyPartialModIface this_mod -- Need to record this because it depends on the -instantiated-with flag -- which could change - mi_sig_of = if semantic_mod == this_mod + & set_mi_sig_of ( if semantic_mod == this_mod then Nothing - else Just semantic_mod, - mi_hsc_src = hsc_src, - mi_deps = deps, - mi_usages = usages, - mi_exports = mkIfaceExports exports, + else Just semantic_mod) + & set_mi_hsc_src ( hsc_src) + & set_mi_deps ( deps) + & set_mi_usages ( usages) + & set_mi_exports ( mkIfaceExports exports) -- Sort these lexicographically, so that -- the result is stable across compilations - mi_insts = sortBy cmp_inst iface_insts, - mi_fam_insts = sortBy cmp_fam_inst iface_fam_insts, - mi_rules = sortBy cmp_rule iface_rules, - - mi_fixities = fixities, - mi_warns = warns, - mi_anns = annotations, - mi_globals = rdrs, - mi_used_th = used_th, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_hpc = isHpcUsed hpc_info, - mi_trust = trust_info, - mi_trust_pkg = pkg_trust_req, - mi_complete_matches = icomplete_matches, - mi_docs = docs, - mi_final_exts = (), - mi_ext_fields = emptyExtensibleFields, - mi_src_hash = ms_hs_hash mod_summary - } + & set_mi_insts ( sortBy cmp_inst iface_insts) + & set_mi_fam_insts ( sortBy cmp_fam_inst iface_fam_insts) + & set_mi_rules ( sortBy cmp_rule iface_rules) + + & set_mi_fixities ( fixities) + & set_mi_warns ( warns) + & set_mi_anns ( annotations) + & set_mi_globals ( rdrs) + & set_mi_used_th ( used_th) + & set_mi_decls ( decls) + & set_mi_extra_decls ( extra_decls) + & set_mi_hpc ( isHpcUsed hpc_info) + & set_mi_trust ( trust_info) + & set_mi_trust_pkg ( pkg_trust_req) + & set_mi_complete_matches ( icomplete_matches) + & set_mi_docs ( docs) + & set_mi_final_exts ( ()) + & set_mi_ext_fields ( emptyExtensibleFields) + & set_mi_src_hash ( ms_hs_hash mod_summary) + & set_mi_hi_bytes ( PartialIfaceBinHandle) + where cmp_rule = lexicalCompareFS `on` ifRuleName -- Compare these lexicographically by OccName, *not* by unique, @@ -502,3 +535,22 @@ That is, in Y, In the result of mkIfaceExports, the names are grouped by defining module, so we may need to split up a single Avail into multiple ones. -} + +{- +Note [Sharing of ModIface] +~~~~~~~~~~~~~~~~~~~~~~~~~~ +A 'ModIface' contains many duplicated values such as 'Name', 'FastString' and 'IfaceType'. +'Name's and 'FastString's are already deduplicated by default using the 'NameCache' and +'FastStringTable' respectively. +However, 'IfaceType' can be quite expensive in terms of memory usage. +To improve the sharing of 'IfaceType', we introduced deduplication tables during +serialisation of 'ModIface', see Note [Deduplication during iface binary serialisation]. + +We can improve the sharing of 'ModIface' at run-time as well, by serialising the 'ModIface' to +an in-memory buffer, and then deserialising it again. +This implicitly shares duplicated values. + +To avoid re-serialising the 'ModIface' when writing it to disk, we save the serialised 'ModIface' buffer +in 'mi_hi_bytes_' field of said 'ModIface'. This buffer is written to disk directly in 'putIfaceWithExtFields'. +If we have to modify the 'ModIface' after 'shareIface' is called, the buffer needs to be discarded. +-} ===================================== compiler/GHC/Iface/Recomp.hs ===================================== @@ -83,6 +83,7 @@ import Data.Ord import Data.Containers.ListUtils import Data.Bifunctor import GHC.Iface.Errors.Ppr +import qualified GHC.Data.Strict as Strict {- ----------------------------------------------- @@ -1283,7 +1284,9 @@ addFingerprints hsc_env iface0 , mi_fix_fn = fix_fn , mi_hash_fn = lookupOccEnv local_env } - final_iface = iface0 { mi_decls = sorted_decls, mi_extra_decls = sorted_extra_decls, mi_final_exts = final_iface_exts } + final_iface = completePartialModIface iface0 + (sorted_decls) (sorted_extra_decls) (final_iface_exts) + (FullIfaceBinHandle Strict.Nothing) -- return final_iface ===================================== compiler/GHC/Iface/Rename.hs ===================================== @@ -44,6 +44,7 @@ import GHC.Utils.Panic import qualified Data.Traversable as T import Data.IORef +import Data.Function ((&)) tcRnMsgMaybe :: IO (Either (Messages TcRnMessage) a) -> TcM a tcRnMsgMaybe do_this = do @@ -108,13 +109,14 @@ rnModIface hsc_env insts nsubst iface = deps <- rnDependencies (mi_deps iface) -- TODO: -- mi_rules - return iface { mi_module = mod - , mi_sig_of = sig_of - , mi_insts = insts - , mi_fam_insts = fams - , mi_exports = exports - , mi_decls = decls - , mi_deps = deps } + return $ iface + & set_mi_module mod + & set_mi_sig_of sig_of + & set_mi_insts insts + & set_mi_fam_insts fams + & set_mi_exports exports + & set_mi_decls decls + & set_mi_deps deps -- | Rename just the exports of a 'ModIface'. Useful when we're doing -- shaping prior to signature merging. ===================================== compiler/GHC/Tc/Errors/Hole.hs ===================================== @@ -76,7 +76,7 @@ import GHC.Tc.Utils.Unify ( tcSubTypeSigma ) import GHC.HsToCore.Docs ( extractDocs ) import GHC.Hs.Doc -import GHC.Unit.Module.ModIface ( ModIface_(..) ) +import GHC.Unit.Module.ModIface ( mi_docs ) import GHC.Iface.Load ( loadInterfaceForName ) import GHC.Builtin.Utils (knownKeyNames) ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -1562,7 +1562,8 @@ lookupDeclDoc nm = do -- Wasn't in the current module. Try searching other external ones! mIface <- getExternalModIface nm case mIface of - Just ModIface { mi_docs = Just Docs{docs_decls = dmap} } -> + Just iface + | Just Docs{docs_decls = dmap} <- mi_docs iface -> pure $ renderHsDocStrings . map hsDocString <$> lookupUniqMap dmap nm _ -> pure Nothing @@ -1578,7 +1579,8 @@ lookupArgDoc i nm = do Nothing -> do mIface <- getExternalModIface nm case mIface of - Just ModIface { mi_docs = Just Docs{docs_args = amap} } -> + Just iface + | Just Docs{docs_args = amap} <- mi_docs iface-> pure $ renderHsDocString . hsDocString <$> (lookupUniqMap amap nm >>= IntMap.lookup i) _ -> pure Nothing ===================================== compiler/GHC/Tc/Utils/Backpack.hs ===================================== @@ -87,6 +87,7 @@ import Control.Monad import Data.List (find) import GHC.Iface.Errors.Types +import Data.Function ((&)) checkHsigDeclM :: ModIface -> TyThing -> TyThing -> TcRn () checkHsigDeclM sig_iface sig_thing real_thing = do @@ -369,8 +370,8 @@ tcRnMergeSignatures hsc_env hpm orig_tcg_env iface = thinModIface :: [AvailInfo] -> ModIface -> ModIface thinModIface avails iface = - iface { - mi_exports = avails, + iface + & set_mi_exports avails -- mi_fixities = ..., -- mi_warns = ..., -- mi_anns = ..., @@ -378,10 +379,9 @@ thinModIface avails iface = -- perhaps there might be two IfaceTopBndr that are the same -- OccName but different Name. Requires better understanding -- of invariants here. - mi_decls = exported_decls ++ non_exported_decls ++ dfun_decls + & set_mi_decls (exported_decls ++ non_exported_decls ++ dfun_decls) -- mi_insts = ..., -- mi_fam_insts = ..., - } where decl_pred occs decl = nameOccName (ifName decl) `elemOccSet` occs filter_decls occs = filter (decl_pred occs . snd) (mi_decls iface) ===================================== compiler/GHC/Unit/Module/ModIface.hs ===================================== @@ -7,7 +7,61 @@ module GHC.Unit.Module.ModIface ( ModIface - , ModIface_ (..) + , ModIface_ + , restoreFromOldModIface + , addSourceFingerprint + , mi_module + , mi_sig_of + , mi_hsc_src + , mi_src_hash + , mi_hi_bytes + , mi_deps + , mi_usages + , mi_exports + , mi_used_th + , mi_fixities + , mi_warns + , mi_anns + , mi_insts + , mi_fam_insts + , mi_rules + , mi_decls + , mi_extra_decls + , mi_globals + , mi_hpc + , mi_trust + , mi_trust_pkg + , mi_complete_matches + , mi_docs + , mi_final_exts + , mi_ext_fields + , set_mi_module + , set_mi_sig_of + , set_mi_hsc_src + , set_mi_src_hash + , set_mi_hi_bytes + , set_mi_deps + , set_mi_usages + , set_mi_exports + , set_mi_used_th + , set_mi_fixities + , set_mi_warns + , set_mi_anns + , set_mi_insts + , set_mi_fam_insts + , set_mi_rules + , set_mi_decls + , set_mi_extra_decls + , set_mi_globals + , set_mi_hpc + , set_mi_trust + , set_mi_trust_pkg + , set_mi_complete_matches + , set_mi_docs + , set_mi_final_exts + , set_mi_ext_fields + , completePartialModIface + , IfaceBinHandle(..) , PartialModIface , ModIfaceBackend (..) , IfaceDeclExts @@ -58,6 +112,7 @@ import GHC.Utils.Binary import Control.DeepSeq import Control.Exception +import qualified GHC.Data.Strict as Strict {- Note [Interface file stages] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -139,7 +194,9 @@ type family IfaceBackendExts (phase :: ModIfacePhase) = bk | bk -> phase where IfaceBackendExts 'ModIfaceCore = () IfaceBackendExts 'ModIfaceFinal = ModIfaceBackend - +data IfaceBinHandle (phase :: ModIfacePhase) where + PartialIfaceBinHandle :: IfaceBinHandle 'ModIfaceCore + FullIfaceBinHandle :: Strict.Maybe FullBinData -> IfaceBinHandle 'ModIfaceFinal -- | A 'ModIface' plus a 'ModDetails' summarises everything we know -- about a compiled module. The 'ModIface' is the stuff *before* linking, @@ -155,60 +212,60 @@ type family IfaceBackendExts (phase :: ModIfacePhase) = bk | bk -> phase where -- strict and others are not. data ModIface_ (phase :: ModIfacePhase) = ModIface { - mi_module :: !Module, -- ^ Name of the module we are for - mi_sig_of :: !(Maybe Module), -- ^ Are we a sig of another mod? + mi_module_ :: !Module, -- ^ Name of the module we are for + mi_sig_of_ :: !(Maybe Module), -- ^ Are we a sig of another mod? - mi_hsc_src :: !HscSource, -- ^ Boot? Signature? + mi_hsc_src_ :: !HscSource, -- ^ Boot? Signature? - mi_deps :: Dependencies, + mi_deps_ :: Dependencies, -- ^ The dependencies of the module. This is -- consulted for directly-imported modules, but not -- for anything else (hence lazy) - mi_usages :: [Usage], + mi_usages_ :: [Usage], -- ^ Usages; kept sorted so that it's easy to decide -- whether to write a new iface file (changing usages -- doesn't affect the hash of this module) -- NOT STRICT! we read this field lazily from the interface file -- It is *only* consulted by the recompilation checker - mi_exports :: ![IfaceExport], + mi_exports_ :: ![IfaceExport], -- ^ Exports -- Kept sorted by (mod,occ), to make version comparisons easier -- Records the modules that are the declaration points for things -- exported by this module, and the 'OccName's of those things - mi_used_th :: !Bool, + mi_used_th_ :: !Bool, -- ^ Module required TH splices when it was compiled. -- This disables recompilation avoidance (see #481). - mi_fixities :: [(OccName,Fixity)], + mi_fixities_ :: [(OccName,Fixity)], -- ^ Fixities -- NOT STRICT! we read this field lazily from the interface file - mi_warns :: IfaceWarnings, + mi_warns_ :: IfaceWarnings, -- ^ Warnings -- NOT STRICT! we read this field lazily from the interface file - mi_anns :: [IfaceAnnotation], + mi_anns_ :: [IfaceAnnotation], -- ^ Annotations -- NOT STRICT! we read this field lazily from the interface file - mi_decls :: [IfaceDeclExts phase], + mi_decls_ :: [IfaceDeclExts phase], -- ^ Type, class and variable declarations -- The hash of an Id changes if its fixity or deprecations change -- (as well as its type of course) -- Ditto data constructors, class operations, except that -- the hash of the parent class/tycon changes - mi_extra_decls :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo], + mi_extra_decls_ :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo], -- ^ Extra variable definitions which are **NOT** exposed but when -- combined with mi_decls allows us to restart code generation. -- See Note [Interface Files with Core Definitions] and Note [Interface File with Core: Sharing RHSs] - mi_globals :: !(Maybe IfGlobalRdrEnv), + mi_globals_ :: !(Maybe IfGlobalRdrEnv), -- ^ Binds all the things defined at the top level in -- the /original source/ code for this module. which -- is NOT the same as mi_exports, nor mi_decls (which @@ -224,36 +281,36 @@ data ModIface_ (phase :: ModIfacePhase) -- 'HomeModInfo', but that leads to more plumbing. -- Instance declarations and rules - mi_insts :: [IfaceClsInst], -- ^ Sorted class instance - mi_fam_insts :: [IfaceFamInst], -- ^ Sorted family instances - mi_rules :: [IfaceRule], -- ^ Sorted rules + mi_insts_ :: [IfaceClsInst], -- ^ Sorted class instance + mi_fam_insts_ :: [IfaceFamInst], -- ^ Sorted family instances + mi_rules_ :: [IfaceRule], -- ^ Sorted rules - mi_hpc :: !AnyHpcUsage, + mi_hpc_ :: !AnyHpcUsage, -- ^ True if this program uses Hpc at any point in the program. - mi_trust :: !IfaceTrustInfo, + mi_trust_ :: !IfaceTrustInfo, -- ^ Safe Haskell Trust information for this module. - mi_trust_pkg :: !Bool, + mi_trust_pkg_ :: !Bool, -- ^ Do we require the package this module resides in be trusted -- to trust this module? This is used for the situation where a -- module is Safe (so doesn't require the package be trusted -- itself) but imports some trustworthy modules from its own -- package (which does require its own package be trusted). -- See Note [Trust Own Package] in GHC.Rename.Names - mi_complete_matches :: ![IfaceCompleteMatch], + mi_complete_matches_ :: ![IfaceCompleteMatch], - mi_docs :: !(Maybe Docs), + mi_docs_ :: !(Maybe Docs), -- ^ Docstrings and related data for use by haddock, the ghci -- @:doc@ command, and other tools. -- -- @Just _@ @<=>@ the module was built with @-haddock at . - mi_final_exts :: !(IfaceBackendExts phase), + mi_final_exts_ :: !(IfaceBackendExts phase), -- ^ Either `()` or `ModIfaceBackend` for -- a fully instantiated interface. - mi_ext_fields :: !ExtensibleFields, + mi_ext_fields_ :: !ExtensibleFields, -- ^ Additional optional fields, where the Map key represents -- the field name, resulting in a (size, serialized data) pair. -- Because the data is intended to be serialized through the @@ -262,8 +319,13 @@ data ModIface_ (phase :: ModIfacePhase) -- chosen over `ByteString`s. -- - mi_src_hash :: !Fingerprint + mi_src_hash_ :: !Fingerprint, -- ^ Hash of the .hs source, used for recompilation checking. + mi_hi_bytes_ :: !(IfaceBinHandle phase) + -- ^ A serialised in-memory buffer of this 'ModIface'. + -- If this handle is given, we can avoid serialising the 'ModIface' + -- when writing this 'ModIface' to disk, and write this buffer to disk instead. + -- See Note [Sharing of ModIface]. } {- @@ -343,33 +405,34 @@ renameFreeHoles fhs insts = -- See Note [Strictness in ModIface] about where we use lazyPut vs put instance Binary ModIface where put_ bh (ModIface { - mi_module = mod, - mi_sig_of = sig_of, - mi_hsc_src = hsc_src, - mi_src_hash = _src_hash, -- Don't `put_` this in the instance + mi_module_ = mod, + mi_sig_of_ = sig_of, + mi_hsc_src_ = hsc_src, + mi_src_hash_ = _src_hash, -- Don't `put_` this in the instance -- because we are going to write it -- out separately in the actual file - mi_deps = deps, - mi_usages = usages, - mi_exports = exports, - mi_used_th = used_th, - mi_fixities = fixities, - mi_warns = warns, - mi_anns = anns, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_insts = insts, - mi_fam_insts = fam_insts, - mi_rules = rules, - mi_hpc = hpc_info, - mi_trust = trust, - mi_trust_pkg = trust_pkg, - mi_complete_matches = complete_matches, - mi_docs = docs, - mi_ext_fields = _ext_fields, -- Don't `put_` this in the instance so we + mi_hi_bytes_ = _hi_bytes, -- TODO: explain + mi_deps_ = deps, + mi_usages_ = usages, + mi_exports_ = exports, + mi_used_th_ = used_th, + mi_fixities_ = fixities, + mi_warns_ = warns, + mi_anns_ = anns, + mi_decls_ = decls, + mi_extra_decls_ = extra_decls, + mi_insts_ = insts, + mi_fam_insts_ = fam_insts, + mi_rules_ = rules, + mi_hpc_ = hpc_info, + mi_trust_ = trust, + mi_trust_pkg_ = trust_pkg, + mi_complete_matches_ = complete_matches, + mi_docs_ = docs, + mi_ext_fields_ = _ext_fields, -- Don't `put_` this in the instance so we -- can deal with it's pointer in the header -- when we write the actual file - mi_final_exts = ModIfaceBackend { + mi_final_exts_ = ModIfaceBackend { mi_iface_hash = iface_hash, mi_mod_hash = mod_hash, mi_flag_hash = flag_hash, @@ -444,33 +507,34 @@ instance Binary ModIface where complete_matches <- get bh docs <- lazyGetMaybe bh return (ModIface { - mi_module = mod, - mi_sig_of = sig_of, - mi_hsc_src = hsc_src, - mi_src_hash = fingerprint0, -- placeholder because this is dealt + mi_module_ = mod, + mi_sig_of_ = sig_of, + mi_hsc_src_ = hsc_src, + mi_src_hash_ = fingerprint0, -- placeholder because this is dealt -- with specially when the file is read - mi_deps = deps, - mi_usages = usages, - mi_exports = exports, - mi_used_th = used_th, - mi_anns = anns, - mi_fixities = fixities, - mi_warns = warns, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_globals = Nothing, - mi_insts = insts, - mi_fam_insts = fam_insts, - mi_rules = rules, - mi_hpc = hpc_info, - mi_trust = trust, - mi_trust_pkg = trust_pkg, + mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing, + mi_deps_ = deps, + mi_usages_ = usages, + mi_exports_ = exports, + mi_used_th_ = used_th, + mi_anns_ = anns, + mi_fixities_ = fixities, + mi_warns_ = warns, + mi_decls_ = decls, + mi_extra_decls_ = extra_decls, + mi_globals_ = Nothing, + mi_insts_ = insts, + mi_fam_insts_ = fam_insts, + mi_rules_ = rules, + mi_hpc_ = hpc_info, + mi_trust_ = trust, + mi_trust_pkg_ = trust_pkg, -- And build the cached values - mi_complete_matches = complete_matches, - mi_docs = docs, - mi_ext_fields = emptyExtensibleFields, -- placeholder because this is dealt + mi_complete_matches_ = complete_matches, + mi_docs_ = docs, + mi_ext_fields_ = emptyExtensibleFields, -- placeholder because this is dealt -- with specially when the file is read - mi_final_exts = ModIfaceBackend { + mi_final_exts_ = ModIfaceBackend { mi_iface_hash = iface_hash, mi_mod_hash = mod_hash, mi_flag_hash = flag_hash, @@ -487,42 +551,45 @@ instance Binary ModIface where mi_hash_fn = mkIfaceHashCache decls }}) + -- | The original names declared of a certain module that are exported type IfaceExport = AvailInfo emptyPartialModIface :: Module -> PartialModIface emptyPartialModIface mod - = ModIface { mi_module = mod, - mi_sig_of = Nothing, - mi_hsc_src = HsSrcFile, - mi_src_hash = fingerprint0, - mi_deps = noDependencies, - mi_usages = [], - mi_exports = [], - mi_used_th = False, - mi_fixities = [], - mi_warns = IfWarnSome [] [], - mi_anns = [], - mi_insts = [], - mi_fam_insts = [], - mi_rules = [], - mi_decls = [], - mi_extra_decls = Nothing, - mi_globals = Nothing, - mi_hpc = False, - mi_trust = noIfaceTrustInfo, - mi_trust_pkg = False, - mi_complete_matches = [], - mi_docs = Nothing, - mi_final_exts = (), - mi_ext_fields = emptyExtensibleFields + = ModIface { mi_module_ = mod, + mi_sig_of_ = Nothing, + mi_hsc_src_ = HsSrcFile, + mi_src_hash_ = fingerprint0, + mi_hi_bytes_ = PartialIfaceBinHandle, + mi_deps_ = noDependencies, + mi_usages_ = [], + mi_exports_ = [], + mi_used_th_ = False, + mi_fixities_ = [], + mi_warns_ = IfWarnSome [] [], + mi_anns_ = [], + mi_insts_ = [], + mi_fam_insts_ = [], + mi_rules_ = [], + mi_decls_ = [], + mi_extra_decls_ = Nothing, + mi_globals_ = Nothing, + mi_hpc_ = False, + mi_trust_ = noIfaceTrustInfo, + mi_trust_pkg_ = False, + mi_complete_matches_ = [], + mi_docs_ = Nothing, + mi_final_exts_ = (), + mi_ext_fields_ = emptyExtensibleFields } emptyFullModIface :: Module -> ModIface emptyFullModIface mod = (emptyPartialModIface mod) - { mi_decls = [] - , mi_final_exts = ModIfaceBackend + { mi_decls_ = [] + , mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing + , mi_final_exts_ = ModIfaceBackend { mi_iface_hash = fingerprint0, mi_mod_hash = fingerprint0, mi_flag_hash = fingerprint0, @@ -557,36 +624,36 @@ emptyIfaceHashCache _occ = Nothing instance ( NFData (IfaceBackendExts (phase :: ModIfacePhase)) , NFData (IfaceDeclExts (phase :: ModIfacePhase)) ) => NFData (ModIface_ phase) where - rnf (ModIface{ mi_module, mi_sig_of, mi_hsc_src, mi_deps, mi_usages - , mi_exports, mi_used_th, mi_fixities, mi_warns, mi_anns - , mi_decls, mi_extra_decls, mi_globals, mi_insts - , mi_fam_insts, mi_rules, mi_hpc, mi_trust, mi_trust_pkg - , mi_complete_matches, mi_docs, mi_final_exts - , mi_ext_fields, mi_src_hash }) - = rnf mi_module - `seq` rnf mi_sig_of - `seq` mi_hsc_src - `seq` mi_deps - `seq` mi_usages - `seq` mi_exports - `seq` rnf mi_used_th - `seq` mi_fixities - `seq` rnf mi_warns - `seq` rnf mi_anns - `seq` rnf mi_decls - `seq` rnf mi_extra_decls - `seq` rnf mi_globals - `seq` rnf mi_insts - `seq` rnf mi_fam_insts - `seq` rnf mi_rules - `seq` rnf mi_hpc - `seq` mi_trust - `seq` rnf mi_trust_pkg - `seq` rnf mi_complete_matches - `seq` rnf mi_docs - `seq` mi_final_exts - `seq` mi_ext_fields - `seq` rnf mi_src_hash + rnf (ModIface{ mi_module_, mi_sig_of_, mi_hsc_src_, mi_deps_, mi_usages_ + , mi_exports_, mi_used_th_, mi_fixities_, mi_warns_, mi_anns_ + , mi_decls_, mi_extra_decls_, mi_globals_, mi_insts_ + , mi_fam_insts_, mi_rules_, mi_hpc_, mi_trust_, mi_trust_pkg_ + , mi_complete_matches_, mi_docs_, mi_final_exts_ + , mi_ext_fields_, mi_src_hash_ }) + = rnf mi_module_ + `seq` rnf mi_sig_of_ + `seq` mi_hsc_src_ + `seq` mi_deps_ + `seq` mi_usages_ + `seq` mi_exports_ + `seq` rnf mi_used_th_ + `seq` mi_fixities_ + `seq` rnf mi_warns_ + `seq` rnf mi_anns_ + `seq` rnf mi_decls_ + `seq` rnf mi_extra_decls_ + `seq` rnf mi_globals_ + `seq` rnf mi_insts_ + `seq` rnf mi_fam_insts_ + `seq` rnf mi_rules_ + `seq` rnf mi_hpc_ + `seq` mi_trust_ + `seq` rnf mi_trust_pkg_ + `seq` rnf mi_complete_matches_ + `seq` rnf mi_docs_ + `seq` mi_final_exts_ + `seq` mi_ext_fields_ + `seq` rnf mi_src_hash_ `seq` () instance NFData (ModIfaceBackend) where @@ -626,5 +693,158 @@ type WhetherHasOrphans = Bool -- | Does this module define family instances? type WhetherHasFamInst = Bool +completePartialModIface :: PartialModIface + -> [(Fingerprint, IfaceDecl)] + -> Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] + -> ModIfaceBackend + -> IfaceBinHandle 'ModIfaceFinal + -> ModIface +completePartialModIface partial decls extra_decls final_exts hi_bytes = partial + { mi_decls_ = decls + , mi_extra_decls_ = extra_decls + , mi_final_exts_ = final_exts + , mi_hi_bytes_ = hi_bytes + } + +addSourceFingerprint :: Fingerprint -> ModIface_ 'ModIfaceFinal -> ModIface_ 'ModIfaceFinal +addSourceFingerprint val iface = iface { mi_src_hash_ = val } + +restoreFromOldModIface :: ModIface_ phase -> ModIface_ phase -> ModIface_ phase +restoreFromOldModIface old new = new + { mi_globals_ = mi_globals_ old + , mi_hsc_src_ = mi_hsc_src_ old + , mi_src_hash_ = mi_src_hash_ old + } + +set_mi_module :: Module -> ModIface_ phase -> ModIface_ phase +set_mi_module val iface = clear_mi_hi_bytes $ iface { mi_module_ = val } + +set_mi_sig_of :: Maybe Module -> ModIface_ phase -> ModIface_ phase +set_mi_sig_of val iface = clear_mi_hi_bytes $ iface { mi_sig_of_ = val } + +set_mi_hsc_src :: HscSource -> ModIface_ phase -> ModIface_ phase +set_mi_hsc_src val iface = clear_mi_hi_bytes $ iface { mi_hsc_src_ = val } + +set_mi_src_hash :: Fingerprint -> ModIface_ phase -> ModIface_ phase +set_mi_src_hash val iface = clear_mi_hi_bytes $ iface { mi_src_hash_ = val } + +set_mi_hi_bytes :: IfaceBinHandle phase -> ModIface_ phase -> ModIface_ phase +set_mi_hi_bytes val iface = iface { mi_hi_bytes_ = val } + +set_mi_deps :: Dependencies -> ModIface_ phase -> ModIface_ phase +set_mi_deps val iface = clear_mi_hi_bytes $ iface { mi_deps_ = val } + +set_mi_usages :: [Usage] -> ModIface_ phase -> ModIface_ phase +set_mi_usages val iface = clear_mi_hi_bytes $ iface { mi_usages_ = val } + +set_mi_exports :: [IfaceExport] -> ModIface_ phase -> ModIface_ phase +set_mi_exports val iface = clear_mi_hi_bytes $ iface { mi_exports_ = val } + +set_mi_used_th :: Bool -> ModIface_ phase -> ModIface_ phase +set_mi_used_th val iface = clear_mi_hi_bytes $ iface { mi_used_th_ = val } + +set_mi_fixities :: [(OccName, Fixity)] -> ModIface_ phase -> ModIface_ phase +set_mi_fixities val iface = clear_mi_hi_bytes $ iface { mi_fixities_ = val } +set_mi_warns :: IfaceWarnings -> ModIface_ phase -> ModIface_ phase +set_mi_warns val iface = clear_mi_hi_bytes $ iface { mi_warns_ = val } + +set_mi_anns :: [IfaceAnnotation] -> ModIface_ phase -> ModIface_ phase +set_mi_anns val iface = clear_mi_hi_bytes $ iface { mi_anns_ = val } + +set_mi_insts :: [IfaceClsInst] -> ModIface_ phase -> ModIface_ phase +set_mi_insts val iface = clear_mi_hi_bytes $ iface { mi_insts_ = val } + +set_mi_fam_insts :: [IfaceFamInst] -> ModIface_ phase -> ModIface_ phase +set_mi_fam_insts val iface = clear_mi_hi_bytes $ iface { mi_fam_insts_ = val } + +set_mi_rules :: [IfaceRule] -> ModIface_ phase -> ModIface_ phase +set_mi_rules val iface = clear_mi_hi_bytes $ iface { mi_rules_ = val } + +set_mi_decls :: [IfaceDeclExts phase] -> ModIface_ phase -> ModIface_ phase +set_mi_decls val iface = clear_mi_hi_bytes $ iface { mi_decls_ = val } + +set_mi_extra_decls :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] -> ModIface_ phase -> ModIface_ phase +set_mi_extra_decls val iface = clear_mi_hi_bytes $ iface { mi_extra_decls_ = val } + +set_mi_globals :: Maybe IfGlobalRdrEnv -> ModIface_ phase -> ModIface_ phase +set_mi_globals val iface = clear_mi_hi_bytes $ iface { mi_globals_ = val } + +set_mi_hpc :: AnyHpcUsage -> ModIface_ phase -> ModIface_ phase +set_mi_hpc val iface = clear_mi_hi_bytes $ iface { mi_hpc_ = val } + +set_mi_trust :: IfaceTrustInfo -> ModIface_ phase -> ModIface_ phase +set_mi_trust val iface = clear_mi_hi_bytes $ iface { mi_trust_ = val } + +set_mi_trust_pkg :: Bool -> ModIface_ phase -> ModIface_ phase +set_mi_trust_pkg val iface = clear_mi_hi_bytes $ iface { mi_trust_pkg_ = val } + +set_mi_complete_matches :: [IfaceCompleteMatch] -> ModIface_ phase -> ModIface_ phase +set_mi_complete_matches val iface = clear_mi_hi_bytes $ iface { mi_complete_matches_ = val } + +set_mi_docs :: Maybe Docs -> ModIface_ phase -> ModIface_ phase +set_mi_docs val iface = clear_mi_hi_bytes $ iface { mi_docs_ = val } + +set_mi_final_exts :: IfaceBackendExts phase -> ModIface_ phase -> ModIface_ phase +set_mi_final_exts val iface = clear_mi_hi_bytes $ iface { mi_final_exts_ = val } + +set_mi_ext_fields :: ExtensibleFields -> ModIface_ phase -> ModIface_ phase +set_mi_ext_fields val iface = clear_mi_hi_bytes $ iface { mi_ext_fields_ = val } + +clear_mi_hi_bytes :: ModIface_ phase -> ModIface_ phase +clear_mi_hi_bytes iface = iface + { mi_hi_bytes_ = case mi_hi_bytes iface of + PartialIfaceBinHandle -> PartialIfaceBinHandle + FullIfaceBinHandle _ -> FullIfaceBinHandle Strict.Nothing + } +mi_module :: ModIface_ phase -> Module +mi_module = mi_module_ +mi_sig_of :: ModIface_ phase -> Maybe Module +mi_sig_of = mi_sig_of_ +mi_hsc_src :: ModIface_ phase -> HscSource +mi_hsc_src = mi_hsc_src_ +mi_deps :: ModIface_ phase -> Dependencies +mi_deps = mi_deps_ +mi_usages :: ModIface_ phase -> [Usage] +mi_usages = mi_usages_ +mi_exports :: ModIface_ phase -> [IfaceExport] +mi_exports = mi_exports_ +mi_used_th :: ModIface_ phase -> Bool +mi_used_th = mi_used_th_ +mi_fixities :: ModIface_ phase -> [(OccName, Fixity)] +mi_fixities = mi_fixities_ +mi_warns :: ModIface_ phase -> IfaceWarnings +mi_warns = mi_warns_ +mi_anns :: ModIface_ phase -> [IfaceAnnotation] +mi_anns = mi_anns_ +mi_decls :: ModIface_ phase -> [IfaceDeclExts phase] +mi_decls = mi_decls_ +mi_extra_decls :: ModIface_ phase -> Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] +mi_extra_decls = mi_extra_decls_ +mi_globals :: ModIface_ phase -> Maybe IfGlobalRdrEnv +mi_globals = mi_globals_ +mi_insts :: ModIface_ phase -> [IfaceClsInst] +mi_insts = mi_insts_ +mi_fam_insts :: ModIface_ phase -> [IfaceFamInst] +mi_fam_insts = mi_fam_insts_ +mi_rules :: ModIface_ phase -> [IfaceRule] +mi_rules = mi_rules_ +mi_hpc :: ModIface_ phase -> AnyHpcUsage +mi_hpc = mi_hpc_ +mi_trust :: ModIface_ phase -> IfaceTrustInfo +mi_trust = mi_trust_ +mi_trust_pkg :: ModIface_ phase -> Bool +mi_trust_pkg = mi_trust_pkg_ +mi_complete_matches :: ModIface_ phase -> [IfaceCompleteMatch] +mi_complete_matches = mi_complete_matches_ +mi_docs :: ModIface_ phase -> Maybe Docs +mi_docs = mi_docs_ +mi_final_exts :: ModIface_ phase -> IfaceBackendExts phase +mi_final_exts = mi_final_exts_ +mi_ext_fields :: ModIface_ phase -> ExtensibleFields +mi_ext_fields = mi_ext_fields_ +mi_src_hash :: ModIface_ phase -> Fingerprint +mi_src_hash = mi_src_hash_ +mi_hi_bytes :: ModIface_ phase -> IfaceBinHandle phase +mi_hi_bytes = mi_hi_bytes_ ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -19,7 +19,7 @@ -- http://www.cs.york.ac.uk/fp/nhc98/ module GHC.Utils.Binary - ( {-type-} Bin, + ( {-type-} Bin, RelBin(..), getRelBin, {-class-} Binary(..), {-type-} ReadBinHandle, WriteBinHandle, SymbolTable, Dictionary, @@ -32,10 +32,14 @@ module GHC.Utils.Binary seekBinWriter, seekBinReader, + seekBinReaderRel, tellBinReader, tellBinWriter, castBin, withBinBuffer, + freezeWriteHandle, + shrinkBinBuffer, + thawReadHandle, foldGet, foldGet', @@ -44,7 +48,9 @@ module GHC.Utils.Binary readBinMemN, putAt, getAt, + putAtRel, forwardPut, forwardPut_, forwardGet, + forwardPutRel, forwardPutRel_, forwardGetRel, -- * For writing instances putByte, @@ -99,6 +105,9 @@ module GHC.Utils.Binary BindingName(..), simpleBindingNameWriter, simpleBindingNameReader, + FullBinData(..), freezeBinHandle, thawBinHandle, putFullBinData, + freezeBinHandle2, + BinArray, ) where import GHC.Prelude @@ -123,7 +132,7 @@ import Foreign hiding (shiftL, shiftR, void) import Data.Array import Data.Array.IO import Data.Array.Unsafe -import Data.ByteString (ByteString) +import Data.ByteString (ByteString, copy) import Data.Coerce import qualified Data.ByteString.Internal as BS import qualified Data.ByteString.Unsafe as BS @@ -153,7 +162,6 @@ import GHC.ForeignPtr ( unsafeWithForeignPtr ) import Unsafe.Coerce (unsafeCoerce) import GHC.Data.TrieMap - type BinArray = ForeignPtr Word8 #if !MIN_VERSION_base(4,15,0) @@ -193,6 +201,51 @@ dataHandle (BinData size bin) = do handleData :: WriteBinHandle -> IO BinData handleData (WriteBinMem _ ixr _ binr) = BinData <$> readFastMutInt ixr <*> readIORef binr +--------------------------------------------------------------- +-- FullBinData +--------------------------------------------------------------- + +data FullBinData = FullBinData + { fbd_readerUserData :: ReaderUserData + , fbd_off_s :: {-# UNPACK #-} !Int + -- ^ start offset + , fbd_off_e :: {-# UNPACK #-} !Int + -- ^ end offset + , fbd_size :: {-# UNPACK #-} !Int + -- ^ total buffer size + , fbd_buffer :: {-# UNPACK #-} !BinArray + } + +-- Equality and Ord assume that two distinct buffers are different, even if they compare the same things. +instance Eq FullBinData where + (FullBinData _ b c d e) == (FullBinData _ b1 c1 d1 e1) = b == b1 && c == c1 && d == d1 && e == e1 + +instance Ord FullBinData where + compare (FullBinData _ b c d e) (FullBinData _ b1 c1 d1 e1) = + compare b b1 `mappend` compare c c1 `mappend` compare d d1 `mappend` compare e e1 + +putFullBinData :: WriteBinHandle -> FullBinData -> IO () +putFullBinData bh (FullBinData _ o1 o2 _sz ba) = do + let sz = o2 - o1 + putPrim bh sz $ \dest -> + unsafeWithForeignPtr (ba `plusForeignPtr` o1) $ \orig -> + copyBytes dest orig sz + +freezeBinHandle :: Bin () -> ReadBinHandle -> IO FullBinData +freezeBinHandle (BinPtr len) (ReadBinMem user_data ixr sz binr) = do + ix <- readFastMutInt ixr + pure (FullBinData user_data ix len sz binr) + +freezeBinHandle2 :: ReadBinHandle -> Bin () -> IO FullBinData +freezeBinHandle2 (ReadBinMem user_data ixr sz binr) (BinPtr start) = do + ix <- readFastMutInt ixr + pure (FullBinData user_data start ix sz binr) + +thawBinHandle :: FullBinData -> IO ReadBinHandle +thawBinHandle (FullBinData user_data ix _end sz ba) = do + ixr <- newFastMutInt ix + return $ ReadBinMem user_data ixr sz ba + --------------------------------------------------------------- -- BinHandle --------------------------------------------------------------- @@ -286,9 +339,30 @@ unsafeUnpackBinBuffer (BS.BS arr len) = do newtype Bin a = BinPtr Int deriving (Eq, Ord, Show, Bounded) +data RelBin a = RelBin !(Bin a) !(Bin a) + deriving (Eq, Ord, Show, Bounded) + +newtype RelBinPtr a = RelBinPtr (Bin a) + castBin :: Bin a -> Bin b castBin (BinPtr i) = BinPtr i +getRelBin :: ReadBinHandle -> IO (RelBin a) +getRelBin bh = do + start <- tellBinReader bh + off <- get bh + pure $ RelBin start off + +makeAbsoluteBin :: RelBin a -> Bin a +makeAbsoluteBin (RelBin (BinPtr !start) (BinPtr !offset)) = BinPtr (start + offset) + +makeRelativeBin :: RelBin a -> RelBinPtr a +makeRelativeBin (RelBin _ offset) = RelBinPtr offset + +toRelBin :: Bin (RelBinPtr a) -> Bin a -> RelBin a +toRelBin (BinPtr !start) (BinPtr !goal) = + RelBin (BinPtr start) (BinPtr $! goal - start) + --------------------------------------------------------------- -- class Binary --------------------------------------------------------------- @@ -309,6 +383,9 @@ class Binary a where putAt :: Binary a => WriteBinHandle -> Bin a -> a -> IO () putAt bh p x = do seekBinWriter bh p; put_ bh x; return () +putAtRel :: WriteBinHandle -> Bin (RelBinPtr a) -> Bin a -> IO () +putAtRel bh from to = putAt bh from (makeRelativeBin $ toRelBin from to) + getAt :: Binary a => ReadBinHandle -> Bin a -> IO a getAt bh p = do seekBinReader bh p; get bh @@ -327,6 +404,44 @@ openBinMem size , wbm_arr_r = arr_r } +-- | Freeze the given 'WriteBinHandle' and turn it into an equivalent 'ReadBinHandle'. +-- +-- The current offset of the 'WriteBinHandle' is maintained in the new 'ReadBinHandle'. +freezeWriteHandle :: WriteBinHandle -> IO ReadBinHandle +freezeWriteHandle wbm = do + rbm_off_r <- newFastMutInt =<< readFastMutInt (wbm_off_r wbm) + rbm_sz_r <- readFastMutInt (wbm_sz_r wbm) + rbm_arr_r <- readIORef (wbm_arr_r wbm) + pure $ ReadBinMem + { rbm_userData = noReaderUserData + , rbm_off_r = rbm_off_r + , rbm_sz_r = rbm_sz_r + , rbm_arr_r = rbm_arr_r + } + +-- Copy the BinBuffer to a new BinBuffer which is exactly the right size. +-- This performs a copy of the underlying buffer. +-- The buffer may be truncated if the offset is not at the end of the written +-- output. +-- +-- UserData is also discarded during the copy +-- You should just use this when translating a Put handle into a Get handle. +shrinkBinBuffer :: WriteBinHandle -> IO ReadBinHandle +shrinkBinBuffer bh = withBinBuffer bh $ \bs -> do + unsafeUnpackBinBuffer (copy bs) + +thawReadHandle :: ReadBinHandle -> IO WriteBinHandle +thawReadHandle rbm = do + wbm_off_r <- newFastMutInt =<< readFastMutInt (rbm_off_r rbm) + wbm_sz_r <- newFastMutInt (rbm_sz_r rbm) + wbm_arr_r <- newIORef (rbm_arr_r rbm) + pure $ WriteBinMem + { wbm_userData = noWriterUserData + , wbm_off_r = wbm_off_r + , wbm_sz_r = wbm_sz_r + , wbm_arr_r = wbm_arr_r + } + tellBinWriter :: WriteBinHandle -> IO (Bin a) tellBinWriter (WriteBinMem _ r _ _) = do ix <- readFastMutInt r; return (BinPtr ix) @@ -352,12 +467,18 @@ seekBinNoExpandWriter (WriteBinMem _ ix_r sz_r _) (BinPtr !p) = do else writeFastMutInt ix_r p -- | SeekBin but without calling expandBin -seekBinReader :: ReadBinHandle -> Bin a -> IO () +seekBinReader :: HasCallStack => ReadBinHandle -> Bin a -> IO () seekBinReader (ReadBinMem _ ix_r sz_r _) (BinPtr !p) = do if (p > sz_r) then panic "seekBinReader: seek out of range" else writeFastMutInt ix_r p +seekBinReaderRel :: HasCallStack => ReadBinHandle -> RelBin a -> IO () +seekBinReaderRel (ReadBinMem _ ix_r sz_r _) (RelBin (BinPtr !start) (BinPtr !offset)) = do + if (start + offset > sz_r) + then panic "seekBinReaderRel: seek out of range" + else writeFastMutInt ix_r (start + offset) + writeBinMem :: WriteBinHandle -> FilePath -> IO () writeBinMem (WriteBinMem _ ix_r _ arr_r) fn = do h <- openBinaryFile fn WriteMode @@ -1078,6 +1199,11 @@ instance Binary (Bin a) where put_ bh (BinPtr i) = putWord32 bh (fromIntegral i :: Word32) get bh = do i <- getWord32 bh; return (BinPtr (fromIntegral (i :: Word32))) +-- Instance uses fixed-width encoding to allow inserting +-- Bin placeholders in the stream. +instance Binary (RelBinPtr a) where + put_ bh (RelBinPtr i) = put_ bh i + get bh = RelBinPtr <$> get bh -- ----------------------------------------------------------------------------- -- Forward reading/writing @@ -1106,7 +1232,7 @@ forwardPut_ :: WriteBinHandle -> (b -> IO a) -> IO b -> IO () forwardPut_ bh put_A put_B = void $ forwardPut bh put_A put_B -- | Read a value stored using a forward reference -forwardGet :: ReadBinHandle -> IO a -> IO a +forwardGet :: HasCallStack => ReadBinHandle -> IO a -> IO a forwardGet bh get_A = do -- read forward reference p <- get bh -- a BinPtr @@ -1118,6 +1244,43 @@ forwardGet bh get_A = do seekBinReader bh p_a pure r + +-- | "forwardPutRel put_A put_B" outputs A after B but allows A to be read before B +-- by using a forward reference. +forwardPutRel :: WriteBinHandle -> (b -> IO a) -> IO b -> IO (a,b) +forwardPutRel bh put_A put_B = do + -- write placeholder pointer to A + pre_a <- tellBinWriter bh + put_ bh pre_a + + -- write B + r_b <- put_B + + -- update A's pointer + a <- tellBinWriter bh + putAtRel bh pre_a a + seekBinNoExpandWriter bh a + + -- write A + r_a <- put_A r_b + pure (r_a,r_b) + +forwardPutRel_ :: WriteBinHandle -> (b -> IO a) -> IO b -> IO () +forwardPutRel_ bh put_A put_B = void $ forwardPutRel bh put_A put_B + +-- | Read a value stored using a forward reference +forwardGetRel :: ReadBinHandle -> IO a -> IO a +forwardGetRel bh get_A = do + -- read forward reference + p <- getRelBin bh + -- store current position + p_a <- tellBinReader bh + -- go read the forward value, then seek back + seekBinReader bh $ makeAbsoluteBin p + r <- get_A + seekBinReader bh p_a + pure r + -- ----------------------------------------------------------------------------- -- Lazy reading/writing @@ -1127,19 +1290,19 @@ lazyPut = lazyPut' put_ lazyGet :: Binary a => ReadBinHandle -> IO a lazyGet = lazyGet' get -lazyPut' :: HasDebugCallStack => (WriteBinHandle -> a -> IO ()) -> WriteBinHandle -> a -> IO () +lazyPut' :: (WriteBinHandle -> a -> IO ()) -> WriteBinHandle -> a -> IO () lazyPut' f bh a = do -- output the obj with a ptr to skip over it: pre_a <- tellBinWriter bh put_ bh pre_a -- save a slot for the ptr f bh a -- dump the object q <- tellBinWriter bh -- q = ptr to after object - putAt bh pre_a q -- fill in slot before a with ptr to q + putAtRel bh pre_a q -- fill in slot before a with ptr to q seekBinWriter bh q -- finally carry on writing at q lazyGet' :: HasDebugCallStack => (ReadBinHandle -> IO a) -> ReadBinHandle -> IO a lazyGet' f bh = do - p <- get bh -- a BinPtr + p <- getRelBin bh -- a BinPtr p_a <- tellBinReader bh a <- unsafeInterleaveIO $ do -- NB: Use a fresh rbm_off_r variable in the child thread, for thread @@ -1148,7 +1311,7 @@ lazyGet' f bh = do let bh' = bh { rbm_off_r = off_r } seekBinReader bh' p_a f bh' - seekBinReader bh p -- skip over the object for now + seekBinReader bh (makeAbsoluteBin p) -- skip over the object for now return a -- | Serialize the constructor strictly but lazily serialize a value inside a @@ -1442,13 +1605,13 @@ putGenericSymbolTable gen_sym_tab serialiser bh = do mapM_ (\n -> serialiser bh n) (reverse todo) loop snd <$> - (forwardPut bh (const $ readFastMutInt symtab_next >>= put_ bh) $ + (forwardPutRel bh (const $ readFastMutInt symtab_next >>= put_ bh) $ loop) -- | Read the elements of a 'GenericSymbolTable' from disk into a 'SymbolTable'. getGenericSymbolTable :: forall a . (ReadBinHandle -> IO a) -> ReadBinHandle -> IO (SymbolTable a) getGenericSymbolTable deserialiser bh = do - sz <- forwardGet bh (get bh) :: IO Int + sz <- forwardGetRel bh (get bh) :: IO Int mut_arr <- newArray_ (0, sz-1) :: IO (IOArray Int a) forM_ [0..(sz-1)] $ \i -> do f <- deserialiser bh ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit fa76e1ee98906f5bc8fc4598524610020b653412 +Subproject commit eaa6e1870997f09b9023cba09d6b5431cf5b0174 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cbd7902510ffeb80e96d23afcf693b684c63fa09...a2fbe8ff172e5f4307d629b388cc9d885816b388 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cbd7902510ffeb80e96d23afcf693b684c63fa09...a2fbe8ff172e5f4307d629b388cc9d885816b388 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 12:01:36 2024 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 06 May 2024 08:01:36 -0400 Subject: [Git][ghc/ghc][wip/T24334] 2 commits: Simplifier: Preserve OccInfo on DataAlt fields when case binder is dead (#24770) Message-ID: <6638c6a01bbcc_1b731d57d21c4182@gitlab.mail> Sebastian Graf pushed to branch wip/T24334 at Glasgow Haskell Compiler / GHC Commits: ffa35d44 by Sebastian Graf at 2024-05-06T13:58:20+02:00 Simplifier: Preserve OccInfo on DataAlt fields when case binder is dead (#24770) See the adjusted `Note [DataAlt occ info]`. Fixes #24770. - - - - - a6ecbc65 by Sebastian Graf at 2024-05-06T14:01:25+02:00 Kill seqRule, discard dead seq# in Prep (#24334) Discarding seq#s in Core land via `seqRule` was problematic; see #24334. So instead we discard certain dead, discardable seq#s in Prep now. See the updated `Note [seq# magic]`. This fixes the symptoms of #24334. - - - - - 10 changed files: - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Types/Id/Make.hs - testsuite/tests/codeGen/should_compile/T24264.hs - + testsuite/tests/core-to-stg/T24334.hs - + testsuite/tests/core-to-stg/T24334.stdout - testsuite/tests/core-to-stg/all.T - + testsuite/tests/simplCore/should_compile/T24770.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -2067,21 +2067,18 @@ unsafeEqualityProofRule {- ********************************************************************* * * - Rules for seq# and spark# + Rules for spark# * * ********************************************************************* -} -seqRule :: RuleM CoreExpr -seqRule = do +-- spark# :: forall a s . a -> State# s -> (# State# s, a #) +sparkRule :: RuleM CoreExpr +sparkRule = do -- reduce on HNF [Type _ty_a, Type _ty_s, a, s] <- getArgs guard $ exprIsHNF a return $ mkCoreUnboxedTuple [s, a] - --- spark# :: forall a s . a -> State# s -> (# State# s, a #) -sparkRule :: RuleM CoreExpr -sparkRule = seqRule -- reduce on HNF, just the same - -- XXX perhaps we shouldn't do this, because a spark eliminated by - -- this rule won't be counted as a dud at runtime? + -- XXX perhaps we shouldn't do this, because a spark eliminated by + -- this rule won't be counted as a dud at runtime? {- ************************************************************************ @@ -2158,9 +2155,7 @@ builtinRules platform <- getPlatform return $ Var (primOpId IntAndOp) `App` arg `App` mkIntVal platform (d - 1) - ], - - mkBasicRule seqHashName 4 seqRule + ] ] ++ builtinBignumRules {-# NOINLINE builtinRules #-} ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -3234,13 +3234,12 @@ The point is that we bring into the envt a binding after the outer case, and that makes (a,b) alive. At least we do unless the case binder is guaranteed dead. -Note [Case alternative occ info] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -When we are simply reconstructing a case (the common case), we always -zap the occurrence info on the binders in the alternatives. Even -if the case binder is dead, the scrutinee is usually a variable, and *that* -can bring the case-alternative binders back to life. -See Note [Add unfolding for scrutinee] +Note [DataAlt occ info] +~~~~~~~~~~~~~~~~~~~~~~~ +It is in general possible that a DataAlt field binder comes back to life +through the case binder, as in Note [Add unfolding for scrutinee]. +Thus, when we are simply reconstructing a case (the common case), and the +case binder is not dead, we zap the occurrence info on DataAlt field binders. Note [Improving seq] ~~~~~~~~~~~~~~~~~~~ @@ -3397,7 +3396,8 @@ simplAlt env scrut' _ case_bndr' cont' (Alt (LitAlt lit) bndrs rhs) simplAlt env scrut' _ case_bndr' cont' (Alt (DataAlt con) vs rhs) = do { -- See Note [Adding evaluatedness info to pattern-bound variables] - let vs_with_evals = addEvals scrut' con vs + let vs_with_evals = zapIdOccInfoIfCaseBndrAlive case_bndr' $ + addEvals scrut' con vs ; (env', vs') <- simplBinders env vs_with_evals -- Bind the case-binder to (con args) @@ -3449,7 +3449,7 @@ addEvals scrut con vs -- a list of arguments only to throw it away immediately. , Just (Var f) <- stripNArgs 4 scr , f `hasKey` seqHashKey - , let x' = zapIdOccInfoAndSetEvald MarkedStrict x + , let x' = setCaseBndrEvald MarkedStrict x = [s, x'] -- Deal with banged datacon fields @@ -3459,7 +3459,7 @@ addEvals _scrut con vs = go vs the_strs go [] [] = [] go (v:vs') strs | isTyVar v = v : go vs' strs - go (v:vs') (str:strs) = zapIdOccInfoAndSetEvald str v : go vs' strs + go (v:vs') (str:strs) = setCaseBndrEvald str v : go vs' strs go _ _ = pprPanic "Simplify.addEvals" (ppr con $$ ppr vs $$ @@ -3473,11 +3473,12 @@ addEvals _scrut con vs = go vs the_strs strdisp MarkedStrict = text "MarkedStrict" strdisp NotMarkedStrict = text "NotMarkedStrict" -zapIdOccInfoAndSetEvald :: StrictnessMark -> Id -> Id -zapIdOccInfoAndSetEvald str v = - setCaseBndrEvald str $ -- Add eval'dness info - zapIdOccInfo v -- And kill occ info; - -- see Note [Case alternative occ info] +zapIdOccInfoIfCaseBndrAlive :: OutId -> [Id] -> [Id] +-- Kill occ info if case binder is alive; +-- see Note [DataAlt occ info] +zapIdOccInfoIfCaseBndrAlive case_bndr field_bndrs + | isDeadBinder case_bndr = field_bndrs + | otherwise = map zapIdOccInfo field_bndrs addDefaultUnfoldings :: SimplEnv -> Maybe OutExpr -> OutId -> [AltCon] -> SimplEnv addDefaultUnfoldings env mb_scrut case_bndr imposs_deflt_cons ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -890,6 +890,18 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con [covar] _]) floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } +cpeRhsE env (Case scrut bndr _ [Alt (DataAlt dc) [token_out, res] rhs]) + -- See item (SEQ4) of Note [seq# magic]. We want to match + -- case seq# @a @RealWorld s of (# s', _ #) -> rhs[s'] + -- and simplify to rhs[s]. Triggers in T15226. + | isUnboxedTupleDataCon dc + , (Var f,[_ty1, _ty2, value, Var token_in]) <- collectArgs scrut + , f `hasKey` seqHashKey + , exprOkToDiscard value + , Var token_in' <- lookupCorePrepEnv env token_in + , isDeadBinder res, isDeadBinder bndr -- check that bndr and res are dead + = cpeRhsE (extendCorePrepEnv env token_out token_in') rhs + cpeRhsE env (Case scrut bndr ty alts) = do { (floats, scrut') <- cpeBody env scrut ; (env', bndr2) <- cpCloneBndr env bndr ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -2295,9 +2295,16 @@ Things to note also we can attach an evaldUnfolding to x' to discard any subsequent evals such as the `case x' of __DEFAULT`. +(SEQ4) + T15226 demonstrates that we want to discard ok-for-discard seq#s. That is, + simplify `case seq# s of (# s', _ #) -> rhs[s']` to `rhs[s]`. + You might wonder whether the Simplifier could do this. But see the excellent + example in #24334 (immortalised as test T24334) for why it should be done in + CorePrep. + Implementing seq#. The compiler has magic for `seq#` in -- GHC.Core.Opt.ConstantFold.seqRule: eliminate (seq# s) +- GHC.CoreToStg.Prep.cpeRhsE: Implement (SEQ4). - Simplify.addEvals records evaluated-ness for the result (cf. (SEQ3)); see Note [Adding evaluatedness info to pattern-bound variables] ===================================== testsuite/tests/codeGen/should_compile/T24264.hs ===================================== @@ -24,12 +24,8 @@ fun3 :: a -> IO a {-# OPAQUE fun3 #-} fun3 x = do pure () - -- "evaluate $! x" - case x of !x' -> IO (noinline seq# x') - -- noinline to work around the bogus seqRule - -- This ideally also should not push a continuation to the stack - -- before entering 'x'. It currently does, but let's wait for - -- !11515 to land before worrying about that. + evaluate $! x + -- This should not push a continuation to the stack before entering 'x' funPair :: a -> IO (a, a) {-# OPAQUE funPair #-} ===================================== testsuite/tests/core-to-stg/T24334.hs ===================================== @@ -0,0 +1,20 @@ +import Control.Exception +import Data.IORef + +strictPrint :: Show a => a -> IO () +{-# OPAQUE strictPrint #-} +strictPrint x = print $! x + +f :: Show a => a -> IORef a -> IO () +{-# OPAQUE f #-} +f x r = do + x' <- evaluate $! x + writeIORef r x' + strictPrint x' + +main :: IO () +main = do + r <- newIORef (42 :: Int) + f (error "foo") r `catch` \(e :: SomeException) -> return () + n <- readIORef r + print n ===================================== testsuite/tests/core-to-stg/T24334.stdout ===================================== @@ -0,0 +1 @@ +42 ===================================== testsuite/tests/core-to-stg/all.T ===================================== @@ -5,4 +5,5 @@ test('T23270', [grep_errmsg(r'patError')], compile, ['-O0 -dsuppress-uniques -dd test('T23914', normal, compile, ['-O']) test('T14895', normal, compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-uniques']) test('T24124', normal, compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-uniques']) +test('T24334', normal, compile_and_run, ['-O']) test('T24463', normal, compile, ['-O']) ===================================== testsuite/tests/simplCore/should_compile/T24770.hs ===================================== @@ -0,0 +1,3 @@ +module T24770 where + +foo = getLine >> getLine ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -514,3 +514,4 @@ test('T24229a', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typea test('T24229b', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques -dppr-cols=99999']) test('T24370', normal, compile, ['-O']) test('T24551', normal, compile, ['-O -dcore-lint']) +test('T24770', [ grep_errmsg(r'Dead') ], compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5549b0f474598b784bc6c41c55f3e0fa537ab4f4...a6ecbc656b1a908240dda63aefdd696ae0c88745 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5549b0f474598b784bc6c41c55f3e0fa537ab4f4...a6ecbc656b1a908240dda63aefdd696ae0c88745 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 12:06:30 2024 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 06 May 2024 08:06:30 -0400 Subject: [Git][ghc/ghc][wip/T24334] 55 commits: Refactor the Binary serialisation interface Message-ID: <6638c7c62e116_1b731d6e4d6c464c6@gitlab.mail> Sebastian Graf pushed to branch wip/T24334 at Glasgow Haskell Compiler / GHC Commits: fa03b1fb by Fendor at 2024-04-26T18:03:13-04:00 Refactor the Binary serialisation interface The goal is simplifiy adding deduplication tables to `ModIface` interface serialisation. We identify two main points of interest that make this difficult: 1. UserData hardcodes what `Binary` instances can have deduplication tables. Moreover, it heavily uses partial functions. 2. GHC.Iface.Binary hardcodes the deduplication tables for 'Name' and 'FastString', making it difficult to add more deduplication. Instead of having a single `UserData` record with fields for all the types that can have deduplication tables, we allow to provide custom serialisers for any `Typeable`. These are wrapped in existentials and stored in a `Map` indexed by their respective `TypeRep`. The `Binary` instance of the type to deduplicate still needs to explicitly look up the decoder via `findUserDataReader` and `findUserDataWriter`, which is no worse than the status-quo. `Map` was chosen as microbenchmarks indicate it is the fastest for a small number of keys (< 10). To generalise the deduplication table serialisation mechanism, we introduce the types `ReaderTable` and `WriterTable` which provide a simple interface that is sufficient to implement a general purpose deduplication mechanism for `writeBinIface` and `readBinIface`. This allows us to provide a list of deduplication tables for serialisation that can be extended more easily, for example for `IfaceTyCon`, see the issue https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for more motivation. In addition to this refactoring, we split `UserData` into `ReaderUserData` and `WriterUserData`, to avoid partial functions and reduce overall memory usage, as we need fewer mutable variables. Bump haddock submodule to accomodate for `UserData` split. ------------------------- Metric Increase: MultiLayerModulesTH_Make MultiLayerModulesRecomp T21839c ------------------------- - - - - - bac57298 by Fendor at 2024-04-26T18:03:13-04:00 Split `BinHandle` into `ReadBinHandle` and `WriteBinHandle` A `BinHandle` contains too much information for reading data. For example, it needs to keep a `FastMutInt` and a `IORef BinData`, when the non-mutable variants would suffice. Additionally, this change has the benefit that anyone can immediately tell whether the `BinHandle` is used for reading or writing. Bump haddock submodule BinHandle split. - - - - - 4d6394dd by Simon Peyton Jones at 2024-04-26T18:03:49-04:00 Fix missing escaping-kind check in tcPatSynSig Note [Escaping kind in type signatures] explains how we deal with escaping kinds in type signatures, e.g. f :: forall r (a :: TYPE r). a where the kind of the body is (TYPE r), but `r` is not in scope outside the forall-type. I had missed this subtlety in tcPatSynSig, leading to #24686. This MR fixes it; and a similar bug in tc_top_lhs_type. (The latter is tested by T24686a.) - - - - - 981c2c2c by Alan Zimmerman at 2024-04-26T18:04:25-04:00 EPA: check-exact: check that the roundtrip reproduces the source Closes #24670 - - - - - a8616747 by Andrew Lelechenko at 2024-04-26T18:05:01-04:00 Document that setEnv is not thread-safe - - - - - 1e41de83 by Bryan Richter at 2024-04-26T18:05:37-04:00 CI: Work around frequent Signal 9 errors - - - - - a6d5f9da by Naïm Favier at 2024-04-27T17:52:40-04:00 ghc-internal: add MonadFix instance for (,) Closes https://gitlab.haskell.org/ghc/ghc/-/issues/24288, implements CLC proposal https://github.com/haskell/core-libraries-committee/issues/238. Adds a MonadFix instance for tuples, permitting value recursion in the "native" writer monad and bringing consistency with the existing instance for transformers's WriterT (and, to a lesser extent, for Solo). - - - - - 64feadcd by Rodrigo Mesquita at 2024-04-27T17:53:16-04:00 bindist: Fix xattr cleaning The original fix (725343aa) was incorrect because it used the shell bracket syntax which is the quoting syntax in autoconf, making the test for existence be incorrect and therefore `xattr` was never run. Fixes #24554 - - - - - e2094df3 by damhiya at 2024-04-28T23:52:00+09:00 Make read accepts binary integer formats CLC proposal : https://github.com/haskell/core-libraries-committee/issues/177 - - - - - 1c2fd963 by Alan Zimmerman at 2024-04-29T23:17:00-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 - - - - - 4189d17e by Sylvain Henry at 2024-04-29T23:17:42-04:00 LLVM: better unreachable default destination in Switch (#24717) See added note. Co-authored-by: Siddharth Bhat <siddu.druid at gmail.com> - - - - - a3725c88 by Cheng Shao at 2024-04-29T23:18:20-04:00 ci: enable wasm jobs for MRs with wasm label This patch enables wasm jobs for MRs with wasm label. Previously the wasm label didn't actually have any effect on the CI pipeline, and full-ci needed to be applied to run wasm jobs which was a waste of runners when working on the wasm backend, hence the fix here. - - - - - 702f7964 by Matthew Pickering at 2024-04-29T23:18:56-04:00 Make interface files and object files depend on inplace .conf file A potential fix for #24737 - - - - - 728af21e by Cheng Shao at 2024-04-30T05:30:23-04:00 utils: remove obsolete vagrant scripts Vagrantfile has long been removed in !5288. This commit further removes the obsolete vagrant scripts in the tree. - - - - - 36f2c342 by Cheng Shao at 2024-04-30T05:31:00-04:00 Update autoconf scripts Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 - - - - - ecbf22a6 by Ben Gamari at 2024-04-30T05:31:36-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 7eab4e01 by Alan Zimmerman at 2024-05-04T16:14:55+01:00 EPA: Widen stmtslist to include last semicolon Closes #24754 - - - - - 06f7db40 by Teo Camarasu at 2024-05-05T00:19:38-04:00 doc: Fix type error in hs_try_putmvar example - - - - - af000532 by Moritz Schuler at 2024-05-05T06:30:58-04:00 Fix parsing of module names in CLI arguments closes issue #24732 - - - - - da74e9c9 by Ben Gamari at 2024-05-05T06:31:34-04:00 ghc-platform: Add Setup.hs The Hadrian bootstrapping script relies upon `Setup.hs` to drive its build. Addresses #24761. - - - - - 35d34fde by Alan Zimmerman at 2024-05-05T12:52:40-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 - - - - - 03c5dfbf by Simon Peyton Jones at 2024-05-05T12:53:15-04:00 Fix a float-out error Ticket #24768 showed that the Simplifier was accidentally destroying a join point. It turned out to be that we were sending a bottoming join point to the top, accidentally abstracting over /other/ join points. Easily fixed. - - - - - adba68e7 by John Ericson at 2024-05-05T19:35:56-04:00 Substitute bindist files with Hadrian not configure The `ghc-toolchain` overhaul will eventually replace all this stuff with something much more cleaned up, but I think it is still worth making this sort of cleanup in the meantime so other untanglings and dead code cleaning can procede. I was able to delete a fair amount of dead code doing this too. `LLVMTarget_CPP` is renamed to / merged with `LLVMTarget` because it wasn't actually turned into a valid CPP identifier. (Original to 1345c7cc42c45e63ab1726a8fd24a7e4d4222467, actually.) Progress on #23966 Co-Authored-By: Sylvain Henry <hsyl20 at gmail.com> - - - - - 18f4ff84 by Alan Zimmerman at 2024-05-05T19:36:32-04:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 - - - - - b842dce9 by Sebastian Graf at 2024-05-06T14:06:17+02:00 Simplifier: Preserve OccInfo on DataAlt fields when case binder is dead (#24770) See the adjusted `Note [DataAlt occ info]`. Fixes #24770. - - - - - 3aca1d9e by Sebastian Graf at 2024-05-06T14:06:17+02:00 Kill seqRule, discard dead seq# in Prep (#24334) Discarding seq#s in Core land via `seqRule` was problematic; see #24334. So instead we discard certain dead, discardable seq#s in Prep now. See the updated `Note [seq# magic]`. This fixes the symptoms of #24334. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - compiler/GHC.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Driver/Pipeline/Execute.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a6ecbc656b1a908240dda63aefdd696ae0c88745...3aca1d9eb7c157be7c3910067ce812a9fce4bf61 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a6ecbc656b1a908240dda63aefdd696ae0c88745...3aca1d9eb7c157be7c3910067ce812a9fce4bf61 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 12:29:29 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Mon, 06 May 2024 08:29:29 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/improve-pat-to-ty] Improve pattern to type pattern transformation (23739) Message-ID: <6638cd29d1b80_1b731da2d4b0494d3@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/improve-pat-to-ty at Glasgow Haskell Compiler / GHC Commits: 31bbc591 by Andrei Borzenkov at 2024-05-06T16:29:03+04:00 Improve pattern to type pattern transformation (23739) `pat_to_type_pat` function now can handle more patterns: - TuplePat - ListPat - LitPat - NPat - ConPat Allowing these new constructors in type patterns significantly increases possible shapes of type patterns without `type` keyword. This patch also changes how lookups in `lookupOccRnConstr` are performed, because we need to fall back into types when we didn't find a constructor on data level to perform `ConPat` to type transformation properly. - - - - - 15 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Utils/Env.hs - testsuite/tests/rename/should_fail/T19843c.stderr - testsuite/tests/type-data/should_fail/TDPattern.stderr - + testsuite/tests/typecheck/should_compile/T23739a.hs - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T23739b.hs - + testsuite/tests/typecheck/should_fail/T23739b.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -38,6 +38,7 @@ module GHC.Hs.Type ( HsWildCardBndrs(..), HsPatSigType(..), HsPSRn(..), HsTyPat(..), HsTyPatRn(..), + HsTyPatRnBuilder(..), tpBuilderExplicitTV, tpBuilderPatSig, buildHsTyPatRn, builderFromHsTyPatRn, HsSigType(..), LHsSigType, LHsSigWcType, LHsWcType, HsTupleSort(..), HsContext, LHsContext, fromMaybeContext, @@ -128,6 +129,7 @@ import Data.Maybe import Data.Data (Data) import qualified Data.Semigroup as S +import GHC.Data.Bag {- ************************************************************************ @@ -245,6 +247,51 @@ data HsTyPatRn = HsTPRn } deriving Data +-- | A variant of HsTyPatRn that uses Bags for efficient concatenation. +-- See Note [Implicit and explicit type variable binders] in GHC.Rename.Pat +data HsTyPatRnBuilder = + HsTPRnB { + hstpb_nwcs :: Bag Name, + hstpb_imp_tvs :: Bag Name, + hstpb_exp_tvs :: Bag Name + } + +tpBuilderExplicitTV :: Name -> HsTyPatRnBuilder +tpBuilderExplicitTV name = mempty {hstpb_exp_tvs = unitBag name} + +tpBuilderPatSig :: HsPSRn -> HsTyPatRnBuilder +tpBuilderPatSig HsPSRn {hsps_nwcs, hsps_imp_tvs} = + mempty { + hstpb_nwcs = listToBag hsps_nwcs, + hstpb_imp_tvs = listToBag hsps_imp_tvs + } + +instance Semigroup HsTyPatRnBuilder where + HsTPRnB nwcs1 imp_tvs1 exptvs1 <> HsTPRnB nwcs2 imp_tvs2 exptvs2 = + HsTPRnB + (nwcs1 `unionBags` nwcs2) + (imp_tvs1 `unionBags` imp_tvs2) + (exptvs1 `unionBags` exptvs2) + +instance Monoid HsTyPatRnBuilder where + mempty = HsTPRnB emptyBag emptyBag emptyBag + +buildHsTyPatRn :: HsTyPatRnBuilder -> HsTyPatRn +buildHsTyPatRn HsTPRnB {hstpb_nwcs, hstpb_imp_tvs, hstpb_exp_tvs} = + HsTPRn { + hstp_nwcs = bagToList hstpb_nwcs, + hstp_imp_tvs = bagToList hstpb_imp_tvs, + hstp_exp_tvs = bagToList hstpb_exp_tvs + } + +builderFromHsTyPatRn :: HsTyPatRn -> HsTyPatRnBuilder +builderFromHsTyPatRn HsTPRn{hstp_nwcs, hstp_imp_tvs, hstp_exp_tvs} = + HsTPRnB { + hstpb_nwcs = listToBag hstp_nwcs, + hstpb_imp_tvs = listToBag hstp_imp_tvs, + hstpb_exp_tvs = listToBag hstp_exp_tvs + } + type instance XXHsPatSigType (GhcPass _) = DataConCantHappen type instance XXHsTyPat (GhcPass _) = DataConCantHappen ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -1032,7 +1032,15 @@ lookupOccRn = lookupOccRn' WL_Anything -- lookupOccRnConstr looks up an occurrence of a RdrName and displays -- constructors and pattern synonyms as suggestions if it is not in scope lookupOccRnConstr :: RdrName -> RnM Name -lookupOccRnConstr = lookupOccRn' WL_Constructor +lookupOccRnConstr rdr_name + = do { mb_gre <- lookupOccRn_maybe rdr_name + ; case mb_gre of + Just gre -> return $ greName gre + Nothing -> do + { mb_ty_gre <- lookup_promoted rdr_name + ; case mb_ty_gre of + Just gre -> return $ greName gre + Nothing -> reportUnboundName' WL_Constructor rdr_name} } -- lookupOccRnRecField looks up an occurrence of a RdrName and displays -- record fields as suggestions if it is not in scope ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -71,7 +71,6 @@ import GHC.Types.SourceText import GHC.Utils.Misc import GHC.Data.FastString ( uniqCompareFS ) import GHC.Data.List.SetOps( removeDups ) -import GHC.Data.Bag ( Bag, unitBag, unionBags, emptyBag, listToBag, bagToList ) import GHC.Utils.Outputable import GHC.Utils.Panic.Plain import GHC.Types.SrcLoc @@ -89,7 +88,6 @@ import Data.Functor.Identity ( Identity (..) ) import qualified Data.List.NonEmpty as NE import Data.Maybe import Data.Ratio -import qualified Data.Semigroup as S import Control.Monad.Trans.Writer.CPS import Control.Monad.Trans.Class import Control.Monad.Trans.Reader @@ -1242,43 +1240,6 @@ lookupTypeOccTPRnM rdr_name = liftRnFV $ do name <- lookupTypeOccRn rdr_name pure (name, unitFV name) --- | A variant of HsTyPatRn that uses Bags for efficient concatenation. --- See Note [Implicit and explicit type variable binders] -data HsTyPatRnBuilder = - HsTPRnB { - hstpb_nwcs :: Bag Name, - hstpb_imp_tvs :: Bag Name, - hstpb_exp_tvs :: Bag Name - } - -tpb_exp_tv :: Name -> HsTyPatRnBuilder -tpb_exp_tv name = mempty {hstpb_exp_tvs = unitBag name} - -tpb_hsps :: HsPSRn -> HsTyPatRnBuilder -tpb_hsps HsPSRn {hsps_nwcs, hsps_imp_tvs} = - mempty { - hstpb_nwcs = listToBag hsps_nwcs, - hstpb_imp_tvs = listToBag hsps_imp_tvs - } - -instance Semigroup HsTyPatRnBuilder where - HsTPRnB nwcs1 imp_tvs1 exptvs1 <> HsTPRnB nwcs2 imp_tvs2 exptvs2 = - HsTPRnB - (nwcs1 `unionBags` nwcs2) - (imp_tvs1 `unionBags` imp_tvs2) - (exptvs1 `unionBags` exptvs2) - -instance Monoid HsTyPatRnBuilder where - mempty = HsTPRnB emptyBag emptyBag emptyBag - -buildHsTyPatRn :: HsTyPatRnBuilder -> HsTyPatRn -buildHsTyPatRn HsTPRnB {hstpb_nwcs, hstpb_imp_tvs, hstpb_exp_tvs} = - HsTPRn { - hstp_nwcs = bagToList hstpb_nwcs, - hstp_imp_tvs = bagToList hstpb_imp_tvs, - hstp_exp_tvs = bagToList hstpb_exp_tvs - } - rn_lty_pat :: LHsType GhcPs -> TPRnM (LHsType GhcRn) rn_lty_pat (L l hs_ty) = do hs_ty' <- rn_ty_pat hs_ty @@ -1292,7 +1253,7 @@ rn_ty_pat_var lrdr@(L l rdr) = do then do -- binder name <- liftTPRnCps $ newPatName (LamMk True) lrdr - tellTPB (tpb_exp_tv name) + tellTPB (tpBuilderExplicitTV name) pure (L l name) else do -- usage @@ -1413,7 +1374,7 @@ rn_ty_pat (HsKindSig an ty ki) = do ~(HsPS hsps ki') <- liftRnWithCont $ rnHsPatSigKind AlwaysBind ctxt (HsPS noAnn ki) ty' <- rn_lty_pat ty - tellTPB (tpb_hsps hsps) + tellTPB (tpBuilderPatSig hsps) pure (HsKindSig an ty' ki') rn_ty_pat (HsSpliceTy _ splice) = do ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -56,7 +56,6 @@ import GHC.Types.Name.Env import GHC.Types.Name.Reader import GHC.Types.SrcLoc import GHC.Types.Var.Env ( emptyTidyEnv, mkInScopeSet ) -import GHC.Types.SourceText import GHC.Data.Maybe import GHC.Utils.Misc import GHC.Utils.Outputable as Outputable @@ -899,18 +898,12 @@ expr_to_type earg = where unwrap_op_tv (L _ (HsTyVar _ _ op_id)) = return op_id unwrap_op_tv _ = failWith $ TcRnIllformedTypeArgument (L l e) - go (L l e@(HsOverLit _ lit)) = - do { tylit <- case ol_val lit of - HsIntegral n -> return $ HsNumTy NoSourceText (il_value n) - HsIsString _ s -> return $ HsStrTy NoSourceText s - HsFractional _ -> failWith $ TcRnIllformedTypeArgument (L l e) - ; return (L l (HsTyLit noExtField tylit)) } - go (L l e@(HsLit _ lit)) = - do { tylit <- case lit of - HsChar _ c -> return $ HsCharTy NoSourceText c - HsString _ s -> return $ HsStrTy NoSourceText s - _ -> failWith $ TcRnIllformedTypeArgument (L l e) - ; return (L l (HsTyLit noExtField tylit)) } + go (L l (HsOverLit _ lit)) + | Just tylit <- tyLitFromOverloadedLit (ol_val lit) + = return (L l (HsTyLit noExtField tylit)) + go (L l (HsLit _ lit)) + | Just tylit <- tyLitFromLit lit + = return (L l (HsTyLit noExtField tylit)) go (L l (ExplicitTuple _ tup_args boxity)) -- Neither unboxed tuples (#e1,e2#) nor tuple sections (e1,,e2,) can be promoted | isBoxed boxity ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -37,8 +37,6 @@ import GHC.Hs import GHC.Hs.Syn.Type import GHC.Tc.Gen.HsType -import GHC.Rename.Unbound ( unknownNameSuggestions, WhatLooking(..) ) - import GHC.Tc.Gen.Bind( chooseInferredQuantifiers ) import GHC.Tc.Gen.Sig( tcUserTypeSig, tcInstSig ) import GHC.Tc.TyCl.PatSyn( patSynBuilderOcc ) @@ -78,12 +76,10 @@ import GHC.Builtin.Types( multiplicityTy ) import GHC.Builtin.Names import GHC.Builtin.Names.TH( liftStringName, liftName ) -import GHC.Driver.Env import GHC.Driver.DynFlags import GHC.Utils.Misc import GHC.Utils.Outputable as Outputable import GHC.Utils.Panic -import qualified GHC.LanguageExtensions as LangExt import GHC.Data.Maybe import Control.Monad @@ -1164,46 +1160,11 @@ tc_infer_id id_name AGlobal (AConLike (RealDataCon con)) -> tcInferDataCon con AGlobal (AConLike (PatSynCon ps)) -> tcInferPatSyn id_name ps - (tcTyThingTyCon_maybe -> Just tc) -> fail_tycon tc -- TyCon or TcTyCon - ATyVar name _ -> fail_tyvar name + (tcTyThingTyCon_maybe -> Just tc) -> failIllegalTyCon tc -- TyCon or TcTyCon + ATyVar name _ -> failIllegalTyVal name _ -> failWithTc $ TcRnExpectedValueId thing } where - fail_tycon tc = do - gre <- getGlobalRdrEnv - let nm = tyConName tc - pprov = case lookupGRE_Name gre nm of - Just gre -> nest 2 (pprNameProvenance gre) - Nothing -> empty - err | isClassTyCon tc = ClassTE - | otherwise = TyConTE - fail_with_msg dataName nm pprov err - - fail_tyvar nm = - let pprov = nest 2 (text "bound at" <+> ppr (getSrcLoc nm)) - in fail_with_msg varName nm pprov TyVarTE - - fail_with_msg whatName nm pprov err = do - (import_errs, hints) <- get_suggestions whatName - unit_state <- hsc_units <$> getTopEnv - let - -- TODO: unfortunate to have to convert to SDoc here. - -- This should go away once we refactor ErrInfo. - hint_msg = vcat $ map ppr hints - import_err_msg = vcat $ map ppr import_errs - info = ErrInfo { errInfoContext = pprov, errInfoSupplementary = import_err_msg $$ hint_msg } - failWithTc $ TcRnMessageWithInfo unit_state ( - mkDetailedMessage info (TcRnIllegalTermLevelUse nm err)) - - get_suggestions ns = do - required_type_arguments <- xoptM LangExt.RequiredTypeArguments - if required_type_arguments && isVarNameSpace ns - then return ([], []) -- See Note [Suppress hints with RequiredTypeArguments] - else do - let occ = mkOccNameFS ns (occNameFS (occName id_name)) - lcl_env <- getLocalRdrEnv - unknownNameSuggestions lcl_env WL_Anything (mkRdrUnqual occ) - return_id id = return (HsVar noExtField (noLocA id), idType id) {- Note [Suppress hints with RequiredTypeArguments] ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -73,7 +73,10 @@ module GHC.Tc.Gen.HsType ( HoleMode(..), -- Error messages - funAppCtxt, addTyConFlavCtxt + funAppCtxt, addTyConFlavCtxt, + + -- Utils + tyLitFromLit, tyLitFromOverloadedLit, ) where import GHC.Prelude hiding ( head, init, last, tail ) @@ -140,6 +143,7 @@ import qualified Data.List.NonEmpty as NE import Data.List ( mapAccumL ) import Control.Monad import Data.Tuple( swap ) +import GHC.Types.SourceText {- ---------------------------- @@ -4689,3 +4693,22 @@ addTyConFlavCtxt :: Name -> TyConFlavour tc -> TcM a -> TcM a addTyConFlavCtxt name flav = addErrCtxt $ hsep [ text "In the", ppr flav , text "declaration for", quotes (ppr name) ] + +{- +************************************************************************ +* * + Utils for constructing TyLit +* * +************************************************************************ +-} + + +tyLitFromLit :: HsLit GhcRn -> Maybe (HsTyLit GhcRn) +tyLitFromLit (HsString x str) = Just (HsStrTy x str) +tyLitFromLit (HsChar x char) = Just (HsCharTy x char) +tyLitFromLit _ = Nothing + +tyLitFromOverloadedLit :: OverLitVal -> Maybe (HsTyLit GhcRn) +tyLitFromOverloadedLit (HsIntegral n) = Just $ HsNumTy NoSourceText (il_value n) +tyLitFromOverloadedLit (HsIsString _ s) = Just $ HsStrTy NoSourceText s +tyLitFromOverloadedLit HsFractional{} = Nothing ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -78,6 +78,8 @@ import Language.Haskell.Syntax.Basic (FieldLabelString(..)) import Data.List( partition ) import Data.Maybe (isJust) +import Control.Monad.Trans.Writer.CPS +import Control.Monad.Trans.Class {- ************************************************************************ @@ -504,53 +506,74 @@ tc_forall_pat tv _ pat thing_inside ; let pat' = XPat $ ExpansionPat pat (EmbTyPat arg_ty tp) ; return (pat', result) } + -- Convert a Pat into the equivalent HsTyPat. -- See `expr_to_type` (GHC.Tc.Gen.App) for the HsExpr counterpart. -- The `TcM` monad is only used to fail on ill-formed type patterns. pat_to_type_pat :: Pat GhcRn -> TcM (HsTyPat GhcRn) -pat_to_type_pat (EmbTyPat _ tp) = return tp -pat_to_type_pat (VarPat _ lname) = return (HsTP x b) +pat_to_type_pat pat = do + (ty, x) <- runWriterT (pat_to_type pat) + pure (HsTP (buildHsTyPatRn x) ty) + +pat_to_type :: Pat GhcRn -> WriterT HsTyPatRnBuilder TcM (LHsType GhcRn) +pat_to_type (EmbTyPat _ (HsTP x t)) = + do { tell (builderFromHsTyPatRn x) + ; return t } +pat_to_type (VarPat _ lname) = + do { tell (tpBuilderExplicitTV (unLoc lname)) + ; return b } where b = noLocA (HsTyVar noAnn NotPromoted lname) - x = HsTPRn { hstp_nwcs = [] - , hstp_imp_tvs = [] - , hstp_exp_tvs = [unLoc lname] } -pat_to_type_pat (WildPat _) = return (HsTP x b) +pat_to_type (WildPat _) = return b where b = noLocA (HsWildCardTy noExtField) - x = HsTPRn { hstp_nwcs = [] - , hstp_imp_tvs = [] - , hstp_exp_tvs = [] } -pat_to_type_pat (SigPat _ pat sig_ty) - = do { HsTP x_hstp t <- pat_to_type_pat (unLoc pat) +pat_to_type (SigPat _ pat sig_ty) + = do { t <- pat_to_type (unLoc pat) ; let { !(HsPS x_hsps k) = sig_ty - ; x = append_hstp_hsps x_hstp x_hsps ; b = noLocA (HsKindSig noAnn t k) } - ; return (HsTP x b) } - where - -- Quadratic for nested signatures ((p :: t1) :: t2) - -- but those are unlikely to occur in practice. - append_hstp_hsps :: HsTyPatRn -> HsPSRn -> HsTyPatRn - append_hstp_hsps t p - = HsTPRn { hstp_nwcs = hstp_nwcs t ++ hsps_nwcs p - , hstp_imp_tvs = hstp_imp_tvs t ++ hsps_imp_tvs p - , hstp_exp_tvs = hstp_exp_tvs t } -pat_to_type_pat (ParPat _ pat) - = do { HsTP x t <- pat_to_type_pat (unLoc pat) - ; return (HsTP x (noLocA (HsParTy noAnn t))) } -pat_to_type_pat (SplicePat (HsUntypedSpliceTop mod_finalizers pat) splice) = do - { HsTP x t <- pat_to_type_pat pat - ; return (HsTP x (noLocA (HsSpliceTy (HsUntypedSpliceTop mod_finalizers t) splice))) } -pat_to_type_pat pat = - -- There are other cases to handle (ConPat, ListPat, TuplePat, etc), but these - -- would always be rejected by the unification in `tcHsTyPat`, so it's fine to - -- skip them here. This won't continue to be the case when visible forall is - -- permitted in data constructors: - -- - -- data T a where { Typed :: forall a -> a -> T a } - -- g :: T Int -> Int - -- g (Typed Int x) = x -- Note the `Int` type pattern - -- - -- See ticket #18389. When this feature lands, it would be best to extend - -- `pat_to_type_pat` to handle as many pattern forms as possible. + ; tell (tpBuilderPatSig x_hsps) + ; return b } +pat_to_type (ParPat _ pat) + = do { t <- pat_to_type (unLoc pat) + ; return (noLocA (HsParTy noAnn t)) } +pat_to_type (SplicePat (HsUntypedSpliceTop mod_finalizers pat) splice) = do + { t <- pat_to_type pat + ; return (noLocA (HsSpliceTy (HsUntypedSpliceTop mod_finalizers t) splice)) } + +pat_to_type (TuplePat NoExtField pats Boxed) + = do { tys <- traverse (pat_to_type . unLoc) pats + ; let t = noLocA (HsExplicitTupleTy noExtField tys) + ; pure t } +pat_to_type (ListPat NoExtField pats) + = do { tys <- traverse (pat_to_type . unLoc) pats + ; let t = noLocA (HsExplicitListTy NoExtField NotPromoted tys) + ; pure t } + +pat_to_type (LitPat NoExtField lit) + | Just ty_lit <- tyLitFromLit lit + = do { let t = noLocA (HsTyLit noExtField ty_lit) + ; pure t } +pat_to_type (NPat _ (L _ lit) _ _) + | Just ty_lit <- tyLitFromOverloadedLit (ol_val lit) + = do { let t = noLocA (HsTyLit noExtField ty_lit) + ; pure t} + +pat_to_type (ConPat _ lname (InfixCon left right)) + = do { lty <- pat_to_type (unLoc left) + ; rty <- pat_to_type (unLoc right) + ; let { t = noLocA (HsOpTy noAnn NotPromoted lty lname rty)} + ; pure t } +pat_to_type (ConPat _ lname (PrefixCon invis_args vis_args)) + = do { let { appHead = noLocA (HsTyVar noAnn NotPromoted lname) + ; (x_invis, ty_invis) = foldl' apply_invis_arg (mempty, appHead) invis_args } + ; tell x_invis + ; tys_vis <- traverse (pat_to_type . unLoc) vis_args + ; let t = foldl' mkHsAppTy ty_invis tys_vis + ; pure t } + where + apply_invis_arg :: (HsTyPatRnBuilder, LHsType GhcRn) -> HsConPatTyArg GhcRn -> (HsTyPatRnBuilder, LHsType GhcRn) + apply_invis_arg (!hx, !h) (HsConPatTyArg _ (HsTP argx arg)) + = ((hx `mappend` builderFromHsTyPatRn argx), (mkHsAppKindTy noExtField h arg)) + +pat_to_type pat = lift $ failWith $ TcRnIllformedTypePattern pat -- This failure is the only use of the TcM monad in `pat_to_type_pat` ===================================== compiler/GHC/Tc/Utils/Env.hs ===================================== @@ -28,6 +28,7 @@ module GHC.Tc.Utils.Env( tcLookupLocatedClass, tcLookupAxiom, lookupGlobal, lookupGlobal_maybe, addTypecheckedBinds, + failIllegalTyCon, failIllegalTyVal, -- Local environment tcExtendKindEnv, tcExtendKindEnvList, @@ -137,6 +138,7 @@ import Data.List ( intercalate ) import Control.Monad import GHC.Iface.Errors.Types import GHC.Types.Error +import GHC.Rename.Unbound ( unknownNameSuggestions, WhatLooking(..) ) {- ********************************************************************* * * @@ -278,6 +280,7 @@ tcLookupConLike name = do thing <- tcLookupGlobal name case thing of AConLike cl -> return cl + ATyCon tc -> failIllegalTyCon tc _ -> wrongThingErr WrongThingConLike (AGlobal thing) name tcLookupRecSelParent :: HsRecUpdParent GhcRn -> TcM RecSelParent @@ -349,6 +352,45 @@ tcGetInstEnvs = do { eps <- getEps instance MonadThings (IOEnv (Env TcGblEnv TcLclEnv)) where lookupThing = tcLookupGlobal +-- Illegal term-level use of type things +failIllegalTyCon :: TyCon -> TcM a +failIllegalTyVal :: Name -> TcM a +(failIllegalTyCon, failIllegalTyVal) = (fail_tycon, fail_tyvar) + where + fail_tycon tc = do + gre <- getGlobalRdrEnv + let nm = tyConName tc + pprov = case lookupGRE_Name gre nm of + Just gre -> nest 2 (pprNameProvenance gre) + Nothing -> empty + err | isClassTyCon tc = ClassTE + | otherwise = TyConTE + fail_with_msg dataName nm pprov err + + fail_tyvar nm = + let pprov = nest 2 (text "bound at" <+> ppr (getSrcLoc nm)) + in fail_with_msg varName nm pprov TyVarTE + + fail_with_msg whatName nm pprov err = do + (import_errs, hints) <- get_suggestions whatName nm + unit_state <- hsc_units <$> getTopEnv + let + -- TODO: unfortunate to have to convert to SDoc here. + -- This should go away once we refactor ErrInfo. + hint_msg = vcat $ map ppr hints + import_err_msg = vcat $ map ppr import_errs + info = ErrInfo { errInfoContext = pprov, errInfoSupplementary = import_err_msg $$ hint_msg } + failWithTc $ TcRnMessageWithInfo unit_state ( + mkDetailedMessage info (TcRnIllegalTermLevelUse nm err)) + + get_suggestions ns nm = do + required_type_arguments <- xoptM LangExt.RequiredTypeArguments + if required_type_arguments && isVarNameSpace ns + then return ([], []) -- See Note [Suppress hints with RequiredTypeArguments] + else do + let occ = mkOccNameFS ns (occNameFS (occName nm)) + lcl_env <- getLocalRdrEnv + unknownNameSuggestions lcl_env WL_Constructor (mkRdrUnqual occ) {- ************************************************************************ * * ===================================== testsuite/tests/rename/should_fail/T19843c.stderr ===================================== @@ -1,4 +1,7 @@ +T19843c.hs:6:6: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Map’ + • imported from ‘Data.Map’ at T19843c.hs:3:1-22 + (and originally defined in ‘Data.Map.Internal’) + • In the pattern: Map k v + In an equation for ‘foo’: foo (Map k v) = undefined -T19843c.hs:6:6: error: [GHC-76037] - Not in scope: data constructor ‘Map.Map’ - NB: the module ‘Data.Map’ does not export ‘Map’. ===================================== testsuite/tests/type-data/should_fail/TDPattern.stderr ===================================== @@ -1,3 +1,6 @@ +TDPattern.hs:7:3: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Zero’ + • defined at TDPattern.hs:4:17 + • In the pattern: Zero + In an equation for ‘f’: f Zero = 0 -TDPattern.hs:7:3: [GHC-76037] - Not in scope: data constructor ‘Zero’ ===================================== testsuite/tests/typecheck/should_compile/T23739a.hs ===================================== @@ -0,0 +1,52 @@ +{-# LANGUAGE TypeAbstractions, + ExplicitNamespaces, + RequiredTypeArguments, + DataKinds, + NoListTuplePuns, + OverloadedStrings #-} + +module T23739a where + +import Data.Tuple.Experimental +import GHC.TypeLits + +f1 :: forall a -> a ~ (Int, Bool) => Unit +f1 (b,c) = () + +f2 :: forall a -> a ~ (Int : Bool : Double : []) => Unit +f2 [a,b,c] = () + +f3 :: forall a -> a ~ [Int, Bool, Double] => Unit +f3 [a,b,c] = () + +f4 :: forall a -> a ~ [Int, Bool, Double] => Unit +f4 (a : b : c : []) = () + +f5 :: forall a -> a ~ "blah" => Unit +f5 "blah" = () + +f6 :: forall a -> a ~ 'c' => Unit +f6 'c' = () + +f7 :: forall a -> a ~ UnconsSymbol "blah" => Unit +f7 (Just ('b', "lah")) = () + +f8 :: forall a -> Unit +f8 _ = () + +f9 :: forall a -> a ~ 42 => Unit +f9 42 = () + +f10 :: forall a -> a ~ () => Unit +f10 () = () + +f11 :: forall a -> a ~ Int => Unit +f11 Int = () + +f12 :: forall a -> a ~ (Left @Bool @(Maybe b) True) => Unit +f12 (Left @Bool @(Maybe a) True) = () + +data Tup a = MkTup a a + +f13 :: forall a -> a ~ (Int, MkTup 'f' 'g', 42, True, [1,2,3,4,5], (), "blah", "wombat", 'd', UnconsSymbol "corner") => Unit +f13 (Int, 'f' `MkTup` 'g', 42, True, 1 : 2 : 3 : [4,5], () ,"blah", x, 'd', Just ('c', "orner")) = () ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -915,3 +915,4 @@ test('WarnDefaultedExceptionContext', normal, compile, ['-Wdefaulted-exception-c test('T24470b', normal, compile, ['']) test('T24566', [], makefile_test, []) test('T23764', normal, compile, ['']) +test('T23739a', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T23739b.hs ===================================== @@ -0,0 +1,14 @@ + +module T23739b where + +import Data.Tuple.Experimental +import GHC.TypeLits + +g1 :: Int -> Unit +g1 Int = () + +g2 :: Int +g2 = Int{} + +g3 :: Int +g3 = Int ===================================== testsuite/tests/typecheck/should_fail/T23739b.stderr ===================================== @@ -0,0 +1,21 @@ +T23739b.hs:8:4: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Int’ + • imported from ‘Prelude’ at T23739b.hs:2:8-14 + (and originally defined in ‘GHC.Types’) + • In the pattern: Int + In an equation for ‘g1’: g1 Int = () + +T23739b.hs:11:6: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Int’ + • imported from ‘Prelude’ at T23739b.hs:2:8-14 + (and originally defined in ‘GHC.Types’) + • In the expression: Int {} + In an equation for ‘g2’: g2 = Int {} + +T23739b.hs:14:6: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Int’ + • imported from ‘Prelude’ at T23739b.hs:2:8-14 + (and originally defined in ‘GHC.Types’) + • In the expression: Int + In an equation for ‘g3’: g3 = Int + ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -725,4 +725,4 @@ test('T17594g', normal, compile_fail, ['']) test('T24470a', normal, compile_fail, ['']) test('T24553', normal, compile_fail, ['']) - +test('T23739b', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/31bbc591bca46fb3bcb168491b6199eb29de3dc8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/31bbc591bca46fb3bcb168491b6199eb29de3dc8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 13:04:22 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Mon, 06 May 2024 09:04:22 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/improve-pat-to-ty] Improve pattern to type pattern transformation (23739) Message-ID: <6638d5565008_17f48e3f8734549e6@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/improve-pat-to-ty at Glasgow Haskell Compiler / GHC Commits: 84c9b79b by Andrei Borzenkov at 2024-05-06T17:04:03+04:00 Improve pattern to type pattern transformation (23739) `pat_to_type_pat` function now can handle more patterns: - TuplePat - ListPat - LitPat - NPat - ConPat Allowing these new constructors in type patterns significantly increases possible shapes of type patterns without `type` keyword. This patch also changes how lookups in `lookupOccRnConstr` are performed, because we need to fall back into types when we didn't find a constructor on data level to perform `ConPat` to type transformation properly. - - - - - 15 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Utils/Env.hs - testsuite/tests/rename/should_fail/T19843c.stderr - testsuite/tests/type-data/should_fail/TDPattern.stderr - + testsuite/tests/typecheck/should_compile/T23739a.hs - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T23739b.hs - + testsuite/tests/typecheck/should_fail/T23739b.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -38,6 +38,7 @@ module GHC.Hs.Type ( HsWildCardBndrs(..), HsPatSigType(..), HsPSRn(..), HsTyPat(..), HsTyPatRn(..), + HsTyPatRnBuilder(..), tpBuilderExplicitTV, tpBuilderPatSig, buildHsTyPatRn, builderFromHsTyPatRn, HsSigType(..), LHsSigType, LHsSigWcType, LHsWcType, HsTupleSort(..), HsContext, LHsContext, fromMaybeContext, @@ -128,6 +129,7 @@ import Data.Maybe import Data.Data (Data) import qualified Data.Semigroup as S +import GHC.Data.Bag {- ************************************************************************ @@ -245,6 +247,51 @@ data HsTyPatRn = HsTPRn } deriving Data +-- | A variant of HsTyPatRn that uses Bags for efficient concatenation. +-- See Note [Implicit and explicit type variable binders] in GHC.Rename.Pat +data HsTyPatRnBuilder = + HsTPRnB { + hstpb_nwcs :: Bag Name, + hstpb_imp_tvs :: Bag Name, + hstpb_exp_tvs :: Bag Name + } + +tpBuilderExplicitTV :: Name -> HsTyPatRnBuilder +tpBuilderExplicitTV name = mempty {hstpb_exp_tvs = unitBag name} + +tpBuilderPatSig :: HsPSRn -> HsTyPatRnBuilder +tpBuilderPatSig HsPSRn {hsps_nwcs, hsps_imp_tvs} = + mempty { + hstpb_nwcs = listToBag hsps_nwcs, + hstpb_imp_tvs = listToBag hsps_imp_tvs + } + +instance Semigroup HsTyPatRnBuilder where + HsTPRnB nwcs1 imp_tvs1 exptvs1 <> HsTPRnB nwcs2 imp_tvs2 exptvs2 = + HsTPRnB + (nwcs1 `unionBags` nwcs2) + (imp_tvs1 `unionBags` imp_tvs2) + (exptvs1 `unionBags` exptvs2) + +instance Monoid HsTyPatRnBuilder where + mempty = HsTPRnB emptyBag emptyBag emptyBag + +buildHsTyPatRn :: HsTyPatRnBuilder -> HsTyPatRn +buildHsTyPatRn HsTPRnB {hstpb_nwcs, hstpb_imp_tvs, hstpb_exp_tvs} = + HsTPRn { + hstp_nwcs = bagToList hstpb_nwcs, + hstp_imp_tvs = bagToList hstpb_imp_tvs, + hstp_exp_tvs = bagToList hstpb_exp_tvs + } + +builderFromHsTyPatRn :: HsTyPatRn -> HsTyPatRnBuilder +builderFromHsTyPatRn HsTPRn{hstp_nwcs, hstp_imp_tvs, hstp_exp_tvs} = + HsTPRnB { + hstpb_nwcs = listToBag hstp_nwcs, + hstpb_imp_tvs = listToBag hstp_imp_tvs, + hstpb_exp_tvs = listToBag hstp_exp_tvs + } + type instance XXHsPatSigType (GhcPass _) = DataConCantHappen type instance XXHsTyPat (GhcPass _) = DataConCantHappen ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -1032,7 +1032,15 @@ lookupOccRn = lookupOccRn' WL_Anything -- lookupOccRnConstr looks up an occurrence of a RdrName and displays -- constructors and pattern synonyms as suggestions if it is not in scope lookupOccRnConstr :: RdrName -> RnM Name -lookupOccRnConstr = lookupOccRn' WL_Constructor +lookupOccRnConstr rdr_name + = do { mb_gre <- lookupOccRn_maybe rdr_name + ; case mb_gre of + Just gre -> return $ greName gre + Nothing -> do + { mb_ty_gre <- lookup_promoted rdr_name + ; case mb_ty_gre of + Just gre -> return $ greName gre + Nothing -> reportUnboundName' WL_Constructor rdr_name} } -- lookupOccRnRecField looks up an occurrence of a RdrName and displays -- record fields as suggestions if it is not in scope ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -71,7 +71,6 @@ import GHC.Types.SourceText import GHC.Utils.Misc import GHC.Data.FastString ( uniqCompareFS ) import GHC.Data.List.SetOps( removeDups ) -import GHC.Data.Bag ( Bag, unitBag, unionBags, emptyBag, listToBag, bagToList ) import GHC.Utils.Outputable import GHC.Utils.Panic.Plain import GHC.Types.SrcLoc @@ -89,7 +88,6 @@ import Data.Functor.Identity ( Identity (..) ) import qualified Data.List.NonEmpty as NE import Data.Maybe import Data.Ratio -import qualified Data.Semigroup as S import Control.Monad.Trans.Writer.CPS import Control.Monad.Trans.Class import Control.Monad.Trans.Reader @@ -1242,43 +1240,6 @@ lookupTypeOccTPRnM rdr_name = liftRnFV $ do name <- lookupTypeOccRn rdr_name pure (name, unitFV name) --- | A variant of HsTyPatRn that uses Bags for efficient concatenation. --- See Note [Implicit and explicit type variable binders] -data HsTyPatRnBuilder = - HsTPRnB { - hstpb_nwcs :: Bag Name, - hstpb_imp_tvs :: Bag Name, - hstpb_exp_tvs :: Bag Name - } - -tpb_exp_tv :: Name -> HsTyPatRnBuilder -tpb_exp_tv name = mempty {hstpb_exp_tvs = unitBag name} - -tpb_hsps :: HsPSRn -> HsTyPatRnBuilder -tpb_hsps HsPSRn {hsps_nwcs, hsps_imp_tvs} = - mempty { - hstpb_nwcs = listToBag hsps_nwcs, - hstpb_imp_tvs = listToBag hsps_imp_tvs - } - -instance Semigroup HsTyPatRnBuilder where - HsTPRnB nwcs1 imp_tvs1 exptvs1 <> HsTPRnB nwcs2 imp_tvs2 exptvs2 = - HsTPRnB - (nwcs1 `unionBags` nwcs2) - (imp_tvs1 `unionBags` imp_tvs2) - (exptvs1 `unionBags` exptvs2) - -instance Monoid HsTyPatRnBuilder where - mempty = HsTPRnB emptyBag emptyBag emptyBag - -buildHsTyPatRn :: HsTyPatRnBuilder -> HsTyPatRn -buildHsTyPatRn HsTPRnB {hstpb_nwcs, hstpb_imp_tvs, hstpb_exp_tvs} = - HsTPRn { - hstp_nwcs = bagToList hstpb_nwcs, - hstp_imp_tvs = bagToList hstpb_imp_tvs, - hstp_exp_tvs = bagToList hstpb_exp_tvs - } - rn_lty_pat :: LHsType GhcPs -> TPRnM (LHsType GhcRn) rn_lty_pat (L l hs_ty) = do hs_ty' <- rn_ty_pat hs_ty @@ -1292,7 +1253,7 @@ rn_ty_pat_var lrdr@(L l rdr) = do then do -- binder name <- liftTPRnCps $ newPatName (LamMk True) lrdr - tellTPB (tpb_exp_tv name) + tellTPB (tpBuilderExplicitTV name) pure (L l name) else do -- usage @@ -1413,7 +1374,7 @@ rn_ty_pat (HsKindSig an ty ki) = do ~(HsPS hsps ki') <- liftRnWithCont $ rnHsPatSigKind AlwaysBind ctxt (HsPS noAnn ki) ty' <- rn_lty_pat ty - tellTPB (tpb_hsps hsps) + tellTPB (tpBuilderPatSig hsps) pure (HsKindSig an ty' ki') rn_ty_pat (HsSpliceTy _ splice) = do ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -56,7 +56,6 @@ import GHC.Types.Name.Env import GHC.Types.Name.Reader import GHC.Types.SrcLoc import GHC.Types.Var.Env ( emptyTidyEnv, mkInScopeSet ) -import GHC.Types.SourceText import GHC.Data.Maybe import GHC.Utils.Misc import GHC.Utils.Outputable as Outputable @@ -899,18 +898,12 @@ expr_to_type earg = where unwrap_op_tv (L _ (HsTyVar _ _ op_id)) = return op_id unwrap_op_tv _ = failWith $ TcRnIllformedTypeArgument (L l e) - go (L l e@(HsOverLit _ lit)) = - do { tylit <- case ol_val lit of - HsIntegral n -> return $ HsNumTy NoSourceText (il_value n) - HsIsString _ s -> return $ HsStrTy NoSourceText s - HsFractional _ -> failWith $ TcRnIllformedTypeArgument (L l e) - ; return (L l (HsTyLit noExtField tylit)) } - go (L l e@(HsLit _ lit)) = - do { tylit <- case lit of - HsChar _ c -> return $ HsCharTy NoSourceText c - HsString _ s -> return $ HsStrTy NoSourceText s - _ -> failWith $ TcRnIllformedTypeArgument (L l e) - ; return (L l (HsTyLit noExtField tylit)) } + go (L l (HsOverLit _ lit)) + | Just tylit <- tyLitFromOverloadedLit (ol_val lit) + = return (L l (HsTyLit noExtField tylit)) + go (L l (HsLit _ lit)) + | Just tylit <- tyLitFromLit lit + = return (L l (HsTyLit noExtField tylit)) go (L l (ExplicitTuple _ tup_args boxity)) -- Neither unboxed tuples (#e1,e2#) nor tuple sections (e1,,e2,) can be promoted | isBoxed boxity ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -37,8 +37,6 @@ import GHC.Hs import GHC.Hs.Syn.Type import GHC.Tc.Gen.HsType -import GHC.Rename.Unbound ( unknownNameSuggestions, WhatLooking(..) ) - import GHC.Tc.Gen.Bind( chooseInferredQuantifiers ) import GHC.Tc.Gen.Sig( tcUserTypeSig, tcInstSig ) import GHC.Tc.TyCl.PatSyn( patSynBuilderOcc ) @@ -78,12 +76,10 @@ import GHC.Builtin.Types( multiplicityTy ) import GHC.Builtin.Names import GHC.Builtin.Names.TH( liftStringName, liftName ) -import GHC.Driver.Env import GHC.Driver.DynFlags import GHC.Utils.Misc import GHC.Utils.Outputable as Outputable import GHC.Utils.Panic -import qualified GHC.LanguageExtensions as LangExt import GHC.Data.Maybe import Control.Monad @@ -1164,46 +1160,11 @@ tc_infer_id id_name AGlobal (AConLike (RealDataCon con)) -> tcInferDataCon con AGlobal (AConLike (PatSynCon ps)) -> tcInferPatSyn id_name ps - (tcTyThingTyCon_maybe -> Just tc) -> fail_tycon tc -- TyCon or TcTyCon - ATyVar name _ -> fail_tyvar name + (tcTyThingTyCon_maybe -> Just tc) -> failIllegalTyCon tc -- TyCon or TcTyCon + ATyVar name _ -> failIllegalTyVal name _ -> failWithTc $ TcRnExpectedValueId thing } where - fail_tycon tc = do - gre <- getGlobalRdrEnv - let nm = tyConName tc - pprov = case lookupGRE_Name gre nm of - Just gre -> nest 2 (pprNameProvenance gre) - Nothing -> empty - err | isClassTyCon tc = ClassTE - | otherwise = TyConTE - fail_with_msg dataName nm pprov err - - fail_tyvar nm = - let pprov = nest 2 (text "bound at" <+> ppr (getSrcLoc nm)) - in fail_with_msg varName nm pprov TyVarTE - - fail_with_msg whatName nm pprov err = do - (import_errs, hints) <- get_suggestions whatName - unit_state <- hsc_units <$> getTopEnv - let - -- TODO: unfortunate to have to convert to SDoc here. - -- This should go away once we refactor ErrInfo. - hint_msg = vcat $ map ppr hints - import_err_msg = vcat $ map ppr import_errs - info = ErrInfo { errInfoContext = pprov, errInfoSupplementary = import_err_msg $$ hint_msg } - failWithTc $ TcRnMessageWithInfo unit_state ( - mkDetailedMessage info (TcRnIllegalTermLevelUse nm err)) - - get_suggestions ns = do - required_type_arguments <- xoptM LangExt.RequiredTypeArguments - if required_type_arguments && isVarNameSpace ns - then return ([], []) -- See Note [Suppress hints with RequiredTypeArguments] - else do - let occ = mkOccNameFS ns (occNameFS (occName id_name)) - lcl_env <- getLocalRdrEnv - unknownNameSuggestions lcl_env WL_Anything (mkRdrUnqual occ) - return_id id = return (HsVar noExtField (noLocA id), idType id) {- Note [Suppress hints with RequiredTypeArguments] ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -73,7 +73,10 @@ module GHC.Tc.Gen.HsType ( HoleMode(..), -- Error messages - funAppCtxt, addTyConFlavCtxt + funAppCtxt, addTyConFlavCtxt, + + -- Utils + tyLitFromLit, tyLitFromOverloadedLit, ) where import GHC.Prelude hiding ( head, init, last, tail ) @@ -140,6 +143,7 @@ import qualified Data.List.NonEmpty as NE import Data.List ( mapAccumL ) import Control.Monad import Data.Tuple( swap ) +import GHC.Types.SourceText {- ---------------------------- @@ -4689,3 +4693,22 @@ addTyConFlavCtxt :: Name -> TyConFlavour tc -> TcM a -> TcM a addTyConFlavCtxt name flav = addErrCtxt $ hsep [ text "In the", ppr flav , text "declaration for", quotes (ppr name) ] + +{- +************************************************************************ +* * + Utils for constructing TyLit +* * +************************************************************************ +-} + + +tyLitFromLit :: HsLit GhcRn -> Maybe (HsTyLit GhcRn) +tyLitFromLit (HsString x str) = Just (HsStrTy x str) +tyLitFromLit (HsChar x char) = Just (HsCharTy x char) +tyLitFromLit _ = Nothing + +tyLitFromOverloadedLit :: OverLitVal -> Maybe (HsTyLit GhcRn) +tyLitFromOverloadedLit (HsIntegral n) = Just $ HsNumTy NoSourceText (il_value n) +tyLitFromOverloadedLit (HsIsString _ s) = Just $ HsStrTy NoSourceText s +tyLitFromOverloadedLit HsFractional{} = Nothing ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -78,6 +78,8 @@ import Language.Haskell.Syntax.Basic (FieldLabelString(..)) import Data.List( partition ) import Data.Maybe (isJust) +import Control.Monad.Trans.Writer.CPS +import Control.Monad.Trans.Class {- ************************************************************************ @@ -504,53 +506,74 @@ tc_forall_pat tv _ pat thing_inside ; let pat' = XPat $ ExpansionPat pat (EmbTyPat arg_ty tp) ; return (pat', result) } + -- Convert a Pat into the equivalent HsTyPat. -- See `expr_to_type` (GHC.Tc.Gen.App) for the HsExpr counterpart. -- The `TcM` monad is only used to fail on ill-formed type patterns. pat_to_type_pat :: Pat GhcRn -> TcM (HsTyPat GhcRn) -pat_to_type_pat (EmbTyPat _ tp) = return tp -pat_to_type_pat (VarPat _ lname) = return (HsTP x b) +pat_to_type_pat pat = do + (ty, x) <- runWriterT (pat_to_type pat) + pure (HsTP (buildHsTyPatRn x) ty) + +pat_to_type :: Pat GhcRn -> WriterT HsTyPatRnBuilder TcM (LHsType GhcRn) +pat_to_type (EmbTyPat _ (HsTP x t)) = + do { tell (builderFromHsTyPatRn x) + ; return t } +pat_to_type (VarPat _ lname) = + do { tell (tpBuilderExplicitTV (unLoc lname)) + ; return b } where b = noLocA (HsTyVar noAnn NotPromoted lname) - x = HsTPRn { hstp_nwcs = [] - , hstp_imp_tvs = [] - , hstp_exp_tvs = [unLoc lname] } -pat_to_type_pat (WildPat _) = return (HsTP x b) +pat_to_type (WildPat _) = return b where b = noLocA (HsWildCardTy noExtField) - x = HsTPRn { hstp_nwcs = [] - , hstp_imp_tvs = [] - , hstp_exp_tvs = [] } -pat_to_type_pat (SigPat _ pat sig_ty) - = do { HsTP x_hstp t <- pat_to_type_pat (unLoc pat) +pat_to_type (SigPat _ pat sig_ty) + = do { t <- pat_to_type (unLoc pat) ; let { !(HsPS x_hsps k) = sig_ty - ; x = append_hstp_hsps x_hstp x_hsps ; b = noLocA (HsKindSig noAnn t k) } - ; return (HsTP x b) } - where - -- Quadratic for nested signatures ((p :: t1) :: t2) - -- but those are unlikely to occur in practice. - append_hstp_hsps :: HsTyPatRn -> HsPSRn -> HsTyPatRn - append_hstp_hsps t p - = HsTPRn { hstp_nwcs = hstp_nwcs t ++ hsps_nwcs p - , hstp_imp_tvs = hstp_imp_tvs t ++ hsps_imp_tvs p - , hstp_exp_tvs = hstp_exp_tvs t } -pat_to_type_pat (ParPat _ pat) - = do { HsTP x t <- pat_to_type_pat (unLoc pat) - ; return (HsTP x (noLocA (HsParTy noAnn t))) } -pat_to_type_pat (SplicePat (HsUntypedSpliceTop mod_finalizers pat) splice) = do - { HsTP x t <- pat_to_type_pat pat - ; return (HsTP x (noLocA (HsSpliceTy (HsUntypedSpliceTop mod_finalizers t) splice))) } -pat_to_type_pat pat = - -- There are other cases to handle (ConPat, ListPat, TuplePat, etc), but these - -- would always be rejected by the unification in `tcHsTyPat`, so it's fine to - -- skip them here. This won't continue to be the case when visible forall is - -- permitted in data constructors: - -- - -- data T a where { Typed :: forall a -> a -> T a } - -- g :: T Int -> Int - -- g (Typed Int x) = x -- Note the `Int` type pattern - -- - -- See ticket #18389. When this feature lands, it would be best to extend - -- `pat_to_type_pat` to handle as many pattern forms as possible. + ; tell (tpBuilderPatSig x_hsps) + ; return b } +pat_to_type (ParPat _ pat) + = do { t <- pat_to_type (unLoc pat) + ; return (noLocA (HsParTy noAnn t)) } +pat_to_type (SplicePat (HsUntypedSpliceTop mod_finalizers pat) splice) = do + { t <- pat_to_type pat + ; return (noLocA (HsSpliceTy (HsUntypedSpliceTop mod_finalizers t) splice)) } + +pat_to_type (TuplePat _ pats Boxed) + = do { tys <- traverse (pat_to_type . unLoc) pats + ; let t = noLocA (HsExplicitTupleTy noExtField tys) + ; pure t } +pat_to_type (ListPat _ pats) + = do { tys <- traverse (pat_to_type . unLoc) pats + ; let t = noLocA (HsExplicitListTy NoExtField NotPromoted tys) + ; pure t } + +pat_to_type (LitPat _ lit) + | Just ty_lit <- tyLitFromLit lit + = do { let t = noLocA (HsTyLit noExtField ty_lit) + ; pure t } +pat_to_type (NPat _ (L _ lit) _ _) + | Just ty_lit <- tyLitFromOverloadedLit (ol_val lit) + = do { let t = noLocA (HsTyLit noExtField ty_lit) + ; pure t} + +pat_to_type (ConPat _ lname (InfixCon left right)) + = do { lty <- pat_to_type (unLoc left) + ; rty <- pat_to_type (unLoc right) + ; let { t = noLocA (HsOpTy noAnn NotPromoted lty lname rty)} + ; pure t } +pat_to_type (ConPat _ lname (PrefixCon invis_args vis_args)) + = do { let { appHead = noLocA (HsTyVar noAnn NotPromoted lname)} + ; ty_invis <- foldM apply_invis_arg appHead invis_args + ; tys_vis <- traverse (pat_to_type . unLoc) vis_args + ; let t = foldl' mkHsAppTy ty_invis tys_vis + ; pure t } + where + apply_invis_arg :: LHsType GhcRn -> HsConPatTyArg GhcRn -> WriterT HsTyPatRnBuilder TcM (LHsType GhcRn) + apply_invis_arg !t (HsConPatTyArg _ (HsTP argx arg)) + = do { tell (builderFromHsTyPatRn argx) + ; pure (mkHsAppKindTy noExtField t arg)} + +pat_to_type pat = lift $ failWith $ TcRnIllformedTypePattern pat -- This failure is the only use of the TcM monad in `pat_to_type_pat` ===================================== compiler/GHC/Tc/Utils/Env.hs ===================================== @@ -28,6 +28,7 @@ module GHC.Tc.Utils.Env( tcLookupLocatedClass, tcLookupAxiom, lookupGlobal, lookupGlobal_maybe, addTypecheckedBinds, + failIllegalTyCon, failIllegalTyVal, -- Local environment tcExtendKindEnv, tcExtendKindEnvList, @@ -137,6 +138,7 @@ import Data.List ( intercalate ) import Control.Monad import GHC.Iface.Errors.Types import GHC.Types.Error +import GHC.Rename.Unbound ( unknownNameSuggestions, WhatLooking(..) ) {- ********************************************************************* * * @@ -278,6 +280,7 @@ tcLookupConLike name = do thing <- tcLookupGlobal name case thing of AConLike cl -> return cl + ATyCon tc -> failIllegalTyCon tc _ -> wrongThingErr WrongThingConLike (AGlobal thing) name tcLookupRecSelParent :: HsRecUpdParent GhcRn -> TcM RecSelParent @@ -349,6 +352,45 @@ tcGetInstEnvs = do { eps <- getEps instance MonadThings (IOEnv (Env TcGblEnv TcLclEnv)) where lookupThing = tcLookupGlobal +-- Illegal term-level use of type things +failIllegalTyCon :: TyCon -> TcM a +failIllegalTyVal :: Name -> TcM a +(failIllegalTyCon, failIllegalTyVal) = (fail_tycon, fail_tyvar) + where + fail_tycon tc = do + gre <- getGlobalRdrEnv + let nm = tyConName tc + pprov = case lookupGRE_Name gre nm of + Just gre -> nest 2 (pprNameProvenance gre) + Nothing -> empty + err | isClassTyCon tc = ClassTE + | otherwise = TyConTE + fail_with_msg dataName nm pprov err + + fail_tyvar nm = + let pprov = nest 2 (text "bound at" <+> ppr (getSrcLoc nm)) + in fail_with_msg varName nm pprov TyVarTE + + fail_with_msg whatName nm pprov err = do + (import_errs, hints) <- get_suggestions whatName nm + unit_state <- hsc_units <$> getTopEnv + let + -- TODO: unfortunate to have to convert to SDoc here. + -- This should go away once we refactor ErrInfo. + hint_msg = vcat $ map ppr hints + import_err_msg = vcat $ map ppr import_errs + info = ErrInfo { errInfoContext = pprov, errInfoSupplementary = import_err_msg $$ hint_msg } + failWithTc $ TcRnMessageWithInfo unit_state ( + mkDetailedMessage info (TcRnIllegalTermLevelUse nm err)) + + get_suggestions ns nm = do + required_type_arguments <- xoptM LangExt.RequiredTypeArguments + if required_type_arguments && isVarNameSpace ns + then return ([], []) -- See Note [Suppress hints with RequiredTypeArguments] + else do + let occ = mkOccNameFS ns (occNameFS (occName nm)) + lcl_env <- getLocalRdrEnv + unknownNameSuggestions lcl_env WL_Constructor (mkRdrUnqual occ) {- ************************************************************************ * * ===================================== testsuite/tests/rename/should_fail/T19843c.stderr ===================================== @@ -1,4 +1,7 @@ +T19843c.hs:6:6: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Map’ + • imported from ‘Data.Map’ at T19843c.hs:3:1-22 + (and originally defined in ‘Data.Map.Internal’) + • In the pattern: Map k v + In an equation for ‘foo’: foo (Map k v) = undefined -T19843c.hs:6:6: error: [GHC-76037] - Not in scope: data constructor ‘Map.Map’ - NB: the module ‘Data.Map’ does not export ‘Map’. ===================================== testsuite/tests/type-data/should_fail/TDPattern.stderr ===================================== @@ -1,3 +1,6 @@ +TDPattern.hs:7:3: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Zero’ + • defined at TDPattern.hs:4:17 + • In the pattern: Zero + In an equation for ‘f’: f Zero = 0 -TDPattern.hs:7:3: [GHC-76037] - Not in scope: data constructor ‘Zero’ ===================================== testsuite/tests/typecheck/should_compile/T23739a.hs ===================================== @@ -0,0 +1,52 @@ +{-# LANGUAGE TypeAbstractions, + ExplicitNamespaces, + RequiredTypeArguments, + DataKinds, + NoListTuplePuns, + OverloadedStrings #-} + +module T23739a where + +import Data.Tuple.Experimental +import GHC.TypeLits + +f1 :: forall a -> a ~ (Int, Bool) => Unit +f1 (b,c) = () + +f2 :: forall a -> a ~ (Int : Bool : Double : []) => Unit +f2 [a,b,c] = () + +f3 :: forall a -> a ~ [Int, Bool, Double] => Unit +f3 [a,b,c] = () + +f4 :: forall a -> a ~ [Int, Bool, Double] => Unit +f4 (a : b : c : []) = () + +f5 :: forall a -> a ~ "blah" => Unit +f5 "blah" = () + +f6 :: forall a -> a ~ 'c' => Unit +f6 'c' = () + +f7 :: forall a -> a ~ UnconsSymbol "blah" => Unit +f7 (Just ('b', "lah")) = () + +f8 :: forall a -> Unit +f8 _ = () + +f9 :: forall a -> a ~ 42 => Unit +f9 42 = () + +f10 :: forall a -> a ~ () => Unit +f10 () = () + +f11 :: forall a -> a ~ Int => Unit +f11 Int = () + +f12 :: forall a -> a ~ (Left @Bool @(Maybe b) True) => Unit +f12 (Left @Bool @(Maybe a) True) = () + +data Tup a = MkTup a a + +f13 :: forall a -> a ~ (Int, MkTup 'f' 'g', 42, True, [1,2,3,4,5], (), "blah", "wombat", 'd', UnconsSymbol "corner") => Unit +f13 (Int, 'f' `MkTup` 'g', 42, True, 1 : 2 : 3 : [4,5], () ,"blah", x, 'd', Just ('c', "orner")) = () ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -915,3 +915,4 @@ test('WarnDefaultedExceptionContext', normal, compile, ['-Wdefaulted-exception-c test('T24470b', normal, compile, ['']) test('T24566', [], makefile_test, []) test('T23764', normal, compile, ['']) +test('T23739a', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T23739b.hs ===================================== @@ -0,0 +1,14 @@ + +module T23739b where + +import Data.Tuple.Experimental +import GHC.TypeLits + +g1 :: Int -> Unit +g1 Int = () + +g2 :: Int +g2 = Int{} + +g3 :: Int +g3 = Int ===================================== testsuite/tests/typecheck/should_fail/T23739b.stderr ===================================== @@ -0,0 +1,21 @@ +T23739b.hs:8:4: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Int’ + • imported from ‘Prelude’ at T23739b.hs:2:8-14 + (and originally defined in ‘GHC.Types’) + • In the pattern: Int + In an equation for ‘g1’: g1 Int = () + +T23739b.hs:11:6: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Int’ + • imported from ‘Prelude’ at T23739b.hs:2:8-14 + (and originally defined in ‘GHC.Types’) + • In the expression: Int {} + In an equation for ‘g2’: g2 = Int {} + +T23739b.hs:14:6: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Int’ + • imported from ‘Prelude’ at T23739b.hs:2:8-14 + (and originally defined in ‘GHC.Types’) + • In the expression: Int + In an equation for ‘g3’: g3 = Int + ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -725,4 +725,4 @@ test('T17594g', normal, compile_fail, ['']) test('T24470a', normal, compile_fail, ['']) test('T24553', normal, compile_fail, ['']) - +test('T23739b', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/84c9b79b894bfdf27cf6ad8307dc1dfa3ea1b945 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/84c9b79b894bfdf27cf6ad8307dc1dfa3ea1b945 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 13:24:45 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Mon, 06 May 2024 09:24:45 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/az/T24771-datadecl-comments Message-ID: <6638da1da7759_17f48e762e9c5955@gitlab.mail> Alan Zimmerman pushed new branch wip/az/T24771-datadecl-comments at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/T24771-datadecl-comments You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 13:39:51 2024 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 06 May 2024 09:39:51 -0400 Subject: [Git][ghc/ghc][wip/T24334] 2 commits: Simplifier: Preserve OccInfo on DataAlt fields when case binder is dead (#24770) Message-ID: <6638dda77e075_17f48e99e580642f6@gitlab.mail> Sebastian Graf pushed to branch wip/T24334 at Glasgow Haskell Compiler / GHC Commits: 16d2ca25 by Sebastian Graf at 2024-05-06T15:39:38+02:00 Simplifier: Preserve OccInfo on DataAlt fields when case binder is dead (#24770) See the adjusted `Note [DataAlt occ info]`. This change also has a positive repercussion on `Note [Combine case alts: awkward corner]`. Fixes #24770. - - - - - 769878d5 by Sebastian Graf at 2024-05-06T15:39:38+02:00 Kill seqRule, discard dead seq# in Prep (#24334) Discarding seq#s in Core land via `seqRule` was problematic; see #24334. So instead we discard certain dead, discardable seq#s in Prep now. See the updated `Note [seq# magic]`. This fixes the symptoms of #24334. - - - - - 11 changed files: - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Types/Id/Make.hs - testsuite/tests/codeGen/should_compile/T24264.hs - + testsuite/tests/core-to-stg/T24334.hs - + testsuite/tests/core-to-stg/T24334.stdout - testsuite/tests/core-to-stg/all.T - + testsuite/tests/simplCore/should_compile/T24770.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/CSE.hs ===================================== @@ -9,12 +9,8 @@ module GHC.Core.Opt.CSE (cseProgram, cseOneExpr) where import GHC.Prelude import GHC.Core.Subst -import GHC.Types.Var ( Var ) import GHC.Types.Var.Env ( mkInScopeSet ) -import GHC.Types.Id ( Id, idType, idHasRules, zapStableUnfolding - , idInlineActivation, setInlineActivation - , zapIdOccInfo, zapIdUsageInfo, idInlinePragma - , isJoinId, idJoinPointHood, idUnfolding ) +import GHC.Types.Id import GHC.Core.Utils ( mkAltExpr , exprIsTickedString , stripTicksE, stripTicksT, mkTicks ) @@ -762,14 +758,13 @@ combineAlts alts where find_bndr_free_alt :: [CoreAlt] -> (Maybe CoreAlt, [CoreAlt]) - -- The (Just alt) is a binder-free alt - -- See Note [Combine case alts: awkward corner] + -- The (Just alt) is an alt where all fields are dead find_bndr_free_alt [] = (Nothing, []) find_bndr_free_alt (alt@(Alt _ bndrs _) : alts) - | null bndrs = (Just alt, alts) - | otherwise = case find_bndr_free_alt alts of - (mb_bf, alts) -> (mb_bf, alt:alts) + | all isDeadBinder bndrs = (Just alt, alts) + | otherwise = case find_bndr_free_alt alts of + (mb_bf, alts) -> (mb_bf, alt:alts) identical_alt rhs1 (Alt _ _ rhs) = eqCoreExpr rhs1 rhs -- Even if this alt has binders, they will have been cloned @@ -823,9 +818,9 @@ big for cheapEqExpr to catch it. Note [Combine case alts: awkward corner] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We would really like to check isDeadBinder on the binders in the -alternative. But alas, the simplifer zaps occ-info on binders in case -alternatives; see Note [Case alternative occ info] in GHC.Core.Opt.Simplify. +We check isDeadBinder on field binders in order to collapse into a DEFAULT alt. +But alas, the simplifer zaps occ-info on field binders in DataAlts when +the case binder is alive; see Note [DataAlt occ info] in GHC.Core.Opt.Simplify. * One alternative (perhaps a good one) would be to do OccAnal just before CSE. Then perhaps we could get rid of combineIdenticalAlts @@ -833,14 +828,12 @@ alternatives; see Note [Case alternative occ info] in GHC.Core.Opt.Simplify. * Another would be for CSE to return free vars as it goes. -* But the current solution is to find a nullary alternative (including - the DEFAULT alt, if any). This will not catch - case x of - A y -> blah - B z p -> blah - where no alternative is nullary or DEFAULT. But the current - solution is at least cheap. - +* But the current solution is to accept that we do not catch cases such as + case x of c + A _ -> blah[c] + B _ _ -> blah[c] + where the case binder c is alive and no alternative is DEFAULT. + But the current solution is at least cheap. ************************************************************************ * * ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -2067,21 +2067,18 @@ unsafeEqualityProofRule {- ********************************************************************* * * - Rules for seq# and spark# + Rules for spark# * * ********************************************************************* -} -seqRule :: RuleM CoreExpr -seqRule = do +-- spark# :: forall a s . a -> State# s -> (# State# s, a #) +sparkRule :: RuleM CoreExpr +sparkRule = do -- reduce on HNF [Type _ty_a, Type _ty_s, a, s] <- getArgs guard $ exprIsHNF a return $ mkCoreUnboxedTuple [s, a] - --- spark# :: forall a s . a -> State# s -> (# State# s, a #) -sparkRule :: RuleM CoreExpr -sparkRule = seqRule -- reduce on HNF, just the same - -- XXX perhaps we shouldn't do this, because a spark eliminated by - -- this rule won't be counted as a dud at runtime? + -- XXX perhaps we shouldn't do this, because a spark eliminated by + -- this rule won't be counted as a dud at runtime? {- ************************************************************************ @@ -2158,9 +2155,7 @@ builtinRules platform <- getPlatform return $ Var (primOpId IntAndOp) `App` arg `App` mkIntVal platform (d - 1) - ], - - mkBasicRule seqHashName 4 seqRule + ] ] ++ builtinBignumRules {-# NOINLINE builtinRules #-} ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -3234,13 +3234,12 @@ The point is that we bring into the envt a binding after the outer case, and that makes (a,b) alive. At least we do unless the case binder is guaranteed dead. -Note [Case alternative occ info] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -When we are simply reconstructing a case (the common case), we always -zap the occurrence info on the binders in the alternatives. Even -if the case binder is dead, the scrutinee is usually a variable, and *that* -can bring the case-alternative binders back to life. -See Note [Add unfolding for scrutinee] +Note [DataAlt occ info] +~~~~~~~~~~~~~~~~~~~~~~~ +It is in general possible that a DataAlt field binder comes back to life +through the case binder, as in Note [Add unfolding for scrutinee]. +Thus, when we are simply reconstructing a case (the common case), and the +case binder is not dead, we zap the occurrence info on DataAlt field binders. Note [Improving seq] ~~~~~~~~~~~~~~~~~~~ @@ -3397,7 +3396,8 @@ simplAlt env scrut' _ case_bndr' cont' (Alt (LitAlt lit) bndrs rhs) simplAlt env scrut' _ case_bndr' cont' (Alt (DataAlt con) vs rhs) = do { -- See Note [Adding evaluatedness info to pattern-bound variables] - let vs_with_evals = addEvals scrut' con vs + let vs_with_evals = zapIdOccInfoIfCaseBndrAlive case_bndr' $ + addEvals scrut' con vs ; (env', vs') <- simplBinders env vs_with_evals -- Bind the case-binder to (con args) @@ -3449,7 +3449,7 @@ addEvals scrut con vs -- a list of arguments only to throw it away immediately. , Just (Var f) <- stripNArgs 4 scr , f `hasKey` seqHashKey - , let x' = zapIdOccInfoAndSetEvald MarkedStrict x + , let x' = setCaseBndrEvald MarkedStrict x = [s, x'] -- Deal with banged datacon fields @@ -3459,7 +3459,7 @@ addEvals _scrut con vs = go vs the_strs go [] [] = [] go (v:vs') strs | isTyVar v = v : go vs' strs - go (v:vs') (str:strs) = zapIdOccInfoAndSetEvald str v : go vs' strs + go (v:vs') (str:strs) = setCaseBndrEvald str v : go vs' strs go _ _ = pprPanic "Simplify.addEvals" (ppr con $$ ppr vs $$ @@ -3473,11 +3473,12 @@ addEvals _scrut con vs = go vs the_strs strdisp MarkedStrict = text "MarkedStrict" strdisp NotMarkedStrict = text "NotMarkedStrict" -zapIdOccInfoAndSetEvald :: StrictnessMark -> Id -> Id -zapIdOccInfoAndSetEvald str v = - setCaseBndrEvald str $ -- Add eval'dness info - zapIdOccInfo v -- And kill occ info; - -- see Note [Case alternative occ info] +zapIdOccInfoIfCaseBndrAlive :: OutId -> [CoreBndr] -> [CoreBndr] +-- Kill occ info if case binder is alive; +-- see Note [DataAlt occ info] +zapIdOccInfoIfCaseBndrAlive case_bndr field_bndrs + | isDeadBinder case_bndr = field_bndrs + | otherwise = [ if isTyVar v then v else zapIdOccInfo v | v <- field_bndrs ] addDefaultUnfoldings :: SimplEnv -> Maybe OutExpr -> OutId -> [AltCon] -> SimplEnv addDefaultUnfoldings env mb_scrut case_bndr imposs_deflt_cons ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -890,6 +890,18 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con [covar] _]) floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } +cpeRhsE env (Case scrut bndr _ [Alt (DataAlt dc) [token_out, res] rhs]) + -- See item (SEQ4) of Note [seq# magic]. We want to match + -- case seq# @a @RealWorld s of (# s', _ #) -> rhs[s'] + -- and simplify to rhs[s]. Triggers in T15226. + | isUnboxedTupleDataCon dc + , (Var f,[_ty1, _ty2, value, Var token_in]) <- collectArgs scrut + , f `hasKey` seqHashKey + , exprOkToDiscard value + , Var token_in' <- lookupCorePrepEnv env token_in + , isDeadBinder res, isDeadBinder bndr -- check that bndr and res are dead + = cpeRhsE (extendCorePrepEnv env token_out token_in') rhs + cpeRhsE env (Case scrut bndr ty alts) = do { (floats, scrut') <- cpeBody env scrut ; (env', bndr2) <- cpCloneBndr env bndr ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -2295,9 +2295,16 @@ Things to note also we can attach an evaldUnfolding to x' to discard any subsequent evals such as the `case x' of __DEFAULT`. +(SEQ4) + T15226 demonstrates that we want to discard ok-for-discard seq#s. That is, + simplify `case seq# s of (# s', _ #) -> rhs[s']` to `rhs[s]`. + You might wonder whether the Simplifier could do this. But see the excellent + example in #24334 (immortalised as test T24334) for why it should be done in + CorePrep. + Implementing seq#. The compiler has magic for `seq#` in -- GHC.Core.Opt.ConstantFold.seqRule: eliminate (seq# s) +- GHC.CoreToStg.Prep.cpeRhsE: Implement (SEQ4). - Simplify.addEvals records evaluated-ness for the result (cf. (SEQ3)); see Note [Adding evaluatedness info to pattern-bound variables] ===================================== testsuite/tests/codeGen/should_compile/T24264.hs ===================================== @@ -24,12 +24,8 @@ fun3 :: a -> IO a {-# OPAQUE fun3 #-} fun3 x = do pure () - -- "evaluate $! x" - case x of !x' -> IO (noinline seq# x') - -- noinline to work around the bogus seqRule - -- This ideally also should not push a continuation to the stack - -- before entering 'x'. It currently does, but let's wait for - -- !11515 to land before worrying about that. + evaluate $! x + -- This should not push a continuation to the stack before entering 'x' funPair :: a -> IO (a, a) {-# OPAQUE funPair #-} ===================================== testsuite/tests/core-to-stg/T24334.hs ===================================== @@ -0,0 +1,20 @@ +import Control.Exception +import Data.IORef + +strictPrint :: Show a => a -> IO () +{-# OPAQUE strictPrint #-} +strictPrint x = print $! x + +f :: Show a => a -> IORef a -> IO () +{-# OPAQUE f #-} +f x r = do + x' <- evaluate $! x + writeIORef r x' + strictPrint x' + +main :: IO () +main = do + r <- newIORef (42 :: Int) + f (error "foo") r `catch` \(e :: SomeException) -> return () + n <- readIORef r + print n ===================================== testsuite/tests/core-to-stg/T24334.stdout ===================================== @@ -0,0 +1 @@ +42 ===================================== testsuite/tests/core-to-stg/all.T ===================================== @@ -5,4 +5,5 @@ test('T23270', [grep_errmsg(r'patError')], compile, ['-O0 -dsuppress-uniques -dd test('T23914', normal, compile, ['-O']) test('T14895', normal, compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-uniques']) test('T24124', normal, compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-uniques']) +test('T24334', normal, compile_and_run, ['-O']) test('T24463', normal, compile, ['-O']) ===================================== testsuite/tests/simplCore/should_compile/T24770.hs ===================================== @@ -0,0 +1,3 @@ +module T24770 where + +foo = getLine >> getLine ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -516,3 +516,4 @@ test('T24370', normal, compile, ['-O']) test('T24551', normal, compile, ['-O -dcore-lint']) test('T24726', normal, compile, ['-dcore-lint -dsuppress-uniques']) test('T24768', normal, compile, ['-O']) +test('T24770', [ grep_errmsg(r'Dead') ], compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3aca1d9eb7c157be7c3910067ce812a9fce4bf61...769878d597cb3ce789335efc350140a32859594e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3aca1d9eb7c157be7c3910067ce812a9fce4bf61...769878d597cb3ce789335efc350140a32859594e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 14:18:21 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Mon, 06 May 2024 10:18:21 -0400 Subject: [Git][ghc/ghc][wip/az/T24771-datadecl-comments] EPA: preserve comments in data decls Message-ID: <6638e6adbd544_17f48edc43a86854a@gitlab.mail> Alan Zimmerman pushed to branch wip/az/T24771-datadecl-comments at Glasgow Haskell Compiler / GHC Commits: a70c45ce by Alan Zimmerman at 2024-05-06T15:18:08+01:00 EPA: preserve comments in data decls Closes #24771 - - - - - 6 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - testsuite/tests/printer/Makefile - testsuite/tests/printer/Test24755.hs - + testsuite/tests/printer/Test24771.hs - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -2486,9 +2486,8 @@ forall :: { Located ([AddEpAnn], Maybe [LHsTyVarBndr Specificity GhcPs]) } | {- empty -} { noLoc ([], Nothing) } constr_stuff :: { Located (LocatedN RdrName, HsConDeclH98Details GhcPs) } - : infixtype {% fmap (reLoc. (fmap (\b -> (dataConBuilderCon b, - dataConBuilderDetails b)))) - (runPV $1) } + : infixtype {% do { b <- runPV $1 + ; return (sL1 b (dataConBuilderCon b, dataConBuilderDetails b)) }} | '(#' usum_constr '#)' {% let (t, tag, arity) = $2 in pure (sLL $1 $3 $ mkUnboxedSumCon t tag arity)} usum_constr :: { (LHsType GhcPs, Int, Int) } -- constructor for the data decls SumN# ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -236,7 +236,8 @@ mkTyData loc' is_type_data new_or_data cType (L _ (mcxt, tycl_hdr)) ; let anns' = annsIn Semi.<> ann ; data_cons <- checkNewOrData loc' (unLoc tc) is_type_data new_or_data data_cons ; defn <- mkDataDefn cType mcxt ksig data_cons maybe_deriv - ; let loc = EpAnn (spanAsAnchor loc') noAnn cs + ; !cs' <- getCommentsFor loc' + ; let loc = EpAnn (spanAsAnchor loc') noAnn (cs' Semi.<> cs) ; return (L loc (DataDecl { tcdDExt = anns', tcdLName = tc, tcdTyVars = tyvars, tcdFixity = fixity, @@ -2065,25 +2066,26 @@ instance DisambTD (HsType GhcPs) where return (L (addCommentsToEpAnn l cs) ty) mkUnpackednessPV = addUnpackednessP -dataConBuilderCon :: DataConBuilder -> LocatedN RdrName -dataConBuilderCon (PrefixDataConBuilder _ dc) = dc -dataConBuilderCon (InfixDataConBuilder _ dc _) = dc +dataConBuilderCon :: LocatedA DataConBuilder -> LocatedN RdrName +dataConBuilderCon (L _ (PrefixDataConBuilder _ dc)) = dc +dataConBuilderCon (L _ (InfixDataConBuilder _ dc _)) = dc -dataConBuilderDetails :: DataConBuilder -> HsConDeclH98Details GhcPs +dataConBuilderDetails :: LocatedA DataConBuilder -> HsConDeclH98Details GhcPs -- Detect when the record syntax is used: -- data T = MkT { ... } -dataConBuilderDetails (PrefixDataConBuilder flds _) +dataConBuilderDetails (L _ (PrefixDataConBuilder flds _)) | [L (EpAnn anc _ cs) (HsRecTy an fields)] <- toList flds = RecCon (L (EpAnn anc an cs) fields) -- Normal prefix constructor, e.g. data T = MkT A B C -dataConBuilderDetails (PrefixDataConBuilder flds _) +dataConBuilderDetails (L _ (PrefixDataConBuilder flds _)) = PrefixCon noTypeArgs (map hsLinear (toList flds)) -- Infix constructor, e.g. data T = Int :! Bool -dataConBuilderDetails (InfixDataConBuilder lhs _ rhs) - = InfixCon (hsLinear lhs) (hsLinear rhs) +dataConBuilderDetails (L (EpAnn _ _ csl) (InfixDataConBuilder (L (EpAnn anc ann csll) lhs) _ rhs)) + = InfixCon (hsLinear (L (EpAnn anc ann (csl Semi.<> csll)) lhs)) (hsLinear rhs) + instance DisambTD DataConBuilder where mkHsAppTyHeadPV = tyToDataConBuilder ===================================== testsuite/tests/printer/Makefile ===================================== @@ -866,3 +866,8 @@ Test24755: Test24753: $(CHECK_PPR) $(LIBDIR) Test24753.hs $(CHECK_EXACT) $(LIBDIR) Test24753.hs + +.PHONY: Test24771 +Test24771: + $(CHECK_PPR) $(LIBDIR) Test24771.hs + $(CHECK_EXACT) $(LIBDIR) Test24771.hs ===================================== testsuite/tests/printer/Test24755.hs ===================================== @@ -3,6 +3,6 @@ module Test24755 where class - a -- Before operator - :+ - b -- After operator + a -- c1 + :+ -- c2 + b -- c3 ===================================== testsuite/tests/printer/Test24771.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeOperators #-} +module Test24771 where + +data Foo + = Int -- c1 + :* -- c2 + String -- c3 ===================================== testsuite/tests/printer/all.T ===================================== @@ -206,3 +206,4 @@ test('Test24749', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24749']) test('Test24754', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24754']) test('Test24755', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24755']) test('Test24753', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24753']) +test('Test24771', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24771']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a70c45ce50c82795f90b29af1c86f4b6847ec40f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a70c45ce50c82795f90b29af1c86f4b6847ec40f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 14:25:41 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Mon, 06 May 2024 10:25:41 -0400 Subject: [Git][ghc/ghc][wip/no-mi-globals] Fix tests Message-ID: <6638e86520e93_17f48ef2f4f4692d7@gitlab.mail> Hannes Siebenhandl pushed to branch wip/no-mi-globals at Glasgow Haskell Compiler / GHC Commits: 17e88156 by Fendor at 2024-05-06T16:25:33+02:00 Fix tests - - - - - 1 changed file: - compiler/GHC/Rename/Names.hs Changes: ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -339,29 +339,31 @@ importSpec (L loc (ImportDecl { ideclName = loc_imp_mod_name rnImportDecl :: Module -> (LImportDecl GhcPs, SDoc) -> RnM (LImportDecl GhcRn, ImportUserSpec , GlobalRdrEnv, ImportAvails, AnyHpcUsage) rnImportDecl this_mod - ( ldecl@(L loc decl@(ImportDecl { ideclSafe = mod_safe - , ideclExt = XImportDeclPass { ideclImplicit = implicit }})) - , import_reason) + (L loc decl@(ImportDecl { ideclName = loc_imp_mod_name + , ideclPkgQual = raw_pkg_qual + , ideclSource = want_boot, ideclSafe = mod_safe + , ideclQualified = qual_style + , ideclExt = XImportDeclPass { ideclImplicit = implicit } + , ideclAs = as_mod, ideclImportList = imp_details }), import_reason) = setSrcSpanA loc $ do - (imp_spec,imp_details) <- importSpec ldecl - let pkg_qual = is_pkg_qual imp_spec - want_boot = is_isboot imp_spec - case pkg_qual of - NoPkgQual -> pure () - _ -> do + case raw_pkg_qual of + NoRawPkgQual -> pure () + RawPkgQual _ -> do pkg_imports <- xoptM LangExt.PackageImports when (not pkg_imports) $ addErr TcRnPackageImportsDisabled - let qual_only = is_qual imp_spec + let qual_only = isImportDeclQualified qual_style -- If there's an error in loadInterface, (e.g. interface -- file not found) we get lots of spurious errors from 'filterImports' - let imp_mod_name = moduleName $ is_mod imp_spec + let imp_mod_name = unLoc loc_imp_mod_name doc = ppr imp_mod_name <+> import_reason hsc_env <- getTopEnv + unit_env <- hsc_unit_env <$> getTopEnv + let pkg_qual = renameRawPkgQual unit_env imp_mod_name raw_pkg_qual -- Check for self-import, which confuses the typechecker (#9032) -- ghc --make rejects self-import cycles already, but batch-mode may not @@ -414,6 +416,12 @@ rnImportDecl this_mod when (mod_safe && not (safeImportsOn dflags)) $ addErr (TcRnSafeImportsDisabled imp_mod_name) + let imp_mod = mi_module iface + qual_mod_name = fmap unLoc as_mod `orElse` imp_mod_name + imp_spec = ImpDeclSpec { is_mod = imp_mod, is_qual = qual_only, + is_dloc = locA loc, is_as = qual_mod_name, + is_pkg_qual = pkg_qual, is_isboot = want_boot } + -- filter the imports according to the import declaration (new_imp_details, imp_user_list, gbl_env) <- filterImports hsc_env iface imp_spec imp_details View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/17e8815659bcf054661c63fc6521e66dbc4d4952 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/17e8815659bcf054661c63fc6521e66dbc4d4952 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 14:30:57 2024 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 06 May 2024 10:30:57 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24718 Message-ID: <6638e9a125c6d_17f48e11577cc7172d@gitlab.mail> Sebastian Graf pushed new branch wip/T24718 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24718 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 14:42:45 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Mon, 06 May 2024 10:42:45 -0400 Subject: [Git][ghc/ghc][wip/no-mi-globals] Fix tests Message-ID: <6638ec65da518_17f48e132df6075171@gitlab.mail> Hannes Siebenhandl pushed to branch wip/no-mi-globals at Glasgow Haskell Compiler / GHC Commits: c5d5361e by Fendor at 2024-05-06T16:42:35+02:00 Fix tests - - - - - 1 changed file: - compiler/GHC/Rename/Names.hs Changes: ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -300,25 +300,25 @@ Running generateModules from #14693 with DEPTH=16, WIDTH=30 finishes in -} -importSpec :: LImportDecl GhcPs -> RnM (ImpDeclSpec, Maybe (ImportListInterpretation, LocatedL [LIE GhcPs])) -importSpec (L loc (ImportDecl { ideclName = loc_imp_mod_name - , ideclPkgQual = raw_pkg_qual - , ideclSource = want_boot - , ideclQualified = qual_style - , ideclAs = as_mod, ideclImportList = imp_details })) - = do hsc_env <- getTopEnv - let unit_env = hsc_unit_env hsc_env - let imp_mod_name = unLoc loc_imp_mod_name - let pkg_qual = renameRawPkgQual unit_env imp_mod_name raw_pkg_qual - res <- liftIO $ findImportedModule hsc_env imp_mod_name pkg_qual - imp_mod <- case res of - Found _ mod -> pure mod - err -> failWithTc $ TcRnInterfaceError $ Can'tFindInterface (cannotFindModule hsc_env imp_mod_name err) $ LookingForModule imp_mod_name want_boot - let qual_only = isImportDeclQualified qual_style - qual_mod_name = fmap unLoc as_mod `orElse` imp_mod_name - imp_spec = ImpDeclSpec { is_mod = imp_mod, is_qual = qual_only, is_pkg_qual = pkg_qual, - is_dloc = locA loc, is_as = qual_mod_name, is_isboot = want_boot } - pure (imp_spec, imp_details) +-- importSpec :: LImportDecl GhcPs -> RnM (ImpDeclSpec, Maybe (ImportListInterpretation, LocatedL [LIE GhcPs])) +-- importSpec (L loc (ImportDecl { ideclName = loc_imp_mod_name +-- , ideclPkgQual = raw_pkg_qual +-- , ideclSource = want_boot +-- , ideclQualified = qual_style +-- , ideclAs = as_mod, ideclImportList = imp_details })) +-- = do hsc_env <- getTopEnv +-- let unit_env = hsc_unit_env hsc_env +-- let imp_mod_name = unLoc loc_imp_mod_name +-- let pkg_qual = renameRawPkgQual unit_env imp_mod_name raw_pkg_qual +-- res <- liftIO $ findImportedModule hsc_env imp_mod_name pkg_qual +-- imp_mod <- case res of +-- Found _ mod -> pure mod +-- err -> failWithTc $ TcRnInterfaceError $ Can'tFindInterface (cannotFindModule hsc_env imp_mod_name err) $ LookingForModule imp_mod_name want_boot +-- let qual_only = isImportDeclQualified qual_style +-- qual_mod_name = fmap unLoc as_mod `orElse` imp_mod_name +-- imp_spec = ImpDeclSpec { is_mod = imp_mod, is_qual = qual_only, is_pkg_qual = pkg_qual, +-- is_dloc = locA loc, is_as = qual_mod_name, is_isboot = want_boot } +-- pure (imp_spec, imp_details) -- | Given a located import declaration @decl@ from @this_mod@, @@ -339,29 +339,31 @@ importSpec (L loc (ImportDecl { ideclName = loc_imp_mod_name rnImportDecl :: Module -> (LImportDecl GhcPs, SDoc) -> RnM (LImportDecl GhcRn, ImportUserSpec , GlobalRdrEnv, ImportAvails, AnyHpcUsage) rnImportDecl this_mod - ( ldecl@(L loc decl@(ImportDecl { ideclSafe = mod_safe - , ideclExt = XImportDeclPass { ideclImplicit = implicit }})) - , import_reason) + (L loc decl@(ImportDecl { ideclName = loc_imp_mod_name + , ideclPkgQual = raw_pkg_qual + , ideclSource = want_boot, ideclSafe = mod_safe + , ideclQualified = qual_style + , ideclExt = XImportDeclPass { ideclImplicit = implicit } + , ideclAs = as_mod, ideclImportList = imp_details }), import_reason) = setSrcSpanA loc $ do - (imp_spec,imp_details) <- importSpec ldecl - let pkg_qual = is_pkg_qual imp_spec - want_boot = is_isboot imp_spec - case pkg_qual of - NoPkgQual -> pure () - _ -> do + case raw_pkg_qual of + NoRawPkgQual -> pure () + RawPkgQual _ -> do pkg_imports <- xoptM LangExt.PackageImports when (not pkg_imports) $ addErr TcRnPackageImportsDisabled - let qual_only = is_qual imp_spec + let qual_only = isImportDeclQualified qual_style -- If there's an error in loadInterface, (e.g. interface -- file not found) we get lots of spurious errors from 'filterImports' - let imp_mod_name = moduleName $ is_mod imp_spec + let imp_mod_name = unLoc loc_imp_mod_name doc = ppr imp_mod_name <+> import_reason hsc_env <- getTopEnv + unit_env <- hsc_unit_env <$> getTopEnv + let pkg_qual = renameRawPkgQual unit_env imp_mod_name raw_pkg_qual -- Check for self-import, which confuses the typechecker (#9032) -- ghc --make rejects self-import cycles already, but batch-mode may not @@ -414,6 +416,12 @@ rnImportDecl this_mod when (mod_safe && not (safeImportsOn dflags)) $ addErr (TcRnSafeImportsDisabled imp_mod_name) + let imp_mod = mi_module iface + qual_mod_name = fmap unLoc as_mod `orElse` imp_mod_name + imp_spec = ImpDeclSpec { is_mod = imp_mod, is_qual = qual_only, + is_dloc = locA loc, is_as = qual_mod_name, + is_pkg_qual = pkg_qual, is_isboot = want_boot } + -- filter the imports according to the import declaration (new_imp_details, imp_user_list, gbl_env) <- filterImports hsc_env iface imp_spec imp_details View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c5d5361e5283481750605f0eb6de949e7baaaabb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c5d5361e5283481750605f0eb6de949e7baaaabb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 14:45:56 2024 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 06 May 2024 10:45:56 -0400 Subject: [Git][ghc/ghc][wip/T24334] 2 commits: Simplifier: Preserve OccInfo on DataAlt fields when case binder is dead (#24770) Message-ID: <6638ed24a96a3_17f48e144af887727c@gitlab.mail> Sebastian Graf pushed to branch wip/T24334 at Glasgow Haskell Compiler / GHC Commits: 59d07d79 by Sebastian Graf at 2024-05-06T16:45:33+02:00 Simplifier: Preserve OccInfo on DataAlt fields when case binder is dead (#24770) See the adjusted `Note [DataAlt occ info]`. This change also has a positive repercussion on `Note [Combine case alts: awkward corner]`. Fixes #24770. - - - - - 14656b59 by Sebastian Graf at 2024-05-06T16:45:33+02:00 Kill seqRule, discard dead seq# in Prep (#24334) Discarding seq#s in Core land via `seqRule` was problematic; see #24334. So instead we discard certain dead, discardable seq#s in Prep now. See the updated `Note [seq# magic]`. This fixes the symptoms of #24334. - - - - - 11 changed files: - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Types/Id/Make.hs - testsuite/tests/codeGen/should_compile/T24264.hs - + testsuite/tests/core-to-stg/T24334.hs - + testsuite/tests/core-to-stg/T24334.stdout - testsuite/tests/core-to-stg/all.T - + testsuite/tests/simplCore/should_compile/T24770.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/CSE.hs ===================================== @@ -9,12 +9,8 @@ module GHC.Core.Opt.CSE (cseProgram, cseOneExpr) where import GHC.Prelude import GHC.Core.Subst -import GHC.Types.Var ( Var ) import GHC.Types.Var.Env ( mkInScopeSet ) -import GHC.Types.Id ( Id, idType, idHasRules, zapStableUnfolding - , idInlineActivation, setInlineActivation - , zapIdOccInfo, zapIdUsageInfo, idInlinePragma - , isJoinId, idJoinPointHood, idUnfolding ) +import GHC.Types.Id import GHC.Core.Utils ( mkAltExpr , exprIsTickedString , stripTicksE, stripTicksT, mkTicks ) @@ -754,7 +750,7 @@ combineAlts alts , Alt _ bndrs1 rhs1 <- alt1 , let filtered_alts = filterOut (identical_alt rhs1) rest_alts , not (equalLength rest_alts filtered_alts) - = assertPpr (null bndrs1) (ppr alts) $ + = assertPpr (all isDeadBinder bndrs1) (ppr alts) $ Alt DEFAULT [] rhs1 : filtered_alts | otherwise @@ -762,14 +758,13 @@ combineAlts alts where find_bndr_free_alt :: [CoreAlt] -> (Maybe CoreAlt, [CoreAlt]) - -- The (Just alt) is a binder-free alt - -- See Note [Combine case alts: awkward corner] + -- The (Just alt) is an alt where all fields are dead find_bndr_free_alt [] = (Nothing, []) find_bndr_free_alt (alt@(Alt _ bndrs _) : alts) - | null bndrs = (Just alt, alts) - | otherwise = case find_bndr_free_alt alts of - (mb_bf, alts) -> (mb_bf, alt:alts) + | all isDeadBinder bndrs = (Just alt, alts) + | otherwise = case find_bndr_free_alt alts of + (mb_bf, alts) -> (mb_bf, alt:alts) identical_alt rhs1 (Alt _ _ rhs) = eqCoreExpr rhs1 rhs -- Even if this alt has binders, they will have been cloned @@ -823,9 +818,9 @@ big for cheapEqExpr to catch it. Note [Combine case alts: awkward corner] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We would really like to check isDeadBinder on the binders in the -alternative. But alas, the simplifer zaps occ-info on binders in case -alternatives; see Note [Case alternative occ info] in GHC.Core.Opt.Simplify. +We check isDeadBinder on field binders in order to collapse into a DEFAULT alt. +But alas, the simplifer zaps occ-info on field binders in DataAlts when +the case binder is alive; see Note [DataAlt occ info] in GHC.Core.Opt.Simplify. * One alternative (perhaps a good one) would be to do OccAnal just before CSE. Then perhaps we could get rid of combineIdenticalAlts @@ -833,14 +828,12 @@ alternatives; see Note [Case alternative occ info] in GHC.Core.Opt.Simplify. * Another would be for CSE to return free vars as it goes. -* But the current solution is to find a nullary alternative (including - the DEFAULT alt, if any). This will not catch - case x of - A y -> blah - B z p -> blah - where no alternative is nullary or DEFAULT. But the current - solution is at least cheap. - +* But the current solution is to accept that we do not catch cases such as + case x of c + A _ -> blah[c] + B _ _ -> blah[c] + where the case binder c is alive and no alternative is DEFAULT. + But the current solution is at least cheap. ************************************************************************ * * ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -2067,21 +2067,18 @@ unsafeEqualityProofRule {- ********************************************************************* * * - Rules for seq# and spark# + Rules for spark# * * ********************************************************************* -} -seqRule :: RuleM CoreExpr -seqRule = do +-- spark# :: forall a s . a -> State# s -> (# State# s, a #) +sparkRule :: RuleM CoreExpr +sparkRule = do -- reduce on HNF [Type _ty_a, Type _ty_s, a, s] <- getArgs guard $ exprIsHNF a return $ mkCoreUnboxedTuple [s, a] - --- spark# :: forall a s . a -> State# s -> (# State# s, a #) -sparkRule :: RuleM CoreExpr -sparkRule = seqRule -- reduce on HNF, just the same - -- XXX perhaps we shouldn't do this, because a spark eliminated by - -- this rule won't be counted as a dud at runtime? + -- XXX perhaps we shouldn't do this, because a spark eliminated by + -- this rule won't be counted as a dud at runtime? {- ************************************************************************ @@ -2158,9 +2155,7 @@ builtinRules platform <- getPlatform return $ Var (primOpId IntAndOp) `App` arg `App` mkIntVal platform (d - 1) - ], - - mkBasicRule seqHashName 4 seqRule + ] ] ++ builtinBignumRules {-# NOINLINE builtinRules #-} ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -3234,13 +3234,28 @@ The point is that we bring into the envt a binding after the outer case, and that makes (a,b) alive. At least we do unless the case binder is guaranteed dead. -Note [Case alternative occ info] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -When we are simply reconstructing a case (the common case), we always -zap the occurrence info on the binders in the alternatives. Even -if the case binder is dead, the scrutinee is usually a variable, and *that* -can bring the case-alternative binders back to life. -See Note [Add unfolding for scrutinee] +Note [DataAlt occ info] +~~~~~~~~~~~~~~~~~~~~~~~ +It is in general possible that a DataAlt field binder comes back to life +through inlining of unfoldings, as in Note [Add unfolding for scrutinee]. +More concretely, + + 1. If the case binder is alive, its unfolding might bring back the field binder: + case blah of y { I# _ -> $wf (case y of I# v -> v) } + ==> + case blah of y { I# v -> $wf v } + 2. Even if the case binder appears to be dead, there is the scenario in + Note [Add unfolding for scrutinee], in which the fields come back alive + through a variable scrutinee and the reverse binder swap, as follows: + join j = case x of Just v -> blah v; Nothing -> ... in + case x of Just _ -> jump j; Nothing -> ... + ==> { inline j, unfold x to Just v, simplify } + join j = case x of Just v -> blah v; Nothing -> ... in + case x of Just v -> blah v; Nothing -> ... + +Thus, when we are simply reconstructing a case (the common case), and the +case binder is not dead or might be subject to the binder swap, we zap the +occurrence info on DataAlt field binders. Note [Improving seq] ~~~~~~~~~~~~~~~~~~~ @@ -3397,7 +3412,8 @@ simplAlt env scrut' _ case_bndr' cont' (Alt (LitAlt lit) bndrs rhs) simplAlt env scrut' _ case_bndr' cont' (Alt (DataAlt con) vs rhs) = do { -- See Note [Adding evaluatedness info to pattern-bound variables] - let vs_with_evals = addEvals scrut' con vs + let vs_with_evals = zapIdOccInfoIfCaseBndrAlive scrut' case_bndr' $ + addEvals scrut' con vs ; (env', vs') <- simplBinders env vs_with_evals -- Bind the case-binder to (con args) @@ -3449,7 +3465,7 @@ addEvals scrut con vs -- a list of arguments only to throw it away immediately. , Just (Var f) <- stripNArgs 4 scr , f `hasKey` seqHashKey - , let x' = zapIdOccInfoAndSetEvald MarkedStrict x + , let x' = setCaseBndrEvald MarkedStrict x = [s, x'] -- Deal with banged datacon fields @@ -3459,7 +3475,7 @@ addEvals _scrut con vs = go vs the_strs go [] [] = [] go (v:vs') strs | isTyVar v = v : go vs' strs - go (v:vs') (str:strs) = zapIdOccInfoAndSetEvald str v : go vs' strs + go (v:vs') (str:strs) = setCaseBndrEvald str v : go vs' strs go _ _ = pprPanic "Simplify.addEvals" (ppr con $$ ppr vs $$ @@ -3473,11 +3489,22 @@ addEvals _scrut con vs = go vs the_strs strdisp MarkedStrict = text "MarkedStrict" strdisp NotMarkedStrict = text "NotMarkedStrict" -zapIdOccInfoAndSetEvald :: StrictnessMark -> Id -> Id -zapIdOccInfoAndSetEvald str v = - setCaseBndrEvald str $ -- Add eval'dness info - zapIdOccInfo v -- And kill occ info; - -- see Note [Case alternative occ info] +zapIdOccInfoIfCaseBndrAlive :: Maybe CoreExpr -> OutId -> [CoreBndr] -> [CoreBndr] +-- Kill occ info if we do binder swap and the case binder is alive; +-- see Note [DataAlt occ info] +zapIdOccInfoIfCaseBndrAlive mb_scrut case_bndr field_bndrs + | not (isDeadBinder case_bndr) -- if the case binder is alive, + = zapped_field_bndrs -- the field binders might come back alive + + | Just scrut <- mb_scrut -- if binder swap takes place, + , Just _ <- scrutBinderSwap_maybe scrut -- the case binder might come back alive + = zapped_field_bndrs + + | otherwise + = field_bndrs -- otherwise the field binders stay dead + where + zapped_field_bndrs = + [ if isTyVar v then v else zapIdOccInfo v | v <- field_bndrs ] addDefaultUnfoldings :: SimplEnv -> Maybe OutExpr -> OutId -> [AltCon] -> SimplEnv addDefaultUnfoldings env mb_scrut case_bndr imposs_deflt_cons ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -890,6 +890,18 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con [covar] _]) floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } +cpeRhsE env (Case scrut bndr _ [Alt (DataAlt dc) [token_out, res] rhs]) + -- See item (SEQ4) of Note [seq# magic]. We want to match + -- case seq# @a @RealWorld s of (# s', _ #) -> rhs[s'] + -- and simplify to rhs[s]. Triggers in T15226. + | isUnboxedTupleDataCon dc + , (Var f,[_ty1, _ty2, value, Var token_in]) <- collectArgs scrut + , f `hasKey` seqHashKey + , exprOkToDiscard value + , Var token_in' <- lookupCorePrepEnv env token_in + , isDeadBinder res, isDeadBinder bndr -- check that bndr and res are dead + = cpeRhsE (extendCorePrepEnv env token_out token_in') rhs + cpeRhsE env (Case scrut bndr ty alts) = do { (floats, scrut') <- cpeBody env scrut ; (env', bndr2) <- cpCloneBndr env bndr ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -2295,9 +2295,16 @@ Things to note also we can attach an evaldUnfolding to x' to discard any subsequent evals such as the `case x' of __DEFAULT`. +(SEQ4) + T15226 demonstrates that we want to discard ok-for-discard seq#s. That is, + simplify `case seq# s of (# s', _ #) -> rhs[s']` to `rhs[s]`. + You might wonder whether the Simplifier could do this. But see the excellent + example in #24334 (immortalised as test T24334) for why it should be done in + CorePrep. + Implementing seq#. The compiler has magic for `seq#` in -- GHC.Core.Opt.ConstantFold.seqRule: eliminate (seq# s) +- GHC.CoreToStg.Prep.cpeRhsE: Implement (SEQ4). - Simplify.addEvals records evaluated-ness for the result (cf. (SEQ3)); see Note [Adding evaluatedness info to pattern-bound variables] ===================================== testsuite/tests/codeGen/should_compile/T24264.hs ===================================== @@ -24,12 +24,8 @@ fun3 :: a -> IO a {-# OPAQUE fun3 #-} fun3 x = do pure () - -- "evaluate $! x" - case x of !x' -> IO (noinline seq# x') - -- noinline to work around the bogus seqRule - -- This ideally also should not push a continuation to the stack - -- before entering 'x'. It currently does, but let's wait for - -- !11515 to land before worrying about that. + evaluate $! x + -- This should not push a continuation to the stack before entering 'x' funPair :: a -> IO (a, a) {-# OPAQUE funPair #-} ===================================== testsuite/tests/core-to-stg/T24334.hs ===================================== @@ -0,0 +1,20 @@ +import Control.Exception +import Data.IORef + +strictPrint :: Show a => a -> IO () +{-# OPAQUE strictPrint #-} +strictPrint x = print $! x + +f :: Show a => a -> IORef a -> IO () +{-# OPAQUE f #-} +f x r = do + x' <- evaluate $! x + writeIORef r x' + strictPrint x' + +main :: IO () +main = do + r <- newIORef (42 :: Int) + f (error "foo") r `catch` \(e :: SomeException) -> return () + n <- readIORef r + print n ===================================== testsuite/tests/core-to-stg/T24334.stdout ===================================== @@ -0,0 +1 @@ +42 ===================================== testsuite/tests/core-to-stg/all.T ===================================== @@ -5,4 +5,5 @@ test('T23270', [grep_errmsg(r'patError')], compile, ['-O0 -dsuppress-uniques -dd test('T23914', normal, compile, ['-O']) test('T14895', normal, compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-uniques']) test('T24124', normal, compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-uniques']) +test('T24334', normal, compile_and_run, ['-O']) test('T24463', normal, compile, ['-O']) ===================================== testsuite/tests/simplCore/should_compile/T24770.hs ===================================== @@ -0,0 +1,3 @@ +module T24770 where + +foo = getLine >> getLine ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -516,3 +516,4 @@ test('T24370', normal, compile, ['-O']) test('T24551', normal, compile, ['-O -dcore-lint']) test('T24726', normal, compile, ['-dcore-lint -dsuppress-uniques']) test('T24768', normal, compile, ['-O']) +test('T24770', [ grep_errmsg(r'Dead') ], compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/769878d597cb3ce789335efc350140a32859594e...14656b5948b1a423c177c14a0e4320d74b19170d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/769878d597cb3ce789335efc350140a32859594e...14656b5948b1a423c177c14a0e4320d74b19170d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 15:14:12 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Mon, 06 May 2024 11:14:12 -0400 Subject: [Git][ghc/ghc][wip/no-mi-globals] Fix tests Message-ID: <6638f3c4161ad_17f48e1808ea482885@gitlab.mail> Hannes Siebenhandl pushed to branch wip/no-mi-globals at Glasgow Haskell Compiler / GHC Commits: 0bdac551 by Fendor at 2024-05-06T17:14:02+02:00 Fix tests - - - - - 1 changed file: - compiler/GHC/Rename/Names.hs Changes: ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -50,8 +50,7 @@ import GHC.Tc.Types.LclEnv import GHC.Tc.Zonk.TcType ( tcInitTidyEnv ) import GHC.Hs -import GHC.Iface.Load ( loadSrcInterface, cannotFindModule ) -import GHC.Iface.Errors.Types +import GHC.Iface.Load ( loadSrcInterface ) import GHC.Iface.Syntax ( fromIfaceWarnings ) import GHC.Builtin.Names import GHC.Parser.PostProcess ( setRdrNameSpace ) @@ -110,8 +109,6 @@ import qualified Data.Set as S import System.FilePath (()) import System.IO -import GHC.Unit.Finder - {- ************************************************************************ * * @@ -300,25 +297,25 @@ Running generateModules from #14693 with DEPTH=16, WIDTH=30 finishes in -} -importSpec :: LImportDecl GhcPs -> RnM (ImpDeclSpec, Maybe (ImportListInterpretation, LocatedL [LIE GhcPs])) -importSpec (L loc (ImportDecl { ideclName = loc_imp_mod_name - , ideclPkgQual = raw_pkg_qual - , ideclSource = want_boot - , ideclQualified = qual_style - , ideclAs = as_mod, ideclImportList = imp_details })) - = do hsc_env <- getTopEnv - let unit_env = hsc_unit_env hsc_env - let imp_mod_name = unLoc loc_imp_mod_name - let pkg_qual = renameRawPkgQual unit_env imp_mod_name raw_pkg_qual - res <- liftIO $ findImportedModule hsc_env imp_mod_name pkg_qual - imp_mod <- case res of - Found _ mod -> pure mod - err -> failWithTc $ TcRnInterfaceError $ Can'tFindInterface (cannotFindModule hsc_env imp_mod_name err) $ LookingForModule imp_mod_name want_boot - let qual_only = isImportDeclQualified qual_style - qual_mod_name = fmap unLoc as_mod `orElse` imp_mod_name - imp_spec = ImpDeclSpec { is_mod = imp_mod, is_qual = qual_only, is_pkg_qual = pkg_qual, - is_dloc = locA loc, is_as = qual_mod_name, is_isboot = want_boot } - pure (imp_spec, imp_details) +-- importSpec :: LImportDecl GhcPs -> RnM (ImpDeclSpec, Maybe (ImportListInterpretation, LocatedL [LIE GhcPs])) +-- importSpec (L loc (ImportDecl { ideclName = loc_imp_mod_name +-- , ideclPkgQual = raw_pkg_qual +-- , ideclSource = want_boot +-- , ideclQualified = qual_style +-- , ideclAs = as_mod, ideclImportList = imp_details })) +-- = do hsc_env <- getTopEnv +-- let unit_env = hsc_unit_env hsc_env +-- let imp_mod_name = unLoc loc_imp_mod_name +-- let pkg_qual = renameRawPkgQual unit_env imp_mod_name raw_pkg_qual +-- res <- liftIO $ findImportedModule hsc_env imp_mod_name pkg_qual +-- imp_mod <- case res of +-- Found _ mod -> pure mod +-- err -> failWithTc $ TcRnInterfaceError $ Can'tFindInterface (cannotFindModule hsc_env imp_mod_name err) $ LookingForModule imp_mod_name want_boot +-- let qual_only = isImportDeclQualified qual_style +-- qual_mod_name = fmap unLoc as_mod `orElse` imp_mod_name +-- imp_spec = ImpDeclSpec { is_mod = imp_mod, is_qual = qual_only, is_pkg_qual = pkg_qual, +-- is_dloc = locA loc, is_as = qual_mod_name, is_isboot = want_boot } +-- pure (imp_spec, imp_details) -- | Given a located import declaration @decl@ from @this_mod@, @@ -339,29 +336,31 @@ importSpec (L loc (ImportDecl { ideclName = loc_imp_mod_name rnImportDecl :: Module -> (LImportDecl GhcPs, SDoc) -> RnM (LImportDecl GhcRn, ImportUserSpec , GlobalRdrEnv, ImportAvails, AnyHpcUsage) rnImportDecl this_mod - ( ldecl@(L loc decl@(ImportDecl { ideclSafe = mod_safe - , ideclExt = XImportDeclPass { ideclImplicit = implicit }})) - , import_reason) + (L loc decl@(ImportDecl { ideclName = loc_imp_mod_name + , ideclPkgQual = raw_pkg_qual + , ideclSource = want_boot, ideclSafe = mod_safe + , ideclQualified = qual_style + , ideclExt = XImportDeclPass { ideclImplicit = implicit } + , ideclAs = as_mod, ideclImportList = imp_details }), import_reason) = setSrcSpanA loc $ do - (imp_spec,imp_details) <- importSpec ldecl - let pkg_qual = is_pkg_qual imp_spec - want_boot = is_isboot imp_spec - case pkg_qual of - NoPkgQual -> pure () - _ -> do + case raw_pkg_qual of + NoRawPkgQual -> pure () + RawPkgQual _ -> do pkg_imports <- xoptM LangExt.PackageImports when (not pkg_imports) $ addErr TcRnPackageImportsDisabled - let qual_only = is_qual imp_spec + let qual_only = isImportDeclQualified qual_style -- If there's an error in loadInterface, (e.g. interface -- file not found) we get lots of spurious errors from 'filterImports' - let imp_mod_name = moduleName $ is_mod imp_spec + let imp_mod_name = unLoc loc_imp_mod_name doc = ppr imp_mod_name <+> import_reason hsc_env <- getTopEnv + unit_env <- hsc_unit_env <$> getTopEnv + let pkg_qual = renameRawPkgQual unit_env imp_mod_name raw_pkg_qual -- Check for self-import, which confuses the typechecker (#9032) -- ghc --make rejects self-import cycles already, but batch-mode may not @@ -414,6 +413,12 @@ rnImportDecl this_mod when (mod_safe && not (safeImportsOn dflags)) $ addErr (TcRnSafeImportsDisabled imp_mod_name) + let imp_mod = mi_module iface + qual_mod_name = fmap unLoc as_mod `orElse` imp_mod_name + imp_spec = ImpDeclSpec { is_mod = imp_mod, is_qual = qual_only, + is_dloc = locA loc, is_as = qual_mod_name, + is_pkg_qual = pkg_qual, is_isboot = want_boot } + -- filter the imports according to the import declaration (new_imp_details, imp_user_list, gbl_env) <- filterImports hsc_env iface imp_spec imp_details View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0bdac55166d607fb99b7835e0864d5f070c42c18 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0bdac55166d607fb99b7835e0864d5f070c42c18 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 15:22:54 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Mon, 06 May 2024 11:22:54 -0400 Subject: [Git][ghc/ghc][wip/fendor/ghc-iface-sharing-avoid-reserialisation] Avoid unneccessarily re-serialising the `ModIface` Message-ID: <6638f5ce8689e_17f48e19a2e5483577@gitlab.mail> Hannes Siebenhandl pushed to branch wip/fendor/ghc-iface-sharing-avoid-reserialisation at Glasgow Haskell Compiler / GHC Commits: fb7238c5 by Fendor at 2024-05-06T17:22:32+02:00 Avoid unneccessarily re-serialising the `ModIface` To reduce memory usage of `ModIface`, we serialise `ModIface` to an in-memory byte array, which implicitly shares duplicated values. This serailised byte array can be reused to avoid work when we actually write the `ModIface` to disk. We introduce a new field to `ModIface` which allows us to save the byte array, and write it to disk if the `ModIface` wasn't changed after the initial serialisation. This requires us to change absolute offsets, for example to jump to the deduplication table for `Name` or `FastString` with relative offsets, as the deduplication byte array doesn't contain header information, such as fingerprints. To allow us to dump the binary blob to disk, we need to replace all absolute offsets with relative ones. This leads to new primitives for `ModIface`, which help to construct relative offsets. - - - - - 15 changed files: - compiler/GHC.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Ext/Fields.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Unit/Module/ModIface.hs - compiler/GHC/Utils/Binary.hs - testsuite/tests/plugins/simple-plugin/Simple/RemovePlugin.hs - utils/haddock Changes: ===================================== compiler/GHC.hs ===================================== @@ -98,7 +98,32 @@ module GHC ( lookupGlobalName, findGlobalAnns, mkNamePprCtxForModule, - ModIface, ModIface_(..), + ModIface, + mi_module, + mi_sig_of, + mi_hsc_src, + mi_src_hash, + mi_hi_bytes, + mi_deps, + mi_usages, + mi_exports, + mi_used_th, + mi_fixities, + mi_warns, + mi_anns, + mi_insts, + mi_fam_insts, + mi_rules, + mi_decls, + mi_extra_decls, + mi_globals, + mi_hpc, + mi_trust, + mi_trust_pkg, + mi_complete_matches, + mi_docs, + mi_final_exts, + mi_ext_fields, SafeHaskellMode(..), -- * Printing ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -63,6 +63,8 @@ import Data.Map.Strict (Map) import Data.Word import System.IO.Unsafe import Data.Typeable (Typeable) +import qualified GHC.Data.Strict as Strict +import Data.Function ((&)) -- --------------------------------------------------------------------------- @@ -160,21 +162,24 @@ readBinIface profile name_cache checkHiWay traceBinIface hi_path = do mod_iface <- getIfaceWithExtFields name_cache bh - return mod_iface - { mi_src_hash = src_hash - } + return $ mod_iface + & addSourceFingerprint src_hash + getIfaceWithExtFields :: NameCache -> ReadBinHandle -> IO ModIface getIfaceWithExtFields name_cache bh = do - extFields_p <- get bh + start <- tellBinReader bh + extFields_p_rel <- getRelBin bh mod_iface <- getWithUserData name_cache bh - seekBinReader bh extFields_p + seekBinReader bh start + seekBinReaderRel bh extFields_p_rel extFields <- get bh - pure mod_iface - { mi_ext_fields = extFields - } + modIfaceData <- freezeBinHandle2 bh start + pure $ mod_iface + & set_mi_ext_fields extFields + & set_mi_hi_bytes (FullIfaceBinHandle $ Strict.Just modIfaceData) -- | This performs a get action after reading the dictionary and symbol @@ -204,7 +209,7 @@ getTables name_cache bh = do -- add it to the 'ReaderUserData' of 'ReadBinHandle'. decodeReaderTable :: Typeable a => ReaderTable a -> ReadBinHandle -> IO ReadBinHandle decodeReaderTable tbl bh0 = do - table <- Binary.forwardGet bh (getTable tbl bh0) + table <- Binary.forwardGetRel bh (getTable tbl bh0) let binaryReader = mkReaderFromTable tbl table pure $ addReaderToUserData binaryReader bh0 @@ -241,11 +246,18 @@ writeBinIface profile traceBinIface compressionLevel hi_path mod_iface = do -- And send the result to the file writeBinMem bh hi_path --- | Puts the 'ModIface' +-- | Puts the 'ModIface' to the 'WriteBinHandle'. +-- +-- This avoids serialisation of the 'ModIface' if the fields 'mi_hi_bytes' contains a +-- 'Just' value. This fields can only be populated by reading the 'ModIface' using +-- 'getIfaceWithExtFields' and not modifying it in any way afterwards. putIfaceWithExtFields :: TraceBinIFace -> CompressionIFace -> WriteBinHandle -> ModIface -> IO () putIfaceWithExtFields traceBinIface compressionLevel bh mod_iface = - forwardPut_ bh (\_ -> put_ bh (mi_ext_fields mod_iface)) $ do - putWithUserData traceBinIface compressionLevel bh mod_iface + case mi_hi_bytes mod_iface of + FullIfaceBinHandle Strict.Nothing -> do + forwardPutRel_ bh (\_ -> put_ bh (mi_ext_fields mod_iface)) $ do + putWithUserData traceBinIface compressionLevel bh mod_iface + FullIfaceBinHandle (Strict.Just binData) -> putFullBinData bh binData -- | Put a piece of data with an initialised `UserData` field. This -- is necessary if you want to serialise Names or FastStrings. @@ -316,7 +328,7 @@ putAllTables _ [] act = do a <- act pure ([], a) putAllTables bh (x : xs) act = do - (r, (res, a)) <- forwardPut bh (const $ putTable x bh) $ do + (r, (res, a)) <- forwardPutRel bh (const $ putTable x bh) $ do putAllTables bh xs act pure (r : res, a) @@ -468,7 +480,7 @@ to the table we need to deserialise first. What deduplication tables exist and the order of serialisation is currently statically specified in 'putWithTables'. 'putWithTables' also takes care of the serialisation of used deduplication tables. The deserialisation of the deduplication tables happens 'getTables', using 'Binary' utility -functions such as 'forwardGet'. +functions such as 'forwardGetRel'. Here, a visualisation of the table structure we currently have (ignoring 'ExtensibleFields'): @@ -529,7 +541,6 @@ initWriteIfaceType compressionLevel = do putGenericSymTab sym_tab bh ty _ -> putIfaceType bh ty - fullIfaceTypeSerialiser sym_tab bh ty = do put_ bh ifaceTypeSharedByte putGenericSymTab sym_tab bh ty ===================================== compiler/GHC/Iface/Ext/Binary.hs ===================================== @@ -235,7 +235,7 @@ readHieFileContents bh0 name_cache = do get bh1 where get_dictionary tbl bin_handle = do - fsTable <- Binary.forwardGet bin_handle (getTable tbl bin_handle) + fsTable <- Binary.forwardGetRel bin_handle (getTable tbl bin_handle) let fsReader = mkReaderFromTable tbl fsTable bhFs = addReaderToUserData fsReader bin_handle ===================================== compiler/GHC/Iface/Ext/Fields.hs ===================================== @@ -41,7 +41,7 @@ instance Binary ExtensibleFields where -- to point to the start of each payload: forM_ header_entries $ \(field_p_p, dat) -> do field_p <- tellBinWriter bh - putAt bh field_p_p field_p + putAtRel bh field_p_p field_p seekBinWriter bh field_p put_ bh dat @@ -50,11 +50,11 @@ instance Binary ExtensibleFields where -- Get the names and field pointers: header_entries <- replicateM n $ - (,) <$> get bh <*> get bh + (,) <$> get bh <*> getRelBin bh -- Seek to and get each field's payload: fields <- forM header_entries $ \(name, field_p) -> do - seekBinReader bh field_p + seekBinReaderRel bh field_p dat <- get bh return (name, dat) ===================================== compiler/GHC/Iface/Load.hs ===================================== @@ -117,6 +117,7 @@ import System.FilePath import System.Directory import GHC.Driver.Env.KnotVars import GHC.Iface.Errors.Types +import Data.Function ((&)) {- ************************************************************************ @@ -515,14 +516,12 @@ loadInterface doc_str mod from ; new_eps_anns <- tcIfaceAnnotations (mi_anns iface) ; new_eps_complete_matches <- tcIfaceCompleteMatches (mi_complete_matches iface) - ; let { final_iface = iface { - mi_decls = panic "No mi_decls in PIT", - mi_insts = panic "No mi_insts in PIT", - mi_fam_insts = panic "No mi_fam_insts in PIT", - mi_rules = panic "No mi_rules in PIT", - mi_anns = panic "No mi_anns in PIT" - } - } + ; let final_iface = iface + & set_mi_decls (panic "No mi_decls in PIT") + & set_mi_insts (panic "No mi_insts in PIT") + & set_mi_fam_insts (panic "No mi_fam_insts in PIT") + & set_mi_rules (panic "No mi_rules in PIT") + & set_mi_anns (panic "No mi_anns in PIT") ; let bad_boot = mi_boot iface == IsBoot && isJust (lookupKnotVars (if_rec_types gbl_env) mod) @@ -1017,13 +1016,13 @@ readIface dflags name_cache wanted_mod file_path = do -- See Note [GHC.Prim] in primops.txt.pp. ghcPrimIface :: ModIface ghcPrimIface - = empty_iface { - mi_exports = ghcPrimExports, - mi_decls = [], - mi_fixities = fixities, - mi_final_exts = (mi_final_exts empty_iface){ mi_fix_fn = mkIfaceFixCache fixities }, - mi_docs = Just ghcPrimDeclDocs -- See Note [GHC.Prim Docs] - } + = empty_iface + & set_mi_exports ghcPrimExports + & set_mi_decls [] + & set_mi_fixities fixities + & set_mi_final_exts ((mi_final_exts empty_iface){ mi_fix_fn = mkIfaceFixCache fixities }) + & set_mi_docs (Just ghcPrimDeclDocs) -- See Note [GHC.Prim Docs] + where empty_iface = emptyFullModIface gHC_PRIM @@ -1107,7 +1106,7 @@ pprModIfaceSimple unit_state iface = -- -- The UnitState is used to pretty-print units pprModIface :: UnitState -> ModIface -> SDoc -pprModIface unit_state iface at ModIface{ mi_final_exts = exts } +pprModIface unit_state iface = vcat [ text "interface" <+> ppr (mi_module iface) <+> pp_hsc_src (mi_hsc_src iface) <+> (if mi_orphan exts then text "[orphan module]" else Outputable.empty) @@ -1148,6 +1147,7 @@ pprModIface unit_state iface at ModIface{ mi_final_exts = exts } , text "extensible fields:" $$ nest 2 (pprExtensibleFields (mi_ext_fields iface)) ] where + exts = mi_final_exts iface pp_hsc_src HsBootFile = text "[boot]" pp_hsc_src HsigFile = text "[hsig]" pp_hsc_src HsSrcFile = Outputable.empty ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -144,7 +144,7 @@ mkFullIface hsc_env partial_iface mb_stg_infos mb_cmm_infos = do full_iface <- {-# SCC "addFingerprints" #-} - addFingerprints hsc_env partial_iface{ mi_decls = decls } + addFingerprints hsc_env (set_mi_decls decls partial_iface) -- Debug printing let unit_state = hsc_units hsc_env @@ -153,8 +153,24 @@ mkFullIface hsc_env partial_iface mb_stg_infos mb_cmm_infos = do final_iface <- shareIface (hsc_NC hsc_env) (flagsToIfCompression $ hsc_dflags hsc_env) full_iface return final_iface +-- | Compress an 'ModIface' and share as many values as possible, depending on the 'CompressionIFace' level. +-- See Note [Sharing of ModIface]. +-- +-- We compress the 'ModIface' by serialising the 'ModIface' to an in-memory byte array, and then deserialising it. +-- The deserialisation will deduplicate certain values depending on the 'CompressionIFace' level. +-- See Note [Deduplication during iface binary serialisation] for how we do that. +-- +-- Additionally, we cache the serialised byte array, so if the 'ModIface' is not modified +-- after calling 'shareIface', 'writeBinIface' will reuse that buffer without serialising the 'ModIface' again. +-- Modifying the 'ModIface' forces us to re-serialise it again. shareIface :: NameCache -> CompressionIFace -> ModIface -> IO ModIface -shareIface _ NormalCompression mi = pure mi +shareIface _ NormalCompression mi = do + -- In 'NormalCompression', the sharing isn't reducing the memory usage, as 'Name's and 'FastString's are + -- already shared, and at this compression level, we don't compress/share anything else. + -- Thus, for a brief moment we simply double the memory residency for no reason. + -- Therefore, we only try to share expensive values if the compression mode is higher than + -- 'NormalCompression' + pure mi shareIface nc compressionLevel mi = do bh <- openBinMem (1024 * 1024) start <- tellBinWriter bh @@ -162,10 +178,7 @@ shareIface nc compressionLevel mi = do rbh <- shrinkBinBuffer bh seekBinReader rbh start res <- getIfaceWithExtFields nc rbh - let resiface = res - { mi_src_hash = mi_src_hash mi - , mi_globals = mi_globals mi - } + let resiface = restoreFromOldModIface mi res forceModIface resiface return resiface @@ -322,40 +335,40 @@ mkIface_ hsc_env icomplete_matches = map mkIfaceCompleteMatch complete_matches !rdrs = maybeGlobalRdrEnv rdr_env - ModIface { - mi_module = this_mod, + emptyPartialModIface this_mod -- Need to record this because it depends on the -instantiated-with flag -- which could change - mi_sig_of = if semantic_mod == this_mod + & set_mi_sig_of ( if semantic_mod == this_mod then Nothing - else Just semantic_mod, - mi_hsc_src = hsc_src, - mi_deps = deps, - mi_usages = usages, - mi_exports = mkIfaceExports exports, + else Just semantic_mod) + & set_mi_hsc_src ( hsc_src) + & set_mi_deps ( deps) + & set_mi_usages ( usages) + & set_mi_exports ( mkIfaceExports exports) -- Sort these lexicographically, so that -- the result is stable across compilations - mi_insts = sortBy cmp_inst iface_insts, - mi_fam_insts = sortBy cmp_fam_inst iface_fam_insts, - mi_rules = sortBy cmp_rule iface_rules, - - mi_fixities = fixities, - mi_warns = warns, - mi_anns = annotations, - mi_globals = rdrs, - mi_used_th = used_th, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_hpc = isHpcUsed hpc_info, - mi_trust = trust_info, - mi_trust_pkg = pkg_trust_req, - mi_complete_matches = icomplete_matches, - mi_docs = docs, - mi_final_exts = (), - mi_ext_fields = emptyExtensibleFields, - mi_src_hash = ms_hs_hash mod_summary - } + & set_mi_insts ( sortBy cmp_inst iface_insts) + & set_mi_fam_insts ( sortBy cmp_fam_inst iface_fam_insts) + & set_mi_rules ( sortBy cmp_rule iface_rules) + + & set_mi_fixities ( fixities) + & set_mi_warns ( warns) + & set_mi_anns ( annotations) + & set_mi_globals ( rdrs) + & set_mi_used_th ( used_th) + & set_mi_decls ( decls) + & set_mi_extra_decls ( extra_decls) + & set_mi_hpc ( isHpcUsed hpc_info) + & set_mi_trust ( trust_info) + & set_mi_trust_pkg ( pkg_trust_req) + & set_mi_complete_matches ( icomplete_matches) + & set_mi_docs ( docs) + & set_mi_final_exts ( ()) + & set_mi_ext_fields ( emptyExtensibleFields) + & set_mi_src_hash ( ms_hs_hash mod_summary) + & set_mi_hi_bytes ( PartialIfaceBinHandle) + where cmp_rule = lexicalCompareFS `on` ifRuleName -- Compare these lexicographically by OccName, *not* by unique, @@ -522,3 +535,22 @@ That is, in Y, In the result of mkIfaceExports, the names are grouped by defining module, so we may need to split up a single Avail into multiple ones. -} + +{- +Note [Sharing of ModIface] +~~~~~~~~~~~~~~~~~~~~~~~~~~ +A 'ModIface' contains many duplicated values such as 'Name', 'FastString' and 'IfaceType'. +'Name's and 'FastString's are already deduplicated by default using the 'NameCache' and +'FastStringTable' respectively. +However, 'IfaceType' can be quite expensive in terms of memory usage. +To improve the sharing of 'IfaceType', we introduced deduplication tables during +serialisation of 'ModIface', see Note [Deduplication during iface binary serialisation]. + +We can improve the sharing of 'ModIface' at run-time as well, by serialising the 'ModIface' to +an in-memory buffer, and then deserialising it again. +This implicitly shares duplicated values. + +To avoid re-serialising the 'ModIface' when writing it to disk, we save the serialised 'ModIface' buffer +in 'mi_hi_bytes_' field of said 'ModIface'. This buffer is written to disk directly in 'putIfaceWithExtFields'. +If we have to modify the 'ModIface' after 'shareIface' is called, the buffer needs to be discarded. +-} ===================================== compiler/GHC/Iface/Recomp.hs ===================================== @@ -83,6 +83,7 @@ import Data.Ord import Data.Containers.ListUtils import Data.Bifunctor import GHC.Iface.Errors.Ppr +import qualified GHC.Data.Strict as Strict {- ----------------------------------------------- @@ -1283,7 +1284,9 @@ addFingerprints hsc_env iface0 , mi_fix_fn = fix_fn , mi_hash_fn = lookupOccEnv local_env } - final_iface = iface0 { mi_decls = sorted_decls, mi_extra_decls = sorted_extra_decls, mi_final_exts = final_iface_exts } + final_iface = completePartialModIface iface0 + (sorted_decls) (sorted_extra_decls) (final_iface_exts) + (FullIfaceBinHandle Strict.Nothing) -- return final_iface ===================================== compiler/GHC/Iface/Rename.hs ===================================== @@ -44,6 +44,7 @@ import GHC.Utils.Panic import qualified Data.Traversable as T import Data.IORef +import Data.Function ((&)) tcRnMsgMaybe :: IO (Either (Messages TcRnMessage) a) -> TcM a tcRnMsgMaybe do_this = do @@ -108,13 +109,14 @@ rnModIface hsc_env insts nsubst iface = deps <- rnDependencies (mi_deps iface) -- TODO: -- mi_rules - return iface { mi_module = mod - , mi_sig_of = sig_of - , mi_insts = insts - , mi_fam_insts = fams - , mi_exports = exports - , mi_decls = decls - , mi_deps = deps } + return $ iface + & set_mi_module mod + & set_mi_sig_of sig_of + & set_mi_insts insts + & set_mi_fam_insts fams + & set_mi_exports exports + & set_mi_decls decls + & set_mi_deps deps -- | Rename just the exports of a 'ModIface'. Useful when we're doing -- shaping prior to signature merging. ===================================== compiler/GHC/Tc/Errors/Hole.hs ===================================== @@ -76,7 +76,7 @@ import GHC.Tc.Utils.Unify ( tcSubTypeSigma ) import GHC.HsToCore.Docs ( extractDocs ) import GHC.Hs.Doc -import GHC.Unit.Module.ModIface ( ModIface_(..) ) +import GHC.Unit.Module.ModIface ( mi_docs ) import GHC.Iface.Load ( loadInterfaceForName ) import GHC.Builtin.Utils (knownKeyNames) ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -1562,7 +1562,8 @@ lookupDeclDoc nm = do -- Wasn't in the current module. Try searching other external ones! mIface <- getExternalModIface nm case mIface of - Just ModIface { mi_docs = Just Docs{docs_decls = dmap} } -> + Just iface + | Just Docs{docs_decls = dmap} <- mi_docs iface -> pure $ renderHsDocStrings . map hsDocString <$> lookupUniqMap dmap nm _ -> pure Nothing @@ -1578,7 +1579,8 @@ lookupArgDoc i nm = do Nothing -> do mIface <- getExternalModIface nm case mIface of - Just ModIface { mi_docs = Just Docs{docs_args = amap} } -> + Just iface + | Just Docs{docs_args = amap} <- mi_docs iface-> pure $ renderHsDocString . hsDocString <$> (lookupUniqMap amap nm >>= IntMap.lookup i) _ -> pure Nothing ===================================== compiler/GHC/Tc/Utils/Backpack.hs ===================================== @@ -87,6 +87,7 @@ import Control.Monad import Data.List (find) import GHC.Iface.Errors.Types +import Data.Function ((&)) checkHsigDeclM :: ModIface -> TyThing -> TyThing -> TcRn () checkHsigDeclM sig_iface sig_thing real_thing = do @@ -369,8 +370,8 @@ tcRnMergeSignatures hsc_env hpm orig_tcg_env iface = thinModIface :: [AvailInfo] -> ModIface -> ModIface thinModIface avails iface = - iface { - mi_exports = avails, + iface + & set_mi_exports avails -- mi_fixities = ..., -- mi_warns = ..., -- mi_anns = ..., @@ -378,10 +379,9 @@ thinModIface avails iface = -- perhaps there might be two IfaceTopBndr that are the same -- OccName but different Name. Requires better understanding -- of invariants here. - mi_decls = exported_decls ++ non_exported_decls ++ dfun_decls + & set_mi_decls (exported_decls ++ non_exported_decls ++ dfun_decls) -- mi_insts = ..., -- mi_fam_insts = ..., - } where decl_pred occs decl = nameOccName (ifName decl) `elemOccSet` occs filter_decls occs = filter (decl_pred occs . snd) (mi_decls iface) ===================================== compiler/GHC/Unit/Module/ModIface.hs ===================================== @@ -7,7 +7,61 @@ module GHC.Unit.Module.ModIface ( ModIface - , ModIface_ (..) + , ModIface_ + , restoreFromOldModIface + , addSourceFingerprint + , mi_module + , mi_sig_of + , mi_hsc_src + , mi_src_hash + , mi_hi_bytes + , mi_deps + , mi_usages + , mi_exports + , mi_used_th + , mi_fixities + , mi_warns + , mi_anns + , mi_insts + , mi_fam_insts + , mi_rules + , mi_decls + , mi_extra_decls + , mi_globals + , mi_hpc + , mi_trust + , mi_trust_pkg + , mi_complete_matches + , mi_docs + , mi_final_exts + , mi_ext_fields + , set_mi_module + , set_mi_sig_of + , set_mi_hsc_src + , set_mi_src_hash + , set_mi_hi_bytes + , set_mi_deps + , set_mi_usages + , set_mi_exports + , set_mi_used_th + , set_mi_fixities + , set_mi_warns + , set_mi_anns + , set_mi_insts + , set_mi_fam_insts + , set_mi_rules + , set_mi_decls + , set_mi_extra_decls + , set_mi_globals + , set_mi_hpc + , set_mi_trust + , set_mi_trust_pkg + , set_mi_complete_matches + , set_mi_docs + , set_mi_final_exts + , set_mi_ext_fields + , completePartialModIface + , IfaceBinHandle(..) , PartialModIface , ModIfaceBackend (..) , IfaceDeclExts @@ -58,6 +112,7 @@ import GHC.Utils.Binary import Control.DeepSeq import Control.Exception +import qualified GHC.Data.Strict as Strict {- Note [Interface file stages] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -139,7 +194,9 @@ type family IfaceBackendExts (phase :: ModIfacePhase) = bk | bk -> phase where IfaceBackendExts 'ModIfaceCore = () IfaceBackendExts 'ModIfaceFinal = ModIfaceBackend - +data IfaceBinHandle (phase :: ModIfacePhase) where + PartialIfaceBinHandle :: IfaceBinHandle 'ModIfaceCore + FullIfaceBinHandle :: Strict.Maybe FullBinData -> IfaceBinHandle 'ModIfaceFinal -- | A 'ModIface' plus a 'ModDetails' summarises everything we know -- about a compiled module. The 'ModIface' is the stuff *before* linking, @@ -155,60 +212,60 @@ type family IfaceBackendExts (phase :: ModIfacePhase) = bk | bk -> phase where -- strict and others are not. data ModIface_ (phase :: ModIfacePhase) = ModIface { - mi_module :: !Module, -- ^ Name of the module we are for - mi_sig_of :: !(Maybe Module), -- ^ Are we a sig of another mod? + mi_module_ :: !Module, -- ^ Name of the module we are for + mi_sig_of_ :: !(Maybe Module), -- ^ Are we a sig of another mod? - mi_hsc_src :: !HscSource, -- ^ Boot? Signature? + mi_hsc_src_ :: !HscSource, -- ^ Boot? Signature? - mi_deps :: Dependencies, + mi_deps_ :: Dependencies, -- ^ The dependencies of the module. This is -- consulted for directly-imported modules, but not -- for anything else (hence lazy) - mi_usages :: [Usage], + mi_usages_ :: [Usage], -- ^ Usages; kept sorted so that it's easy to decide -- whether to write a new iface file (changing usages -- doesn't affect the hash of this module) -- NOT STRICT! we read this field lazily from the interface file -- It is *only* consulted by the recompilation checker - mi_exports :: ![IfaceExport], + mi_exports_ :: ![IfaceExport], -- ^ Exports -- Kept sorted by (mod,occ), to make version comparisons easier -- Records the modules that are the declaration points for things -- exported by this module, and the 'OccName's of those things - mi_used_th :: !Bool, + mi_used_th_ :: !Bool, -- ^ Module required TH splices when it was compiled. -- This disables recompilation avoidance (see #481). - mi_fixities :: [(OccName,Fixity)], + mi_fixities_ :: [(OccName,Fixity)], -- ^ Fixities -- NOT STRICT! we read this field lazily from the interface file - mi_warns :: IfaceWarnings, + mi_warns_ :: IfaceWarnings, -- ^ Warnings -- NOT STRICT! we read this field lazily from the interface file - mi_anns :: [IfaceAnnotation], + mi_anns_ :: [IfaceAnnotation], -- ^ Annotations -- NOT STRICT! we read this field lazily from the interface file - mi_decls :: [IfaceDeclExts phase], + mi_decls_ :: [IfaceDeclExts phase], -- ^ Type, class and variable declarations -- The hash of an Id changes if its fixity or deprecations change -- (as well as its type of course) -- Ditto data constructors, class operations, except that -- the hash of the parent class/tycon changes - mi_extra_decls :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo], + mi_extra_decls_ :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo], -- ^ Extra variable definitions which are **NOT** exposed but when -- combined with mi_decls allows us to restart code generation. -- See Note [Interface Files with Core Definitions] and Note [Interface File with Core: Sharing RHSs] - mi_globals :: !(Maybe IfGlobalRdrEnv), + mi_globals_ :: !(Maybe IfGlobalRdrEnv), -- ^ Binds all the things defined at the top level in -- the /original source/ code for this module. which -- is NOT the same as mi_exports, nor mi_decls (which @@ -224,36 +281,36 @@ data ModIface_ (phase :: ModIfacePhase) -- 'HomeModInfo', but that leads to more plumbing. -- Instance declarations and rules - mi_insts :: [IfaceClsInst], -- ^ Sorted class instance - mi_fam_insts :: [IfaceFamInst], -- ^ Sorted family instances - mi_rules :: [IfaceRule], -- ^ Sorted rules + mi_insts_ :: [IfaceClsInst], -- ^ Sorted class instance + mi_fam_insts_ :: [IfaceFamInst], -- ^ Sorted family instances + mi_rules_ :: [IfaceRule], -- ^ Sorted rules - mi_hpc :: !AnyHpcUsage, + mi_hpc_ :: !AnyHpcUsage, -- ^ True if this program uses Hpc at any point in the program. - mi_trust :: !IfaceTrustInfo, + mi_trust_ :: !IfaceTrustInfo, -- ^ Safe Haskell Trust information for this module. - mi_trust_pkg :: !Bool, + mi_trust_pkg_ :: !Bool, -- ^ Do we require the package this module resides in be trusted -- to trust this module? This is used for the situation where a -- module is Safe (so doesn't require the package be trusted -- itself) but imports some trustworthy modules from its own -- package (which does require its own package be trusted). -- See Note [Trust Own Package] in GHC.Rename.Names - mi_complete_matches :: ![IfaceCompleteMatch], + mi_complete_matches_ :: ![IfaceCompleteMatch], - mi_docs :: !(Maybe Docs), + mi_docs_ :: !(Maybe Docs), -- ^ Docstrings and related data for use by haddock, the ghci -- @:doc@ command, and other tools. -- -- @Just _@ @<=>@ the module was built with @-haddock at . - mi_final_exts :: !(IfaceBackendExts phase), + mi_final_exts_ :: !(IfaceBackendExts phase), -- ^ Either `()` or `ModIfaceBackend` for -- a fully instantiated interface. - mi_ext_fields :: !ExtensibleFields, + mi_ext_fields_ :: !ExtensibleFields, -- ^ Additional optional fields, where the Map key represents -- the field name, resulting in a (size, serialized data) pair. -- Because the data is intended to be serialized through the @@ -262,8 +319,13 @@ data ModIface_ (phase :: ModIfacePhase) -- chosen over `ByteString`s. -- - mi_src_hash :: !Fingerprint + mi_src_hash_ :: !Fingerprint, -- ^ Hash of the .hs source, used for recompilation checking. + mi_hi_bytes_ :: !(IfaceBinHandle phase) + -- ^ A serialised in-memory buffer of this 'ModIface'. + -- If this handle is given, we can avoid serialising the 'ModIface' + -- when writing this 'ModIface' to disk, and write this buffer to disk instead. + -- See Note [Sharing of ModIface]. } {- @@ -343,33 +405,34 @@ renameFreeHoles fhs insts = -- See Note [Strictness in ModIface] about where we use lazyPut vs put instance Binary ModIface where put_ bh (ModIface { - mi_module = mod, - mi_sig_of = sig_of, - mi_hsc_src = hsc_src, - mi_src_hash = _src_hash, -- Don't `put_` this in the instance + mi_module_ = mod, + mi_sig_of_ = sig_of, + mi_hsc_src_ = hsc_src, + mi_src_hash_ = _src_hash, -- Don't `put_` this in the instance -- because we are going to write it -- out separately in the actual file - mi_deps = deps, - mi_usages = usages, - mi_exports = exports, - mi_used_th = used_th, - mi_fixities = fixities, - mi_warns = warns, - mi_anns = anns, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_insts = insts, - mi_fam_insts = fam_insts, - mi_rules = rules, - mi_hpc = hpc_info, - mi_trust = trust, - mi_trust_pkg = trust_pkg, - mi_complete_matches = complete_matches, - mi_docs = docs, - mi_ext_fields = _ext_fields, -- Don't `put_` this in the instance so we + mi_hi_bytes_ = _hi_bytes, -- TODO: explain + mi_deps_ = deps, + mi_usages_ = usages, + mi_exports_ = exports, + mi_used_th_ = used_th, + mi_fixities_ = fixities, + mi_warns_ = warns, + mi_anns_ = anns, + mi_decls_ = decls, + mi_extra_decls_ = extra_decls, + mi_insts_ = insts, + mi_fam_insts_ = fam_insts, + mi_rules_ = rules, + mi_hpc_ = hpc_info, + mi_trust_ = trust, + mi_trust_pkg_ = trust_pkg, + mi_complete_matches_ = complete_matches, + mi_docs_ = docs, + mi_ext_fields_ = _ext_fields, -- Don't `put_` this in the instance so we -- can deal with it's pointer in the header -- when we write the actual file - mi_final_exts = ModIfaceBackend { + mi_final_exts_ = ModIfaceBackend { mi_iface_hash = iface_hash, mi_mod_hash = mod_hash, mi_flag_hash = flag_hash, @@ -444,33 +507,34 @@ instance Binary ModIface where complete_matches <- get bh docs <- lazyGetMaybe bh return (ModIface { - mi_module = mod, - mi_sig_of = sig_of, - mi_hsc_src = hsc_src, - mi_src_hash = fingerprint0, -- placeholder because this is dealt + mi_module_ = mod, + mi_sig_of_ = sig_of, + mi_hsc_src_ = hsc_src, + mi_src_hash_ = fingerprint0, -- placeholder because this is dealt -- with specially when the file is read - mi_deps = deps, - mi_usages = usages, - mi_exports = exports, - mi_used_th = used_th, - mi_anns = anns, - mi_fixities = fixities, - mi_warns = warns, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_globals = Nothing, - mi_insts = insts, - mi_fam_insts = fam_insts, - mi_rules = rules, - mi_hpc = hpc_info, - mi_trust = trust, - mi_trust_pkg = trust_pkg, + mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing, + mi_deps_ = deps, + mi_usages_ = usages, + mi_exports_ = exports, + mi_used_th_ = used_th, + mi_anns_ = anns, + mi_fixities_ = fixities, + mi_warns_ = warns, + mi_decls_ = decls, + mi_extra_decls_ = extra_decls, + mi_globals_ = Nothing, + mi_insts_ = insts, + mi_fam_insts_ = fam_insts, + mi_rules_ = rules, + mi_hpc_ = hpc_info, + mi_trust_ = trust, + mi_trust_pkg_ = trust_pkg, -- And build the cached values - mi_complete_matches = complete_matches, - mi_docs = docs, - mi_ext_fields = emptyExtensibleFields, -- placeholder because this is dealt + mi_complete_matches_ = complete_matches, + mi_docs_ = docs, + mi_ext_fields_ = emptyExtensibleFields, -- placeholder because this is dealt -- with specially when the file is read - mi_final_exts = ModIfaceBackend { + mi_final_exts_ = ModIfaceBackend { mi_iface_hash = iface_hash, mi_mod_hash = mod_hash, mi_flag_hash = flag_hash, @@ -487,42 +551,45 @@ instance Binary ModIface where mi_hash_fn = mkIfaceHashCache decls }}) + -- | The original names declared of a certain module that are exported type IfaceExport = AvailInfo emptyPartialModIface :: Module -> PartialModIface emptyPartialModIface mod - = ModIface { mi_module = mod, - mi_sig_of = Nothing, - mi_hsc_src = HsSrcFile, - mi_src_hash = fingerprint0, - mi_deps = noDependencies, - mi_usages = [], - mi_exports = [], - mi_used_th = False, - mi_fixities = [], - mi_warns = IfWarnSome [] [], - mi_anns = [], - mi_insts = [], - mi_fam_insts = [], - mi_rules = [], - mi_decls = [], - mi_extra_decls = Nothing, - mi_globals = Nothing, - mi_hpc = False, - mi_trust = noIfaceTrustInfo, - mi_trust_pkg = False, - mi_complete_matches = [], - mi_docs = Nothing, - mi_final_exts = (), - mi_ext_fields = emptyExtensibleFields + = ModIface { mi_module_ = mod, + mi_sig_of_ = Nothing, + mi_hsc_src_ = HsSrcFile, + mi_src_hash_ = fingerprint0, + mi_hi_bytes_ = PartialIfaceBinHandle, + mi_deps_ = noDependencies, + mi_usages_ = [], + mi_exports_ = [], + mi_used_th_ = False, + mi_fixities_ = [], + mi_warns_ = IfWarnSome [] [], + mi_anns_ = [], + mi_insts_ = [], + mi_fam_insts_ = [], + mi_rules_ = [], + mi_decls_ = [], + mi_extra_decls_ = Nothing, + mi_globals_ = Nothing, + mi_hpc_ = False, + mi_trust_ = noIfaceTrustInfo, + mi_trust_pkg_ = False, + mi_complete_matches_ = [], + mi_docs_ = Nothing, + mi_final_exts_ = (), + mi_ext_fields_ = emptyExtensibleFields } emptyFullModIface :: Module -> ModIface emptyFullModIface mod = (emptyPartialModIface mod) - { mi_decls = [] - , mi_final_exts = ModIfaceBackend + { mi_decls_ = [] + , mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing + , mi_final_exts_ = ModIfaceBackend { mi_iface_hash = fingerprint0, mi_mod_hash = fingerprint0, mi_flag_hash = fingerprint0, @@ -557,36 +624,36 @@ emptyIfaceHashCache _occ = Nothing instance ( NFData (IfaceBackendExts (phase :: ModIfacePhase)) , NFData (IfaceDeclExts (phase :: ModIfacePhase)) ) => NFData (ModIface_ phase) where - rnf (ModIface{ mi_module, mi_sig_of, mi_hsc_src, mi_deps, mi_usages - , mi_exports, mi_used_th, mi_fixities, mi_warns, mi_anns - , mi_decls, mi_extra_decls, mi_globals, mi_insts - , mi_fam_insts, mi_rules, mi_hpc, mi_trust, mi_trust_pkg - , mi_complete_matches, mi_docs, mi_final_exts - , mi_ext_fields, mi_src_hash }) - = rnf mi_module - `seq` rnf mi_sig_of - `seq` mi_hsc_src - `seq` mi_deps - `seq` mi_usages - `seq` mi_exports - `seq` rnf mi_used_th - `seq` mi_fixities - `seq` rnf mi_warns - `seq` rnf mi_anns - `seq` rnf mi_decls - `seq` rnf mi_extra_decls - `seq` rnf mi_globals - `seq` rnf mi_insts - `seq` rnf mi_fam_insts - `seq` rnf mi_rules - `seq` rnf mi_hpc - `seq` mi_trust - `seq` rnf mi_trust_pkg - `seq` rnf mi_complete_matches - `seq` rnf mi_docs - `seq` mi_final_exts - `seq` mi_ext_fields - `seq` rnf mi_src_hash + rnf (ModIface{ mi_module_, mi_sig_of_, mi_hsc_src_, mi_deps_, mi_usages_ + , mi_exports_, mi_used_th_, mi_fixities_, mi_warns_, mi_anns_ + , mi_decls_, mi_extra_decls_, mi_globals_, mi_insts_ + , mi_fam_insts_, mi_rules_, mi_hpc_, mi_trust_, mi_trust_pkg_ + , mi_complete_matches_, mi_docs_, mi_final_exts_ + , mi_ext_fields_, mi_src_hash_ }) + = rnf mi_module_ + `seq` rnf mi_sig_of_ + `seq` mi_hsc_src_ + `seq` mi_deps_ + `seq` mi_usages_ + `seq` mi_exports_ + `seq` rnf mi_used_th_ + `seq` mi_fixities_ + `seq` rnf mi_warns_ + `seq` rnf mi_anns_ + `seq` rnf mi_decls_ + `seq` rnf mi_extra_decls_ + `seq` rnf mi_globals_ + `seq` rnf mi_insts_ + `seq` rnf mi_fam_insts_ + `seq` rnf mi_rules_ + `seq` rnf mi_hpc_ + `seq` mi_trust_ + `seq` rnf mi_trust_pkg_ + `seq` rnf mi_complete_matches_ + `seq` rnf mi_docs_ + `seq` mi_final_exts_ + `seq` mi_ext_fields_ + `seq` rnf mi_src_hash_ `seq` () instance NFData (ModIfaceBackend) where @@ -626,5 +693,158 @@ type WhetherHasOrphans = Bool -- | Does this module define family instances? type WhetherHasFamInst = Bool +completePartialModIface :: PartialModIface + -> [(Fingerprint, IfaceDecl)] + -> Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] + -> ModIfaceBackend + -> IfaceBinHandle 'ModIfaceFinal + -> ModIface +completePartialModIface partial decls extra_decls final_exts hi_bytes = partial + { mi_decls_ = decls + , mi_extra_decls_ = extra_decls + , mi_final_exts_ = final_exts + , mi_hi_bytes_ = hi_bytes + } + +addSourceFingerprint :: Fingerprint -> ModIface_ 'ModIfaceFinal -> ModIface_ 'ModIfaceFinal +addSourceFingerprint val iface = iface { mi_src_hash_ = val } + +restoreFromOldModIface :: ModIface_ phase -> ModIface_ phase -> ModIface_ phase +restoreFromOldModIface old new = new + { mi_globals_ = mi_globals_ old + , mi_hsc_src_ = mi_hsc_src_ old + , mi_src_hash_ = mi_src_hash_ old + } + +set_mi_module :: Module -> ModIface_ phase -> ModIface_ phase +set_mi_module val iface = clear_mi_hi_bytes $ iface { mi_module_ = val } + +set_mi_sig_of :: Maybe Module -> ModIface_ phase -> ModIface_ phase +set_mi_sig_of val iface = clear_mi_hi_bytes $ iface { mi_sig_of_ = val } + +set_mi_hsc_src :: HscSource -> ModIface_ phase -> ModIface_ phase +set_mi_hsc_src val iface = clear_mi_hi_bytes $ iface { mi_hsc_src_ = val } + +set_mi_src_hash :: Fingerprint -> ModIface_ phase -> ModIface_ phase +set_mi_src_hash val iface = clear_mi_hi_bytes $ iface { mi_src_hash_ = val } + +set_mi_hi_bytes :: IfaceBinHandle phase -> ModIface_ phase -> ModIface_ phase +set_mi_hi_bytes val iface = iface { mi_hi_bytes_ = val } + +set_mi_deps :: Dependencies -> ModIface_ phase -> ModIface_ phase +set_mi_deps val iface = clear_mi_hi_bytes $ iface { mi_deps_ = val } + +set_mi_usages :: [Usage] -> ModIface_ phase -> ModIface_ phase +set_mi_usages val iface = clear_mi_hi_bytes $ iface { mi_usages_ = val } + +set_mi_exports :: [IfaceExport] -> ModIface_ phase -> ModIface_ phase +set_mi_exports val iface = clear_mi_hi_bytes $ iface { mi_exports_ = val } + +set_mi_used_th :: Bool -> ModIface_ phase -> ModIface_ phase +set_mi_used_th val iface = clear_mi_hi_bytes $ iface { mi_used_th_ = val } + +set_mi_fixities :: [(OccName, Fixity)] -> ModIface_ phase -> ModIface_ phase +set_mi_fixities val iface = clear_mi_hi_bytes $ iface { mi_fixities_ = val } +set_mi_warns :: IfaceWarnings -> ModIface_ phase -> ModIface_ phase +set_mi_warns val iface = clear_mi_hi_bytes $ iface { mi_warns_ = val } + +set_mi_anns :: [IfaceAnnotation] -> ModIface_ phase -> ModIface_ phase +set_mi_anns val iface = clear_mi_hi_bytes $ iface { mi_anns_ = val } + +set_mi_insts :: [IfaceClsInst] -> ModIface_ phase -> ModIface_ phase +set_mi_insts val iface = clear_mi_hi_bytes $ iface { mi_insts_ = val } + +set_mi_fam_insts :: [IfaceFamInst] -> ModIface_ phase -> ModIface_ phase +set_mi_fam_insts val iface = clear_mi_hi_bytes $ iface { mi_fam_insts_ = val } + +set_mi_rules :: [IfaceRule] -> ModIface_ phase -> ModIface_ phase +set_mi_rules val iface = clear_mi_hi_bytes $ iface { mi_rules_ = val } + +set_mi_decls :: [IfaceDeclExts phase] -> ModIface_ phase -> ModIface_ phase +set_mi_decls val iface = clear_mi_hi_bytes $ iface { mi_decls_ = val } + +set_mi_extra_decls :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] -> ModIface_ phase -> ModIface_ phase +set_mi_extra_decls val iface = clear_mi_hi_bytes $ iface { mi_extra_decls_ = val } + +set_mi_globals :: Maybe IfGlobalRdrEnv -> ModIface_ phase -> ModIface_ phase +set_mi_globals val iface = clear_mi_hi_bytes $ iface { mi_globals_ = val } + +set_mi_hpc :: AnyHpcUsage -> ModIface_ phase -> ModIface_ phase +set_mi_hpc val iface = clear_mi_hi_bytes $ iface { mi_hpc_ = val } + +set_mi_trust :: IfaceTrustInfo -> ModIface_ phase -> ModIface_ phase +set_mi_trust val iface = clear_mi_hi_bytes $ iface { mi_trust_ = val } + +set_mi_trust_pkg :: Bool -> ModIface_ phase -> ModIface_ phase +set_mi_trust_pkg val iface = clear_mi_hi_bytes $ iface { mi_trust_pkg_ = val } + +set_mi_complete_matches :: [IfaceCompleteMatch] -> ModIface_ phase -> ModIface_ phase +set_mi_complete_matches val iface = clear_mi_hi_bytes $ iface { mi_complete_matches_ = val } + +set_mi_docs :: Maybe Docs -> ModIface_ phase -> ModIface_ phase +set_mi_docs val iface = clear_mi_hi_bytes $ iface { mi_docs_ = val } + +set_mi_final_exts :: IfaceBackendExts phase -> ModIface_ phase -> ModIface_ phase +set_mi_final_exts val iface = clear_mi_hi_bytes $ iface { mi_final_exts_ = val } + +set_mi_ext_fields :: ExtensibleFields -> ModIface_ phase -> ModIface_ phase +set_mi_ext_fields val iface = clear_mi_hi_bytes $ iface { mi_ext_fields_ = val } + +clear_mi_hi_bytes :: ModIface_ phase -> ModIface_ phase +clear_mi_hi_bytes iface = iface + { mi_hi_bytes_ = case mi_hi_bytes iface of + PartialIfaceBinHandle -> PartialIfaceBinHandle + FullIfaceBinHandle _ -> FullIfaceBinHandle Strict.Nothing + } +mi_module :: ModIface_ phase -> Module +mi_module = mi_module_ +mi_sig_of :: ModIface_ phase -> Maybe Module +mi_sig_of = mi_sig_of_ +mi_hsc_src :: ModIface_ phase -> HscSource +mi_hsc_src = mi_hsc_src_ +mi_deps :: ModIface_ phase -> Dependencies +mi_deps = mi_deps_ +mi_usages :: ModIface_ phase -> [Usage] +mi_usages = mi_usages_ +mi_exports :: ModIface_ phase -> [IfaceExport] +mi_exports = mi_exports_ +mi_used_th :: ModIface_ phase -> Bool +mi_used_th = mi_used_th_ +mi_fixities :: ModIface_ phase -> [(OccName, Fixity)] +mi_fixities = mi_fixities_ +mi_warns :: ModIface_ phase -> IfaceWarnings +mi_warns = mi_warns_ +mi_anns :: ModIface_ phase -> [IfaceAnnotation] +mi_anns = mi_anns_ +mi_decls :: ModIface_ phase -> [IfaceDeclExts phase] +mi_decls = mi_decls_ +mi_extra_decls :: ModIface_ phase -> Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] +mi_extra_decls = mi_extra_decls_ +mi_globals :: ModIface_ phase -> Maybe IfGlobalRdrEnv +mi_globals = mi_globals_ +mi_insts :: ModIface_ phase -> [IfaceClsInst] +mi_insts = mi_insts_ +mi_fam_insts :: ModIface_ phase -> [IfaceFamInst] +mi_fam_insts = mi_fam_insts_ +mi_rules :: ModIface_ phase -> [IfaceRule] +mi_rules = mi_rules_ +mi_hpc :: ModIface_ phase -> AnyHpcUsage +mi_hpc = mi_hpc_ +mi_trust :: ModIface_ phase -> IfaceTrustInfo +mi_trust = mi_trust_ +mi_trust_pkg :: ModIface_ phase -> Bool +mi_trust_pkg = mi_trust_pkg_ +mi_complete_matches :: ModIface_ phase -> [IfaceCompleteMatch] +mi_complete_matches = mi_complete_matches_ +mi_docs :: ModIface_ phase -> Maybe Docs +mi_docs = mi_docs_ +mi_final_exts :: ModIface_ phase -> IfaceBackendExts phase +mi_final_exts = mi_final_exts_ +mi_ext_fields :: ModIface_ phase -> ExtensibleFields +mi_ext_fields = mi_ext_fields_ +mi_src_hash :: ModIface_ phase -> Fingerprint +mi_src_hash = mi_src_hash_ +mi_hi_bytes :: ModIface_ phase -> IfaceBinHandle phase +mi_hi_bytes = mi_hi_bytes_ ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -19,7 +19,7 @@ -- http://www.cs.york.ac.uk/fp/nhc98/ module GHC.Utils.Binary - ( {-type-} Bin, + ( {-type-} Bin, RelBin(..), getRelBin, {-class-} Binary(..), {-type-} ReadBinHandle, WriteBinHandle, SymbolTable, Dictionary, @@ -32,6 +32,7 @@ module GHC.Utils.Binary seekBinWriter, seekBinReader, + seekBinReaderRel, tellBinReader, tellBinWriter, castBin, @@ -47,7 +48,9 @@ module GHC.Utils.Binary readBinMemN, putAt, getAt, + putAtRel, forwardPut, forwardPut_, forwardGet, + forwardPutRel, forwardPutRel_, forwardGetRel, -- * For writing instances putByte, @@ -102,6 +105,9 @@ module GHC.Utils.Binary BindingName(..), simpleBindingNameWriter, simpleBindingNameReader, + FullBinData(..), freezeBinHandle, thawBinHandle, putFullBinData, + freezeBinHandle2, + BinArray, ) where import GHC.Prelude @@ -156,7 +162,6 @@ import GHC.ForeignPtr ( unsafeWithForeignPtr ) import Unsafe.Coerce (unsafeCoerce) import GHC.Data.TrieMap - type BinArray = ForeignPtr Word8 #if !MIN_VERSION_base(4,15,0) @@ -196,6 +201,51 @@ dataHandle (BinData size bin) = do handleData :: WriteBinHandle -> IO BinData handleData (WriteBinMem _ ixr _ binr) = BinData <$> readFastMutInt ixr <*> readIORef binr +--------------------------------------------------------------- +-- FullBinData +--------------------------------------------------------------- + +data FullBinData = FullBinData + { fbd_readerUserData :: ReaderUserData + , fbd_off_s :: {-# UNPACK #-} !Int + -- ^ start offset + , fbd_off_e :: {-# UNPACK #-} !Int + -- ^ end offset + , fbd_size :: {-# UNPACK #-} !Int + -- ^ total buffer size + , fbd_buffer :: {-# UNPACK #-} !BinArray + } + +-- Equality and Ord assume that two distinct buffers are different, even if they compare the same things. +instance Eq FullBinData where + (FullBinData _ b c d e) == (FullBinData _ b1 c1 d1 e1) = b == b1 && c == c1 && d == d1 && e == e1 + +instance Ord FullBinData where + compare (FullBinData _ b c d e) (FullBinData _ b1 c1 d1 e1) = + compare b b1 `mappend` compare c c1 `mappend` compare d d1 `mappend` compare e e1 + +putFullBinData :: WriteBinHandle -> FullBinData -> IO () +putFullBinData bh (FullBinData _ o1 o2 _sz ba) = do + let sz = o2 - o1 + putPrim bh sz $ \dest -> + unsafeWithForeignPtr (ba `plusForeignPtr` o1) $ \orig -> + copyBytes dest orig sz + +freezeBinHandle :: Bin () -> ReadBinHandle -> IO FullBinData +freezeBinHandle (BinPtr len) (ReadBinMem user_data ixr sz binr) = do + ix <- readFastMutInt ixr + pure (FullBinData user_data ix len sz binr) + +freezeBinHandle2 :: ReadBinHandle -> Bin () -> IO FullBinData +freezeBinHandle2 (ReadBinMem user_data ixr sz binr) (BinPtr start) = do + ix <- readFastMutInt ixr + pure (FullBinData user_data start ix sz binr) + +thawBinHandle :: FullBinData -> IO ReadBinHandle +thawBinHandle (FullBinData user_data ix _end sz ba) = do + ixr <- newFastMutInt ix + return $ ReadBinMem user_data ixr sz ba + --------------------------------------------------------------- -- BinHandle --------------------------------------------------------------- @@ -289,9 +339,30 @@ unsafeUnpackBinBuffer (BS.BS arr len) = do newtype Bin a = BinPtr Int deriving (Eq, Ord, Show, Bounded) +data RelBin a = RelBin !(Bin a) !(Bin a) + deriving (Eq, Ord, Show, Bounded) + +newtype RelBinPtr a = RelBinPtr (Bin a) + castBin :: Bin a -> Bin b castBin (BinPtr i) = BinPtr i +getRelBin :: ReadBinHandle -> IO (RelBin a) +getRelBin bh = do + start <- tellBinReader bh + off <- get bh + pure $ RelBin start off + +makeAbsoluteBin :: RelBin a -> Bin a +makeAbsoluteBin (RelBin (BinPtr !start) (BinPtr !offset)) = BinPtr (start + offset) + +makeRelativeBin :: RelBin a -> RelBinPtr a +makeRelativeBin (RelBin _ offset) = RelBinPtr offset + +toRelBin :: Bin (RelBinPtr a) -> Bin a -> RelBin a +toRelBin (BinPtr !start) (BinPtr !goal) = + RelBin (BinPtr start) (BinPtr $! goal - start) + --------------------------------------------------------------- -- class Binary --------------------------------------------------------------- @@ -312,6 +383,9 @@ class Binary a where putAt :: Binary a => WriteBinHandle -> Bin a -> a -> IO () putAt bh p x = do seekBinWriter bh p; put_ bh x; return () +putAtRel :: WriteBinHandle -> Bin (RelBinPtr a) -> Bin a -> IO () +putAtRel bh from to = putAt bh from (makeRelativeBin $ toRelBin from to) + getAt :: Binary a => ReadBinHandle -> Bin a -> IO a getAt bh p = do seekBinReader bh p; get bh @@ -393,12 +467,18 @@ seekBinNoExpandWriter (WriteBinMem _ ix_r sz_r _) (BinPtr !p) = do else writeFastMutInt ix_r p -- | SeekBin but without calling expandBin -seekBinReader :: ReadBinHandle -> Bin a -> IO () +seekBinReader :: HasCallStack => ReadBinHandle -> Bin a -> IO () seekBinReader (ReadBinMem _ ix_r sz_r _) (BinPtr !p) = do if (p > sz_r) then panic "seekBinReader: seek out of range" else writeFastMutInt ix_r p +seekBinReaderRel :: HasCallStack => ReadBinHandle -> RelBin a -> IO () +seekBinReaderRel (ReadBinMem _ ix_r sz_r _) (RelBin (BinPtr !start) (BinPtr !offset)) = do + if (start + offset > sz_r) + then panic "seekBinReaderRel: seek out of range" + else writeFastMutInt ix_r (start + offset) + writeBinMem :: WriteBinHandle -> FilePath -> IO () writeBinMem (WriteBinMem _ ix_r _ arr_r) fn = do h <- openBinaryFile fn WriteMode @@ -1119,6 +1199,11 @@ instance Binary (Bin a) where put_ bh (BinPtr i) = putWord32 bh (fromIntegral i :: Word32) get bh = do i <- getWord32 bh; return (BinPtr (fromIntegral (i :: Word32))) +-- Instance uses fixed-width encoding to allow inserting +-- Bin placeholders in the stream. +instance Binary (RelBinPtr a) where + put_ bh (RelBinPtr i) = put_ bh i + get bh = RelBinPtr <$> get bh -- ----------------------------------------------------------------------------- -- Forward reading/writing @@ -1147,7 +1232,7 @@ forwardPut_ :: WriteBinHandle -> (b -> IO a) -> IO b -> IO () forwardPut_ bh put_A put_B = void $ forwardPut bh put_A put_B -- | Read a value stored using a forward reference -forwardGet :: ReadBinHandle -> IO a -> IO a +forwardGet :: HasCallStack => ReadBinHandle -> IO a -> IO a forwardGet bh get_A = do -- read forward reference p <- get bh -- a BinPtr @@ -1159,6 +1244,43 @@ forwardGet bh get_A = do seekBinReader bh p_a pure r + +-- | "forwardPutRel put_A put_B" outputs A after B but allows A to be read before B +-- by using a forward reference. +forwardPutRel :: WriteBinHandle -> (b -> IO a) -> IO b -> IO (a,b) +forwardPutRel bh put_A put_B = do + -- write placeholder pointer to A + pre_a <- tellBinWriter bh + put_ bh pre_a + + -- write B + r_b <- put_B + + -- update A's pointer + a <- tellBinWriter bh + putAtRel bh pre_a a + seekBinNoExpandWriter bh a + + -- write A + r_a <- put_A r_b + pure (r_a,r_b) + +forwardPutRel_ :: WriteBinHandle -> (b -> IO a) -> IO b -> IO () +forwardPutRel_ bh put_A put_B = void $ forwardPutRel bh put_A put_B + +-- | Read a value stored using a forward reference +forwardGetRel :: ReadBinHandle -> IO a -> IO a +forwardGetRel bh get_A = do + -- read forward reference + p <- getRelBin bh + -- store current position + p_a <- tellBinReader bh + -- go read the forward value, then seek back + seekBinReader bh $ makeAbsoluteBin p + r <- get_A + seekBinReader bh p_a + pure r + -- ----------------------------------------------------------------------------- -- Lazy reading/writing @@ -1168,19 +1290,19 @@ lazyPut = lazyPut' put_ lazyGet :: Binary a => ReadBinHandle -> IO a lazyGet = lazyGet' get -lazyPut' :: HasDebugCallStack => (WriteBinHandle -> a -> IO ()) -> WriteBinHandle -> a -> IO () +lazyPut' :: (WriteBinHandle -> a -> IO ()) -> WriteBinHandle -> a -> IO () lazyPut' f bh a = do -- output the obj with a ptr to skip over it: pre_a <- tellBinWriter bh put_ bh pre_a -- save a slot for the ptr f bh a -- dump the object q <- tellBinWriter bh -- q = ptr to after object - putAt bh pre_a q -- fill in slot before a with ptr to q + putAtRel bh pre_a q -- fill in slot before a with ptr to q seekBinWriter bh q -- finally carry on writing at q lazyGet' :: HasDebugCallStack => (ReadBinHandle -> IO a) -> ReadBinHandle -> IO a lazyGet' f bh = do - p <- get bh -- a BinPtr + p <- getRelBin bh -- a BinPtr p_a <- tellBinReader bh a <- unsafeInterleaveIO $ do -- NB: Use a fresh rbm_off_r variable in the child thread, for thread @@ -1189,7 +1311,7 @@ lazyGet' f bh = do let bh' = bh { rbm_off_r = off_r } seekBinReader bh' p_a f bh' - seekBinReader bh p -- skip over the object for now + seekBinReader bh (makeAbsoluteBin p) -- skip over the object for now return a -- | Serialize the constructor strictly but lazily serialize a value inside a @@ -1483,13 +1605,13 @@ putGenericSymbolTable gen_sym_tab serialiser bh = do mapM_ (\n -> serialiser bh n) (reverse todo) loop snd <$> - (forwardPut bh (const $ readFastMutInt symtab_next >>= put_ bh) $ + (forwardPutRel bh (const $ readFastMutInt symtab_next >>= put_ bh) $ loop) -- | Read the elements of a 'GenericSymbolTable' from disk into a 'SymbolTable'. getGenericSymbolTable :: forall a . (ReadBinHandle -> IO a) -> ReadBinHandle -> IO (SymbolTable a) getGenericSymbolTable deserialiser bh = do - sz <- forwardGet bh (get bh) :: IO Int + sz <- forwardGetRel bh (get bh) :: IO Int mut_arr <- newArray_ (0, sz-1) :: IO (IOArray Int a) forM_ [0..(sz-1)] $ \i -> do f <- deserialiser bh ===================================== testsuite/tests/plugins/simple-plugin/Simple/RemovePlugin.hs ===================================== @@ -64,9 +64,10 @@ metaPlugin' _ meta = pprPanic "meta" (showAstData BlankSrcSpan BlankEpAnnotation interfaceLoadPlugin' :: [CommandLineOption] -> ModIface -> IfM lcl ModIface interfaceLoadPlugin' [name, "interface"] iface - = return $ iface { mi_exports = filter (availNotNamedAs name) - (mi_exports iface) - } + = return $ set_mi_exports (filter (availNotNamedAs name) + (mi_exports iface)) + iface + interfaceLoadPlugin' _ iface = return iface availNotNamedAs :: String -> AvailInfo -> Bool ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit fa76e1ee98906f5bc8fc4598524610020b653412 +Subproject commit eaa6e1870997f09b9023cba09d6b5431cf5b0174 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fb7238c50a4fb7b46db430b78794b4e0549c5f42 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fb7238c50a4fb7b46db430b78794b4e0549c5f42 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 17:44:46 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 06 May 2024 13:44:46 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Substitute bindist files with Hadrian not configure Message-ID: <6639170e1b6c2_17f48e2979a94120920@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: adba68e7 by John Ericson at 2024-05-05T19:35:56-04:00 Substitute bindist files with Hadrian not configure The `ghc-toolchain` overhaul will eventually replace all this stuff with something much more cleaned up, but I think it is still worth making this sort of cleanup in the meantime so other untanglings and dead code cleaning can procede. I was able to delete a fair amount of dead code doing this too. `LLVMTarget_CPP` is renamed to / merged with `LLVMTarget` because it wasn't actually turned into a valid CPP identifier. (Original to 1345c7cc42c45e63ab1726a8fd24a7e4d4222467, actually.) Progress on #23966 Co-Authored-By: Sylvain Henry <hsyl20 at gmail.com> - - - - - 18f4ff84 by Alan Zimmerman at 2024-05-05T19:36:32-04:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 - - - - - ed4adb41 by Matthew Craven at 2024-05-06T13:44:21-04:00 Add test cases for #24664 ...since none are present in the original MR !12463 fixing this issue. - - - - - e4644bcb by Alan Zimmerman at 2024-05-06T13:44:21-04:00 EPA: preserve comments in data decls Closes #24771 - - - - - 21 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - configure.ac - distrib/configure.ac.in - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cfg/system.config.in - hadrian/src/Oracles/Setting.hs - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Rules/Generate.hs - mk/project.mk.in - + testsuite/tests/codeGen/should_run/T24664a.hs - + testsuite/tests/codeGen/should_run/T24664a.stdout - + testsuite/tests/codeGen/should_run/T24664b.hs - + testsuite/tests/codeGen/should_run/T24664b.stdout - testsuite/tests/codeGen/should_run/all.T - testsuite/tests/printer/Makefile - + testsuite/tests/printer/Test24753.hs - testsuite/tests/printer/Test24755.hs - + testsuite/tests/printer/Test24771.hs - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -2486,9 +2486,8 @@ forall :: { Located ([AddEpAnn], Maybe [LHsTyVarBndr Specificity GhcPs]) } | {- empty -} { noLoc ([], Nothing) } constr_stuff :: { Located (LocatedN RdrName, HsConDeclH98Details GhcPs) } - : infixtype {% fmap (reLoc. (fmap (\b -> (dataConBuilderCon b, - dataConBuilderDetails b)))) - (runPV $1) } + : infixtype {% do { b <- runPV $1 + ; return (sL1 b (dataConBuilderCon b, dataConBuilderDetails b)) }} | '(#' usum_constr '#)' {% let (t, tag, arity) = $2 in pure (sLL $1 $3 $ mkUnboxedSumCon t tag arity)} usum_constr :: { (LHsType GhcPs, Int, Int) } -- constructor for the data decls SumN# ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -236,7 +236,8 @@ mkTyData loc' is_type_data new_or_data cType (L _ (mcxt, tycl_hdr)) ; let anns' = annsIn Semi.<> ann ; data_cons <- checkNewOrData loc' (unLoc tc) is_type_data new_or_data data_cons ; defn <- mkDataDefn cType mcxt ksig data_cons maybe_deriv - ; let loc = EpAnn (spanAsAnchor loc') noAnn cs + ; !cs' <- getCommentsFor loc' + ; let loc = EpAnn (spanAsAnchor loc') noAnn (cs' Semi.<> cs) ; return (L loc (DataDecl { tcdDExt = anns', tcdLName = tc, tcdTyVars = tyvars, tcdFixity = fixity, @@ -2059,28 +2060,32 @@ instance DisambTD (HsType GhcPs) where mkHsAppTyHeadPV = return mkHsAppTyPV t1 t2 = return (mkHsAppTy t1 t2) mkHsAppKindTyPV t at ki = return (mkHsAppKindTy at t ki) - mkHsOpTyPV prom t1 op t2 = return (mkLHsOpTy prom t1 op t2) + mkHsOpTyPV prom t1 op t2 = do + let (L l ty) = mkLHsOpTy prom t1 op t2 + !cs <- getCommentsFor (locA l) + return (L (addCommentsToEpAnn l cs) ty) mkUnpackednessPV = addUnpackednessP -dataConBuilderCon :: DataConBuilder -> LocatedN RdrName -dataConBuilderCon (PrefixDataConBuilder _ dc) = dc -dataConBuilderCon (InfixDataConBuilder _ dc _) = dc +dataConBuilderCon :: LocatedA DataConBuilder -> LocatedN RdrName +dataConBuilderCon (L _ (PrefixDataConBuilder _ dc)) = dc +dataConBuilderCon (L _ (InfixDataConBuilder _ dc _)) = dc -dataConBuilderDetails :: DataConBuilder -> HsConDeclH98Details GhcPs +dataConBuilderDetails :: LocatedA DataConBuilder -> HsConDeclH98Details GhcPs -- Detect when the record syntax is used: -- data T = MkT { ... } -dataConBuilderDetails (PrefixDataConBuilder flds _) +dataConBuilderDetails (L _ (PrefixDataConBuilder flds _)) | [L (EpAnn anc _ cs) (HsRecTy an fields)] <- toList flds = RecCon (L (EpAnn anc an cs) fields) -- Normal prefix constructor, e.g. data T = MkT A B C -dataConBuilderDetails (PrefixDataConBuilder flds _) +dataConBuilderDetails (L _ (PrefixDataConBuilder flds _)) = PrefixCon noTypeArgs (map hsLinear (toList flds)) -- Infix constructor, e.g. data T = Int :! Bool -dataConBuilderDetails (InfixDataConBuilder lhs _ rhs) - = InfixCon (hsLinear lhs) (hsLinear rhs) +dataConBuilderDetails (L (EpAnn _ _ csl) (InfixDataConBuilder (L (EpAnn anc ann csll) lhs) _ rhs)) + = InfixCon (hsLinear (L (EpAnn anc ann (csl Semi.<> csll)) lhs)) (hsLinear rhs) + instance DisambTD DataConBuilder where mkHsAppTyHeadPV = tyToDataConBuilder @@ -2101,8 +2106,9 @@ instance DisambTD DataConBuilder where mkHsOpTyPV prom lhs tc rhs = do check_no_ops (unLoc rhs) -- check the RHS because parsing type operators is right-associative data_con <- eitherToP $ tyConToDataCon tc + !cs <- getCommentsFor (locA l) checkNotPromotedDataCon prom data_con - return $ L l (InfixDataConBuilder lhs data_con rhs) + return $ L (addCommentsToEpAnn l cs) (InfixDataConBuilder lhs data_con rhs) where l = combineLocsA lhs rhs check_no_ops (HsBangTy _ _ t) = check_no_ops (unLoc t) @@ -3223,8 +3229,8 @@ mkSumOrTuplePat l Boxed a at Sum{} _ = mkLHsOpTy :: PromotionFlag -> LHsType GhcPs -> LocatedN RdrName -> LHsType GhcPs -> LHsType GhcPs mkLHsOpTy prom x op y = - let loc = getLoc x `combineSrcSpansA` (noAnnSrcSpan $ getLocA op) `combineSrcSpansA` getLoc y - in L loc (mkHsOpTy prom x op y) + let loc = locA x `combineSrcSpans` locA op `combineSrcSpans` locA y + in L (noAnnSrcSpan loc) (mkHsOpTy prom x op y) mkMultTy :: EpToken "%" -> LHsType GhcPs -> EpUniToken "->" "→" -> HsArrow GhcPs mkMultTy pct t@(L _ (HsTyLit _ (HsNumTy (SourceText (unpackFS -> "1")) 1))) arr ===================================== configure.ac ===================================== @@ -379,15 +379,7 @@ then else TargetPlatformFull="${target_alias}" fi -if test "$CrossCompiling" = "YES" -then - # Use value passed by user from --target= - CrossCompilePrefix="${TargetPlatformFull}-" -else - CrossCompilePrefix="" -fi AC_SUBST(CrossCompiling) -AC_SUBST(CrossCompilePrefix) AC_SUBST(TargetPlatformFull) dnl ** Which gcc to use? @@ -623,9 +615,6 @@ FP_LD_NO_WARN_DUPLICATE_LIBRARIES([target], [CONF_GCC_LINKER_OPTS_STAGE2]) FP_MERGE_OBJECTS_SUPPORTS_RESPONSE_FILES GHC_LLVM_TARGET_SET_VAR -# we intend to pass trough --targets to llvm as is. -LLVMTarget_CPP=` echo "$LlvmTarget"` -AC_SUBST(LLVMTarget_CPP) # The target is substituted into the distrib/configure.ac file AC_SUBST(LlvmTarget) @@ -951,12 +940,10 @@ PREP_TARGET_FILE FIND_GHC_TOOLCHAIN([hadrian/cfg]) AC_CONFIG_FILES( -[ mk/project.mk - hadrian/cfg/system.config +[ hadrian/cfg/system.config hadrian/ghci-cabal hadrian/ghci-multi-cabal hadrian/ghci-stack - distrib/configure.ac hadrian/cfg/default.host.target hadrian/cfg/default.target ]) ===================================== distrib/configure.ac.in ===================================== @@ -23,19 +23,12 @@ bootstrap_llvm_target=@LlvmTarget@ TargetHasLibm=@TargetHasLibm@ AC_SUBST(TargetHasLibm) -FFIIncludeDir=@FFIIncludeDir@ -FFILibDir=@FFILibDir@ -AC_SUBST(FFILibDir) -AC_SUBST(FFIIncludeDir) - -LibdwIncludeDir=@LibdwIncludeDir@ -LibdwLibDir=@LibdwLibDir@ -AC_SUBST(LibdwLibDir) -AC_SUBST(LibdwIncludeDir) - UseLibffiForAdjustors=@UseLibffiForAdjustors@ AC_SUBST(UseLibffiForAdjustors) +GhcWithSMP=@GhcWithSMP@ +AC_SUBST(GhcWithSMP) + # We have to run these unconditionally as FPTOOLS_SET_PLATFORMS_VARS wants the # values it computes. AC_CANONICAL_BUILD @@ -59,13 +52,11 @@ if test "$target" != "$host" ; then fi LeadingUnderscore="@LeadingUnderscore@" CrossCompilePrefix="@CrossCompilePrefix@" -TargetPlatformFull="${target}" TablesNextToCode="@TablesNextToCode@" AC_SUBST(LeadingUnderscore) AC_SUBST(CrossCompiling) AC_SUBST(CrossCompilePrefix) -AC_SUBST(TargetPlatformFull) AC_SUBST(TablesNextToCode) Unregisterised="@Unregisterised@" ===================================== hadrian/bindist/Makefile ===================================== @@ -123,7 +123,7 @@ lib/settings : config.mk @echo ',("target has subsections via symbols", "$(TargetHasSubsectionsViaSymbols)")' >> $@ @echo ',("target has libm", "$(TargetHasLibm)")' >> $@ @echo ',("Unregisterised", "$(GhcUnregisterised)")' >> $@ - @echo ',("LLVM target", "$(LLVMTarget_CPP)")' >> $@ + @echo ',("LLVM target", "$(LLVMTarget)")' >> $@ @echo ',("LLVM llc command", "$(SettingsLlcCommand)")' >> $@ @echo ',("LLVM opt command", "$(SettingsOptCommand)")' >> $@ @echo ',("LLVM llvm-as command", "$(SettingsLlvmAsCommand)")' >> $@ ===================================== hadrian/bindist/config.mk.in ===================================== @@ -134,20 +134,9 @@ CrossCompiling = @CrossCompiling@ CrossCompilePrefix = @CrossCompilePrefix@ GhcUnregisterised = @Unregisterised@ -# ArchSupportsSMP should be set iff there is support for that arch in -# rts/include/stg/SMP.h -ifeq "$(TargetArch_CPP)" "arm" -# We don't support load/store barriers pre-ARMv7. See #10433. -ArchSupportsSMP=$(if $(filter $(ARM_ISA),ARMv5 ARMv6),NO,YES) -else ifeq "$(TargetArch_CPP)" "javascript" -ArchSupportsSMP=NO -else -ArchSupportsSMP=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(TargetArch_CPP), i386 x86_64 sparc powerpc powerpc64 powerpc64le s390x aarch64 riscv64))) -endif - # The THREADED_RTS requires `BaseReg` to be in a register and the # `GhcUnregisterised` mode doesn't allow that. -GhcWithSMP := $(strip $(if $(filter YESNO, $(ArchSupportsSMP)$(GhcUnregisterised)),YES,NO)) +GhcWithSMP := @GhcWithSMP@ # Whether to include GHCi in the compiler. Depends on whether the RTS linker # has support for this OS/ARCH combination. ===================================== hadrian/cfg/system.config.in ===================================== @@ -128,3 +128,5 @@ use-lib-dl = @UseLibdl@ use-lib-bfd = @UseLibbfd@ use-lib-pthread = @UseLibpthread@ need-libatomic = @NeedLibatomic@ + +emsdk-version = @ConfiguredEmsdkVersion@ ===================================== hadrian/src/Oracles/Setting.hs ===================================== @@ -72,6 +72,7 @@ data Setting = CursesIncludeDir | SystemGhc | TargetPlatformFull | BourneShell + | EmsdkVersion -- TODO compute solely in Hadrian, removing these variables' definitions -- from aclocal.m4 whenever they can be calculated from other variables @@ -128,6 +129,7 @@ setting key = lookupSystemConfig $ case key of SystemGhc -> "system-ghc" TargetPlatformFull -> "target-platform-full" BourneShell -> "bourne-shell" + EmsdkVersion -> "emsdk-version" -- | Look up the value of a 'SettingList' in @cfg/system.config@, tracking the -- result. ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -337,6 +337,7 @@ bindistRules = do -- Prepare binary distribution configure script -- (generated under /distrib/configure by 'autoreconf') root -/- "bindist" -/- "ghc-*" -/- "configure" %> \configurePath -> do + need ["distrib" -/- "configure.ac"] ghcRoot <- topDirectory copyFile (ghcRoot -/- "aclocal.m4") (ghcRoot -/- "distrib" -/- "aclocal.m4") copyDirectory (ghcRoot -/- "m4") (ghcRoot -/- "distrib") @@ -360,8 +361,7 @@ bindistRules = do -- creating the archive). forM_ bindistInstallFiles $ \file -> root -/- "bindist" -/- "ghc-*" -/- file %> \dest -> do - ghcRoot <- topDirectory - copyFile (ghcRoot -/- fixup file) dest + copyFile (fixup file) dest where fixup f | f `elem` ["INSTALL", "README"] = "distrib" -/- f ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -371,6 +371,57 @@ templateRules = do [ interpolateVar "LlvmMinVersion" $ replaceEq '.' ',' <$> setting LlvmMinVersion , interpolateVar "LlvmMaxVersion" $ replaceEq '.' ',' <$> setting LlvmMaxVersion ] + bindistRules + +bindistRules :: Rules () +bindistRules = do + templateRule ("mk" -/- "project.mk") $ mconcat + [ interpolateSetting "ProjectName" ProjectName + , interpolateSetting "ProjectVersion" ProjectVersion + , interpolateSetting "ProjectVersionInt" ProjectVersionInt + , interpolateSetting "ProjectPatchLevel" ProjectPatchLevel + , interpolateSetting "ProjectPatchLevel1" ProjectPatchLevel1 + , interpolateSetting "ProjectPatchLevel2" ProjectPatchLevel2 + , interpolateSetting "ProjectGitCommitId" ProjectGitCommitId + + , interpolateVar "HostOS_CPP" $ fmap cppify $ interp $ queryHost queryOS + + , interpolateVar "TargetPlatform" $ getTarget targetPlatformTriple + , interpolateVar "TargetPlatform_CPP" $ cppify <$> getTarget targetPlatformTriple + , interpolateVar "TargetArch_CPP" $ cppify <$> getTarget queryArch + , interpolateVar "TargetOS_CPP" $ cppify <$> getTarget queryOS + , interpolateVar "LLVMTarget" $ getTarget tgtLlvmTarget + ] + templateRule ("distrib" -/- "configure.ac") $ mconcat + [ interpolateSetting "ConfiguredEmsdkVersion" EmsdkVersion + , interpolateVar "CrossCompilePrefix" $ do + crossCompiling <- interp $ getFlag CrossCompiling + tpf <- setting TargetPlatformFull + pure $ if crossCompiling then tpf <> "-" else "" + , interpolateVar "LeadingUnderscore" $ yesNo <$> getTarget tgtSymbolsHaveLeadingUnderscore + , interpolateSetting "LlvmMaxVersion" LlvmMaxVersion + , interpolateSetting "LlvmMinVersion" LlvmMinVersion + , interpolateVar "LlvmTarget" $ getTarget tgtLlvmTarget + , interpolateSetting "ProjectVersion" ProjectVersion + , interpolateVar "SettingsUseDistroMINGW" $ settingsFileSetting ToolchainSetting_DistroMinGW + , interpolateVar "TablesNextToCode" $ yesNo <$> getTarget tgtTablesNextToCode + , interpolateVar "TargetHasLibm" $ lookupSystemConfig "target-has-libm" + , interpolateVar "TargetPlatform" $ getTarget targetPlatformTriple + , interpolateVar "TargetWordBigEndian" $ getTarget isBigEndian + , interpolateVar "TargetWordSize" $ getTarget wordSize + , interpolateVar "Unregisterised" $ yesNo <$> getTarget tgtUnregisterised + , interpolateVar "UseLibdw" $ fmap yesNo $ interp $ getFlag UseLibdw + , interpolateVar "UseLibffiForAdjustors" $ yesNo <$> getTarget tgtUseLibffiForAdjustors + , interpolateVar "GhcWithSMP" $ yesNo <$> targetSupportsSMP + ] + where + interp = interpretInContext (semiEmptyTarget Stage2) + getTarget = interp . queryTarget + +-- | Given a 'String' replace characters '.' and '-' by underscores ('_') so that +-- the resulting 'String' is a valid C preprocessor identifier. +cppify :: String -> String +cppify = replaceEq '-' '_' . replaceEq '.' '_' -- Generators @@ -486,10 +537,11 @@ generateSettings settingsFile = do arSupportsAtFile' = yesNo . arSupportsAtFile . tgtAr arSupportsDashL' = yesNo . arSupportsDashL . tgtAr ranlibPath = maybe "" (prgPath . ranlibProgram) . tgtRanlib - isBigEndian = yesNo . (\case BigEndian -> True; LittleEndian -> False) . tgtEndianness - wordSize = show . wordSize2Bytes . tgtWordSize mergeObjsSupportsResponseFiles' = maybe "NO" (yesNo . mergeObjsSupportsResponseFiles) . tgtMergeObjs +isBigEndian, wordSize :: Toolchain.Target -> String +isBigEndian = yesNo . (\case BigEndian -> True; LittleEndian -> False) . tgtEndianness +wordSize = show . wordSize2Bytes . tgtWordSize -- | Generate @Config.hs@ files. generateConfigHs :: Expr String ===================================== mk/project.mk.in ===================================== @@ -1,5 +1,5 @@ # WARNING: mk/project.mk is automatically generated from mk/project.mk.in by -# ./configure. Make sure you are editing mk/project.mk.in, not mk/project.mk. +# Hadrian. Make sure you are editing mk/project.mk.in, not mk/project.mk. ################################################################################ # @@ -25,8 +25,7 @@ # random .o-file stuff might change even if the .hi syntax doesn't ProjectName = @ProjectName@ -ProjectTags = -ProjectVersion = @ProjectVersion@$(ProjectTags) +ProjectVersion = @ProjectVersion@ ProjectVersionInt = @ProjectVersionInt@ ProjectPatchLevel = @ProjectPatchLevel@ ProjectPatchLevel1 = @ProjectPatchLevel1@ @@ -81,41 +80,14 @@ ProjectGitCommitId = @ProjectGitCommitId@ # You have to do a lot of work by hand to cross compile: see the # section on "Porting GHC" in the Building Guide. -HOSTPLATFORM = @HostPlatform@ TARGETPLATFORM = @TargetPlatform@ -BUILDPLATFORM = @BuildPlatform@ -HostPlatform_CPP = @HostPlatform_CPP@ -HostArch_CPP = @HostArch_CPP@ HostOS_CPP = @HostOS_CPP@ -HostVendor_CPP = @HostVendor_CPP@ TargetPlatform_CPP = @TargetPlatform_CPP@ TargetArch_CPP = @TargetArch_CPP@ TargetOS_CPP = @TargetOS_CPP@ -TargetVendor_CPP = @TargetVendor_CPP@ -LLVMTarget_CPP = @LLVMTarget_CPP@ - -BuildPlatform_CPP = @BuildPlatform_CPP@ -BuildArch_CPP = @BuildArch_CPP@ -BuildOS_CPP = @BuildOS_CPP@ -BuildVendor_CPP = @BuildVendor_CPP@ - - at HostPlatform_CPP@_HOST = 1 - at TargetPlatform_CPP@_TARGET = 1 - at BuildPlatform_CPP@_BUILD = 1 - - at HostArch_CPP@_HOST_ARCH = 1 - at TargetArch_CPP@_TARGET_ARCH = 1 - at BuildArch_CPP@_BUILD_ARCH = 1 - - at HostOS_CPP@_HOST_OS = 1 - at TargetOS_CPP@_TARGET_OS = 1 - at BuildOS_CPP@_BUILD_OS = 1 - - at HostVendor_CPP@_HOST_VENDOR = 1 - at TargetVendor_CPP@_TARGET_VENDOR = 1 - at BuildVendor_CPP@_BUILD_VENDOR = 1 +LLVMTarget = @LLVMTarget@ ################################################################################ # @@ -123,13 +95,6 @@ BuildVendor_CPP = @BuildVendor_CPP@ # ################################################################################ -# Pin a suffix on executables? If so, what (Windows only). -exeext0=@exeext_host@ -exeext1=@exeext_target@ -exeext2=@exeext_target@ -exeext3=@exeext_target@ -soext=@soext_target@ - # Windows_Host=YES if on a Windows platform ifneq "$(findstring $(HostOS_CPP), mingw32)" "" Windows_Host=YES @@ -143,17 +108,3 @@ Darwin_Host=YES else Darwin_Host=NO endif - -# Windows_Target=YES if we are targeting a Windows platform -ifneq "$(findstring $(TargetOS_CPP), mingw32)" "" -Windows_Target=YES -else -Windows_Target=NO -endif - -# Is the stage0 compiler affected by Bug #9439? -GHC_LLVM_AFFECTED_BY_9439 = @GHC_LLVM_AFFECTED_BY_9439@ - -ifeq "$(TargetArch_CPP)" "arm" -ARM_ISA=@ARM_ISA@ -endif ===================================== testsuite/tests/codeGen/should_run/T24664a.hs ===================================== @@ -0,0 +1,27 @@ +-- This program tests the passing of RUBBISH values +-- with the Int64 representation, which were found +-- to by mis-handled by the JS backend in #24664. + +{-# LANGUAGE MagicHash #-} + +module Main where + +import GHC.Exts (Int64#, intToInt64#) + +takesInt64a :: String -> Int64# -> String -> IO () +{-# OPAQUE takesInt64a #-} +-- Idea: This function takes an Int64# but doesn't use it, +-- so that its argument might be turned into a rubbish literal. +-- We don't want WW to remove the argument entirely, so OPAQUE +takesInt64a str1 _ str2 = putStrLn str1 >> putStrLn str2 + +takesInt64b :: Int64# -> IO () +{-# NOINLINE takesInt64b #-} +-- Idea: This function will get a worker that doesn't take an +-- Int64# at all, and the body of that worker will pass a +-- rubbish literal to takesInt64a since no real arg exists. +takesInt64b x = takesInt64a "first string to print" x "second string to print" + +main :: IO () +main = do + takesInt64b (intToInt64# 12345#) ===================================== testsuite/tests/codeGen/should_run/T24664a.stdout ===================================== @@ -0,0 +1,2 @@ +first string to print +second string to print ===================================== testsuite/tests/codeGen/should_run/T24664b.hs ===================================== @@ -0,0 +1,31 @@ +-- This is a variant of T24664a that could reproduce +-- the compiler crash originally observed in #24664. + +{-# LANGUAGE MagicHash #-} + +module Main where + +import GHC.Exts (Int64#, intToInt64#, uncheckedIShiftRL64#) + +takesInt64a :: String -> Int64# -> String -> IO () +{-# OPAQUE takesInt64a #-} +-- Idea: This function takes an Int64# but doesn't use it, +-- so that its argument might be turned into a rubbish literal. +-- We don't want WW to remove the argument entirely, so OPAQUE +takesInt64a str1 _ str2 = putStrLn str1 >> putStrLn str2 + +takesInt64b :: String -> Int64# -> String -> IO () +{-# NOINLINE takesInt64b #-} +-- Idea: This function will get a worker that doesn't take an +-- Int64# at all, and the body of that worker will pass a +-- rubbish literal to takesInt64a since no real arg exists. +takesInt64b s1 x s2 + = takesInt64a (s1 ++ t) (x `uncheckedIShiftRL64#` 13#) (s2 ++ t) + where t = " string to print" + +takesInt64c :: Int64# -> IO () +takesInt64c x = takesInt64b "first" x "second" + +main :: IO () +main = do + takesInt64c (intToInt64# 12345#) ===================================== testsuite/tests/codeGen/should_run/T24664b.stdout ===================================== @@ -0,0 +1,2 @@ +first string to print +second string to print ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -243,3 +243,6 @@ test('MulMayOflo_full', test('T24264run', normal, compile_and_run, ['']) test('T24295a', normal, compile_and_run, ['-O -floopification']) test('T24295b', normal, compile_and_run, ['-O -floopification -fpedantic-bottoms']) +test('T24664a', normal, compile_and_run, ['-O']) +test('T24664b', normal, compile_and_run, ['-O']) + ===================================== testsuite/tests/printer/Makefile ===================================== @@ -861,3 +861,13 @@ Test24754: Test24755: $(CHECK_PPR) $(LIBDIR) Test24755.hs $(CHECK_EXACT) $(LIBDIR) Test24755.hs + +.PHONY: Test24753 +Test24753: + $(CHECK_PPR) $(LIBDIR) Test24753.hs + $(CHECK_EXACT) $(LIBDIR) Test24753.hs + +.PHONY: Test24771 +Test24771: + $(CHECK_PPR) $(LIBDIR) Test24771.hs + $(CHECK_EXACT) $(LIBDIR) Test24771.hs ===================================== testsuite/tests/printer/Test24753.hs ===================================== @@ -0,0 +1,8 @@ +module Test24753 where + +type ErrorChoiceApi + = "path0" :> Get '[JSON] Int -- c0 + :<|> "path4" :> (ReqBody '[PlainText] Int :> Post '[PlainText] Int -- c4 + :<|> ReqBody '[PlainText] Int :> Post '[JSON] Int) -- c5 + :<|> "path5" :> (ReqBody '[JSON] Int :> Post '[PlainText] Int -- c6 + :<|> ReqBody '[PlainText] Int :> Post '[PlainText] Int) -- c7 ===================================== testsuite/tests/printer/Test24755.hs ===================================== @@ -3,6 +3,6 @@ module Test24755 where class - a -- Before operator - :+ - b -- After operator + a -- c1 + :+ -- c2 + b -- c3 ===================================== testsuite/tests/printer/Test24771.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeOperators #-} +module Test24771 where + +data Foo + = Int -- c1 + :* -- c2 + String -- c3 ===================================== testsuite/tests/printer/all.T ===================================== @@ -205,3 +205,5 @@ test('DataDeclShort', [ignore_stderr, req_ppr_deps], makefile_test, ['DataDeclSh test('Test24749', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24749']) test('Test24754', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24754']) test('Test24755', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24755']) +test('Test24753', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24753']) +test('Test24771', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24771']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0f74e54459ec7838c4f8954929b9f29fb35b73b3...e4644bcbb9793b1a449835efa2f3e23e253d869b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0f74e54459ec7838c4f8954929b9f29fb35b73b3...e4644bcbb9793b1a449835efa2f3e23e253d869b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 18:55:44 2024 From: gitlab at gitlab.haskell.org (Serge S. Gulin (@gulin.serge)) Date: Mon, 06 May 2024 14:55:44 -0400 Subject: [Git][ghc/ghc][wip/T24504] 9 commits: EPA: Widen stmtslist to include last semicolon Message-ID: <663927b07a83b_17f48e339f000129130@gitlab.mail> Serge S. Gulin pushed to branch wip/T24504 at Glasgow Haskell Compiler / GHC Commits: 7eab4e01 by Alan Zimmerman at 2024-05-04T16:14:55+01:00 EPA: Widen stmtslist to include last semicolon Closes #24754 - - - - - 06f7db40 by Teo Camarasu at 2024-05-05T00:19:38-04:00 doc: Fix type error in hs_try_putmvar example - - - - - af000532 by Moritz Schuler at 2024-05-05T06:30:58-04:00 Fix parsing of module names in CLI arguments closes issue #24732 - - - - - da74e9c9 by Ben Gamari at 2024-05-05T06:31:34-04:00 ghc-platform: Add Setup.hs The Hadrian bootstrapping script relies upon `Setup.hs` to drive its build. Addresses #24761. - - - - - 35d34fde by Alan Zimmerman at 2024-05-05T12:52:40-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 - - - - - 03c5dfbf by Simon Peyton Jones at 2024-05-05T12:53:15-04:00 Fix a float-out error Ticket #24768 showed that the Simplifier was accidentally destroying a join point. It turned out to be that we were sending a bottoming join point to the top, accidentally abstracting over /other/ join points. Easily fixed. - - - - - adba68e7 by John Ericson at 2024-05-05T19:35:56-04:00 Substitute bindist files with Hadrian not configure The `ghc-toolchain` overhaul will eventually replace all this stuff with something much more cleaned up, but I think it is still worth making this sort of cleanup in the meantime so other untanglings and dead code cleaning can procede. I was able to delete a fair amount of dead code doing this too. `LLVMTarget_CPP` is renamed to / merged with `LLVMTarget` because it wasn't actually turned into a valid CPP identifier. (Original to 1345c7cc42c45e63ab1726a8fd24a7e4d4222467, actually.) Progress on #23966 Co-Authored-By: Sylvain Henry <hsyl20 at gmail.com> - - - - - 18f4ff84 by Alan Zimmerman at 2024-05-05T19:36:32-04:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 - - - - - aef0553d by Ben Gamari at 2024-05-06T21:52:16+03:00 IPE: Eliminate dependency on Read Instead of encoding the closure type as decimal string we now simply represent it as an integer, eliminating the need for `Read` in `GHC.Internal.InfoProv.Types.peekInfoProv`. Closes #24504. - - - - - 30 changed files: - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/StgToCmm/InfoTableProv.hs - compiler/Language/Haskell/Syntax/Module/Name.hs - configure.ac - distrib/configure.ac.in - docs/users_guide/exts/ffi.rst - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cfg/system.config.in - hadrian/src/Oracles/Setting.hs - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Rules/Generate.hs - libraries/ghc-internal/src/GHC/Internal/InfoProv/Types.hsc - + libraries/ghc-platform/Setup.hs - mk/project.mk.in - rts/IPE.c - rts/Trace.c - rts/include/rts/IPE.h - testsuite/tests/parser/should_compile/DumpSemis.stderr - testsuite/tests/printer/Makefile - + testsuite/tests/printer/Test24753.hs - + testsuite/tests/printer/Test24754.hs - + testsuite/tests/printer/Test24755.hs - testsuite/tests/printer/all.T - + testsuite/tests/rename/should_compile/T24732.hs - + testsuite/tests/rename/should_compile/T24732.stdout - testsuite/tests/rename/should_compile/all.T - + testsuite/tests/simplCore/should_compile/T24768.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f83be2b4642170814cd150318034a2cdbafe1f58...aef0553d0e77398947942c1aa188bb525c21282d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f83be2b4642170814cd150318034a2cdbafe1f58...aef0553d0e77398947942c1aa188bb525c21282d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 18:57:20 2024 From: gitlab at gitlab.haskell.org (Serge S. Gulin (@gulin.serge)) Date: Mon, 06 May 2024 14:57:20 -0400 Subject: [Git][ghc/ghc][wip/T24504] IPE: Eliminate dependency on Read Message-ID: <6639281042b37_17f48e34890ec130121@gitlab.mail> Serge S. Gulin pushed to branch wip/T24504 at Glasgow Haskell Compiler / GHC Commits: c7197311 by Ben Gamari at 2024-05-06T21:56:51+03:00 IPE: Eliminate dependency on Read Instead of encoding the closure type as decimal string we now simply represent it as an integer, eliminating the need for `Read` in `GHC.Internal.InfoProv.Types.peekInfoProv`. Closes #24504. ------------------------- Metric Decrease: T24602_perf_size size_hello_artifact ------------------------- - - - - - 5 changed files: - compiler/GHC/StgToCmm/InfoTableProv.hs - libraries/ghc-internal/src/GHC/Internal/InfoProv/Types.hsc - rts/IPE.c - rts/Trace.c - rts/include/rts/IPE.h Changes: ===================================== compiler/GHC/StgToCmm/InfoTableProv.hs ===================================== @@ -178,7 +178,7 @@ toIpeBufferEntries byte_order cg_ipes = to_ipe_buf_ent :: CgInfoProvEnt -> [Word32] to_ipe_buf_ent cg_ipe = [ ipeTableName cg_ipe - , ipeClosureDesc cg_ipe + , fromIntegral $ ipeClosureDesc cg_ipe , ipeTypeDesc cg_ipe , ipeLabel cg_ipe , ipeSrcFile cg_ipe @@ -193,7 +193,6 @@ toIpeBufferEntries byte_order cg_ipes = toCgIPE :: Platform -> SDocContext -> InfoProvEnt -> State StringTable CgInfoProvEnt toCgIPE platform ctx ipe = do table_name <- lookupStringTable $ ST.pack $ renderWithContext ctx (pprCLabel platform (infoTablePtr ipe)) - closure_desc <- lookupStringTable $ ST.pack $ show (infoProvEntClosureType ipe) type_desc <- lookupStringTable $ ST.pack $ infoTableType ipe let label_str = maybe "" ((\(LexicalFastString s) -> unpackFS s) . snd) (infoTableProv ipe) let (src_loc_file, src_loc_span) = @@ -208,7 +207,7 @@ toCgIPE platform ctx ipe = do src_span <- lookupStringTable $ ST.pack src_loc_span return $ CgInfoProvEnt { ipeInfoTablePtr = infoTablePtr ipe , ipeTableName = table_name - , ipeClosureDesc = closure_desc + , ipeClosureDesc = fromIntegral (infoProvEntClosureType ipe) , ipeTypeDesc = type_desc , ipeLabel = label , ipeSrcFile = src_file @@ -218,7 +217,7 @@ toCgIPE platform ctx ipe = do data CgInfoProvEnt = CgInfoProvEnt { ipeInfoTablePtr :: !CLabel , ipeTableName :: !StrTabOffset - , ipeClosureDesc :: !StrTabOffset + , ipeClosureDesc :: !Word32 , ipeTypeDesc :: !StrTabOffset , ipeLabel :: !StrTabOffset , ipeSrcFile :: !StrTabOffset ===================================== libraries/ghc-internal/src/GHC/Internal/InfoProv/Types.hsc ===================================== @@ -18,8 +18,9 @@ module GHC.Internal.InfoProv.Types ) where import GHC.Internal.Base -import GHC.Internal.Data.Maybe import GHC.Internal.Enum +import GHC.Internal.Real (fromIntegral) +import GHC.Internal.Word (Word32) import GHC.Internal.Show (Show) import GHC.Internal.Ptr (Ptr(..), plusPtr) import GHC.Internal.Foreign.C.String.Encoding (CString, peekCString) @@ -28,7 +29,6 @@ import GHC.Internal.Foreign.Marshal.Alloc (allocaBytes) import GHC.Internal.IO.Encoding (utf8) import GHC.Internal.Foreign.Storable (peekByteOff) import GHC.Internal.ClosureTypes -import GHC.Internal.Text.Read import GHC.Prim (whereFrom##) data InfoProv = InfoProv { @@ -70,9 +70,11 @@ getIPE obj fail k = allocaBytes (#size InfoProvEnt) $ \p -> IO $ \s -> ipeProv :: Ptr InfoProvEnt -> Ptr InfoProv ipeProv p = (#ptr InfoProvEnt, prov) p -peekIpName, peekIpDesc, peekIpLabel, peekIpUnitId, peekIpModule, peekIpSrcFile, peekIpSrcSpan, peekIpTyDesc :: Ptr InfoProv -> IO CString -peekIpName p = (# peek InfoProv, table_name) p +peekIpDesc :: Ptr InfoProv -> IO Word32 peekIpDesc p = (# peek InfoProv, closure_desc) p + +peekIpName, peekIpLabel, peekIpUnitId, peekIpModule, peekIpSrcFile, peekIpSrcSpan, peekIpTyDesc :: Ptr InfoProv -> IO CString +peekIpName p = (# peek InfoProv, table_name) p peekIpLabel p = (# peek InfoProv, label) p peekIpUnitId p = (# peek InfoProv, unit_id) p peekIpModule p = (# peek InfoProv, module) p @@ -83,7 +85,7 @@ peekIpTyDesc p = (# peek InfoProv, ty_desc) p peekInfoProv :: Ptr InfoProv -> IO InfoProv peekInfoProv infop = do name <- peekCString utf8 =<< peekIpName infop - desc <- peekCString utf8 =<< peekIpDesc infop + desc <- peekIpDesc infop tyDesc <- peekCString utf8 =<< peekIpTyDesc infop label <- peekCString utf8 =<< peekIpLabel infop unit_id <- peekCString utf8 =<< peekIpUnitId infop @@ -94,7 +96,7 @@ peekInfoProv infop = do ipName = name, -- The INVALID_OBJECT case should be impossible as we -- control the C code generating these values. - ipDesc = maybe INVALID_OBJECT toEnum . readMaybe @Int $ desc, + ipDesc = toEnum $ fromIntegral desc, ipTyDesc = tyDesc, ipLabel = label, ipUnitId = unit_id, ===================================== rts/IPE.c ===================================== @@ -105,7 +105,7 @@ static InfoProvEnt ipeBufferEntryToIpe(const IpeBufferListNode *node, uint32_t i .info = node->tables[idx], .prov = { .table_name = &strings[ent->table_name], - .closure_desc = &strings[ent->closure_desc], + .closure_desc = ent->closure_desc, .ty_desc = &strings[ent->ty_desc], .label = &strings[ent->label], .unit_id = &strings[node->unit_id], ===================================== rts/Trace.c ===================================== @@ -689,7 +689,7 @@ void traceIPE(const InfoProvEnt *ipe) ACQUIRE_LOCK(&trace_utx); tracePreface(); - debugBelch("IPE: table_name %s, closure_desc %s, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", + debugBelch("IPE: table_name %s, closure_desc %d, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", ipe->prov.table_name, ipe->prov.closure_desc, ipe->prov.ty_desc, ipe->prov.label, ipe->prov.unit_id, ipe->prov.module, ipe->prov.src_file, ipe->prov.src_span); ===================================== rts/include/rts/IPE.h ===================================== @@ -15,7 +15,7 @@ typedef struct InfoProv_ { const char *table_name; - const char *closure_desc; + uint32_t closure_desc; // closure type const char *ty_desc; const char *label; const char *unit_id; @@ -54,7 +54,7 @@ typedef uint32_t StringIdx; // to ensure correct packing. typedef struct { StringIdx table_name; - StringIdx closure_desc; + uint32_t closure_desc; // closure type StringIdx ty_desc; StringIdx label; StringIdx src_file; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c71973116b1d9c51b77e28c5d768d1f31bb20e14 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c71973116b1d9c51b77e28c5d768d1f31bb20e14 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 18:58:35 2024 From: gitlab at gitlab.haskell.org (Serge S. Gulin (@gulin.serge)) Date: Mon, 06 May 2024 14:58:35 -0400 Subject: [Git][ghc/ghc][wip/T24504] IPE: Eliminate dependency on Read Message-ID: <6639285b9a743_17f48e3544dd813098f@gitlab.mail> Serge S. Gulin pushed to branch wip/T24504 at Glasgow Haskell Compiler / GHC Commits: 8b3d6c7b by Ben Gamari at 2024-05-06T21:57:56+03:00 IPE: Eliminate dependency on Read Instead of encoding the closure type as decimal string we now simply represent it as an integer, eliminating the need for `Read` in `GHC.Internal.InfoProv.Types.peekInfoProv`. Closes #24504. ------------------------- Metric Decrease: T24602_perf_size size_hello_artifact ------------------------- - - - - - 5 changed files: - compiler/GHC/StgToCmm/InfoTableProv.hs - libraries/ghc-internal/src/GHC/Internal/InfoProv/Types.hsc - rts/IPE.c - rts/Trace.c - rts/include/rts/IPE.h Changes: ===================================== compiler/GHC/StgToCmm/InfoTableProv.hs ===================================== @@ -178,7 +178,7 @@ toIpeBufferEntries byte_order cg_ipes = to_ipe_buf_ent :: CgInfoProvEnt -> [Word32] to_ipe_buf_ent cg_ipe = [ ipeTableName cg_ipe - , ipeClosureDesc cg_ipe + , fromIntegral $ ipeClosureDesc cg_ipe , ipeTypeDesc cg_ipe , ipeLabel cg_ipe , ipeSrcFile cg_ipe @@ -193,7 +193,6 @@ toIpeBufferEntries byte_order cg_ipes = toCgIPE :: Platform -> SDocContext -> InfoProvEnt -> State StringTable CgInfoProvEnt toCgIPE platform ctx ipe = do table_name <- lookupStringTable $ ST.pack $ renderWithContext ctx (pprCLabel platform (infoTablePtr ipe)) - closure_desc <- lookupStringTable $ ST.pack $ show (infoProvEntClosureType ipe) type_desc <- lookupStringTable $ ST.pack $ infoTableType ipe let label_str = maybe "" ((\(LexicalFastString s) -> unpackFS s) . snd) (infoTableProv ipe) let (src_loc_file, src_loc_span) = @@ -208,7 +207,7 @@ toCgIPE platform ctx ipe = do src_span <- lookupStringTable $ ST.pack src_loc_span return $ CgInfoProvEnt { ipeInfoTablePtr = infoTablePtr ipe , ipeTableName = table_name - , ipeClosureDesc = closure_desc + , ipeClosureDesc = fromIntegral (infoProvEntClosureType ipe) , ipeTypeDesc = type_desc , ipeLabel = label , ipeSrcFile = src_file @@ -218,7 +217,7 @@ toCgIPE platform ctx ipe = do data CgInfoProvEnt = CgInfoProvEnt { ipeInfoTablePtr :: !CLabel , ipeTableName :: !StrTabOffset - , ipeClosureDesc :: !StrTabOffset + , ipeClosureDesc :: !Word32 , ipeTypeDesc :: !StrTabOffset , ipeLabel :: !StrTabOffset , ipeSrcFile :: !StrTabOffset ===================================== libraries/ghc-internal/src/GHC/Internal/InfoProv/Types.hsc ===================================== @@ -18,8 +18,9 @@ module GHC.Internal.InfoProv.Types ) where import GHC.Internal.Base -import GHC.Internal.Data.Maybe import GHC.Internal.Enum +import GHC.Internal.Real (fromIntegral) +import GHC.Internal.Word (Word32) import GHC.Internal.Show (Show) import GHC.Internal.Ptr (Ptr(..), plusPtr) import GHC.Internal.Foreign.C.String.Encoding (CString, peekCString) @@ -28,7 +29,6 @@ import GHC.Internal.Foreign.Marshal.Alloc (allocaBytes) import GHC.Internal.IO.Encoding (utf8) import GHC.Internal.Foreign.Storable (peekByteOff) import GHC.Internal.ClosureTypes -import GHC.Internal.Text.Read import GHC.Prim (whereFrom##) data InfoProv = InfoProv { @@ -70,9 +70,11 @@ getIPE obj fail k = allocaBytes (#size InfoProvEnt) $ \p -> IO $ \s -> ipeProv :: Ptr InfoProvEnt -> Ptr InfoProv ipeProv p = (#ptr InfoProvEnt, prov) p -peekIpName, peekIpDesc, peekIpLabel, peekIpUnitId, peekIpModule, peekIpSrcFile, peekIpSrcSpan, peekIpTyDesc :: Ptr InfoProv -> IO CString -peekIpName p = (# peek InfoProv, table_name) p +peekIpDesc :: Ptr InfoProv -> IO Word32 peekIpDesc p = (# peek InfoProv, closure_desc) p + +peekIpName, peekIpLabel, peekIpUnitId, peekIpModule, peekIpSrcFile, peekIpSrcSpan, peekIpTyDesc :: Ptr InfoProv -> IO CString +peekIpName p = (# peek InfoProv, table_name) p peekIpLabel p = (# peek InfoProv, label) p peekIpUnitId p = (# peek InfoProv, unit_id) p peekIpModule p = (# peek InfoProv, module) p @@ -83,7 +85,7 @@ peekIpTyDesc p = (# peek InfoProv, ty_desc) p peekInfoProv :: Ptr InfoProv -> IO InfoProv peekInfoProv infop = do name <- peekCString utf8 =<< peekIpName infop - desc <- peekCString utf8 =<< peekIpDesc infop + desc <- peekIpDesc infop tyDesc <- peekCString utf8 =<< peekIpTyDesc infop label <- peekCString utf8 =<< peekIpLabel infop unit_id <- peekCString utf8 =<< peekIpUnitId infop @@ -94,7 +96,7 @@ peekInfoProv infop = do ipName = name, -- The INVALID_OBJECT case should be impossible as we -- control the C code generating these values. - ipDesc = maybe INVALID_OBJECT toEnum . readMaybe @Int $ desc, + ipDesc = toEnum $ fromIntegral desc, ipTyDesc = tyDesc, ipLabel = label, ipUnitId = unit_id, ===================================== rts/IPE.c ===================================== @@ -105,7 +105,7 @@ static InfoProvEnt ipeBufferEntryToIpe(const IpeBufferListNode *node, uint32_t i .info = node->tables[idx], .prov = { .table_name = &strings[ent->table_name], - .closure_desc = &strings[ent->closure_desc], + .closure_desc = ent->closure_desc, .ty_desc = &strings[ent->ty_desc], .label = &strings[ent->label], .unit_id = &strings[node->unit_id], ===================================== rts/Trace.c ===================================== @@ -689,7 +689,7 @@ void traceIPE(const InfoProvEnt *ipe) ACQUIRE_LOCK(&trace_utx); tracePreface(); - debugBelch("IPE: table_name %s, closure_desc %s, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", + debugBelch("IPE: table_name %s, closure_desc %d, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", ipe->prov.table_name, ipe->prov.closure_desc, ipe->prov.ty_desc, ipe->prov.label, ipe->prov.unit_id, ipe->prov.module, ipe->prov.src_file, ipe->prov.src_span); ===================================== rts/include/rts/IPE.h ===================================== @@ -15,7 +15,7 @@ typedef struct InfoProv_ { const char *table_name; - const char *closure_desc; + uint32_t closure_desc; // closure type const char *ty_desc; const char *label; const char *unit_id; @@ -54,7 +54,7 @@ typedef uint32_t StringIdx; // to ensure correct packing. typedef struct { StringIdx table_name; - StringIdx closure_desc; + uint32_t closure_desc; // closure type StringIdx ty_desc; StringIdx label; StringIdx src_file; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8b3d6c7b028f1a1b0719c18b7d90de6250a354da -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8b3d6c7b028f1a1b0719c18b7d90de6250a354da You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 23:54:55 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 06 May 2024 19:54:55 -0400 Subject: [Git][ghc/ghc][master] Add test cases for #24664 Message-ID: <66396dcfdf4ac_17f48e58ac8c016018f@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a19201d4 by Matthew Craven at 2024-05-06T19:54:29-04:00 Add test cases for #24664 ...since none are present in the original MR !12463 fixing this issue. - - - - - 5 changed files: - + testsuite/tests/codeGen/should_run/T24664a.hs - + testsuite/tests/codeGen/should_run/T24664a.stdout - + testsuite/tests/codeGen/should_run/T24664b.hs - + testsuite/tests/codeGen/should_run/T24664b.stdout - testsuite/tests/codeGen/should_run/all.T Changes: ===================================== testsuite/tests/codeGen/should_run/T24664a.hs ===================================== @@ -0,0 +1,27 @@ +-- This program tests the passing of RUBBISH values +-- with the Int64 representation, which were found +-- to by mis-handled by the JS backend in #24664. + +{-# LANGUAGE MagicHash #-} + +module Main where + +import GHC.Exts (Int64#, intToInt64#) + +takesInt64a :: String -> Int64# -> String -> IO () +{-# OPAQUE takesInt64a #-} +-- Idea: This function takes an Int64# but doesn't use it, +-- so that its argument might be turned into a rubbish literal. +-- We don't want WW to remove the argument entirely, so OPAQUE +takesInt64a str1 _ str2 = putStrLn str1 >> putStrLn str2 + +takesInt64b :: Int64# -> IO () +{-# NOINLINE takesInt64b #-} +-- Idea: This function will get a worker that doesn't take an +-- Int64# at all, and the body of that worker will pass a +-- rubbish literal to takesInt64a since no real arg exists. +takesInt64b x = takesInt64a "first string to print" x "second string to print" + +main :: IO () +main = do + takesInt64b (intToInt64# 12345#) ===================================== testsuite/tests/codeGen/should_run/T24664a.stdout ===================================== @@ -0,0 +1,2 @@ +first string to print +second string to print ===================================== testsuite/tests/codeGen/should_run/T24664b.hs ===================================== @@ -0,0 +1,31 @@ +-- This is a variant of T24664a that could reproduce +-- the compiler crash originally observed in #24664. + +{-# LANGUAGE MagicHash #-} + +module Main where + +import GHC.Exts (Int64#, intToInt64#, uncheckedIShiftRL64#) + +takesInt64a :: String -> Int64# -> String -> IO () +{-# OPAQUE takesInt64a #-} +-- Idea: This function takes an Int64# but doesn't use it, +-- so that its argument might be turned into a rubbish literal. +-- We don't want WW to remove the argument entirely, so OPAQUE +takesInt64a str1 _ str2 = putStrLn str1 >> putStrLn str2 + +takesInt64b :: String -> Int64# -> String -> IO () +{-# NOINLINE takesInt64b #-} +-- Idea: This function will get a worker that doesn't take an +-- Int64# at all, and the body of that worker will pass a +-- rubbish literal to takesInt64a since no real arg exists. +takesInt64b s1 x s2 + = takesInt64a (s1 ++ t) (x `uncheckedIShiftRL64#` 13#) (s2 ++ t) + where t = " string to print" + +takesInt64c :: Int64# -> IO () +takesInt64c x = takesInt64b "first" x "second" + +main :: IO () +main = do + takesInt64c (intToInt64# 12345#) ===================================== testsuite/tests/codeGen/should_run/T24664b.stdout ===================================== @@ -0,0 +1,2 @@ +first string to print +second string to print ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -243,3 +243,6 @@ test('MulMayOflo_full', test('T24264run', normal, compile_and_run, ['']) test('T24295a', normal, compile_and_run, ['-O -floopification']) test('T24295b', normal, compile_and_run, ['-O -floopification -fpedantic-bottoms']) +test('T24664a', normal, compile_and_run, ['-O']) +test('T24664b', normal, compile_and_run, ['-O']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a19201d42cfd3aa54faeb1b5a95b715b9a67a01a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a19201d42cfd3aa54faeb1b5a95b715b9a67a01a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon May 6 23:55:52 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 06 May 2024 19:55:52 -0400 Subject: [Git][ghc/ghc][master] EPA: preserve comments in data decls Message-ID: <66396e082a2e8_17f48e5a5aaa0164720@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 46328a49 by Alan Zimmerman at 2024-05-06T19:55:05-04:00 EPA: preserve comments in data decls Closes #24771 - - - - - 6 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - testsuite/tests/printer/Makefile - testsuite/tests/printer/Test24755.hs - + testsuite/tests/printer/Test24771.hs - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -2486,9 +2486,8 @@ forall :: { Located ([AddEpAnn], Maybe [LHsTyVarBndr Specificity GhcPs]) } | {- empty -} { noLoc ([], Nothing) } constr_stuff :: { Located (LocatedN RdrName, HsConDeclH98Details GhcPs) } - : infixtype {% fmap (reLoc. (fmap (\b -> (dataConBuilderCon b, - dataConBuilderDetails b)))) - (runPV $1) } + : infixtype {% do { b <- runPV $1 + ; return (sL1 b (dataConBuilderCon b, dataConBuilderDetails b)) }} | '(#' usum_constr '#)' {% let (t, tag, arity) = $2 in pure (sLL $1 $3 $ mkUnboxedSumCon t tag arity)} usum_constr :: { (LHsType GhcPs, Int, Int) } -- constructor for the data decls SumN# ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -236,7 +236,8 @@ mkTyData loc' is_type_data new_or_data cType (L _ (mcxt, tycl_hdr)) ; let anns' = annsIn Semi.<> ann ; data_cons <- checkNewOrData loc' (unLoc tc) is_type_data new_or_data data_cons ; defn <- mkDataDefn cType mcxt ksig data_cons maybe_deriv - ; let loc = EpAnn (spanAsAnchor loc') noAnn cs + ; !cs' <- getCommentsFor loc' + ; let loc = EpAnn (spanAsAnchor loc') noAnn (cs' Semi.<> cs) ; return (L loc (DataDecl { tcdDExt = anns', tcdLName = tc, tcdTyVars = tyvars, tcdFixity = fixity, @@ -2065,25 +2066,26 @@ instance DisambTD (HsType GhcPs) where return (L (addCommentsToEpAnn l cs) ty) mkUnpackednessPV = addUnpackednessP -dataConBuilderCon :: DataConBuilder -> LocatedN RdrName -dataConBuilderCon (PrefixDataConBuilder _ dc) = dc -dataConBuilderCon (InfixDataConBuilder _ dc _) = dc +dataConBuilderCon :: LocatedA DataConBuilder -> LocatedN RdrName +dataConBuilderCon (L _ (PrefixDataConBuilder _ dc)) = dc +dataConBuilderCon (L _ (InfixDataConBuilder _ dc _)) = dc -dataConBuilderDetails :: DataConBuilder -> HsConDeclH98Details GhcPs +dataConBuilderDetails :: LocatedA DataConBuilder -> HsConDeclH98Details GhcPs -- Detect when the record syntax is used: -- data T = MkT { ... } -dataConBuilderDetails (PrefixDataConBuilder flds _) +dataConBuilderDetails (L _ (PrefixDataConBuilder flds _)) | [L (EpAnn anc _ cs) (HsRecTy an fields)] <- toList flds = RecCon (L (EpAnn anc an cs) fields) -- Normal prefix constructor, e.g. data T = MkT A B C -dataConBuilderDetails (PrefixDataConBuilder flds _) +dataConBuilderDetails (L _ (PrefixDataConBuilder flds _)) = PrefixCon noTypeArgs (map hsLinear (toList flds)) -- Infix constructor, e.g. data T = Int :! Bool -dataConBuilderDetails (InfixDataConBuilder lhs _ rhs) - = InfixCon (hsLinear lhs) (hsLinear rhs) +dataConBuilderDetails (L (EpAnn _ _ csl) (InfixDataConBuilder (L (EpAnn anc ann csll) lhs) _ rhs)) + = InfixCon (hsLinear (L (EpAnn anc ann (csl Semi.<> csll)) lhs)) (hsLinear rhs) + instance DisambTD DataConBuilder where mkHsAppTyHeadPV = tyToDataConBuilder ===================================== testsuite/tests/printer/Makefile ===================================== @@ -866,3 +866,8 @@ Test24755: Test24753: $(CHECK_PPR) $(LIBDIR) Test24753.hs $(CHECK_EXACT) $(LIBDIR) Test24753.hs + +.PHONY: Test24771 +Test24771: + $(CHECK_PPR) $(LIBDIR) Test24771.hs + $(CHECK_EXACT) $(LIBDIR) Test24771.hs ===================================== testsuite/tests/printer/Test24755.hs ===================================== @@ -3,6 +3,6 @@ module Test24755 where class - a -- Before operator - :+ - b -- After operator + a -- c1 + :+ -- c2 + b -- c3 ===================================== testsuite/tests/printer/Test24771.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeOperators #-} +module Test24771 where + +data Foo + = Int -- c1 + :* -- c2 + String -- c3 ===================================== testsuite/tests/printer/all.T ===================================== @@ -206,3 +206,4 @@ test('Test24749', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24749']) test('Test24754', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24754']) test('Test24755', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24755']) test('Test24753', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24753']) +test('Test24771', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24771']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/46328a49d988143111ab530d7907b9426b58311a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/46328a49d988143111ab530d7907b9426b58311a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 07:12:22 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Tue, 07 May 2024 03:12:22 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/improve-pat-to-ty] Improve pattern to type pattern transformation (23739) Message-ID: <6639d4562d98f_cb8f018483d8286e6@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/improve-pat-to-ty at Glasgow Haskell Compiler / GHC Commits: 2c1e4eea by Andrei Borzenkov at 2024-05-07T11:11:54+04:00 Improve pattern to type pattern transformation (23739) `pat_to_type_pat` function now can handle more patterns: - TuplePat - ListPat - LitPat - NPat - ConPat Allowing these new constructors in type patterns significantly increases possible shapes of type patterns without `type` keyword. This patch also changes how lookups in `lookupOccRnConstr` are performed, because we need to fall back into types when we didn't find a constructor on data level to perform `ConPat` to type transformation properly. - - - - - 15 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Utils/Env.hs - testsuite/tests/rename/should_fail/T19843c.stderr - testsuite/tests/type-data/should_fail/TDPattern.stderr - + testsuite/tests/typecheck/should_compile/T23739a.hs - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T23739b.hs - + testsuite/tests/typecheck/should_fail/T23739b.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -38,6 +38,7 @@ module GHC.Hs.Type ( HsWildCardBndrs(..), HsPatSigType(..), HsPSRn(..), HsTyPat(..), HsTyPatRn(..), + HsTyPatRnBuilder(..), tpBuilderExplicitTV, tpBuilderPatSig, buildHsTyPatRn, builderFromHsTyPatRn, HsSigType(..), LHsSigType, LHsSigWcType, LHsWcType, HsTupleSort(..), HsContext, LHsContext, fromMaybeContext, @@ -128,6 +129,7 @@ import Data.Maybe import Data.Data (Data) import qualified Data.Semigroup as S +import GHC.Data.Bag {- ************************************************************************ @@ -245,6 +247,51 @@ data HsTyPatRn = HsTPRn } deriving Data +-- | A variant of HsTyPatRn that uses Bags for efficient concatenation. +-- See Note [Implicit and explicit type variable binders] in GHC.Rename.Pat +data HsTyPatRnBuilder = + HsTPRnB { + hstpb_nwcs :: Bag Name, + hstpb_imp_tvs :: Bag Name, + hstpb_exp_tvs :: Bag Name + } + +tpBuilderExplicitTV :: Name -> HsTyPatRnBuilder +tpBuilderExplicitTV name = mempty {hstpb_exp_tvs = unitBag name} + +tpBuilderPatSig :: HsPSRn -> HsTyPatRnBuilder +tpBuilderPatSig HsPSRn {hsps_nwcs, hsps_imp_tvs} = + mempty { + hstpb_nwcs = listToBag hsps_nwcs, + hstpb_imp_tvs = listToBag hsps_imp_tvs + } + +instance Semigroup HsTyPatRnBuilder where + HsTPRnB nwcs1 imp_tvs1 exptvs1 <> HsTPRnB nwcs2 imp_tvs2 exptvs2 = + HsTPRnB + (nwcs1 `unionBags` nwcs2) + (imp_tvs1 `unionBags` imp_tvs2) + (exptvs1 `unionBags` exptvs2) + +instance Monoid HsTyPatRnBuilder where + mempty = HsTPRnB emptyBag emptyBag emptyBag + +buildHsTyPatRn :: HsTyPatRnBuilder -> HsTyPatRn +buildHsTyPatRn HsTPRnB {hstpb_nwcs, hstpb_imp_tvs, hstpb_exp_tvs} = + HsTPRn { + hstp_nwcs = bagToList hstpb_nwcs, + hstp_imp_tvs = bagToList hstpb_imp_tvs, + hstp_exp_tvs = bagToList hstpb_exp_tvs + } + +builderFromHsTyPatRn :: HsTyPatRn -> HsTyPatRnBuilder +builderFromHsTyPatRn HsTPRn{hstp_nwcs, hstp_imp_tvs, hstp_exp_tvs} = + HsTPRnB { + hstpb_nwcs = listToBag hstp_nwcs, + hstpb_imp_tvs = listToBag hstp_imp_tvs, + hstpb_exp_tvs = listToBag hstp_exp_tvs + } + type instance XXHsPatSigType (GhcPass _) = DataConCantHappen type instance XXHsTyPat (GhcPass _) = DataConCantHappen ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -1032,7 +1032,15 @@ lookupOccRn = lookupOccRn' WL_Anything -- lookupOccRnConstr looks up an occurrence of a RdrName and displays -- constructors and pattern synonyms as suggestions if it is not in scope lookupOccRnConstr :: RdrName -> RnM Name -lookupOccRnConstr = lookupOccRn' WL_Constructor +lookupOccRnConstr rdr_name + = do { mb_gre <- lookupOccRn_maybe rdr_name + ; case mb_gre of + Just gre -> return $ greName gre + Nothing -> do + { mb_ty_gre <- lookup_promoted rdr_name + ; case mb_ty_gre of + Just gre -> return $ greName gre + Nothing -> reportUnboundName' WL_Constructor rdr_name} } -- lookupOccRnRecField looks up an occurrence of a RdrName and displays -- record fields as suggestions if it is not in scope ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -71,7 +71,6 @@ import GHC.Types.SourceText import GHC.Utils.Misc import GHC.Data.FastString ( uniqCompareFS ) import GHC.Data.List.SetOps( removeDups ) -import GHC.Data.Bag ( Bag, unitBag, unionBags, emptyBag, listToBag, bagToList ) import GHC.Utils.Outputable import GHC.Utils.Panic.Plain import GHC.Types.SrcLoc @@ -89,7 +88,6 @@ import Data.Functor.Identity ( Identity (..) ) import qualified Data.List.NonEmpty as NE import Data.Maybe import Data.Ratio -import qualified Data.Semigroup as S import Control.Monad.Trans.Writer.CPS import Control.Monad.Trans.Class import Control.Monad.Trans.Reader @@ -1242,43 +1240,6 @@ lookupTypeOccTPRnM rdr_name = liftRnFV $ do name <- lookupTypeOccRn rdr_name pure (name, unitFV name) --- | A variant of HsTyPatRn that uses Bags for efficient concatenation. --- See Note [Implicit and explicit type variable binders] -data HsTyPatRnBuilder = - HsTPRnB { - hstpb_nwcs :: Bag Name, - hstpb_imp_tvs :: Bag Name, - hstpb_exp_tvs :: Bag Name - } - -tpb_exp_tv :: Name -> HsTyPatRnBuilder -tpb_exp_tv name = mempty {hstpb_exp_tvs = unitBag name} - -tpb_hsps :: HsPSRn -> HsTyPatRnBuilder -tpb_hsps HsPSRn {hsps_nwcs, hsps_imp_tvs} = - mempty { - hstpb_nwcs = listToBag hsps_nwcs, - hstpb_imp_tvs = listToBag hsps_imp_tvs - } - -instance Semigroup HsTyPatRnBuilder where - HsTPRnB nwcs1 imp_tvs1 exptvs1 <> HsTPRnB nwcs2 imp_tvs2 exptvs2 = - HsTPRnB - (nwcs1 `unionBags` nwcs2) - (imp_tvs1 `unionBags` imp_tvs2) - (exptvs1 `unionBags` exptvs2) - -instance Monoid HsTyPatRnBuilder where - mempty = HsTPRnB emptyBag emptyBag emptyBag - -buildHsTyPatRn :: HsTyPatRnBuilder -> HsTyPatRn -buildHsTyPatRn HsTPRnB {hstpb_nwcs, hstpb_imp_tvs, hstpb_exp_tvs} = - HsTPRn { - hstp_nwcs = bagToList hstpb_nwcs, - hstp_imp_tvs = bagToList hstpb_imp_tvs, - hstp_exp_tvs = bagToList hstpb_exp_tvs - } - rn_lty_pat :: LHsType GhcPs -> TPRnM (LHsType GhcRn) rn_lty_pat (L l hs_ty) = do hs_ty' <- rn_ty_pat hs_ty @@ -1292,7 +1253,7 @@ rn_ty_pat_var lrdr@(L l rdr) = do then do -- binder name <- liftTPRnCps $ newPatName (LamMk True) lrdr - tellTPB (tpb_exp_tv name) + tellTPB (tpBuilderExplicitTV name) pure (L l name) else do -- usage @@ -1413,7 +1374,7 @@ rn_ty_pat (HsKindSig an ty ki) = do ~(HsPS hsps ki') <- liftRnWithCont $ rnHsPatSigKind AlwaysBind ctxt (HsPS noAnn ki) ty' <- rn_lty_pat ty - tellTPB (tpb_hsps hsps) + tellTPB (tpBuilderPatSig hsps) pure (HsKindSig an ty' ki') rn_ty_pat (HsSpliceTy _ splice) = do ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -56,7 +56,6 @@ import GHC.Types.Name.Env import GHC.Types.Name.Reader import GHC.Types.SrcLoc import GHC.Types.Var.Env ( emptyTidyEnv, mkInScopeSet ) -import GHC.Types.SourceText import GHC.Data.Maybe import GHC.Utils.Misc import GHC.Utils.Outputable as Outputable @@ -899,18 +898,12 @@ expr_to_type earg = where unwrap_op_tv (L _ (HsTyVar _ _ op_id)) = return op_id unwrap_op_tv _ = failWith $ TcRnIllformedTypeArgument (L l e) - go (L l e@(HsOverLit _ lit)) = - do { tylit <- case ol_val lit of - HsIntegral n -> return $ HsNumTy NoSourceText (il_value n) - HsIsString _ s -> return $ HsStrTy NoSourceText s - HsFractional _ -> failWith $ TcRnIllformedTypeArgument (L l e) - ; return (L l (HsTyLit noExtField tylit)) } - go (L l e@(HsLit _ lit)) = - do { tylit <- case lit of - HsChar _ c -> return $ HsCharTy NoSourceText c - HsString _ s -> return $ HsStrTy NoSourceText s - _ -> failWith $ TcRnIllformedTypeArgument (L l e) - ; return (L l (HsTyLit noExtField tylit)) } + go (L l (HsOverLit _ lit)) + | Just tylit <- tyLitFromOverloadedLit (ol_val lit) + = return (L l (HsTyLit noExtField tylit)) + go (L l (HsLit _ lit)) + | Just tylit <- tyLitFromLit lit + = return (L l (HsTyLit noExtField tylit)) go (L l (ExplicitTuple _ tup_args boxity)) -- Neither unboxed tuples (#e1,e2#) nor tuple sections (e1,,e2,) can be promoted | isBoxed boxity ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -37,8 +37,6 @@ import GHC.Hs import GHC.Hs.Syn.Type import GHC.Tc.Gen.HsType -import GHC.Rename.Unbound ( unknownNameSuggestions, WhatLooking(..) ) - import GHC.Tc.Gen.Bind( chooseInferredQuantifiers ) import GHC.Tc.Gen.Sig( tcUserTypeSig, tcInstSig ) import GHC.Tc.TyCl.PatSyn( patSynBuilderOcc ) @@ -78,15 +76,14 @@ import GHC.Builtin.Types( multiplicityTy ) import GHC.Builtin.Names import GHC.Builtin.Names.TH( liftStringName, liftName ) -import GHC.Driver.Env import GHC.Driver.DynFlags import GHC.Utils.Misc import GHC.Utils.Outputable as Outputable import GHC.Utils.Panic -import qualified GHC.LanguageExtensions as LangExt import GHC.Data.Maybe import Control.Monad +import GHC.Rename.Unbound (WhatLooking(WL_Anything)) @@ -1164,46 +1161,11 @@ tc_infer_id id_name AGlobal (AConLike (RealDataCon con)) -> tcInferDataCon con AGlobal (AConLike (PatSynCon ps)) -> tcInferPatSyn id_name ps - (tcTyThingTyCon_maybe -> Just tc) -> fail_tycon tc -- TyCon or TcTyCon - ATyVar name _ -> fail_tyvar name + (tcTyThingTyCon_maybe -> Just tc) -> failIllegalTyCon WL_Anything tc -- TyCon or TcTyCon + ATyVar name _ -> failIllegalTyVal name _ -> failWithTc $ TcRnExpectedValueId thing } where - fail_tycon tc = do - gre <- getGlobalRdrEnv - let nm = tyConName tc - pprov = case lookupGRE_Name gre nm of - Just gre -> nest 2 (pprNameProvenance gre) - Nothing -> empty - err | isClassTyCon tc = ClassTE - | otherwise = TyConTE - fail_with_msg dataName nm pprov err - - fail_tyvar nm = - let pprov = nest 2 (text "bound at" <+> ppr (getSrcLoc nm)) - in fail_with_msg varName nm pprov TyVarTE - - fail_with_msg whatName nm pprov err = do - (import_errs, hints) <- get_suggestions whatName - unit_state <- hsc_units <$> getTopEnv - let - -- TODO: unfortunate to have to convert to SDoc here. - -- This should go away once we refactor ErrInfo. - hint_msg = vcat $ map ppr hints - import_err_msg = vcat $ map ppr import_errs - info = ErrInfo { errInfoContext = pprov, errInfoSupplementary = import_err_msg $$ hint_msg } - failWithTc $ TcRnMessageWithInfo unit_state ( - mkDetailedMessage info (TcRnIllegalTermLevelUse nm err)) - - get_suggestions ns = do - required_type_arguments <- xoptM LangExt.RequiredTypeArguments - if required_type_arguments && isVarNameSpace ns - then return ([], []) -- See Note [Suppress hints with RequiredTypeArguments] - else do - let occ = mkOccNameFS ns (occNameFS (occName id_name)) - lcl_env <- getLocalRdrEnv - unknownNameSuggestions lcl_env WL_Anything (mkRdrUnqual occ) - return_id id = return (HsVar noExtField (noLocA id), idType id) {- Note [Suppress hints with RequiredTypeArguments] ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -73,7 +73,10 @@ module GHC.Tc.Gen.HsType ( HoleMode(..), -- Error messages - funAppCtxt, addTyConFlavCtxt + funAppCtxt, addTyConFlavCtxt, + + -- Utils + tyLitFromLit, tyLitFromOverloadedLit, ) where import GHC.Prelude hiding ( head, init, last, tail ) @@ -140,6 +143,7 @@ import qualified Data.List.NonEmpty as NE import Data.List ( mapAccumL ) import Control.Monad import Data.Tuple( swap ) +import GHC.Types.SourceText {- ---------------------------- @@ -4689,3 +4693,22 @@ addTyConFlavCtxt :: Name -> TyConFlavour tc -> TcM a -> TcM a addTyConFlavCtxt name flav = addErrCtxt $ hsep [ text "In the", ppr flav , text "declaration for", quotes (ppr name) ] + +{- +************************************************************************ +* * + Utils for constructing TyLit +* * +************************************************************************ +-} + + +tyLitFromLit :: HsLit GhcRn -> Maybe (HsTyLit GhcRn) +tyLitFromLit (HsString x str) = Just (HsStrTy x str) +tyLitFromLit (HsChar x char) = Just (HsCharTy x char) +tyLitFromLit _ = Nothing + +tyLitFromOverloadedLit :: OverLitVal -> Maybe (HsTyLit GhcRn) +tyLitFromOverloadedLit (HsIntegral n) = Just $ HsNumTy NoSourceText (il_value n) +tyLitFromOverloadedLit (HsIsString _ s) = Just $ HsStrTy NoSourceText s +tyLitFromOverloadedLit HsFractional{} = Nothing ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -78,6 +78,8 @@ import Language.Haskell.Syntax.Basic (FieldLabelString(..)) import Data.List( partition ) import Data.Maybe (isJust) +import Control.Monad.Trans.Writer.CPS +import Control.Monad.Trans.Class {- ************************************************************************ @@ -504,53 +506,74 @@ tc_forall_pat tv _ pat thing_inside ; let pat' = XPat $ ExpansionPat pat (EmbTyPat arg_ty tp) ; return (pat', result) } + -- Convert a Pat into the equivalent HsTyPat. -- See `expr_to_type` (GHC.Tc.Gen.App) for the HsExpr counterpart. -- The `TcM` monad is only used to fail on ill-formed type patterns. pat_to_type_pat :: Pat GhcRn -> TcM (HsTyPat GhcRn) -pat_to_type_pat (EmbTyPat _ tp) = return tp -pat_to_type_pat (VarPat _ lname) = return (HsTP x b) +pat_to_type_pat pat = do + (ty, x) <- runWriterT (pat_to_type pat) + pure (HsTP (buildHsTyPatRn x) ty) + +pat_to_type :: Pat GhcRn -> WriterT HsTyPatRnBuilder TcM (LHsType GhcRn) +pat_to_type (EmbTyPat _ (HsTP x t)) = + do { tell (builderFromHsTyPatRn x) + ; return t } +pat_to_type (VarPat _ lname) = + do { tell (tpBuilderExplicitTV (unLoc lname)) + ; return b } where b = noLocA (HsTyVar noAnn NotPromoted lname) - x = HsTPRn { hstp_nwcs = [] - , hstp_imp_tvs = [] - , hstp_exp_tvs = [unLoc lname] } -pat_to_type_pat (WildPat _) = return (HsTP x b) +pat_to_type (WildPat _) = return b where b = noLocA (HsWildCardTy noExtField) - x = HsTPRn { hstp_nwcs = [] - , hstp_imp_tvs = [] - , hstp_exp_tvs = [] } -pat_to_type_pat (SigPat _ pat sig_ty) - = do { HsTP x_hstp t <- pat_to_type_pat (unLoc pat) +pat_to_type (SigPat _ pat sig_ty) + = do { t <- pat_to_type (unLoc pat) ; let { !(HsPS x_hsps k) = sig_ty - ; x = append_hstp_hsps x_hstp x_hsps ; b = noLocA (HsKindSig noAnn t k) } - ; return (HsTP x b) } - where - -- Quadratic for nested signatures ((p :: t1) :: t2) - -- but those are unlikely to occur in practice. - append_hstp_hsps :: HsTyPatRn -> HsPSRn -> HsTyPatRn - append_hstp_hsps t p - = HsTPRn { hstp_nwcs = hstp_nwcs t ++ hsps_nwcs p - , hstp_imp_tvs = hstp_imp_tvs t ++ hsps_imp_tvs p - , hstp_exp_tvs = hstp_exp_tvs t } -pat_to_type_pat (ParPat _ pat) - = do { HsTP x t <- pat_to_type_pat (unLoc pat) - ; return (HsTP x (noLocA (HsParTy noAnn t))) } -pat_to_type_pat (SplicePat (HsUntypedSpliceTop mod_finalizers pat) splice) = do - { HsTP x t <- pat_to_type_pat pat - ; return (HsTP x (noLocA (HsSpliceTy (HsUntypedSpliceTop mod_finalizers t) splice))) } -pat_to_type_pat pat = - -- There are other cases to handle (ConPat, ListPat, TuplePat, etc), but these - -- would always be rejected by the unification in `tcHsTyPat`, so it's fine to - -- skip them here. This won't continue to be the case when visible forall is - -- permitted in data constructors: - -- - -- data T a where { Typed :: forall a -> a -> T a } - -- g :: T Int -> Int - -- g (Typed Int x) = x -- Note the `Int` type pattern - -- - -- See ticket #18389. When this feature lands, it would be best to extend - -- `pat_to_type_pat` to handle as many pattern forms as possible. + ; tell (tpBuilderPatSig x_hsps) + ; return b } +pat_to_type (ParPat _ pat) + = do { t <- pat_to_type (unLoc pat) + ; return (noLocA (HsParTy noAnn t)) } +pat_to_type (SplicePat (HsUntypedSpliceTop mod_finalizers pat) splice) = do + { t <- pat_to_type pat + ; return (noLocA (HsSpliceTy (HsUntypedSpliceTop mod_finalizers t) splice)) } + +pat_to_type (TuplePat _ pats Boxed) + = do { tys <- traverse (pat_to_type . unLoc) pats + ; let t = noLocA (HsExplicitTupleTy noExtField tys) + ; pure t } +pat_to_type (ListPat _ pats) + = do { tys <- traverse (pat_to_type . unLoc) pats + ; let t = noLocA (HsExplicitListTy NoExtField NotPromoted tys) + ; pure t } + +pat_to_type (LitPat _ lit) + | Just ty_lit <- tyLitFromLit lit + = do { let t = noLocA (HsTyLit noExtField ty_lit) + ; pure t } +pat_to_type (NPat _ (L _ lit) _ _) + | Just ty_lit <- tyLitFromOverloadedLit (ol_val lit) + = do { let t = noLocA (HsTyLit noExtField ty_lit) + ; pure t} + +pat_to_type (ConPat _ lname (InfixCon left right)) + = do { lty <- pat_to_type (unLoc left) + ; rty <- pat_to_type (unLoc right) + ; let { t = noLocA (HsOpTy noAnn NotPromoted lty lname rty)} + ; pure t } +pat_to_type (ConPat _ lname (PrefixCon invis_args vis_args)) + = do { let { appHead = noLocA (HsTyVar noAnn NotPromoted lname)} + ; ty_invis <- foldM apply_invis_arg appHead invis_args + ; tys_vis <- traverse (pat_to_type . unLoc) vis_args + ; let t = foldl' mkHsAppTy ty_invis tys_vis + ; pure t } + where + apply_invis_arg :: LHsType GhcRn -> HsConPatTyArg GhcRn -> WriterT HsTyPatRnBuilder TcM (LHsType GhcRn) + apply_invis_arg !t (HsConPatTyArg _ (HsTP argx arg)) + = do { tell (builderFromHsTyPatRn argx) + ; pure (mkHsAppKindTy noExtField t arg)} + +pat_to_type pat = lift $ failWith $ TcRnIllformedTypePattern pat -- This failure is the only use of the TcM monad in `pat_to_type_pat` ===================================== compiler/GHC/Tc/Utils/Env.hs ===================================== @@ -28,6 +28,7 @@ module GHC.Tc.Utils.Env( tcLookupLocatedClass, tcLookupAxiom, lookupGlobal, lookupGlobal_maybe, addTypecheckedBinds, + failIllegalTyCon, failIllegalTyVal, -- Local environment tcExtendKindEnv, tcExtendKindEnvList, @@ -137,6 +138,7 @@ import Data.List ( intercalate ) import Control.Monad import GHC.Iface.Errors.Types import GHC.Types.Error +import GHC.Rename.Unbound ( unknownNameSuggestions, WhatLooking(..) ) {- ********************************************************************* * * @@ -278,6 +280,7 @@ tcLookupConLike name = do thing <- tcLookupGlobal name case thing of AConLike cl -> return cl + ATyCon tc -> failIllegalTyCon WL_Constructor tc _ -> wrongThingErr WrongThingConLike (AGlobal thing) name tcLookupRecSelParent :: HsRecUpdParent GhcRn -> TcM RecSelParent @@ -349,6 +352,45 @@ tcGetInstEnvs = do { eps <- getEps instance MonadThings (IOEnv (Env TcGblEnv TcLclEnv)) where lookupThing = tcLookupGlobal +-- Illegal term-level use of type things +failIllegalTyCon :: WhatLooking -> TyCon -> TcM a +failIllegalTyVal :: Name -> TcM a +(failIllegalTyCon, failIllegalTyVal) = (fail_tycon, fail_tyvar) + where + fail_tycon what_looking tc = do + gre <- getGlobalRdrEnv + let nm = tyConName tc + pprov = case lookupGRE_Name gre nm of + Just gre -> nest 2 (pprNameProvenance gre) + Nothing -> empty + err | isClassTyCon tc = ClassTE + | otherwise = TyConTE + fail_with_msg what_looking dataName nm pprov err + + fail_tyvar nm = + let pprov = nest 2 (text "bound at" <+> ppr (getSrcLoc nm)) + in fail_with_msg WL_Anything varName nm pprov TyVarTE + + fail_with_msg what_looking whatName nm pprov err = do + (import_errs, hints) <- get_suggestions what_looking whatName nm + unit_state <- hsc_units <$> getTopEnv + let + -- TODO: unfortunate to have to convert to SDoc here. + -- This should go away once we refactor ErrInfo. + hint_msg = vcat $ map ppr hints + import_err_msg = vcat $ map ppr import_errs + info = ErrInfo { errInfoContext = pprov, errInfoSupplementary = import_err_msg $$ hint_msg } + failWithTc $ TcRnMessageWithInfo unit_state ( + mkDetailedMessage info (TcRnIllegalTermLevelUse nm err)) + + get_suggestions what_looking ns nm = do + required_type_arguments <- xoptM LangExt.RequiredTypeArguments + if required_type_arguments && isVarNameSpace ns + then return ([], []) -- See Note [Suppress hints with RequiredTypeArguments] + else do + let occ = mkOccNameFS ns (occNameFS (occName nm)) + lcl_env <- getLocalRdrEnv + unknownNameSuggestions lcl_env what_looking (mkRdrUnqual occ) {- ************************************************************************ * * ===================================== testsuite/tests/rename/should_fail/T19843c.stderr ===================================== @@ -1,4 +1,7 @@ +T19843c.hs:6:6: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Map’ + • imported from ‘Data.Map’ at T19843c.hs:3:1-22 + (and originally defined in ‘Data.Map.Internal’) + • In the pattern: Map k v + In an equation for ‘foo’: foo (Map k v) = undefined -T19843c.hs:6:6: error: [GHC-76037] - Not in scope: data constructor ‘Map.Map’ - NB: the module ‘Data.Map’ does not export ‘Map’. ===================================== testsuite/tests/type-data/should_fail/TDPattern.stderr ===================================== @@ -1,3 +1,6 @@ +TDPattern.hs:7:3: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Zero’ + • defined at TDPattern.hs:4:17 + • In the pattern: Zero + In an equation for ‘f’: f Zero = 0 -TDPattern.hs:7:3: [GHC-76037] - Not in scope: data constructor ‘Zero’ ===================================== testsuite/tests/typecheck/should_compile/T23739a.hs ===================================== @@ -0,0 +1,52 @@ +{-# LANGUAGE TypeAbstractions, + ExplicitNamespaces, + RequiredTypeArguments, + DataKinds, + NoListTuplePuns, + OverloadedStrings #-} + +module T23739a where + +import Data.Tuple.Experimental +import GHC.TypeLits + +f1 :: forall a -> a ~ (Int, Bool) => Unit +f1 (b,c) = () + +f2 :: forall a -> a ~ (Int : Bool : Double : []) => Unit +f2 [a,b,c] = () + +f3 :: forall a -> a ~ [Int, Bool, Double] => Unit +f3 [a,b,c] = () + +f4 :: forall a -> a ~ [Int, Bool, Double] => Unit +f4 (a : b : c : []) = () + +f5 :: forall a -> a ~ "blah" => Unit +f5 "blah" = () + +f6 :: forall a -> a ~ 'c' => Unit +f6 'c' = () + +f7 :: forall a -> a ~ UnconsSymbol "blah" => Unit +f7 (Just ('b', "lah")) = () + +f8 :: forall a -> Unit +f8 _ = () + +f9 :: forall a -> a ~ 42 => Unit +f9 42 = () + +f10 :: forall a -> a ~ () => Unit +f10 () = () + +f11 :: forall a -> a ~ Int => Unit +f11 Int = () + +f12 :: forall a -> a ~ (Left @Bool @(Maybe b) True) => Unit +f12 (Left @Bool @(Maybe a) True) = () + +data Tup a = MkTup a a + +f13 :: forall a -> a ~ (Int, MkTup 'f' 'g', 42, True, [1,2,3,4,5], (), "blah", "wombat", 'd', UnconsSymbol "corner") => Unit +f13 (Int, 'f' `MkTup` 'g', 42, True, 1 : 2 : 3 : [4,5], () ,"blah", x, 'd', Just ('c', "orner")) = () ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -915,3 +915,4 @@ test('WarnDefaultedExceptionContext', normal, compile, ['-Wdefaulted-exception-c test('T24470b', normal, compile, ['']) test('T24566', [], makefile_test, []) test('T23764', normal, compile, ['']) +test('T23739a', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T23739b.hs ===================================== @@ -0,0 +1,14 @@ + +module T23739b where + +import Data.Tuple.Experimental +import GHC.TypeLits + +g1 :: Int -> Unit +g1 Int = () + +g2 :: Int +g2 = Int{} + +g3 :: Int +g3 = Int ===================================== testsuite/tests/typecheck/should_fail/T23739b.stderr ===================================== @@ -0,0 +1,21 @@ +T23739b.hs:8:4: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Int’ + • imported from ‘Prelude’ at T23739b.hs:2:8-14 + (and originally defined in ‘GHC.Types’) + • In the pattern: Int + In an equation for ‘g1’: g1 Int = () + +T23739b.hs:11:6: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Int’ + • imported from ‘Prelude’ at T23739b.hs:2:8-14 + (and originally defined in ‘GHC.Types’) + • In the expression: Int {} + In an equation for ‘g2’: g2 = Int {} + +T23739b.hs:14:6: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Int’ + • imported from ‘Prelude’ at T23739b.hs:2:8-14 + (and originally defined in ‘GHC.Types’) + • In the expression: Int + In an equation for ‘g3’: g3 = Int + ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -725,4 +725,4 @@ test('T17594g', normal, compile_fail, ['']) test('T24470a', normal, compile_fail, ['']) test('T24553', normal, compile_fail, ['']) - +test('T23739b', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2c1e4eeaf99f463e71af25a17d2186f7537c770f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2c1e4eeaf99f463e71af25a17d2186f7537c770f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 07:25:29 2024 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 07 May 2024 03:25:29 -0400 Subject: [Git][ghc/ghc][wip/T24718] Some cherry-picked bits of 59202c8 to fix #24718 Message-ID: <6639d7697695d_cb8f01aa2cc8291b3@gitlab.mail> Sebastian Graf pushed to branch wip/T24718 at Glasgow Haskell Compiler / GHC Commits: 78a25354 by Sebastian Graf at 2024-05-07T09:25:04+02:00 Some cherry-picked bits of 59202c8 to fix #24718 As noted in f3225ed4b3f3c4, the test below is flaky on Darwin. Metric Decrease: MultiLayerModulesTH_Make - - - - - 3 changed files: - compiler/GHC/CoreToStg.hs - + testsuite/tests/core-to-stg/T24718.hs - testsuite/tests/core-to-stg/all.T Changes: ===================================== compiler/GHC/CoreToStg.hs ===================================== @@ -19,8 +19,7 @@ module GHC.CoreToStg ( CoreToStgOpts (..), coreToStg ) where import GHC.Prelude import GHC.Core -import GHC.Core.Utils ( exprType, findDefault, isJoinBind - , exprIsTickedString_maybe ) +import GHC.Core.Utils import GHC.Core.Opt.Arity ( manifestArity ) import GHC.Core.Type import GHC.Core.TyCon @@ -49,7 +48,7 @@ import GHC.Unit.Module import GHC.Data.FastString import GHC.Platform ( Platform ) import GHC.Platform.Ways -import GHC.Builtin.PrimOps ( PrimCall(..), primOpWrapperId ) +import GHC.Builtin.PrimOps import GHC.Utils.Outputable import GHC.Utils.Monad @@ -574,6 +573,19 @@ coreToStgApp f args ticks = do -- This is the guy that turns applications into A-normal form -- --------------------------------------------------------------------------- +getStgArgFromTrivialArg :: HasDebugCallStack => CoreArg -> StgArg +-- A (non-erased) trivial CoreArg corresponds to an atomic StgArg. +-- CoreArgs may not immediately look trivial, e.g., `case e of {}` or +-- `case unsafeequalityProof of UnsafeRefl -> e` might intervene. +-- Good thing we can just call `trivial_expr_fold` here. +getStgArgFromTrivialArg e + | Just s <- exprIsTickedString_maybe e -- This case is just for backport to GHC 9.8, + = StgLitArg (LitString s) -- where we used to treat strings as valid StgArgs + | otherwise + = trivial_expr_fold StgVarArg StgLitArg panic panic e + where + panic = pprPanic "getStgArgFromTrivialArg" (ppr e) + coreToStgArgs :: [CoreArg] -> CtsM ([StgArg], [StgTickish]) coreToStgArgs [] = return ([], []) @@ -586,42 +598,29 @@ coreToStgArgs (Coercion _ : args) -- Coercion argument; See Note [Coercion token = do { (args', ts) <- coreToStgArgs args ; return (StgVarArg coercionTokenId : args', ts) } -coreToStgArgs (Tick t e : args) - = assert (not (tickishIsCode t)) $ - do { (args', ts) <- coreToStgArgs (e : args) - ; let !t' = coreToStgTick (exprType e) t - ; return (args', t':ts) } - coreToStgArgs (arg : args) = do -- Non-type argument (stg_args, ticks) <- coreToStgArgs args - arg' <- coreToStgExpr arg - let - (aticks, arg'') = stripStgTicksTop tickishFloatable arg' - stg_arg = case arg'' of - StgApp v [] -> StgVarArg v - StgConApp con _ [] _ -> StgVarArg (dataConWorkId con) - StgOpApp (StgPrimOp op) [] _ -> StgVarArg (primOpWrapperId op) - StgLit lit -> StgLitArg lit - _ -> pprPanic "coreToStgArgs" (ppr arg $$ pprStgExpr panicStgPprOpts arg' $$ pprStgExpr panicStgPprOpts arg'') - - -- WARNING: what if we have an argument like (v `cast` co) - -- where 'co' changes the representation type? - -- (This really only happens if co is unsafe.) - -- Then all the getArgAmode stuff in CgBindery will set the - -- cg_rep of the CgIdInfo based on the type of v, rather - -- than the type of 'co'. - -- This matters particularly when the function is a primop - -- or foreign call. - -- Wanted: a better solution than this hacky warning - + -- We know that `arg` must be trivial, but it may contain Ticks. + -- Example from test case `decodeMyStack`: + -- $ @... ((src Data.Tuple.snd) @Int @[..]) + -- Note that unfortunately the Tick is not at the top. + -- So we'll traverse the expression twice: + -- * Once with `stripTicksT` (which collects *all* ticks from the expression) + -- * and another time with `getStgArgFromTrivialArg`. + -- Since the argument is trivial, the only place the Tick can occur is + -- somehow wrapping a variable (give or take type args, as above). platform <- getPlatform - let - arg_rep = typePrimRep (exprType arg) - stg_arg_rep = typePrimRep (stgArgType stg_arg) + let arg_ty = exprType arg + ticks' = map (coreToStgTick arg_ty) (stripTicksT (not . tickishIsCode) arg) + arg' = getStgArgFromTrivialArg arg + arg_rep = typePrimRep arg_ty + stg_arg_rep = typePrimRep (stgArgType arg') bad_args = not (primRepsCompatible platform arg_rep stg_arg_rep) - warnPprTrace bad_args "Dangerous-looking argument. Probable cause: bad unsafeCoerce#" (ppr arg) $ - return (stg_arg : stg_args, ticks ++ aticks) + massertPpr (length ticks' <= 1) (text "More than one Tick in trivial arg:" <+> ppr arg) + warnPprTrace bad_args "Dangerous-looking argument. Probable cause: bad unsafeCoerce#" (ppr arg) (return ()) + + return (arg' : stg_args, ticks' ++ ticks) coreToStgTick :: Type -- type of the ticked expression -> CoreTickish ===================================== testsuite/tests/core-to-stg/T24718.hs ===================================== @@ -0,0 +1,12 @@ +module T24718 where + +import GHC.Exts ( Any ) +import Unsafe.Coerce ( unsafeCoerce ) + +data T = MkT (Any -> Any) + +g :: () -> () +g x = x + +f :: T +f = unsafeCoerce MkT g ===================================== testsuite/tests/core-to-stg/all.T ===================================== @@ -2,3 +2,4 @@ test('T19700', normal, compile, ['-O']) test('T23914', normal, compile, ['-O']) +test('T24718', normal, compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/78a253543d466ac511a1664a3e6aff032ca684d5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/78a253543d466ac511a1664a3e6aff032ca684d5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 07:29:19 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 07 May 2024 03:29:19 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Add test cases for #24664 Message-ID: <6639d84fb964d_cb8f01ba84243414e@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: a19201d4 by Matthew Craven at 2024-05-06T19:54:29-04:00 Add test cases for #24664 ...since none are present in the original MR !12463 fixing this issue. - - - - - 46328a49 by Alan Zimmerman at 2024-05-06T19:55:05-04:00 EPA: preserve comments in data decls Closes #24771 - - - - - df19298d by Andrei Borzenkov at 2024-05-07T03:29:00-04:00 Rename Solo# data constructor to MkSolo# (#24673) - data Solo# a = (# a #) + data Solo# a = MkSolo# a And `(# foo #)` syntax now becomes just a syntactic sugar for `MkSolo# a`. - - - - - 356dc690 by Arsen Arsenović at 2024-05-07T03:29:03-04:00 Add the cmm_cpp_is_gcc predicate to the testsuite A future C-- test called T24474-cmm-override-g0 relies on the GCC-specific behaviour of -g3 implying -dD, which, in turn, leads to it emitting #defines past the preprocessing stage. Clang, at least, does not do this, so the test would fail if ran on Clang. As the behaviour here being tested is ``-optCmmP-g3'' undoing effects of the workaround we apply as a fix for bug #24474, and the workaround was for GCC-specific behaviour, the test needs to be marked as fragile on other compilers. - - - - - 3fd0bd0b by Arsen Arsenović at 2024-05-07T03:29:03-04:00 Split out the C-- preprocessor, and make it pass -g0 Previously, C-- was processed with the C preprocessor program. This means that it inherited flags passed via -optc. A flag that is somewhat often passed through -optc is -g. At certain -g levels (>=2), GCC starts emitting defines *after* preprocessing, for the purposes of debug info generation. This is not useful for the C-- compiler, and, in fact, causes lexer errors. We can suppress this effect (safely, if supported) via -g0. As a workaround, in older versions of GCC (<=10), GCC only emitted defines if a certain set of -g*3 flags was passed. Newer versions check the debug level. For the former, we filter out those -g*3 flags and, for the latter, we specify -g0 on top of that. As a compatible and effective solution, this change adds a C-- preprocessor distinct from the C compiler and preprocessor, but that keeps its flags. The command line produced for C-- preprocessing now looks like: $pgmCmmP $optCs_without_g3 $g0_if_supported $optCmmP Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/24474 - - - - - 30 changed files: - compiler/GHC/Builtin/Types.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Recomp/Flags.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools/Cpp.hs - compiler/GHC/SysTools/Tasks.hs - configure.ac - distrib/configure.ac.in - docs/users_guide/phases.rst - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cfg/default.host.target.in - hadrian/cfg/default.target.in - hadrian/src/Rules/Generate.hs - libraries/ghc-boot/GHC/Utils/Encoding.hs - libraries/ghc-experimental/src/Data/Tuple/Experimental.hs - libraries/ghc-prim/GHC/Types.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Syntax.hs - + m4/fp_cmm_cpp_cmd_with_args.m4 - m4/fp_settings.m4 - m4/fp_setup_windows_toolchain.m4 - m4/ghc_toolchain.m4 - m4/prep_target_file.m4 - testsuite/config/ghc - testsuite/driver/testglobals.py - testsuite/driver/testlib.py The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e4644bcbb9793b1a449835efa2f3e23e253d869b...3fd0bd0b961a5a98bd2e58bbffaa510365d5cd02 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e4644bcbb9793b1a449835efa2f3e23e253d869b...3fd0bd0b961a5a98bd2e58bbffaa510365d5cd02 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 09:44:49 2024 From: gitlab at gitlab.haskell.org (Serge S. Gulin (@gulin.serge)) Date: Tue, 07 May 2024 05:44:49 -0400 Subject: [Git][ghc/ghc][wip/T24504] IPE: WIP: Replace closure_desc string representation in logs output on Word64 Message-ID: <6639f81172755_cb8f02df6e14611af@gitlab.mail> Serge S. Gulin pushed to branch wip/T24504 at Glasgow Haskell Compiler / GHC Commits: 7b7db94b by Serge S. Gulin at 2024-05-07T12:44:36+03:00 IPE: WIP: Replace closure_desc string representation in logs output on Word64 - - - - - 1 changed file: - rts/eventlog/EventLog.c Changes: ===================================== rts/eventlog/EventLog.c ===================================== @@ -1445,7 +1445,6 @@ void postIPE(const InfoProvEnt *ipe) const StgWord MAX_IPE_STRING_LEN = 65535; ACQUIRE_LOCK(&eventBufMutex); StgWord table_name_len = MIN(strlen(ipe->prov.table_name), MAX_IPE_STRING_LEN); - StgWord closure_desc_len = MIN(strlen(ipe->prov.closure_desc), MAX_IPE_STRING_LEN); StgWord ty_desc_len = MIN(strlen(ipe->prov.ty_desc), MAX_IPE_STRING_LEN); StgWord label_len = MIN(strlen(ipe->prov.label), MAX_IPE_STRING_LEN); StgWord module_len = MIN(strlen(ipe->prov.module), MAX_IPE_STRING_LEN); @@ -1455,14 +1454,15 @@ void postIPE(const InfoProvEnt *ipe) // 8 for the info word // 1 null after each string // 1 colon between src_file and src_span + // 8 for the closure_desc StgWord extra_comma = 1; - StgWord len = 8+table_name_len+1+closure_desc_len+1+ty_desc_len+1+label_len+1+module_len+1+src_file_len+1+extra_comma+src_span_len+1; + StgWord len = 8+table_name_len+1+8+1+ty_desc_len+1+label_len+1+module_len+1+src_file_len+1+extra_comma+src_span_len+1; CHECK(!ensureRoomForVariableEvent(&eventBuf, len)); postEventHeader(&eventBuf, EVENT_IPE); postPayloadSize(&eventBuf, len); postWord64(&eventBuf, (StgWord) INFO_PTR_TO_STRUCT(ipe->info)); postStringLen(&eventBuf, ipe->prov.table_name, table_name_len); - postStringLen(&eventBuf, ipe->prov.closure_desc, closure_desc_len); + postWord64(&eventBuf, ipe->prov.closure_desc); postStringLen(&eventBuf, ipe->prov.ty_desc, ty_desc_len); postStringLen(&eventBuf, ipe->prov.label, label_len); postStringLen(&eventBuf, ipe->prov.module, module_len); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7b7db94bb5ffe0ff2425117418eba89342037789 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7b7db94bb5ffe0ff2425117418eba89342037789 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 09:45:22 2024 From: gitlab at gitlab.haskell.org (Serge S. Gulin (@gulin.serge)) Date: Tue, 07 May 2024 05:45:22 -0400 Subject: [Git][ghc/ghc][wip/T24504] 4 commits: Add test cases for #24664 Message-ID: <6639f83293199_cb8f02eda2b8619ad@gitlab.mail> Serge S. Gulin pushed to branch wip/T24504 at Glasgow Haskell Compiler / GHC Commits: a19201d4 by Matthew Craven at 2024-05-06T19:54:29-04:00 Add test cases for #24664 ...since none are present in the original MR !12463 fixing this issue. - - - - - 46328a49 by Alan Zimmerman at 2024-05-06T19:55:05-04:00 EPA: preserve comments in data decls Closes #24771 - - - - - c301d80a by Ben Gamari at 2024-05-07T12:44:54+03:00 IPE: Eliminate dependency on Read Instead of encoding the closure type as decimal string we now simply represent it as an integer, eliminating the need for `Read` in `GHC.Internal.InfoProv.Types.peekInfoProv`. Closes #24504. ------------------------- Metric Decrease: T24602_perf_size size_hello_artifact ------------------------- - - - - - 1e9948e3 by Serge S. Gulin at 2024-05-07T12:44:54+03:00 IPE: WIP: Replace closure_desc string representation in logs output on Word64 - - - - - 17 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/StgToCmm/InfoTableProv.hs - libraries/ghc-internal/src/GHC/Internal/InfoProv/Types.hsc - rts/IPE.c - rts/Trace.c - rts/eventlog/EventLog.c - rts/include/rts/IPE.h - + testsuite/tests/codeGen/should_run/T24664a.hs - + testsuite/tests/codeGen/should_run/T24664a.stdout - + testsuite/tests/codeGen/should_run/T24664b.hs - + testsuite/tests/codeGen/should_run/T24664b.stdout - testsuite/tests/codeGen/should_run/all.T - testsuite/tests/printer/Makefile - testsuite/tests/printer/Test24755.hs - + testsuite/tests/printer/Test24771.hs - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -2486,9 +2486,8 @@ forall :: { Located ([AddEpAnn], Maybe [LHsTyVarBndr Specificity GhcPs]) } | {- empty -} { noLoc ([], Nothing) } constr_stuff :: { Located (LocatedN RdrName, HsConDeclH98Details GhcPs) } - : infixtype {% fmap (reLoc. (fmap (\b -> (dataConBuilderCon b, - dataConBuilderDetails b)))) - (runPV $1) } + : infixtype {% do { b <- runPV $1 + ; return (sL1 b (dataConBuilderCon b, dataConBuilderDetails b)) }} | '(#' usum_constr '#)' {% let (t, tag, arity) = $2 in pure (sLL $1 $3 $ mkUnboxedSumCon t tag arity)} usum_constr :: { (LHsType GhcPs, Int, Int) } -- constructor for the data decls SumN# ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -236,7 +236,8 @@ mkTyData loc' is_type_data new_or_data cType (L _ (mcxt, tycl_hdr)) ; let anns' = annsIn Semi.<> ann ; data_cons <- checkNewOrData loc' (unLoc tc) is_type_data new_or_data data_cons ; defn <- mkDataDefn cType mcxt ksig data_cons maybe_deriv - ; let loc = EpAnn (spanAsAnchor loc') noAnn cs + ; !cs' <- getCommentsFor loc' + ; let loc = EpAnn (spanAsAnchor loc') noAnn (cs' Semi.<> cs) ; return (L loc (DataDecl { tcdDExt = anns', tcdLName = tc, tcdTyVars = tyvars, tcdFixity = fixity, @@ -2065,25 +2066,26 @@ instance DisambTD (HsType GhcPs) where return (L (addCommentsToEpAnn l cs) ty) mkUnpackednessPV = addUnpackednessP -dataConBuilderCon :: DataConBuilder -> LocatedN RdrName -dataConBuilderCon (PrefixDataConBuilder _ dc) = dc -dataConBuilderCon (InfixDataConBuilder _ dc _) = dc +dataConBuilderCon :: LocatedA DataConBuilder -> LocatedN RdrName +dataConBuilderCon (L _ (PrefixDataConBuilder _ dc)) = dc +dataConBuilderCon (L _ (InfixDataConBuilder _ dc _)) = dc -dataConBuilderDetails :: DataConBuilder -> HsConDeclH98Details GhcPs +dataConBuilderDetails :: LocatedA DataConBuilder -> HsConDeclH98Details GhcPs -- Detect when the record syntax is used: -- data T = MkT { ... } -dataConBuilderDetails (PrefixDataConBuilder flds _) +dataConBuilderDetails (L _ (PrefixDataConBuilder flds _)) | [L (EpAnn anc _ cs) (HsRecTy an fields)] <- toList flds = RecCon (L (EpAnn anc an cs) fields) -- Normal prefix constructor, e.g. data T = MkT A B C -dataConBuilderDetails (PrefixDataConBuilder flds _) +dataConBuilderDetails (L _ (PrefixDataConBuilder flds _)) = PrefixCon noTypeArgs (map hsLinear (toList flds)) -- Infix constructor, e.g. data T = Int :! Bool -dataConBuilderDetails (InfixDataConBuilder lhs _ rhs) - = InfixCon (hsLinear lhs) (hsLinear rhs) +dataConBuilderDetails (L (EpAnn _ _ csl) (InfixDataConBuilder (L (EpAnn anc ann csll) lhs) _ rhs)) + = InfixCon (hsLinear (L (EpAnn anc ann (csl Semi.<> csll)) lhs)) (hsLinear rhs) + instance DisambTD DataConBuilder where mkHsAppTyHeadPV = tyToDataConBuilder ===================================== compiler/GHC/StgToCmm/InfoTableProv.hs ===================================== @@ -178,7 +178,7 @@ toIpeBufferEntries byte_order cg_ipes = to_ipe_buf_ent :: CgInfoProvEnt -> [Word32] to_ipe_buf_ent cg_ipe = [ ipeTableName cg_ipe - , ipeClosureDesc cg_ipe + , fromIntegral $ ipeClosureDesc cg_ipe , ipeTypeDesc cg_ipe , ipeLabel cg_ipe , ipeSrcFile cg_ipe @@ -193,7 +193,6 @@ toIpeBufferEntries byte_order cg_ipes = toCgIPE :: Platform -> SDocContext -> InfoProvEnt -> State StringTable CgInfoProvEnt toCgIPE platform ctx ipe = do table_name <- lookupStringTable $ ST.pack $ renderWithContext ctx (pprCLabel platform (infoTablePtr ipe)) - closure_desc <- lookupStringTable $ ST.pack $ show (infoProvEntClosureType ipe) type_desc <- lookupStringTable $ ST.pack $ infoTableType ipe let label_str = maybe "" ((\(LexicalFastString s) -> unpackFS s) . snd) (infoTableProv ipe) let (src_loc_file, src_loc_span) = @@ -208,7 +207,7 @@ toCgIPE platform ctx ipe = do src_span <- lookupStringTable $ ST.pack src_loc_span return $ CgInfoProvEnt { ipeInfoTablePtr = infoTablePtr ipe , ipeTableName = table_name - , ipeClosureDesc = closure_desc + , ipeClosureDesc = fromIntegral (infoProvEntClosureType ipe) , ipeTypeDesc = type_desc , ipeLabel = label , ipeSrcFile = src_file @@ -218,7 +217,7 @@ toCgIPE platform ctx ipe = do data CgInfoProvEnt = CgInfoProvEnt { ipeInfoTablePtr :: !CLabel , ipeTableName :: !StrTabOffset - , ipeClosureDesc :: !StrTabOffset + , ipeClosureDesc :: !Word32 , ipeTypeDesc :: !StrTabOffset , ipeLabel :: !StrTabOffset , ipeSrcFile :: !StrTabOffset ===================================== libraries/ghc-internal/src/GHC/Internal/InfoProv/Types.hsc ===================================== @@ -18,8 +18,9 @@ module GHC.Internal.InfoProv.Types ) where import GHC.Internal.Base -import GHC.Internal.Data.Maybe import GHC.Internal.Enum +import GHC.Internal.Real (fromIntegral) +import GHC.Internal.Word (Word32) import GHC.Internal.Show (Show) import GHC.Internal.Ptr (Ptr(..), plusPtr) import GHC.Internal.Foreign.C.String.Encoding (CString, peekCString) @@ -28,7 +29,6 @@ import GHC.Internal.Foreign.Marshal.Alloc (allocaBytes) import GHC.Internal.IO.Encoding (utf8) import GHC.Internal.Foreign.Storable (peekByteOff) import GHC.Internal.ClosureTypes -import GHC.Internal.Text.Read import GHC.Prim (whereFrom##) data InfoProv = InfoProv { @@ -70,9 +70,11 @@ getIPE obj fail k = allocaBytes (#size InfoProvEnt) $ \p -> IO $ \s -> ipeProv :: Ptr InfoProvEnt -> Ptr InfoProv ipeProv p = (#ptr InfoProvEnt, prov) p -peekIpName, peekIpDesc, peekIpLabel, peekIpUnitId, peekIpModule, peekIpSrcFile, peekIpSrcSpan, peekIpTyDesc :: Ptr InfoProv -> IO CString -peekIpName p = (# peek InfoProv, table_name) p +peekIpDesc :: Ptr InfoProv -> IO Word32 peekIpDesc p = (# peek InfoProv, closure_desc) p + +peekIpName, peekIpLabel, peekIpUnitId, peekIpModule, peekIpSrcFile, peekIpSrcSpan, peekIpTyDesc :: Ptr InfoProv -> IO CString +peekIpName p = (# peek InfoProv, table_name) p peekIpLabel p = (# peek InfoProv, label) p peekIpUnitId p = (# peek InfoProv, unit_id) p peekIpModule p = (# peek InfoProv, module) p @@ -83,7 +85,7 @@ peekIpTyDesc p = (# peek InfoProv, ty_desc) p peekInfoProv :: Ptr InfoProv -> IO InfoProv peekInfoProv infop = do name <- peekCString utf8 =<< peekIpName infop - desc <- peekCString utf8 =<< peekIpDesc infop + desc <- peekIpDesc infop tyDesc <- peekCString utf8 =<< peekIpTyDesc infop label <- peekCString utf8 =<< peekIpLabel infop unit_id <- peekCString utf8 =<< peekIpUnitId infop @@ -94,7 +96,7 @@ peekInfoProv infop = do ipName = name, -- The INVALID_OBJECT case should be impossible as we -- control the C code generating these values. - ipDesc = maybe INVALID_OBJECT toEnum . readMaybe @Int $ desc, + ipDesc = toEnum $ fromIntegral desc, ipTyDesc = tyDesc, ipLabel = label, ipUnitId = unit_id, ===================================== rts/IPE.c ===================================== @@ -105,7 +105,7 @@ static InfoProvEnt ipeBufferEntryToIpe(const IpeBufferListNode *node, uint32_t i .info = node->tables[idx], .prov = { .table_name = &strings[ent->table_name], - .closure_desc = &strings[ent->closure_desc], + .closure_desc = ent->closure_desc, .ty_desc = &strings[ent->ty_desc], .label = &strings[ent->label], .unit_id = &strings[node->unit_id], ===================================== rts/Trace.c ===================================== @@ -689,7 +689,7 @@ void traceIPE(const InfoProvEnt *ipe) ACQUIRE_LOCK(&trace_utx); tracePreface(); - debugBelch("IPE: table_name %s, closure_desc %s, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", + debugBelch("IPE: table_name %s, closure_desc %d, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", ipe->prov.table_name, ipe->prov.closure_desc, ipe->prov.ty_desc, ipe->prov.label, ipe->prov.unit_id, ipe->prov.module, ipe->prov.src_file, ipe->prov.src_span); ===================================== rts/eventlog/EventLog.c ===================================== @@ -1445,7 +1445,6 @@ void postIPE(const InfoProvEnt *ipe) const StgWord MAX_IPE_STRING_LEN = 65535; ACQUIRE_LOCK(&eventBufMutex); StgWord table_name_len = MIN(strlen(ipe->prov.table_name), MAX_IPE_STRING_LEN); - StgWord closure_desc_len = MIN(strlen(ipe->prov.closure_desc), MAX_IPE_STRING_LEN); StgWord ty_desc_len = MIN(strlen(ipe->prov.ty_desc), MAX_IPE_STRING_LEN); StgWord label_len = MIN(strlen(ipe->prov.label), MAX_IPE_STRING_LEN); StgWord module_len = MIN(strlen(ipe->prov.module), MAX_IPE_STRING_LEN); @@ -1455,14 +1454,15 @@ void postIPE(const InfoProvEnt *ipe) // 8 for the info word // 1 null after each string // 1 colon between src_file and src_span + // 8 for the closure_desc StgWord extra_comma = 1; - StgWord len = 8+table_name_len+1+closure_desc_len+1+ty_desc_len+1+label_len+1+module_len+1+src_file_len+1+extra_comma+src_span_len+1; + StgWord len = 8+table_name_len+1+8+1+ty_desc_len+1+label_len+1+module_len+1+src_file_len+1+extra_comma+src_span_len+1; CHECK(!ensureRoomForVariableEvent(&eventBuf, len)); postEventHeader(&eventBuf, EVENT_IPE); postPayloadSize(&eventBuf, len); postWord64(&eventBuf, (StgWord) INFO_PTR_TO_STRUCT(ipe->info)); postStringLen(&eventBuf, ipe->prov.table_name, table_name_len); - postStringLen(&eventBuf, ipe->prov.closure_desc, closure_desc_len); + postWord64(&eventBuf, ipe->prov.closure_desc); postStringLen(&eventBuf, ipe->prov.ty_desc, ty_desc_len); postStringLen(&eventBuf, ipe->prov.label, label_len); postStringLen(&eventBuf, ipe->prov.module, module_len); ===================================== rts/include/rts/IPE.h ===================================== @@ -15,7 +15,7 @@ typedef struct InfoProv_ { const char *table_name; - const char *closure_desc; + uint32_t closure_desc; // closure type const char *ty_desc; const char *label; const char *unit_id; @@ -54,7 +54,7 @@ typedef uint32_t StringIdx; // to ensure correct packing. typedef struct { StringIdx table_name; - StringIdx closure_desc; + uint32_t closure_desc; // closure type StringIdx ty_desc; StringIdx label; StringIdx src_file; ===================================== testsuite/tests/codeGen/should_run/T24664a.hs ===================================== @@ -0,0 +1,27 @@ +-- This program tests the passing of RUBBISH values +-- with the Int64 representation, which were found +-- to by mis-handled by the JS backend in #24664. + +{-# LANGUAGE MagicHash #-} + +module Main where + +import GHC.Exts (Int64#, intToInt64#) + +takesInt64a :: String -> Int64# -> String -> IO () +{-# OPAQUE takesInt64a #-} +-- Idea: This function takes an Int64# but doesn't use it, +-- so that its argument might be turned into a rubbish literal. +-- We don't want WW to remove the argument entirely, so OPAQUE +takesInt64a str1 _ str2 = putStrLn str1 >> putStrLn str2 + +takesInt64b :: Int64# -> IO () +{-# NOINLINE takesInt64b #-} +-- Idea: This function will get a worker that doesn't take an +-- Int64# at all, and the body of that worker will pass a +-- rubbish literal to takesInt64a since no real arg exists. +takesInt64b x = takesInt64a "first string to print" x "second string to print" + +main :: IO () +main = do + takesInt64b (intToInt64# 12345#) ===================================== testsuite/tests/codeGen/should_run/T24664a.stdout ===================================== @@ -0,0 +1,2 @@ +first string to print +second string to print ===================================== testsuite/tests/codeGen/should_run/T24664b.hs ===================================== @@ -0,0 +1,31 @@ +-- This is a variant of T24664a that could reproduce +-- the compiler crash originally observed in #24664. + +{-# LANGUAGE MagicHash #-} + +module Main where + +import GHC.Exts (Int64#, intToInt64#, uncheckedIShiftRL64#) + +takesInt64a :: String -> Int64# -> String -> IO () +{-# OPAQUE takesInt64a #-} +-- Idea: This function takes an Int64# but doesn't use it, +-- so that its argument might be turned into a rubbish literal. +-- We don't want WW to remove the argument entirely, so OPAQUE +takesInt64a str1 _ str2 = putStrLn str1 >> putStrLn str2 + +takesInt64b :: String -> Int64# -> String -> IO () +{-# NOINLINE takesInt64b #-} +-- Idea: This function will get a worker that doesn't take an +-- Int64# at all, and the body of that worker will pass a +-- rubbish literal to takesInt64a since no real arg exists. +takesInt64b s1 x s2 + = takesInt64a (s1 ++ t) (x `uncheckedIShiftRL64#` 13#) (s2 ++ t) + where t = " string to print" + +takesInt64c :: Int64# -> IO () +takesInt64c x = takesInt64b "first" x "second" + +main :: IO () +main = do + takesInt64c (intToInt64# 12345#) ===================================== testsuite/tests/codeGen/should_run/T24664b.stdout ===================================== @@ -0,0 +1,2 @@ +first string to print +second string to print ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -243,3 +243,6 @@ test('MulMayOflo_full', test('T24264run', normal, compile_and_run, ['']) test('T24295a', normal, compile_and_run, ['-O -floopification']) test('T24295b', normal, compile_and_run, ['-O -floopification -fpedantic-bottoms']) +test('T24664a', normal, compile_and_run, ['-O']) +test('T24664b', normal, compile_and_run, ['-O']) + ===================================== testsuite/tests/printer/Makefile ===================================== @@ -866,3 +866,8 @@ Test24755: Test24753: $(CHECK_PPR) $(LIBDIR) Test24753.hs $(CHECK_EXACT) $(LIBDIR) Test24753.hs + +.PHONY: Test24771 +Test24771: + $(CHECK_PPR) $(LIBDIR) Test24771.hs + $(CHECK_EXACT) $(LIBDIR) Test24771.hs ===================================== testsuite/tests/printer/Test24755.hs ===================================== @@ -3,6 +3,6 @@ module Test24755 where class - a -- Before operator - :+ - b -- After operator + a -- c1 + :+ -- c2 + b -- c3 ===================================== testsuite/tests/printer/Test24771.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeOperators #-} +module Test24771 where + +data Foo + = Int -- c1 + :* -- c2 + String -- c3 ===================================== testsuite/tests/printer/all.T ===================================== @@ -206,3 +206,4 @@ test('Test24749', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24749']) test('Test24754', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24754']) test('Test24755', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24755']) test('Test24753', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24753']) +test('Test24771', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24771']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7b7db94bb5ffe0ff2425117418eba89342037789...1e9948e386cdb423ba8bbf535bb30302dc203299 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7b7db94bb5ffe0ff2425117418eba89342037789...1e9948e386cdb423ba8bbf535bb30302dc203299 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 09:51:37 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Tue, 07 May 2024 05:51:37 -0400 Subject: [Git][ghc/ghc][wip/reinstallable-th] WIP: Make template-haskell re-installable Message-ID: <6639f9a91f775_cb8f030642b46464f@gitlab.mail> Teo Camarasu pushed to branch wip/reinstallable-th at Glasgow Haskell Compiler / GHC Commits: 75425997 by Teo Camarasu at 2024-05-07T10:51:03+01:00 WIP: Make template-haskell re-installable - - - - - 30 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Plugins.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Gen/Splice.hs-boot - compiler/GHC/Tc/Types/TH.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Unit/Types.hs - compiler/ghc.cabal.in - hadrian/src/Packages.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/ToolArgs.hs - hadrian/src/Settings/Default.hs - hadrian/src/Settings/Packages.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs → libraries/ghc-boot-th/GHC/Internal/TH/Lib.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Map.hs → libraries/ghc-boot-th/GHC/Internal/TH/Lib/Map.hs - + libraries/ghc-boot-th/GHC/Internal/TH/Ppr.hs - + libraries/ghc-boot-th/GHC/Internal/TH/PprLib.hs - + libraries/ghc-boot-th/GHC/Internal/TH/Quote.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Syntax.hs → libraries/ghc-boot-th/GHC/Internal/TH/Syntax.hs - libraries/ghc-boot-th/ghc-boot-th.cabal.in - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/TH.hs - libraries/ghci/GHCi/TH/Binary.hs - libraries/ghci/ghci.cabal.in - libraries/template-haskell/Language/Haskell/TH/Lib.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/754259972914f55170503ba89aa05ffb7869b09a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/754259972914f55170503ba89aa05ffb7869b09a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 09:55:49 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Tue, 07 May 2024 05:55:49 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/romes/12569 Message-ID: <6639faa57535f_cb8f03194df06506c@gitlab.mail> Rodrigo Mesquita pushed new branch wip/romes/12569 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/romes/12569 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 10:02:17 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Tue, 07 May 2024 06:02:17 -0400 Subject: [Git][ghc/ghc][wip/romes/12569] Rename pre-processor invocation args Message-ID: <6639fc293f88f_3f177321fed036136@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/12569 at Glasgow Haskell Compiler / GHC Commits: 5edc63d5 by Rodrigo Mesquita at 2024-05-07T11:02:04+01:00 Rename pre-processor invocation args Small clean up. Uses proper names for the various groups of arguments that make up the pre-processor invocation. - - - - - 1 changed file: - compiler/GHC/SysTools/Tasks.hs Changes: ===================================== compiler/GHC/SysTools/Tasks.hs ===================================== @@ -131,15 +131,15 @@ runSourceCodePreprocessor runSourceCodePreprocessor logger tmpfs dflags preprocessor args = traceSystoolCommand logger logger_name $ do let - (p, args0) = pgm_getter dflags - args1 = Option <$> (augmentImports dflags $ getOpts dflags opt_getter) - args2 = [Option "-Werror" | gopt Opt_WarnIsError dflags] - ++ [Option "-Wundef" | wopt Opt_WarnCPPUndef dflags] - all_args = args0 ++ args1 ++ args2 ++ args + (program, configured_args) = pgm_getter dflags + runtime_args = Option <$> (augmentImports dflags $ getOpts dflags opt_getter) + extra_warns = [Option "-Werror" | gopt Opt_WarnIsError dflags] + ++ [Option "-Wundef" | wopt Opt_WarnCPPUndef dflags] + all_args = configured_args ++ runtime_args ++ extra_warns ++ args - mb_env <- getGccEnv (args0 ++ args1) + mb_env <- getGccEnv (configured_args ++ runtime_args) - runSomething readable_name p all_args mb_env + runSomething readable_name program all_args mb_env where toolSettings' = toolSettings dflags @@ -155,7 +155,8 @@ runSourceCodePreprocessor logger tmpfs dflags preprocessor args = optCFiltered = filter (`notElem` g3Flags) . opt_c -- In the wild (and GHC), there is lots of code assuming that -optc gets -- passed to the C-- preprocessor too. Note that the arguments are - -- reversed by getOpts. + -- reversed by getOpts. That is, in the invocation, first come the runtime + -- C opts, then -g0, then the runtime CmmP opts. cAndCmmOpt dflags = opt_CmmP dflags ++ cmmG0 ++ optCFiltered dflags (logger_name, pgm_getter, opt_getter, readable_name) = case preprocessor of View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5edc63d5a05aebbe96b1771924b2baacc6394cda -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5edc63d5a05aebbe96b1771924b2baacc6394cda You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 11:01:54 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Tue, 07 May 2024 07:01:54 -0400 Subject: [Git][ghc/ghc][wip/hugepages] Implement support for 2MB hugepages Message-ID: <663a0a22f05c1_3f1773862c5c47147@gitlab.mail> Teo Camarasu pushed to branch wip/hugepages at Glasgow Haskell Compiler / GHC Commits: f5c087f4 by Teo Camarasu at 2024-05-07T12:01:08+01:00 Implement support for 2MB hugepages We enable/disable it through a runtime flag (-xH). When enabled we ensure we only (de)allocate in aligned multiples of 2MB. - - - - - 4 changed files: - rts/include/rts/Constants.h - rts/posix/OSMem.c - rts/sm/BlockAlloc.c - rts/sm/OSMem.h Changes: ===================================== rts/include/rts/Constants.h ===================================== @@ -170,7 +170,7 @@ #define BLOCK_SHIFT 12 /* The size of a megablock (2^MBLOCK_SHIFT bytes) */ -#define MBLOCK_SHIFT 21 +#define MBLOCK_SHIFT 20 /* ----------------------------------------------------------------------------- Bitmap/size fields (used in info tables) ===================================== rts/posix/OSMem.c ===================================== @@ -60,12 +60,6 @@ # endif #endif -#if defined(HAVE_LINUX_MMAN_H) -#include - -#define HUGEPAGE_SIZE (2*1024*1024) -#define HUGEPAGE_FLAGS (MAP_HUGETLB | MAP_HUGE_2MB) -#endif #if !defined(darwin_HOST_OS) # undef RESERVE_FLAGS @@ -244,19 +238,19 @@ my_mmap (void *addr, W_ size, int operation) # endif } else if (operation == MEM_COMMIT) { flags = MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE; -#if defined(HUGEPAGE_SIZE) +#if defined(HUGEPAGE_FLAGS) if ( RtsFlags.GcFlags.hugepages && (size & (HUGEPAGE_SIZE - 1)) == 0) { huge_tried += 1; flags |= HUGEPAGE_FLAGS; } -#endif /* defined(HUGEPAGE_SIZE) */ +#endif /* defined(HUGEPAGE_FLAGS) */ } else { flags = MAP_ANON | MAP_PRIVATE; } ret = mmap(addr, size, prot, flags, -1, 0); -#if defined(HUGEPAGE_SIZE) +#if defined(HUGEPAGE_FLAGS) // If the mmap failed, and we tried with HUGEPAGE_FLAGS // then retry without. if (ret == MAP_FAILED && flags & HUGEPAGE_FLAGS){ @@ -698,6 +692,10 @@ void osDecommitMemory(void *at, W_ size) if(r < 0) sysErrorBelch("unable to make released memory unaccessible"); #endif + if(RtsFlags.GcFlags.hugepages) { + ASSERT( ((HUGEPAGE_SIZE - 1) & (uintptr_t)at) == 0); + ASSERT( ((HUGEPAGE_SIZE - 1) & size) == 0); + } #if defined(MADV_FREE) // See Note [MADV_FREE and MADV_DONTNEED]. ===================================== rts/sm/BlockAlloc.c ===================================== @@ -25,7 +25,8 @@ #include -static void initMBlock(void *mblock, uint32_t node); +static void initMBlock(void *mblock, uint32_t node); +static void free_mega_group (bdescr *mg); /* * By default the DEBUG RTS is built with block allocator assertions @@ -478,13 +479,30 @@ alloc_mega_group (uint32_t node, StgWord mblocks) else { void *mblock; + StgWord hugepage_mblocks; + if(RtsFlags.GcFlags.hugepages) { + // Round up allocation to hugepage size + hugepage_mblocks = MBLOCK_ROUND_UP_HUGEPAGE(mblocks); + } + else { + hugepage_mblocks = mblocks; + } + if (RtsFlags.GcFlags.numa) { - mblock = getMBlocksOnNode(node, mblocks); + mblock = getMBlocksOnNode(node, hugepage_mblocks); } else { - mblock = getMBlocks(mblocks); + mblock = getMBlocks(hugepage_mblocks); } initMBlock(mblock, node); // only need to init the 1st one bd = FIRST_BDESCR(mblock); + + // Free the slop + if(hugepage_mblocks > mblocks) { + bdescr *mblock_slop_bd = FIRST_BDESCR((uintptr_t)mblock + (uintptr_t)mblocks*MBLOCK_SIZE); + initMBlock(MBLOCK_ROUND_DOWN(mblock_slop_bd), node); + mblock_slop_bd->blocks = MBLOCK_GROUP_BLOCKS(hugepage_mblocks-mblocks); + free_mega_group(mblock_slop_bd); + } } bd->blocks = MBLOCK_GROUP_BLOCKS(mblocks); return bd; @@ -812,7 +830,7 @@ coalesce_mblocks (bdescr *p) return q; } -static void +void free_mega_group (bdescr *mg) { bdescr *bd, *prev; @@ -1199,10 +1217,15 @@ uint32_t returnMemoryToOS(uint32_t n /* megablocks */) return 0; #else bdescr *bd; + bdescr *rejects; + bdescr *next; uint32_t node; - StgWord size; + StgWord size, unaligned_size, freeable_size; uint32_t init_n; init_n = n; + if(RtsFlags.GcFlags.hugepages) { + n = MBLOCK_ROUND_DOWN_HUGEPAGE(n); + } // TODO: This is inefficient because this loop will essentially result in // quadratic runtime behavior: for each call to `freeMBlocks`, the @@ -1215,22 +1238,64 @@ uint32_t returnMemoryToOS(uint32_t n /* megablocks */) // ToDo: not fair, we free all the memory starting with node 0. for (node = 0; n > 0 && node < n_numa_nodes; node++) { bd = free_mblock_list[node]; + rejects = NULL; while ((n > 0) && (bd != NULL)) { size = BLOCKS_TO_MBLOCKS(bd->blocks); - if (size > n) { - StgWord newSize = size - n; - char *freeAddr = MBLOCK_ROUND_DOWN(bd->start); - freeAddr += newSize * MBLOCK_SIZE; - bd->blocks = MBLOCK_GROUP_BLOCKS(newSize); - freeMBlocks(freeAddr, n); - n = 0; + next = bd->link; + char *aligned_start; + + if(RtsFlags.GcFlags.hugepages) { + aligned_start = (char*)MBLOCK_ROUND_DOWN(bd) + ((uintptr_t)MBLOCK_ROUND_DOWN(bd) & HUGEPAGE_MASK); + unaligned_size = (aligned_start - (char*)MBLOCK_ROUND_DOWN(bd)) / MBLOCK_SIZE; + freeable_size = MBLOCK_ROUND_DOWN_HUGEPAGE(size - unaligned_size); } else { - char *freeAddr = MBLOCK_ROUND_DOWN(bd->start); - n -= size; - bd = bd->link; - freeMBlocks(freeAddr, size); + aligned_start = (char*)MBLOCK_ROUND_DOWN(bd); + unaligned_size = 0; + freeable_size = size; + } + + // We cannot free more than n + freeable_size = stg_min(n, freeable_size); + + // Place the front unaligned section back on the list. + // If we can't free any of it then this is the entire thing. + if (unaligned_size > 0 || freeable_size == 0) { + bd->link = rejects; + rejects = bd; + // If we are freeing some mblocks from the middle then initialise + // the first MBlock and update the sizes. + if (freeable_size > 0) { + bd->blocks = MBLOCK_GROUP_BLOCKS(unaligned_size); + bdescr *aligned_bd; + aligned_bd = FIRST_BDESCR(aligned_start); + aligned_bd->blocks = MBLOCK_GROUP_BLOCKS(freeable_size); + } + } + + if(freeable_size > 0) { + n -= freeable_size; + freeMBlocks(aligned_start, freeable_size); + // add the slop to the rejects list + if (size - unaligned_size - freeable_size > 0) + { + void *slop = aligned_start + freeable_size * MBLOCK_SIZE; + bdescr* slop_bd = FIRST_BDESCR(slop); + slop_bd->blocks = MBLOCK_GROUP_BLOCKS(size - unaligned_size - freeable_size); + slop_bd->link = rejects; + rejects = slop_bd; + } } + bd = next; + } + // Place the rejected mblocks back on the free list. + while(rejects) { + // pop the top of the rejects list. + next = rejects; + rejects = next->link; + // place it back on the free list. + next->link = bd; + bd = next; } free_mblock_list[node] = bd; } ===================================== rts/sm/OSMem.h ===================================== @@ -10,6 +10,20 @@ #include "BeginPrivate.h" +#if defined(HAVE_LINUX_MMAN_H) +#include + +#define HUGEPAGE_SHIFT 21 +#define HUGEPAGE_FLAGS (MAP_HUGETLB | MAP_HUGE_2MB) +#else +#define HUGEPAGE_SHIFT 20 +#endif + +#define HUGEPAGE_SIZE (1 << HUGEPAGE_SHIFT) +#define HUGEPAGE_MASK ((1 << HUGEPAGE_SHIFT) - 1) +#define MBLOCK_ROUND_DOWN_HUGEPAGE(x) ((x) & ~(HUGEPAGE_SHIFT - MBLOCK_SHIFT)) +#define MBLOCK_ROUND_UP_HUGEPAGE(x) ((x) + ((x) & (HUGEPAGE_SHIFT - MBLOCK_SHIFT))) + void osMemInit(void); void *osGetMBlocks(uint32_t n); void osFreeMBlocks(void *addr, uint32_t n); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f5c087f4ecfdb0b486b59e2cb524409576cd9f86 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f5c087f4ecfdb0b486b59e2cb524409576cd9f86 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 11:03:30 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Tue, 07 May 2024 07:03:30 -0400 Subject: [Git][ghc/ghc][wip/reinstallable-th] Split out GHC.Internal.TH.Lift Message-ID: <663a0a825c22_3f177394a7c8479c@gitlab.mail> Teo Camarasu pushed to branch wip/reinstallable-th at Glasgow Haskell Compiler / GHC Commits: ee64ebcf by Teo Camarasu at 2024-05-07T12:03:04+01:00 Split out GHC.Internal.TH.Lift - - - - - 6 changed files: - compiler/GHC/Builtin/Names/TH.hs - + libraries/ghc-boot-th/GHC/Internal/TH/Lift.hs - libraries/ghc-boot-th/GHC/Internal/TH/Quote.hs - libraries/ghc-boot-th/GHC/Internal/TH/Syntax.hs - libraries/ghc-boot-th/ghc-boot-th.cabal.in - libraries/template-haskell/Language/Haskell/TH/Syntax.hs Changes: ===================================== compiler/GHC/Builtin/Names/TH.hs ===================================== @@ -179,21 +179,23 @@ templateHaskellNames = [ -- Quasiquoting quoteDecName, quoteTypeName, quoteExpName, quotePatName] -thSyn, thLib, qqLib :: Module +thSyn, thLib, qqLib, liftLib :: Module thSyn = mkTHModule (fsLit "GHC.Internal.TH.Syntax") thLib = mkTHModule (fsLit "GHC.Internal.TH.Lib") qqLib = mkTHModule (fsLit "GHC.Internal.TH.Quote") +liftLib = mkTHModule (fsLit "GHC.Internal.TH.Lift") mkTHModule :: FastString -> Module mkTHModule m = mkModule thUnit (mkModuleNameFS m) -libFun, libTc, thFun, thTc, thCls, thCon :: FastString -> Unique -> Name +libFun, libTc, thFun, thTc, thCls, thCon, liftFun :: FastString -> Unique -> Name libFun = mk_known_key_name varName thLib libTc = mk_known_key_name tcName thLib thFun = mk_known_key_name varName thSyn thTc = mk_known_key_name tcName thSyn thCls = mk_known_key_name clsName thSyn thCon = mk_known_key_name dataName thSyn +liftFun = mk_known_key_name varName liftLib thFld :: FastString -> FastString -> Unique -> Name thFld con = mk_known_key_name (fieldName con) thSyn @@ -203,7 +205,7 @@ qqFld = mk_known_key_name (fieldName (fsLit "QuasiQuoter")) qqLib -------------------- TH.Syntax ----------------------- liftClassName :: Name -liftClassName = thCls (fsLit "Lift") liftClassKey +liftClassName = mk_known_key_name clsName liftLib (fsLit "Lift") liftClassKey quoteClassName :: Name quoteClassName = thCls (fsLit "Quote") quoteClassKey @@ -239,8 +241,6 @@ returnQName = thFun (fsLit "returnQ") returnQIdKey bindQName = thFun (fsLit "bindQ") bindQIdKey sequenceQName = thFun (fsLit "sequenceQ") sequenceQIdKey newNameName = thFun (fsLit "newName") newNameIdKey -liftName = thFun (fsLit "lift") liftIdKey -liftStringName = thFun (fsLit "liftString") liftStringIdKey mkNameName = thFun (fsLit "mkName") mkNameIdKey mkNameG_vName = thFun (fsLit "mkNameG_v") mkNameG_vIdKey mkNameG_dName = thFun (fsLit "mkNameG_d") mkNameG_dIdKey @@ -253,7 +253,9 @@ mkModNameName = thFun (fsLit "mkModName") mkModNameIdKey unTypeName = thFld (fsLit "TExp") (fsLit "unType") unTypeIdKey unTypeCodeName = thFun (fsLit "unTypeCode") unTypeCodeIdKey unsafeCodeCoerceName = thFun (fsLit "unsafeCodeCoerce") unsafeCodeCoerceIdKey -liftTypedName = thFun (fsLit "liftTyped") liftTypedIdKey +liftName = liftFun (fsLit "lift") liftIdKey +liftStringName = liftFun (fsLit "liftString") liftStringIdKey +liftTypedName = liftFun (fsLit "liftTyped") liftTypedIdKey -------------------- TH.Lib ----------------------- ===================================== libraries/ghc-boot-th/GHC/Internal/TH/Lift.hs ===================================== @@ -0,0 +1,602 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedSums #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE TemplateHaskellQuotes #-} +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE DefaultSignatures #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE Trustworthy #-} +{-# OPTIONS_GHC -fno-warn-inline-rule-shadowing #-} +-- | + +module GHC.Internal.TH.Lift where + +import GHC.Internal.TH.Syntax + +import Prelude +import GHC.Types (TYPE, RuntimeRep(..), Levity(..)) +import Control.Monad (liftM) +import Data.Array.Byte (ByteArray(..)) +import Data.Char (ord) +import Data.Int +import Data.Ratio +import Data.Void ( Void, absurd ) +import GHC.CString ( unpackCString# ) +import GHC.Exts + ( ByteArray#, unsafeFreezeByteArray#, copyAddrToByteArray#, newByteArray# + , isByteArrayPinned#, isTrue#, sizeofByteArray#, unsafeCoerce#, byteArrayContents# + , copyByteArray#, newPinnedByteArray#) +import GHC.ForeignPtr (ForeignPtr(..), ForeignPtrContents(..)) +import GHC.Prim ( Int#, Word#, Char#, Double#, Float#, Addr# ) +import GHC.ST (ST(..), runST) +import GHC.Types ( Int(..), Word(..), Char(..), Double(..), Float(..)) +import Numeric.Natural +import qualified Data.Fixed as Fixed +import Data.Data hiding (Fixity(..)) +import Data.List.NonEmpty ( NonEmpty(..) ) +import Data.Word +import GHC.Lexeme ( startsVarSym, startsVarId ) + +-- See Note [Bootstrapping Template Haskell] + +----------------------------------------------------- +-- +-- The Lift class +-- +----------------------------------------------------- + +-- | A 'Lift' instance can have any of its values turned into a Template +-- Haskell expression. This is needed when a value used within a Template +-- Haskell quotation is bound outside the Oxford brackets (@[| ... |]@ or +-- @[|| ... ||]@) but not at the top level. As an example: +-- +-- > add1 :: Int -> Code Q Int +-- > add1 x = [|| x + 1 ||] +-- +-- Template Haskell has no way of knowing what value @x@ will take on at +-- splice-time, so it requires the type of @x@ to be an instance of 'Lift'. +-- +-- A 'Lift' instance must satisfy @$(lift x) ≡ x@ and @$$(liftTyped x) ≡ x@ +-- for all @x@, where @$(...)@ and @$$(...)@ are Template Haskell splices. +-- It is additionally expected that @'lift' x ≡ 'unTypeCode' ('liftTyped' x)@. +-- +-- 'Lift' instances can be derived automatically by use of the @-XDeriveLift@ +-- GHC language extension: +-- +-- > {-# LANGUAGE DeriveLift #-} +-- > module Foo where +-- > +-- > import Language.Haskell.TH.Syntax +-- > +-- > data Bar a = Bar1 a (Bar a) | Bar2 String +-- > deriving Lift +-- +-- Representation-polymorphic since /template-haskell-2.16.0.0/. +class Lift (t :: TYPE r) where + -- | Turn a value into a Template Haskell expression, suitable for use in + -- a splice. + lift :: Quote m => t -> m Exp + default lift :: (r ~ ('BoxedRep 'Lifted), Quote m) => t -> m Exp + lift = unTypeCode . liftTyped + + -- | Turn a value into a Template Haskell typed expression, suitable for use + -- in a typed splice. + -- + -- @since 2.16.0.0 + liftTyped :: Quote m => t -> Code m t + + +-- If you add any instances here, consider updating test th/TH_Lift +instance Lift Integer where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL x)) + +instance Lift Int where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +-- | @since 2.16.0.0 +instance Lift Int# where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntPrimL (fromIntegral (I# x)))) + +instance Lift Int8 where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +instance Lift Int16 where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +instance Lift Int32 where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +instance Lift Int64 where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +-- | @since 2.16.0.0 +instance Lift Word# where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (WordPrimL (fromIntegral (W# x)))) + +instance Lift Word where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +instance Lift Word8 where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +instance Lift Word16 where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +instance Lift Word32 where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +instance Lift Word64 where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +instance Lift Natural where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +instance Lift (Fixed.Fixed a) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (Fixed.MkFixed x) = do + ex <- lift x + return (ConE mkFixedName `AppE` ex) + where + mkFixedName = 'Fixed.MkFixed + +instance Integral a => Lift (Ratio a) where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (RationalL (toRational x))) + +instance Lift Float where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (RationalL (toRational x))) + +-- | @since 2.16.0.0 +instance Lift Float# where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (FloatPrimL (toRational (F# x)))) + +instance Lift Double where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (RationalL (toRational x))) + +-- | @since 2.16.0.0 +instance Lift Double# where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (DoublePrimL (toRational (D# x)))) + +instance Lift Char where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (CharL x)) + +-- | @since 2.16.0.0 +instance Lift Char# where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (CharPrimL (C# x))) + +instance Lift Bool where + liftTyped x = unsafeCodeCoerce (lift x) + + lift True = return (ConE trueName) + lift False = return (ConE falseName) + +-- | Produces an 'Addr#' literal from the NUL-terminated C-string starting at +-- the given memory address. +-- +-- @since 2.16.0.0 +instance Lift Addr# where + liftTyped x = unsafeCodeCoerce (lift x) + lift x + = return (LitE (StringPrimL (map (fromIntegral . ord) (unpackCString# x)))) + +-- | +-- @since 2.19.0.0 +instance Lift ByteArray where + liftTyped x = unsafeCodeCoerce (lift x) + lift (ByteArray b) = return + (AppE (AppE (VarE addrToByteArrayName) (LitE (IntegerL (fromIntegral len)))) + (LitE (BytesPrimL (Bytes ptr 0 (fromIntegral len))))) + where + len# = sizeofByteArray# b + len = I# len# + pb :: ByteArray# + !(ByteArray pb) + | isTrue# (isByteArrayPinned# b) = ByteArray b + | otherwise = runST $ ST $ + \s -> case newPinnedByteArray# len# s of + (# s', mb #) -> case copyByteArray# b 0# mb 0# len# s' of + s'' -> case unsafeFreezeByteArray# mb s'' of + (# s''', ret #) -> (# s''', ByteArray ret #) + ptr :: ForeignPtr Word8 + ptr = ForeignPtr (byteArrayContents# pb) (PlainPtr (unsafeCoerce# pb)) + +addrToByteArrayName :: Name +addrToByteArrayName = 'addrToByteArray + +addrToByteArray :: Int -> Addr# -> ByteArray +addrToByteArray (I# len) addr = runST $ ST $ + \s -> case newByteArray# len s of + (# s', mb #) -> case copyAddrToByteArray# addr mb 0# len s' of + s'' -> case unsafeFreezeByteArray# mb s'' of + (# s''', ret #) -> (# s''', ByteArray ret #) + +instance Lift a => Lift (Maybe a) where + liftTyped x = unsafeCodeCoerce (lift x) + + lift Nothing = return (ConE nothingName) + lift (Just x) = liftM (ConE justName `AppE`) (lift x) + +instance (Lift a, Lift b) => Lift (Either a b) where + liftTyped x = unsafeCodeCoerce (lift x) + + lift (Left x) = liftM (ConE leftName `AppE`) (lift x) + lift (Right y) = liftM (ConE rightName `AppE`) (lift y) + +instance Lift a => Lift [a] where + liftTyped x = unsafeCodeCoerce (lift x) + lift xs = do { xs' <- mapM lift xs; return (ListE xs') } + +liftString :: Quote m => String -> m Exp +-- Used in GHC.Tc.Gen.Expr to short-circuit the lifting for strings +liftString s = return (LitE (StringL s)) + +-- | @since 2.15.0.0 +instance Lift a => Lift (NonEmpty a) where + liftTyped x = unsafeCodeCoerce (lift x) + + lift (x :| xs) = do + x' <- lift x + xs' <- lift xs + return (InfixE (Just x') (ConE nonemptyName) (Just xs')) + +-- | @since 2.15.0.0 +instance Lift Void where + liftTyped = liftCode . absurd + lift = pure . absurd + +instance Lift () where + liftTyped x = unsafeCodeCoerce (lift x) + lift () = return (ConE (tupleDataName 0)) + +instance (Lift a, Lift b) => Lift (a, b) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (a, b) + = liftM TupE $ sequence $ map (fmap Just) [lift a, lift b] + +instance (Lift a, Lift b, Lift c) => Lift (a, b, c) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (a, b, c) + = liftM TupE $ sequence $ map (fmap Just) [lift a, lift b, lift c] + +instance (Lift a, Lift b, Lift c, Lift d) => Lift (a, b, c, d) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (a, b, c, d) + = liftM TupE $ sequence $ map (fmap Just) [lift a, lift b, lift c, lift d] + +instance (Lift a, Lift b, Lift c, Lift d, Lift e) + => Lift (a, b, c, d, e) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (a, b, c, d, e) + = liftM TupE $ sequence $ map (fmap Just) [ lift a, lift b + , lift c, lift d, lift e ] + +instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f) + => Lift (a, b, c, d, e, f) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (a, b, c, d, e, f) + = liftM TupE $ sequence $ map (fmap Just) [ lift a, lift b, lift c + , lift d, lift e, lift f ] + +instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f, Lift g) + => Lift (a, b, c, d, e, f, g) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (a, b, c, d, e, f, g) + = liftM TupE $ sequence $ map (fmap Just) [ lift a, lift b, lift c + , lift d, lift e, lift f, lift g ] + +-- | @since 2.16.0.0 +instance Lift (# #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (# #) = return (ConE (unboxedTupleTypeName 0)) + +-- | @since 2.16.0.0 +instance (Lift a) => Lift (# a #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (# a #) + = liftM UnboxedTupE $ sequence $ map (fmap Just) [lift a] + +-- | @since 2.16.0.0 +instance (Lift a, Lift b) => Lift (# a, b #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (# a, b #) + = liftM UnboxedTupE $ sequence $ map (fmap Just) [lift a, lift b] + +-- | @since 2.16.0.0 +instance (Lift a, Lift b, Lift c) + => Lift (# a, b, c #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (# a, b, c #) + = liftM UnboxedTupE $ sequence $ map (fmap Just) [lift a, lift b, lift c] + +-- | @since 2.16.0.0 +instance (Lift a, Lift b, Lift c, Lift d) + => Lift (# a, b, c, d #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (# a, b, c, d #) + = liftM UnboxedTupE $ sequence $ map (fmap Just) [ lift a, lift b + , lift c, lift d ] + +-- | @since 2.16.0.0 +instance (Lift a, Lift b, Lift c, Lift d, Lift e) + => Lift (# a, b, c, d, e #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (# a, b, c, d, e #) + = liftM UnboxedTupE $ sequence $ map (fmap Just) [ lift a, lift b + , lift c, lift d, lift e ] + +-- | @since 2.16.0.0 +instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f) + => Lift (# a, b, c, d, e, f #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (# a, b, c, d, e, f #) + = liftM UnboxedTupE $ sequence $ map (fmap Just) [ lift a, lift b, lift c + , lift d, lift e, lift f ] + +-- | @since 2.16.0.0 +instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f, Lift g) + => Lift (# a, b, c, d, e, f, g #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (# a, b, c, d, e, f, g #) + = liftM UnboxedTupE $ sequence $ map (fmap Just) [ lift a, lift b, lift c + , lift d, lift e, lift f + , lift g ] + +-- | @since 2.16.0.0 +instance (Lift a, Lift b) => Lift (# a | b #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift x + = case x of + (# y | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 2 + (# | y #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 2 + +-- | @since 2.16.0.0 +instance (Lift a, Lift b, Lift c) + => Lift (# a | b | c #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift x + = case x of + (# y | | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 3 + (# | y | #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 3 + (# | | y #) -> UnboxedSumE <$> lift y <*> pure 3 <*> pure 3 + +-- | @since 2.16.0.0 +instance (Lift a, Lift b, Lift c, Lift d) + => Lift (# a | b | c | d #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift x + = case x of + (# y | | | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 4 + (# | y | | #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 4 + (# | | y | #) -> UnboxedSumE <$> lift y <*> pure 3 <*> pure 4 + (# | | | y #) -> UnboxedSumE <$> lift y <*> pure 4 <*> pure 4 + +-- | @since 2.16.0.0 +instance (Lift a, Lift b, Lift c, Lift d, Lift e) + => Lift (# a | b | c | d | e #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift x + = case x of + (# y | | | | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 5 + (# | y | | | #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 5 + (# | | y | | #) -> UnboxedSumE <$> lift y <*> pure 3 <*> pure 5 + (# | | | y | #) -> UnboxedSumE <$> lift y <*> pure 4 <*> pure 5 + (# | | | | y #) -> UnboxedSumE <$> lift y <*> pure 5 <*> pure 5 + +-- | @since 2.16.0.0 +instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f) + => Lift (# a | b | c | d | e | f #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift x + = case x of + (# y | | | | | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 6 + (# | y | | | | #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 6 + (# | | y | | | #) -> UnboxedSumE <$> lift y <*> pure 3 <*> pure 6 + (# | | | y | | #) -> UnboxedSumE <$> lift y <*> pure 4 <*> pure 6 + (# | | | | y | #) -> UnboxedSumE <$> lift y <*> pure 5 <*> pure 6 + (# | | | | | y #) -> UnboxedSumE <$> lift y <*> pure 6 <*> pure 6 + +-- | @since 2.16.0.0 +instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f, Lift g) + => Lift (# a | b | c | d | e | f | g #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift x + = case x of + (# y | | | | | | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 7 + (# | y | | | | | #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 7 + (# | | y | | | | #) -> UnboxedSumE <$> lift y <*> pure 3 <*> pure 7 + (# | | | y | | | #) -> UnboxedSumE <$> lift y <*> pure 4 <*> pure 7 + (# | | | | y | | #) -> UnboxedSumE <$> lift y <*> pure 5 <*> pure 7 + (# | | | | | y | #) -> UnboxedSumE <$> lift y <*> pure 6 <*> pure 7 + (# | | | | | | y #) -> UnboxedSumE <$> lift y <*> pure 7 <*> pure 7 + +-- TH has a special form for literal strings, +-- which we should take advantage of. +-- NB: the lhs of the rule has no args, so that +-- the rule will apply to a 'lift' all on its own +-- which happens to be the way the type checker +-- creates it. +{-# RULES "TH:liftString" lift = \s -> return (LitE (StringL s)) #-} + + +trueName, falseName :: Name +trueName = 'True +falseName = 'False + +nothingName, justName :: Name +nothingName = 'Nothing +justName = 'Just + +leftName, rightName :: Name +leftName = 'Left +rightName = 'Right + +nonemptyName :: Name +nonemptyName = '(:|) + +----------------------------------------------------- +-- +-- Generic Lift implementations +-- +----------------------------------------------------- + +-- | 'dataToQa' is an internal utility function for constructing generic +-- conversion functions from types with 'Data' instances to various +-- quasi-quoting representations. See the source of 'dataToExpQ' and +-- 'dataToPatQ' for two example usages: @mkCon@, @mkLit@ +-- and @appQ@ are overloadable to account for different syntax for +-- expressions and patterns; @antiQ@ allows you to override type-specific +-- cases, a common usage is just @const Nothing@, which results in +-- no overloading. +dataToQa :: forall m a k q. (Quote m, Data a) + => (Name -> k) + -> (Lit -> m q) + -> (k -> [m q] -> m q) + -> (forall b . Data b => b -> Maybe (m q)) + -> a + -> m q +dataToQa mkCon mkLit appCon antiQ t = + case antiQ t of + Nothing -> + case constrRep constr of + AlgConstr _ -> + appCon (mkCon funOrConName) conArgs + where + funOrConName :: Name + funOrConName = + case showConstr constr of + "(:)" -> Name (mkOccName ":") + (NameG DataName + (mkPkgName "ghc-prim") + (mkModName "GHC.Types")) + con@"[]" -> Name (mkOccName con) + (NameG DataName + (mkPkgName "ghc-prim") + (mkModName "GHC.Types")) + con@('(':_) -> Name (mkOccName con) + (NameG DataName + (mkPkgName "ghc-prim") + (mkModName "GHC.Tuple")) + + -- Tricky case: see Note [Data for non-algebraic types] + fun@(x:_) | startsVarSym x || startsVarId x + -> mkNameG_v tyconPkg tyconMod fun + con -> mkNameG_d tyconPkg tyconMod con + + where + tycon :: TyCon + tycon = (typeRepTyCon . typeOf) t + + tyconPkg, tyconMod :: String + tyconPkg = tyConPackage tycon + tyconMod = tyConModule tycon + + conArgs :: [m q] + conArgs = gmapQ (dataToQa mkCon mkLit appCon antiQ) t + IntConstr n -> + mkLit $ IntegerL n + FloatConstr n -> + mkLit $ RationalL n + CharConstr c -> + mkLit $ CharL c + where + constr :: Constr + constr = toConstr t + + Just y -> y + + +{- Note [Data for non-algebraic types] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Class Data was originally intended for algebraic data types. But +it is possible to use it for abstract types too. For example, in +package `text` we find + + instance Data Text where + ... + toConstr _ = packConstr + + packConstr :: Constr + packConstr = mkConstr textDataType "pack" [] Prefix + +Here `packConstr` isn't a real data constructor, it's an ordinary +function. Two complications + +* In such a case, we must take care to build the Name using + mkNameG_v (for values), not mkNameG_d (for data constructors). + See #10796. + +* The pseudo-constructor is named only by its string, here "pack". + But 'dataToQa' needs the TyCon of its defining module, and has + to assume it's defined in the same module as the TyCon itself. + But nothing enforces that; #12596 shows what goes wrong if + "pack" is defined in a different module than the data type "Text". + -} + +-- | 'dataToExpQ' converts a value to a 'Exp' representation of the +-- same value, in the SYB style. It is generalized to take a function +-- override type-specific cases; see 'liftData' for a more commonly +-- used variant. +dataToExpQ :: (Quote m, Data a) + => (forall b . Data b => b -> Maybe (m Exp)) + -> a + -> m Exp +dataToExpQ = dataToQa varOrConE litE (foldl appE) + where + -- Make sure that VarE is used if the Constr value relies on a + -- function underneath the surface (instead of a constructor). + -- See #10796. + varOrConE s = + case nameSpace s of + Just VarName -> return (VarE s) + Just (FldName {}) -> return (VarE s) + Just DataName -> return (ConE s) + _ -> error $ "Can't construct an expression from name " + ++ showName s + appE x y = do { a <- x; b <- y; return (AppE a b)} + litE c = return (LitE c) + +-- | 'liftData' is a variant of 'lift' in the 'Lift' type class which +-- works for any type with a 'Data' instance. +liftData :: (Quote m, Data a) => a -> m Exp +liftData = dataToExpQ (const Nothing) + +-- | 'dataToPatQ' converts a value to a 'Pat' representation of the same +-- value, in the SYB style. It takes a function to handle type-specific cases, +-- alternatively, pass @const Nothing@ to get default behavior. +dataToPatQ :: (Quote m, Data a) + => (forall b . Data b => b -> Maybe (m Pat)) + -> a + -> m Pat +dataToPatQ = dataToQa id litP conP + where litP l = return (LitP l) + conP n ps = + case nameSpace n of + Just DataName -> do + ps' <- sequence ps + return (ConP n [] ps') + _ -> error $ "Can't construct a pattern from name " + ++ showName n ===================================== libraries/ghc-boot-th/GHC/Internal/TH/Quote.hs ===================================== @@ -21,6 +21,7 @@ module GHC.Internal.TH.Quote( ) where import GHC.Internal.TH.Syntax +import GHC.Internal.TH.Lift import Prelude -- | The 'QuasiQuoter' type, a value @q@ of this type can be used @@ -48,10 +49,10 @@ data QuasiQuoter = QuasiQuoter { -- the quote [asmq_f|foo.s|] will take input from file @"foo.s"@ instead -- of the inline text quoteFile :: QuasiQuoter -> QuasiQuoter -quoteFile (QuasiQuoter { quoteExp = qe, quotePat = qp, quoteType = qt, quoteDec = qd }) +quoteFile (QuasiQuoter { quoteExp = qe, quotePat = qp, quoteType = qt, quoteDec = qd }) = QuasiQuoter { quoteExp = get qe, quotePat = get qp, quoteType = get qt, quoteDec = get qd } where get :: (String -> Q a) -> String -> Q a - get old_quoter file_name = do { file_cts <- runIO (readFile file_name) + get old_quoter file_name = do { file_cts <- runIO (readFile file_name) ; addDependentFile file_name ; old_quoter file_cts } ===================================== libraries/ghc-boot-th/GHC/Internal/TH/Syntax.hs ===================================== @@ -7,7 +7,6 @@ Trustworthy, DeriveFunctor, DeriveTraversable, BangPatterns, RecordWildCards, ImplicitParams #-} -{-# OPTIONS_GHC -fno-warn-inline-rule-shadowing #-} {-# LANGUAGE TemplateHaskellQuotes #-} {-# LANGUAGE StandaloneKindSignatures #-} @@ -45,34 +44,13 @@ import Data.Word import GHC.Generics ( Generic ) import qualified Data.Kind as Kind (Type) import GHC.Ptr ( Ptr, plusPtr ) -import GHC.Lexeme ( startsVarSym, startsVarId ) import GHC.ForeignSrcLang.Type import GHC.LanguageExtensions.Type import Prelude hiding (Applicative(..)) import Foreign.ForeignPtr import Foreign.C.String import Foreign.C.Types -import GHC.Types (TYPE, RuntimeRep(..), Levity(..)) - -#ifndef BOOTSTRAP_TH -import Control.Monad (liftM) -import Data.Array.Byte (ByteArray(..)) -import Data.Char (ord) -import Data.Int -import Data.Ratio -import Data.Void ( Void, absurd ) -import GHC.CString ( unpackCString# ) -import GHC.Exts - ( ByteArray#, unsafeFreezeByteArray#, copyAddrToByteArray#, newByteArray# - , isByteArrayPinned#, isTrue#, sizeofByteArray#, unsafeCoerce#, byteArrayContents# - , copyByteArray#, newPinnedByteArray#) -import GHC.ForeignPtr (ForeignPtr(..), ForeignPtrContents(..)) -import GHC.Prim ( Int#, Word#, Char#, Double#, Float#, Addr# ) -import GHC.ST (ST(..), runST) -import GHC.Types ( Int(..), Word(..), Char(..), Double(..), Float(..)) -import Numeric.Natural -import qualified Data.Fixed as Fixed -#endif +import GHC.Types (TYPE, RuntimeRep(..)) ----------------------------------------------------- -- @@ -960,570 +938,11 @@ sequenceQ :: forall m . Monad m => forall a . [m a] -> m [a] sequenceQ = sequence ------------------------------------------------------ --- --- The Lift class --- ------------------------------------------------------ - --- | A 'Lift' instance can have any of its values turned into a Template --- Haskell expression. This is needed when a value used within a Template --- Haskell quotation is bound outside the Oxford brackets (@[| ... |]@ or --- @[|| ... ||]@) but not at the top level. As an example: --- --- > add1 :: Int -> Code Q Int --- > add1 x = [|| x + 1 ||] --- --- Template Haskell has no way of knowing what value @x@ will take on at --- splice-time, so it requires the type of @x@ to be an instance of 'Lift'. --- --- A 'Lift' instance must satisfy @$(lift x) ≡ x@ and @$$(liftTyped x) ≡ x@ --- for all @x@, where @$(...)@ and @$$(...)@ are Template Haskell splices. --- It is additionally expected that @'lift' x ≡ 'unTypeCode' ('liftTyped' x)@. --- --- 'Lift' instances can be derived automatically by use of the @-XDeriveLift@ --- GHC language extension: --- --- > {-# LANGUAGE DeriveLift #-} --- > module Foo where --- > --- > import Language.Haskell.TH.Syntax --- > --- > data Bar a = Bar1 a (Bar a) | Bar2 String --- > deriving Lift --- --- Representation-polymorphic since /template-haskell-2.16.0.0/. -class Lift (t :: TYPE r) where - -- | Turn a value into a Template Haskell expression, suitable for use in - -- a splice. - lift :: Quote m => t -> m Exp - default lift :: (r ~ ('BoxedRep 'Lifted), Quote m) => t -> m Exp - lift = unTypeCode . liftTyped - - -- | Turn a value into a Template Haskell typed expression, suitable for use - -- in a typed splice. - -- - -- @since 2.16.0.0 - liftTyped :: Quote m => t -> Code m t - - --- See Note [Bootstrapping Template Haskell] -#ifndef BOOTSTRAP_TH --- If you add any instances here, consider updating test th/TH_Lift -instance Lift Integer where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL x)) - -instance Lift Int where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - --- | @since 2.16.0.0 -instance Lift Int# where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntPrimL (fromIntegral (I# x)))) - -instance Lift Int8 where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - -instance Lift Int16 where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - -instance Lift Int32 where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - -instance Lift Int64 where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - --- | @since 2.16.0.0 -instance Lift Word# where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (WordPrimL (fromIntegral (W# x)))) - -instance Lift Word where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - -instance Lift Word8 where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - -instance Lift Word16 where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - -instance Lift Word32 where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - -instance Lift Word64 where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - -instance Lift Natural where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - -instance Lift (Fixed.Fixed a) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (Fixed.MkFixed x) = do - ex <- lift x - return (ConE mkFixedName `AppE` ex) - where - mkFixedName = 'Fixed.MkFixed - -instance Integral a => Lift (Ratio a) where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (RationalL (toRational x))) - -instance Lift Float where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (RationalL (toRational x))) - --- | @since 2.16.0.0 -instance Lift Float# where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (FloatPrimL (toRational (F# x)))) - -instance Lift Double where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (RationalL (toRational x))) - --- | @since 2.16.0.0 -instance Lift Double# where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (DoublePrimL (toRational (D# x)))) - -instance Lift Char where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (CharL x)) - --- | @since 2.16.0.0 -instance Lift Char# where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (CharPrimL (C# x))) - -instance Lift Bool where - liftTyped x = unsafeCodeCoerce (lift x) - - lift True = return (ConE trueName) - lift False = return (ConE falseName) - --- | Produces an 'Addr#' literal from the NUL-terminated C-string starting at --- the given memory address. --- --- @since 2.16.0.0 -instance Lift Addr# where - liftTyped x = unsafeCodeCoerce (lift x) - lift x - = return (LitE (StringPrimL (map (fromIntegral . ord) (unpackCString# x)))) - --- | --- @since 2.19.0.0 -instance Lift ByteArray where - liftTyped x = unsafeCodeCoerce (lift x) - lift (ByteArray b) = return - (AppE (AppE (VarE addrToByteArrayName) (LitE (IntegerL (fromIntegral len)))) - (LitE (BytesPrimL (Bytes ptr 0 (fromIntegral len))))) - where - len# = sizeofByteArray# b - len = I# len# - pb :: ByteArray# - !(ByteArray pb) - | isTrue# (isByteArrayPinned# b) = ByteArray b - | otherwise = runST $ ST $ - \s -> case newPinnedByteArray# len# s of - (# s', mb #) -> case copyByteArray# b 0# mb 0# len# s' of - s'' -> case unsafeFreezeByteArray# mb s'' of - (# s''', ret #) -> (# s''', ByteArray ret #) - ptr :: ForeignPtr Word8 - ptr = ForeignPtr (byteArrayContents# pb) (PlainPtr (unsafeCoerce# pb)) - -addrToByteArrayName :: Name -addrToByteArrayName = 'addrToByteArray - -addrToByteArray :: Int -> Addr# -> ByteArray -addrToByteArray (I# len) addr = runST $ ST $ - \s -> case newByteArray# len s of - (# s', mb #) -> case copyAddrToByteArray# addr mb 0# len s' of - s'' -> case unsafeFreezeByteArray# mb s'' of - (# s''', ret #) -> (# s''', ByteArray ret #) - -instance Lift a => Lift (Maybe a) where - liftTyped x = unsafeCodeCoerce (lift x) - - lift Nothing = return (ConE nothingName) - lift (Just x) = liftM (ConE justName `AppE`) (lift x) - -instance (Lift a, Lift b) => Lift (Either a b) where - liftTyped x = unsafeCodeCoerce (lift x) - - lift (Left x) = liftM (ConE leftName `AppE`) (lift x) - lift (Right y) = liftM (ConE rightName `AppE`) (lift y) - -instance Lift a => Lift [a] where - liftTyped x = unsafeCodeCoerce (lift x) - lift xs = do { xs' <- mapM lift xs; return (ListE xs') } - -liftString :: Quote m => String -> m Exp --- Used in GHC.Tc.Gen.Expr to short-circuit the lifting for strings -liftString s = return (LitE (StringL s)) - --- | @since 2.15.0.0 -instance Lift a => Lift (NonEmpty a) where - liftTyped x = unsafeCodeCoerce (lift x) - - lift (x :| xs) = do - x' <- lift x - xs' <- lift xs - return (InfixE (Just x') (ConE nonemptyName) (Just xs')) - --- | @since 2.15.0.0 -instance Lift Void where - liftTyped = liftCode . absurd - lift = pure . absurd - -instance Lift () where - liftTyped x = unsafeCodeCoerce (lift x) - lift () = return (ConE (tupleDataName 0)) - -instance (Lift a, Lift b) => Lift (a, b) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (a, b) - = liftM TupE $ sequence $ map (fmap Just) [lift a, lift b] - -instance (Lift a, Lift b, Lift c) => Lift (a, b, c) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (a, b, c) - = liftM TupE $ sequence $ map (fmap Just) [lift a, lift b, lift c] - -instance (Lift a, Lift b, Lift c, Lift d) => Lift (a, b, c, d) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (a, b, c, d) - = liftM TupE $ sequence $ map (fmap Just) [lift a, lift b, lift c, lift d] - -instance (Lift a, Lift b, Lift c, Lift d, Lift e) - => Lift (a, b, c, d, e) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (a, b, c, d, e) - = liftM TupE $ sequence $ map (fmap Just) [ lift a, lift b - , lift c, lift d, lift e ] - -instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f) - => Lift (a, b, c, d, e, f) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (a, b, c, d, e, f) - = liftM TupE $ sequence $ map (fmap Just) [ lift a, lift b, lift c - , lift d, lift e, lift f ] - -instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f, Lift g) - => Lift (a, b, c, d, e, f, g) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (a, b, c, d, e, f, g) - = liftM TupE $ sequence $ map (fmap Just) [ lift a, lift b, lift c - , lift d, lift e, lift f, lift g ] - --- | @since 2.16.0.0 -instance Lift (# #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (# #) = return (ConE (unboxedTupleTypeName 0)) - --- | @since 2.16.0.0 -instance (Lift a) => Lift (# a #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (# a #) - = liftM UnboxedTupE $ sequence $ map (fmap Just) [lift a] - --- | @since 2.16.0.0 -instance (Lift a, Lift b) => Lift (# a, b #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (# a, b #) - = liftM UnboxedTupE $ sequence $ map (fmap Just) [lift a, lift b] - --- | @since 2.16.0.0 -instance (Lift a, Lift b, Lift c) - => Lift (# a, b, c #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (# a, b, c #) - = liftM UnboxedTupE $ sequence $ map (fmap Just) [lift a, lift b, lift c] - --- | @since 2.16.0.0 -instance (Lift a, Lift b, Lift c, Lift d) - => Lift (# a, b, c, d #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (# a, b, c, d #) - = liftM UnboxedTupE $ sequence $ map (fmap Just) [ lift a, lift b - , lift c, lift d ] - --- | @since 2.16.0.0 -instance (Lift a, Lift b, Lift c, Lift d, Lift e) - => Lift (# a, b, c, d, e #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (# a, b, c, d, e #) - = liftM UnboxedTupE $ sequence $ map (fmap Just) [ lift a, lift b - , lift c, lift d, lift e ] - --- | @since 2.16.0.0 -instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f) - => Lift (# a, b, c, d, e, f #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (# a, b, c, d, e, f #) - = liftM UnboxedTupE $ sequence $ map (fmap Just) [ lift a, lift b, lift c - , lift d, lift e, lift f ] - --- | @since 2.16.0.0 -instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f, Lift g) - => Lift (# a, b, c, d, e, f, g #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (# a, b, c, d, e, f, g #) - = liftM UnboxedTupE $ sequence $ map (fmap Just) [ lift a, lift b, lift c - , lift d, lift e, lift f - , lift g ] - --- | @since 2.16.0.0 -instance (Lift a, Lift b) => Lift (# a | b #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift x - = case x of - (# y | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 2 - (# | y #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 2 - --- | @since 2.16.0.0 -instance (Lift a, Lift b, Lift c) - => Lift (# a | b | c #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift x - = case x of - (# y | | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 3 - (# | y | #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 3 - (# | | y #) -> UnboxedSumE <$> lift y <*> pure 3 <*> pure 3 - --- | @since 2.16.0.0 -instance (Lift a, Lift b, Lift c, Lift d) - => Lift (# a | b | c | d #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift x - = case x of - (# y | | | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 4 - (# | y | | #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 4 - (# | | y | #) -> UnboxedSumE <$> lift y <*> pure 3 <*> pure 4 - (# | | | y #) -> UnboxedSumE <$> lift y <*> pure 4 <*> pure 4 - --- | @since 2.16.0.0 -instance (Lift a, Lift b, Lift c, Lift d, Lift e) - => Lift (# a | b | c | d | e #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift x - = case x of - (# y | | | | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 5 - (# | y | | | #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 5 - (# | | y | | #) -> UnboxedSumE <$> lift y <*> pure 3 <*> pure 5 - (# | | | y | #) -> UnboxedSumE <$> lift y <*> pure 4 <*> pure 5 - (# | | | | y #) -> UnboxedSumE <$> lift y <*> pure 5 <*> pure 5 - --- | @since 2.16.0.0 -instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f) - => Lift (# a | b | c | d | e | f #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift x - = case x of - (# y | | | | | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 6 - (# | y | | | | #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 6 - (# | | y | | | #) -> UnboxedSumE <$> lift y <*> pure 3 <*> pure 6 - (# | | | y | | #) -> UnboxedSumE <$> lift y <*> pure 4 <*> pure 6 - (# | | | | y | #) -> UnboxedSumE <$> lift y <*> pure 5 <*> pure 6 - (# | | | | | y #) -> UnboxedSumE <$> lift y <*> pure 6 <*> pure 6 - --- | @since 2.16.0.0 -instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f, Lift g) - => Lift (# a | b | c | d | e | f | g #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift x - = case x of - (# y | | | | | | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 7 - (# | y | | | | | #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 7 - (# | | y | | | | #) -> UnboxedSumE <$> lift y <*> pure 3 <*> pure 7 - (# | | | y | | | #) -> UnboxedSumE <$> lift y <*> pure 4 <*> pure 7 - (# | | | | y | | #) -> UnboxedSumE <$> lift y <*> pure 5 <*> pure 7 - (# | | | | | y | #) -> UnboxedSumE <$> lift y <*> pure 6 <*> pure 7 - (# | | | | | | y #) -> UnboxedSumE <$> lift y <*> pure 7 <*> pure 7 - --- TH has a special form for literal strings, --- which we should take advantage of. --- NB: the lhs of the rule has no args, so that --- the rule will apply to a 'lift' all on its own --- which happens to be the way the type checker --- creates it. -{-# RULES "TH:liftString" lift = \s -> return (LitE (StringL s)) #-} - - -trueName, falseName :: Name -trueName = 'True -falseName = 'False - -nothingName, justName :: Name -nothingName = 'Nothing -justName = 'Just - -leftName, rightName :: Name -leftName = 'Left -rightName = 'Right - -nonemptyName :: Name -nonemptyName = '(:|) -#endif oneName, manyName :: Name oneName = mkNameG DataName "ghc-prim" "GHC.Types" "One" manyName = mkNameG DataName "ghc-prim" "GHC.Types" "Many" ------------------------------------------------------ --- --- Generic Lift implementations --- ------------------------------------------------------ - --- | 'dataToQa' is an internal utility function for constructing generic --- conversion functions from types with 'Data' instances to various --- quasi-quoting representations. See the source of 'dataToExpQ' and --- 'dataToPatQ' for two example usages: @mkCon@, @mkLit@ --- and @appQ@ are overloadable to account for different syntax for --- expressions and patterns; @antiQ@ allows you to override type-specific --- cases, a common usage is just @const Nothing@, which results in --- no overloading. -dataToQa :: forall m a k q. (Quote m, Data a) - => (Name -> k) - -> (Lit -> m q) - -> (k -> [m q] -> m q) - -> (forall b . Data b => b -> Maybe (m q)) - -> a - -> m q -dataToQa mkCon mkLit appCon antiQ t = - case antiQ t of - Nothing -> - case constrRep constr of - AlgConstr _ -> - appCon (mkCon funOrConName) conArgs - where - funOrConName :: Name - funOrConName = - case showConstr constr of - "(:)" -> Name (mkOccName ":") - (NameG DataName - (mkPkgName "ghc-prim") - (mkModName "GHC.Types")) - con@"[]" -> Name (mkOccName con) - (NameG DataName - (mkPkgName "ghc-prim") - (mkModName "GHC.Types")) - con@('(':_) -> Name (mkOccName con) - (NameG DataName - (mkPkgName "ghc-prim") - (mkModName "GHC.Tuple")) - - -- Tricky case: see Note [Data for non-algebraic types] - fun@(x:_) | startsVarSym x || startsVarId x - -> mkNameG_v tyconPkg tyconMod fun - con -> mkNameG_d tyconPkg tyconMod con - - where - tycon :: TyCon - tycon = (typeRepTyCon . typeOf) t - - tyconPkg, tyconMod :: String - tyconPkg = tyConPackage tycon - tyconMod = tyConModule tycon - - conArgs :: [m q] - conArgs = gmapQ (dataToQa mkCon mkLit appCon antiQ) t - IntConstr n -> - mkLit $ IntegerL n - FloatConstr n -> - mkLit $ RationalL n - CharConstr c -> - mkLit $ CharL c - where - constr :: Constr - constr = toConstr t - - Just y -> y - - -{- Note [Data for non-algebraic types] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Class Data was originally intended for algebraic data types. But -it is possible to use it for abstract types too. For example, in -package `text` we find - - instance Data Text where - ... - toConstr _ = packConstr - - packConstr :: Constr - packConstr = mkConstr textDataType "pack" [] Prefix - -Here `packConstr` isn't a real data constructor, it's an ordinary -function. Two complications - -* In such a case, we must take care to build the Name using - mkNameG_v (for values), not mkNameG_d (for data constructors). - See #10796. - -* The pseudo-constructor is named only by its string, here "pack". - But 'dataToQa' needs the TyCon of its defining module, and has - to assume it's defined in the same module as the TyCon itself. - But nothing enforces that; #12596 shows what goes wrong if - "pack" is defined in a different module than the data type "Text". - -} - --- | 'dataToExpQ' converts a value to a 'Exp' representation of the --- same value, in the SYB style. It is generalized to take a function --- override type-specific cases; see 'liftData' for a more commonly --- used variant. -dataToExpQ :: (Quote m, Data a) - => (forall b . Data b => b -> Maybe (m Exp)) - -> a - -> m Exp -dataToExpQ = dataToQa varOrConE litE (foldl appE) - where - -- Make sure that VarE is used if the Constr value relies on a - -- function underneath the surface (instead of a constructor). - -- See #10796. - varOrConE s = - case nameSpace s of - Just VarName -> return (VarE s) - Just (FldName {}) -> return (VarE s) - Just DataName -> return (ConE s) - _ -> error $ "Can't construct an expression from name " - ++ showName s - appE x y = do { a <- x; b <- y; return (AppE a b)} - litE c = return (LitE c) - --- | 'liftData' is a variant of 'lift' in the 'Lift' type class which --- works for any type with a 'Data' instance. -liftData :: (Quote m, Data a) => a -> m Exp -liftData = dataToExpQ (const Nothing) - --- | 'dataToPatQ' converts a value to a 'Pat' representation of the same --- value, in the SYB style. It takes a function to handle type-specific cases, --- alternatively, pass @const Nothing@ to get default behavior. -dataToPatQ :: (Quote m, Data a) - => (forall b . Data b => b -> Maybe (m Pat)) - -> a - -> m Pat -dataToPatQ = dataToQa id litP conP - where litP l = return (LitP l) - conP n ps = - case nameSpace n of - Just DataName -> do - ps' <- sequence ps - return (ConP n [] ps') - _ -> error $ "Can't construct a pattern from name " - ++ showName n ----------------------------------------------------- -- Names and uniques ===================================== libraries/ghc-boot-th/ghc-boot-th.cabal.in ===================================== @@ -48,7 +48,6 @@ Library GHC.Internal.TH.Lib GHC.Internal.TH.Lib.Map GHC.Internal.TH.Syntax - GHC.Internal.TH.Quote GHC.Internal.TH.Ppr GHC.Internal.TH.PprLib @@ -57,9 +56,10 @@ Library ghc-prim, pretty == 1.1.* - if flag(bootstrap) - cpp-options: -DBOOTSTRAP_TH - else + if !flag(bootstrap) -- We need to set the unit ID to template-haskell (without a -- version number) as it's magic. ghc-options: -this-unit-id ghc-boot-th + exposed-modules: + GHC.Internal.TH.Lift + GHC.Internal.TH.Quote ===================================== libraries/template-haskell/Language/Haskell/TH/Syntax.hs ===================================== @@ -1,10 +1,12 @@ module Language.Haskell.TH.Syntax ( module GHC.Internal.TH.Syntax + , module GHC.Internal.TH.Lift , makeRelativeToProject ) where import GHC.Internal.TH.Syntax +import GHC.Internal.TH.Lift import System.FilePath -- The only difference between this module and GHC.Internal.TH.Syntax View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ee64ebcf2cb80276ffcc08868fd094e026e9afe6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ee64ebcf2cb80276ffcc08868fd094e026e9afe6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 11:36:17 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Tue, 07 May 2024 07:36:17 -0400 Subject: [Git][ghc/ghc][wip/fendor/ifacetype-deduplication] 47 commits: utils: remove obsolete vagrant scripts Message-ID: <663a12314160a_3f1773d411ec50734@gitlab.mail> Hannes Siebenhandl pushed to branch wip/fendor/ifacetype-deduplication at Glasgow Haskell Compiler / GHC Commits: 728af21e by Cheng Shao at 2024-04-30T05:30:23-04:00 utils: remove obsolete vagrant scripts Vagrantfile has long been removed in !5288. This commit further removes the obsolete vagrant scripts in the tree. - - - - - 36f2c342 by Cheng Shao at 2024-04-30T05:31:00-04:00 Update autoconf scripts Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 - - - - - ecbf22a6 by Ben Gamari at 2024-04-30T05:31:36-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 7eab4e01 by Alan Zimmerman at 2024-05-04T16:14:55+01:00 EPA: Widen stmtslist to include last semicolon Closes #24754 - - - - - 06f7db40 by Teo Camarasu at 2024-05-05T00:19:38-04:00 doc: Fix type error in hs_try_putmvar example - - - - - af000532 by Moritz Schuler at 2024-05-05T06:30:58-04:00 Fix parsing of module names in CLI arguments closes issue #24732 - - - - - da74e9c9 by Ben Gamari at 2024-05-05T06:31:34-04:00 ghc-platform: Add Setup.hs The Hadrian bootstrapping script relies upon `Setup.hs` to drive its build. Addresses #24761. - - - - - 35d34fde by Alan Zimmerman at 2024-05-05T12:52:40-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 - - - - - 03c5dfbf by Simon Peyton Jones at 2024-05-05T12:53:15-04:00 Fix a float-out error Ticket #24768 showed that the Simplifier was accidentally destroying a join point. It turned out to be that we were sending a bottoming join point to the top, accidentally abstracting over /other/ join points. Easily fixed. - - - - - adba68e7 by John Ericson at 2024-05-05T19:35:56-04:00 Substitute bindist files with Hadrian not configure The `ghc-toolchain` overhaul will eventually replace all this stuff with something much more cleaned up, but I think it is still worth making this sort of cleanup in the meantime so other untanglings and dead code cleaning can procede. I was able to delete a fair amount of dead code doing this too. `LLVMTarget_CPP` is renamed to / merged with `LLVMTarget` because it wasn't actually turned into a valid CPP identifier. (Original to 1345c7cc42c45e63ab1726a8fd24a7e4d4222467, actually.) Progress on #23966 Co-Authored-By: Sylvain Henry <hsyl20 at gmail.com> - - - - - 18f4ff84 by Alan Zimmerman at 2024-05-05T19:36:32-04:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 - - - - - a19201d4 by Matthew Craven at 2024-05-06T19:54:29-04:00 Add test cases for #24664 ...since none are present in the original MR !12463 fixing this issue. - - - - - 46328a49 by Alan Zimmerman at 2024-05-06T19:55:05-04:00 EPA: preserve comments in data decls Closes #24771 - - - - - ae0330ac by Fendor at 2024-05-07T13:15:43+02:00 Add Eq and Ord instance to `IfaceType` We add an `Ord` instance so that we can store `IfaceType` in a `Data.Map` container. This is required to deduplicate `IfaceType` while writing `.hi` files to disk. Deduplication has many beneficial consequences to both file size and memory usage, as the deduplication enables implicit sharing of values. See issue #24540 for more motivation. The `Ord` instance would be unnecessary if we used a `TrieMap` instead of `Data.Map` for the deduplication process. While in theory this is clerarly the better option, experiments on the agda code base showed that a `TrieMap` implementation has worse run-time performance characteristics. To the change itself, we mostly derive `Eq` and `Ord`. This requires us to change occurrences of `FastString` with `LexicalFastString`, since `FastString` has no `Ord` instance. We change the definition of `IfLclName` to a newtype of `LexicalFastString`, to make such changes in the future easier. Bump haddock submodule for IfLclName changes - - - - - dd3cc486 by Fendor at 2024-05-07T13:17:13+02:00 Move out LiteralMap to avoid cyclic module dependencies - - - - - 0276bbd6 by Fendor at 2024-05-07T13:36:05+02:00 Add deduplication table for `IfaceType` The type `IfaceType` is a highly redundant, tree-like data structure. While benchmarking, we realised that the high redundancy of `IfaceType` causes high memory consumption in GHCi sessions when byte code is embedded into the `.hi` file via `-fwrite-if-simplified-core` or `-fbyte-code-and-object-code`. Loading such `.hi` files from disk introduces many duplicates of memory expensive values in `IfaceType`, such as `IfaceTyCon`, `IfaceTyConApp`, `IA_Arg` and many more. We improve the memory behaviour of GHCi by adding an additional deduplication table for `IfaceType` to the serialisation of `ModIface`, similar to how we deduplicate `Name`s and `FastString`s. When reading the interface file back, the table allows us to automatically share identical values of `IfaceType`. To provide some numbers, we evaluated this patch on the agda code base. We loaded the full library from the `.hi` files, which contained the embedded core expressions (`-fwrite-if-simplified-core`). Before this patch: * Load time: 11.7 s, 2.5 GB maximum residency. After this patch: * Load time: 7.3 s, 1.7 GB maximum residency. This deduplication has the beneficial side effect to additionally reduce the size of the on-disk interface files tremendously. For example, on agda, we reduce the size of `.hi` files (with `-fwrite-if-simplified-core`): * Before: 101 MB on disk * Now: 24 MB on disk This has even a beneficial side effect on the cabal store. We reduce the size of the store on disk: * Before: 341 MB on disk * Now: 310 MB on disk Note, none of the dependencies have been compiled with `-fwrite-if-simplified-core`, but `IfaceType` occurs in multiple locations in a `ModIface`. We also add IfaceType deduplication table to .hie serialisation and refactor .hie file serialisation to use the same infrastrucutre as `putWithTables`. Bump haddock submodule to accomodate for changes to the deduplication table layout and binary interface. - - - - - da5a7fff by Matthew Pickering at 2024-05-07T13:36:05+02:00 Add run-time configurability of .hi file compression Introduce the flag `-fwrite-if-compression=<n>` which allows to configure the compression level of writing .hi files. The motivation is that some deduplication operations are too expensive for the average use case. Hence, we introduce multiple compression levels that have a minimal impact on performance, but still reduce the memory residency and `.hi` file size on disk considerably. We introduce three compression levels: * `1`: `Normal` mode. This is the least amount of compression. It deduplicates only `Name` and `FastString`s, and is naturally the fastest compression mode. * `2`: `Safe` mode. It has a noticeable impact on .hi file size and is marginally slower than `Normal` mode. In general, it should be safe to always use `Safe` mode. * `3`: `Full` deduplication mode. Deduplicate as much as we can, resulting in minimal .hi files, but at the cost of additional compilation time. Reading .hi files doesn't need to know the initial compression level, and can always deserialise a `ModIface`. This allows users to experiment with different compression levels for packages, without recompilation of dependencies. Note, the deduplication also has an additional side effect of reduced memory consumption to implicit sharing of deduplicated elements. See https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for example where that matters. ------------------------- Metric Decrease: MultiLayerModulesDefsGhciWithCore T16875 T21839c T24471 hard_hole_fits ------------------------- - - - - - 1ac9d688 by Matthew Pickering at 2024-05-07T13:36:05+02:00 Introduce regression tests for `.hi` file sizes Add regression tests to track how `-fwrite-if-compression` levels affect the size of `.hi` files. - - - - - 30 changed files: - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - compiler/GHC.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map/Expr.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Data/TrieMap.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Session.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5388078182762a2912f2feaae024ec465975f912...1ac9d688e176ade5e309b273fdd298a8ded1d4be -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5388078182762a2912f2feaae024ec465975f912...1ac9d688e176ade5e309b273fdd298a8ded1d4be You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 11:41:44 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 07 May 2024 07:41:44 -0400 Subject: [Git][ghc/ghc][wip/andreask/late_workfree] 29 commits: testsuite: expand size testing infrastructure Message-ID: <663a1378e33a4_3f1773ed23f854319@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/late_workfree at Glasgow Haskell Compiler / GHC Commits: 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 7eab4e01 by Alan Zimmerman at 2024-05-04T16:14:55+01:00 EPA: Widen stmtslist to include last semicolon Closes #24754 - - - - - 06f7db40 by Teo Camarasu at 2024-05-05T00:19:38-04:00 doc: Fix type error in hs_try_putmvar example - - - - - af000532 by Moritz Schuler at 2024-05-05T06:30:58-04:00 Fix parsing of module names in CLI arguments closes issue #24732 - - - - - da74e9c9 by Ben Gamari at 2024-05-05T06:31:34-04:00 ghc-platform: Add Setup.hs The Hadrian bootstrapping script relies upon `Setup.hs` to drive its build. Addresses #24761. - - - - - 35d34fde by Alan Zimmerman at 2024-05-05T12:52:40-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 - - - - - 03c5dfbf by Simon Peyton Jones at 2024-05-05T12:53:15-04:00 Fix a float-out error Ticket #24768 showed that the Simplifier was accidentally destroying a join point. It turned out to be that we were sending a bottoming join point to the top, accidentally abstracting over /other/ join points. Easily fixed. - - - - - adba68e7 by John Ericson at 2024-05-05T19:35:56-04:00 Substitute bindist files with Hadrian not configure The `ghc-toolchain` overhaul will eventually replace all this stuff with something much more cleaned up, but I think it is still worth making this sort of cleanup in the meantime so other untanglings and dead code cleaning can procede. I was able to delete a fair amount of dead code doing this too. `LLVMTarget_CPP` is renamed to / merged with `LLVMTarget` because it wasn't actually turned into a valid CPP identifier. (Original to 1345c7cc42c45e63ab1726a8fd24a7e4d4222467, actually.) Progress on #23966 Co-Authored-By: Sylvain Henry <hsyl20 at gmail.com> - - - - - 18f4ff84 by Alan Zimmerman at 2024-05-05T19:36:32-04:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 - - - - - a19201d4 by Matthew Craven at 2024-05-06T19:54:29-04:00 Add test cases for #24664 ...since none are present in the original MR !12463 fixing this issue. - - - - - 46328a49 by Alan Zimmerman at 2024-05-06T19:55:05-04:00 EPA: preserve comments in data decls Closes #24771 - - - - - badc9751 by Andreas Klebinger at 2024-05-07T13:41:25+02:00 -fprof-late: Only insert cost centres on functions/non-workfree cafs. They are usually useless and doing so for data values comes with a large compile time/code size overhead. Fixes #24103 - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/LateCC.hs - compiler/GHC/Core/LateCC/TopLevelBinds.hs - compiler/GHC/Core/LateCC/Types.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/757f0d6c2c05006fc7556cce949816c54e19e2cb...badc975113ecc47f3d45f14094f7ecd9476efe64 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/757f0d6c2c05006fc7556cce949816c54e19e2cb...badc975113ecc47f3d45f14094f7ecd9476efe64 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 11:47:02 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Tue, 07 May 2024 07:47:02 -0400 Subject: [Git][ghc/ghc][wip/fendor/ghc-iface-sharing-avoid-reserialisation] 49 commits: utils: remove obsolete vagrant scripts Message-ID: <663a14b695922_3f177310265ec56825@gitlab.mail> Hannes Siebenhandl pushed to branch wip/fendor/ghc-iface-sharing-avoid-reserialisation at Glasgow Haskell Compiler / GHC Commits: 728af21e by Cheng Shao at 2024-04-30T05:30:23-04:00 utils: remove obsolete vagrant scripts Vagrantfile has long been removed in !5288. This commit further removes the obsolete vagrant scripts in the tree. - - - - - 36f2c342 by Cheng Shao at 2024-04-30T05:31:00-04:00 Update autoconf scripts Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 - - - - - ecbf22a6 by Ben Gamari at 2024-04-30T05:31:36-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 7eab4e01 by Alan Zimmerman at 2024-05-04T16:14:55+01:00 EPA: Widen stmtslist to include last semicolon Closes #24754 - - - - - 06f7db40 by Teo Camarasu at 2024-05-05T00:19:38-04:00 doc: Fix type error in hs_try_putmvar example - - - - - af000532 by Moritz Schuler at 2024-05-05T06:30:58-04:00 Fix parsing of module names in CLI arguments closes issue #24732 - - - - - da74e9c9 by Ben Gamari at 2024-05-05T06:31:34-04:00 ghc-platform: Add Setup.hs The Hadrian bootstrapping script relies upon `Setup.hs` to drive its build. Addresses #24761. - - - - - 35d34fde by Alan Zimmerman at 2024-05-05T12:52:40-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 - - - - - 03c5dfbf by Simon Peyton Jones at 2024-05-05T12:53:15-04:00 Fix a float-out error Ticket #24768 showed that the Simplifier was accidentally destroying a join point. It turned out to be that we were sending a bottoming join point to the top, accidentally abstracting over /other/ join points. Easily fixed. - - - - - adba68e7 by John Ericson at 2024-05-05T19:35:56-04:00 Substitute bindist files with Hadrian not configure The `ghc-toolchain` overhaul will eventually replace all this stuff with something much more cleaned up, but I think it is still worth making this sort of cleanup in the meantime so other untanglings and dead code cleaning can procede. I was able to delete a fair amount of dead code doing this too. `LLVMTarget_CPP` is renamed to / merged with `LLVMTarget` because it wasn't actually turned into a valid CPP identifier. (Original to 1345c7cc42c45e63ab1726a8fd24a7e4d4222467, actually.) Progress on #23966 Co-Authored-By: Sylvain Henry <hsyl20 at gmail.com> - - - - - 18f4ff84 by Alan Zimmerman at 2024-05-05T19:36:32-04:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 - - - - - a19201d4 by Matthew Craven at 2024-05-06T19:54:29-04:00 Add test cases for #24664 ...since none are present in the original MR !12463 fixing this issue. - - - - - 46328a49 by Alan Zimmerman at 2024-05-06T19:55:05-04:00 EPA: preserve comments in data decls Closes #24771 - - - - - ae0330ac by Fendor at 2024-05-07T13:15:43+02:00 Add Eq and Ord instance to `IfaceType` We add an `Ord` instance so that we can store `IfaceType` in a `Data.Map` container. This is required to deduplicate `IfaceType` while writing `.hi` files to disk. Deduplication has many beneficial consequences to both file size and memory usage, as the deduplication enables implicit sharing of values. See issue #24540 for more motivation. The `Ord` instance would be unnecessary if we used a `TrieMap` instead of `Data.Map` for the deduplication process. While in theory this is clerarly the better option, experiments on the agda code base showed that a `TrieMap` implementation has worse run-time performance characteristics. To the change itself, we mostly derive `Eq` and `Ord`. This requires us to change occurrences of `FastString` with `LexicalFastString`, since `FastString` has no `Ord` instance. We change the definition of `IfLclName` to a newtype of `LexicalFastString`, to make such changes in the future easier. Bump haddock submodule for IfLclName changes - - - - - dd3cc486 by Fendor at 2024-05-07T13:17:13+02:00 Move out LiteralMap to avoid cyclic module dependencies - - - - - 0276bbd6 by Fendor at 2024-05-07T13:36:05+02:00 Add deduplication table for `IfaceType` The type `IfaceType` is a highly redundant, tree-like data structure. While benchmarking, we realised that the high redundancy of `IfaceType` causes high memory consumption in GHCi sessions when byte code is embedded into the `.hi` file via `-fwrite-if-simplified-core` or `-fbyte-code-and-object-code`. Loading such `.hi` files from disk introduces many duplicates of memory expensive values in `IfaceType`, such as `IfaceTyCon`, `IfaceTyConApp`, `IA_Arg` and many more. We improve the memory behaviour of GHCi by adding an additional deduplication table for `IfaceType` to the serialisation of `ModIface`, similar to how we deduplicate `Name`s and `FastString`s. When reading the interface file back, the table allows us to automatically share identical values of `IfaceType`. To provide some numbers, we evaluated this patch on the agda code base. We loaded the full library from the `.hi` files, which contained the embedded core expressions (`-fwrite-if-simplified-core`). Before this patch: * Load time: 11.7 s, 2.5 GB maximum residency. After this patch: * Load time: 7.3 s, 1.7 GB maximum residency. This deduplication has the beneficial side effect to additionally reduce the size of the on-disk interface files tremendously. For example, on agda, we reduce the size of `.hi` files (with `-fwrite-if-simplified-core`): * Before: 101 MB on disk * Now: 24 MB on disk This has even a beneficial side effect on the cabal store. We reduce the size of the store on disk: * Before: 341 MB on disk * Now: 310 MB on disk Note, none of the dependencies have been compiled with `-fwrite-if-simplified-core`, but `IfaceType` occurs in multiple locations in a `ModIface`. We also add IfaceType deduplication table to .hie serialisation and refactor .hie file serialisation to use the same infrastrucutre as `putWithTables`. Bump haddock submodule to accomodate for changes to the deduplication table layout and binary interface. - - - - - da5a7fff by Matthew Pickering at 2024-05-07T13:36:05+02:00 Add run-time configurability of .hi file compression Introduce the flag `-fwrite-if-compression=<n>` which allows to configure the compression level of writing .hi files. The motivation is that some deduplication operations are too expensive for the average use case. Hence, we introduce multiple compression levels that have a minimal impact on performance, but still reduce the memory residency and `.hi` file size on disk considerably. We introduce three compression levels: * `1`: `Normal` mode. This is the least amount of compression. It deduplicates only `Name` and `FastString`s, and is naturally the fastest compression mode. * `2`: `Safe` mode. It has a noticeable impact on .hi file size and is marginally slower than `Normal` mode. In general, it should be safe to always use `Safe` mode. * `3`: `Full` deduplication mode. Deduplicate as much as we can, resulting in minimal .hi files, but at the cost of additional compilation time. Reading .hi files doesn't need to know the initial compression level, and can always deserialise a `ModIface`. This allows users to experiment with different compression levels for packages, without recompilation of dependencies. Note, the deduplication also has an additional side effect of reduced memory consumption to implicit sharing of deduplicated elements. See https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for example where that matters. ------------------------- Metric Decrease: MultiLayerModulesDefsGhciWithCore T16875 T21839c T24471 hard_hole_fits ------------------------- - - - - - 1ac9d688 by Matthew Pickering at 2024-05-07T13:36:05+02:00 Introduce regression tests for `.hi` file sizes Add regression tests to track how `-fwrite-if-compression` levels affect the size of `.hi` files. - - - - - dc88ff55 by Fendor at 2024-05-07T13:46:07+02:00 Improve sharing of duplicated values in `ModIface` As a `ModIface` contains often duplicated values that are not necessarily shared, we improve sharing by serialising the `ModIface` to an in-memory byte array. Serialisation uses deduplication tables, and deserialisation implicitly shares duplicated values. This helps reducing the peak memory usage while compiling in `--make` mode. The peak memory usage is especially reduced when generating interface files with core expressions (`-fwrite-if-simplified-core`). On agda, this reduces the peak memory usage: * `2.2 GB` to `1.9 GB` for a ghci session. On `lib:Cabal`, we report: * `570 MB` to `500 MB` for a ghci session * `790 MB` to `667 MB` for compiling `lib:Cabal` with ghc There is a small impact on execution time, around 2% on the agda code base. - - - - - fb327df3 by Fendor at 2024-05-07T13:46:51+02:00 Avoid unneccessarily re-serialising the `ModIface` To reduce memory usage of `ModIface`, we serialise `ModIface` to an in-memory byte array, which implicitly shares duplicated values. This serailised byte array can be reused to avoid work when we actually write the `ModIface` to disk. We introduce a new field to `ModIface` which allows us to save the byte array, and write it to disk if the `ModIface` wasn't changed after the initial serialisation. This requires us to change absolute offsets, for example to jump to the deduplication table for `Name` or `FastString` with relative offsets, as the deduplication byte array doesn't contain header information, such as fingerprints. To allow us to dump the binary blob to disk, we need to replace all absolute offsets with relative ones. This leads to new primitives for `ModIface`, which help to construct relative offsets. - - - - - 30 changed files: - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - compiler/GHC.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map/Expr.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Data/TrieMap.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Session.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fb7238c50a4fb7b46db430b78794b4e0549c5f42...fb327df38b0c77ba63d6d0e4734c736cbfb34904 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fb7238c50a4fb7b46db430b78794b4e0549c5f42...fb327df38b0c77ba63d6d0e4734c736cbfb34904 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 12:09:38 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 07 May 2024 08:09:38 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Rename Solo# data constructor to MkSolo# (#24673) Message-ID: <663a1a01f10fc_3f17731338d486213c@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: deeff0bc by Andrei Borzenkov at 2024-05-07T08:09:26-04:00 Rename Solo# data constructor to MkSolo# (#24673) - data Solo# a = (# a #) + data Solo# a = MkSolo# a And `(# foo #)` syntax now becomes just a syntactic sugar for `MkSolo# a`. - - - - - 83f9d865 by Arsen Arsenović at 2024-05-07T08:09:30-04:00 Add the cmm_cpp_is_gcc predicate to the testsuite A future C-- test called T24474-cmm-override-g0 relies on the GCC-specific behaviour of -g3 implying -dD, which, in turn, leads to it emitting #defines past the preprocessing stage. Clang, at least, does not do this, so the test would fail if ran on Clang. As the behaviour here being tested is ``-optCmmP-g3'' undoing effects of the workaround we apply as a fix for bug #24474, and the workaround was for GCC-specific behaviour, the test needs to be marked as fragile on other compilers. - - - - - 56261950 by Arsen Arsenović at 2024-05-07T08:09:30-04:00 Split out the C-- preprocessor, and make it pass -g0 Previously, C-- was processed with the C preprocessor program. This means that it inherited flags passed via -optc. A flag that is somewhat often passed through -optc is -g. At certain -g levels (>=2), GCC starts emitting defines *after* preprocessing, for the purposes of debug info generation. This is not useful for the C-- compiler, and, in fact, causes lexer errors. We can suppress this effect (safely, if supported) via -g0. As a workaround, in older versions of GCC (<=10), GCC only emitted defines if a certain set of -g*3 flags was passed. Newer versions check the debug level. For the former, we filter out those -g*3 flags and, for the latter, we specify -g0 on top of that. As a compatible and effective solution, this change adds a C-- preprocessor distinct from the C compiler and preprocessor, but that keeps its flags. The command line produced for C-- preprocessing now looks like: $pgmCmmP $optCs_without_g3 $g0_if_supported $optCmmP Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/24474 - - - - - 30 changed files: - compiler/GHC/Builtin/Types.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Recomp/Flags.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools/Cpp.hs - compiler/GHC/SysTools/Tasks.hs - configure.ac - distrib/configure.ac.in - docs/users_guide/phases.rst - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cfg/default.host.target.in - hadrian/cfg/default.target.in - hadrian/src/Rules/Generate.hs - libraries/ghc-boot/GHC/Utils/Encoding.hs - libraries/ghc-experimental/src/Data/Tuple/Experimental.hs - libraries/ghc-prim/GHC/Types.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Syntax.hs - + m4/fp_cmm_cpp_cmd_with_args.m4 - m4/fp_settings.m4 - m4/fp_setup_windows_toolchain.m4 - m4/ghc_toolchain.m4 - m4/prep_target_file.m4 - testsuite/config/ghc - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - + testsuite/tests/cmm/should_compile/T24474-cmm-gets-c-opts.cmm - + testsuite/tests/cmm/should_compile/T24474-cmm-opt-order.cmm The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3fd0bd0b961a5a98bd2e58bbffaa510365d5cd02...5626195031591b987fa0bfd73c0570a0c2ae2e69 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3fd0bd0b961a5a98bd2e58bbffaa510365d5cd02...5626195031591b987fa0bfd73c0570a0c2ae2e69 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 12:33:49 2024 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 07 May 2024 08:33:49 -0400 Subject: [Git][ghc/ghc][wip/T24334] 2 commits: Simplifier: Preserve OccInfo on DataAlt fields when case binder is dead (#24770) Message-ID: <663a1fad76b0c_3f1773170ead0737a2@gitlab.mail> Sebastian Graf pushed to branch wip/T24334 at Glasgow Haskell Compiler / GHC Commits: a5c61b58 by Sebastian Graf at 2024-05-07T14:33:17+02:00 Simplifier: Preserve OccInfo on DataAlt fields when case binder is dead (#24770) See the adjusted `Note [DataAlt occ info]`. This change also has a positive repercussion on `Note [Combine case alts: awkward corner]`. Fixes #24770. - - - - - 350ea87e by Sebastian Graf at 2024-05-07T14:33:20+02:00 Kill seqRule, discard dead seq# in Prep (#24334) Discarding seq#s in Core land via `seqRule` was problematic; see #24334. So instead we discard certain dead, discardable seq#s in Prep now. See the updated `Note [seq# magic]`. This fixes the symptoms of #24334. - - - - - 15 changed files: - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Types/Id/Make.hs - testsuite/tests/codeGen/should_compile/T24264.hs - + testsuite/tests/core-to-stg/T24334.hs - + testsuite/tests/core-to-stg/T24334.stdout - testsuite/tests/core-to-stg/all.T - testsuite/tests/simplCore/should_compile/T21851.stderr - + testsuite/tests/simplCore/should_compile/T24770.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/CSE.hs ===================================== @@ -9,12 +9,8 @@ module GHC.Core.Opt.CSE (cseProgram, cseOneExpr) where import GHC.Prelude import GHC.Core.Subst -import GHC.Types.Var ( Var ) import GHC.Types.Var.Env ( mkInScopeSet ) -import GHC.Types.Id ( Id, idType, idHasRules, zapStableUnfolding - , idInlineActivation, setInlineActivation - , zapIdOccInfo, zapIdUsageInfo, idInlinePragma - , isJoinId, idJoinPointHood, idUnfolding ) +import GHC.Types.Id import GHC.Core.Utils ( mkAltExpr , exprIsTickedString , stripTicksE, stripTicksT, mkTicks ) @@ -754,7 +750,7 @@ combineAlts alts , Alt _ bndrs1 rhs1 <- alt1 , let filtered_alts = filterOut (identical_alt rhs1) rest_alts , not (equalLength rest_alts filtered_alts) - = assertPpr (null bndrs1) (ppr alts) $ + = assertPpr (all isDeadBinder bndrs1) (ppr alts) $ Alt DEFAULT [] rhs1 : filtered_alts | otherwise @@ -762,14 +758,13 @@ combineAlts alts where find_bndr_free_alt :: [CoreAlt] -> (Maybe CoreAlt, [CoreAlt]) - -- The (Just alt) is a binder-free alt - -- See Note [Combine case alts: awkward corner] + -- The (Just alt) is an alt where all fields are dead find_bndr_free_alt [] = (Nothing, []) find_bndr_free_alt (alt@(Alt _ bndrs _) : alts) - | null bndrs = (Just alt, alts) - | otherwise = case find_bndr_free_alt alts of - (mb_bf, alts) -> (mb_bf, alt:alts) + | all isDeadBinder bndrs = (Just alt, alts) + | otherwise = case find_bndr_free_alt alts of + (mb_bf, alts) -> (mb_bf, alt:alts) identical_alt rhs1 (Alt _ _ rhs) = eqCoreExpr rhs1 rhs -- Even if this alt has binders, they will have been cloned @@ -823,9 +818,9 @@ big for cheapEqExpr to catch it. Note [Combine case alts: awkward corner] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We would really like to check isDeadBinder on the binders in the -alternative. But alas, the simplifer zaps occ-info on binders in case -alternatives; see Note [Case alternative occ info] in GHC.Core.Opt.Simplify. +We check isDeadBinder on field binders in order to collapse into a DEFAULT alt. +But alas, the simplifer often zaps occ-info on field binders in DataAlts when +the case binder is alive; see Note [DataAlt occ info] in GHC.Core.Opt.Simplify. * One alternative (perhaps a good one) would be to do OccAnal just before CSE. Then perhaps we could get rid of combineIdenticalAlts @@ -833,14 +828,12 @@ alternatives; see Note [Case alternative occ info] in GHC.Core.Opt.Simplify. * Another would be for CSE to return free vars as it goes. -* But the current solution is to find a nullary alternative (including - the DEFAULT alt, if any). This will not catch - case x of - A y -> blah - B z p -> blah - where no alternative is nullary or DEFAULT. But the current - solution is at least cheap. - +* But the current solution is to accept that we do not catch cases such as + case x of c + A _ -> blah[c] + B _ _ -> blah[c] + where the case binder c is alive and no alternative is DEFAULT. + But the current solution is at least cheap. ************************************************************************ * * ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -2067,21 +2067,18 @@ unsafeEqualityProofRule {- ********************************************************************* * * - Rules for seq# and spark# + Rules for spark# * * ********************************************************************* -} -seqRule :: RuleM CoreExpr -seqRule = do +-- spark# :: forall a s . a -> State# s -> (# State# s, a #) +sparkRule :: RuleM CoreExpr +sparkRule = do -- reduce on HNF [Type _ty_a, Type _ty_s, a, s] <- getArgs guard $ exprIsHNF a return $ mkCoreUnboxedTuple [s, a] - --- spark# :: forall a s . a -> State# s -> (# State# s, a #) -sparkRule :: RuleM CoreExpr -sparkRule = seqRule -- reduce on HNF, just the same - -- XXX perhaps we shouldn't do this, because a spark eliminated by - -- this rule won't be counted as a dud at runtime? + -- XXX perhaps we shouldn't do this, because a spark eliminated by + -- this rule won't be counted as a dud at runtime? {- ************************************************************************ @@ -2158,9 +2155,7 @@ builtinRules platform <- getPlatform return $ Var (primOpId IntAndOp) `App` arg `App` mkIntVal platform (d - 1) - ], - - mkBasicRule seqHashName 4 seqRule + ] ] ++ builtinBignumRules {-# NOINLINE builtinRules #-} ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -26,7 +26,7 @@ core expression with (hopefully) improved usage information. module GHC.Core.Opt.OccurAnal ( occurAnalysePgm, occurAnalyseExpr, - zapLambdaBndrs, scrutBinderSwap_maybe + zapLambdaBndrs, BinderSwapDecision(..), scrutOkForBinderSwap ) where import GHC.Prelude hiding ( head, init, last, tail ) @@ -3262,7 +3262,7 @@ inline x, cancel the casts, and away we go. Note [Care with binder-swap on dictionaries] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -This Note explains why we need isDictId in scrutBinderSwap_maybe. +This Note explains why we need isDictId in scrutOkForBinderSwap. Consider this tricky example (#21229, #21470): class Sing (b :: Bool) where sing :: Bool @@ -3306,7 +3306,7 @@ Conclusion: for a /dictionary variable/ do not perform the clever cast version of the binder-swap -Hence the subtle isDictId in scrutBinderSwap_maybe. +Hence the subtle isDictId in scrutOkForBinderSwap. Note [Zap case binders in proxy bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -3328,7 +3328,7 @@ addBndrSwap :: OutExpr -> Id -> OccEnv -> OccEnv -- See Note [The binder-swap substitution] addBndrSwap scrut case_bndr env@(OccEnv { occ_bs_env = swap_env, occ_bs_rng = rng_vars }) - | Just (scrut_var, mco) <- scrutBinderSwap_maybe scrut + | DoBinderSwap scrut_var mco <- scrutOkForBinderSwap scrut , scrut_var /= case_bndr -- Consider: case x of x { ... } -- Do not add [x :-> x] to occ_bs_env, else lookupBndrSwap will loop @@ -3342,25 +3342,30 @@ addBndrSwap scrut case_bndr case_bndr' = zapIdOccInfo case_bndr -- See Note [Zap case binders in proxy bindings] -scrutBinderSwap_maybe :: OutExpr -> Maybe (OutVar, MCoercion) --- If (scrutBinderSwap_maybe e = Just (v, mco), then +-- | See bBinderSwaOk. +data BinderSwapDecision + = NoBinderSwap + | DoBinderSwap OutVar MCoercion + +scrutOkForBinderSwap :: OutExpr -> BinderSwapDecision +-- If (scrutOkForBinderSwap e = DoBinderSwap v mco, then -- v = e |> mco -- See Note [Case of cast] -- See Note [Care with binder-swap on dictionaries] -- -- We use this same function in SpecConstr, and Simplify.Iteration, -- when something binder-swap-like is happening -scrutBinderSwap_maybe (Var v) = Just (v, MRefl) -scrutBinderSwap_maybe (Cast (Var v) co) - | not (isDictId v) = Just (v, MCo (mkSymCo co)) +scrutOkForBinderSwap (Var v) = DoBinderSwap v MRefl +scrutOkForBinderSwap (Cast (Var v) co) + | not (isDictId v) = DoBinderSwap v (MCo (mkSymCo co)) -- Cast: see Note [Case of cast] -- isDictId: see Note [Care with binder-swap on dictionaries] -- The isDictId rejects a Constraint/Constraint binder-swap, perhaps -- over-conservatively. But I have never seen one, so I'm leaving -- the code as simple as possible. Losing the binder-swap in a -- rare case probably has very low impact. -scrutBinderSwap_maybe (Tick _ e) = scrutBinderSwap_maybe e -- Drop ticks -scrutBinderSwap_maybe _ = Nothing +scrutOkForBinderSwap (Tick _ e) = scrutOkForBinderSwap e -- Drop ticks +scrutOkForBinderSwap _ = NoBinderSwap lookupBndrSwap :: OccEnv -> Id -> (CoreExpr, Id) -- See Note [The binder-swap substitution] ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -1719,7 +1719,7 @@ extendCaseBndrEnv :: LevelEnv -> LevelEnv extendCaseBndrEnv le@(LE { le_subst = subst, le_env = id_env }) case_bndr (Var scrut_var) - -- We could use OccurAnal. scrutBinderSwap_maybe here, and perhaps + -- We could use OccurAnal. scrutOkForBinderSwap here, and perhaps -- get a bit more floating. But we didn't in the past and it's -- an unforced change, so I'm leaving it. = le { le_subst = extendSubstWithVar subst case_bndr scrut_var ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -23,7 +23,7 @@ import GHC.Core.TyCo.Compare( eqType ) import GHC.Core.Opt.Simplify.Env import GHC.Core.Opt.Simplify.Inline import GHC.Core.Opt.Simplify.Utils -import GHC.Core.Opt.OccurAnal ( occurAnalyseExpr, zapLambdaBndrs, scrutBinderSwap_maybe ) +import GHC.Core.Opt.OccurAnal ( occurAnalyseExpr, zapLambdaBndrs, scrutOkForBinderSwap, BinderSwapDecision (..) ) import GHC.Core.Make ( FloatBind, mkImpossibleExpr, castBottomExpr ) import qualified GHC.Core.Make import GHC.Core.Coercion hiding ( substCo, substCoVar ) @@ -33,7 +33,7 @@ import GHC.Core.FamInstEnv ( FamInstEnv, topNormaliseType_maybe ) import GHC.Core.DataCon ( DataCon, dataConWorkId, dataConRepStrictness , dataConRepArgTys, isUnboxedTupleDataCon - , StrictnessMark (..) ) + , StrictnessMark (..), dataConWrapId_maybe ) import GHC.Core.Opt.Stats ( Tick(..) ) import GHC.Core.Ppr ( pprCoreExpr ) import GHC.Core.Unfold @@ -3234,16 +3234,36 @@ The point is that we bring into the envt a binding after the outer case, and that makes (a,b) alive. At least we do unless the case binder is guaranteed dead. -Note [Case alternative occ info] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -When we are simply reconstructing a case (the common case), we always -zap the occurrence info on the binders in the alternatives. Even -if the case binder is dead, the scrutinee is usually a variable, and *that* -can bring the case-alternative binders back to life. -See Note [Add unfolding for scrutinee] +Note [DataAlt occ info] +~~~~~~~~~~~~~~~~~~~~~~~ +Our general goal is to preserve dead-ness occ-info on the field binders of a +case alternative. Why? It's generally a good idea, but one specific reason is to +support (SEQ4) of Note [seq# magic]. + +But we have to be careful: even if the field binder is not mentioned in the case +alternative and thus annotated IAmDead by OccurAnal, it might "come back to +life" in one of two ways: + + 1. If the case binder is alive, its unfolding might bring back the field + binder, as in Note [knownCon occ info]: + case blah of y { I# _ -> $wf (case y of I# v -> v) } + ==> + case blah of y { I# v -> $wf v } + 2. Even if the case binder appears to be dead, there is the scenario in + Note [Add unfolding for scrutinee], in which the fields come back to live + through the unfolding of variable scrutinee, as follows: + join j = case x of Just v -> blah v; Nothing -> ... in + case x of Just _ -> jump j; Nothing -> ... + ==> { inline j, unfold x to Just v, simplify } + join j = case x of Just v -> blah v; Nothing -> ... in + case x of Just v -> blah v; Nothing -> ... + +Thus, when we are simply reconstructing a case (the common case), and the +case binder is not dead, or the scrutinee is a variable, we zap the +occurrence info on DataAlt field binders. See `adjustFieldOccInfo`. Note [Improving seq] -~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~ Consider type family F :: * -> * type instance F Int = Int @@ -3349,7 +3369,9 @@ simplAlts env0 scrut case_bndr alts cont' -- NB: pass case_bndr::InId, not case_bndr' :: OutId, to prepareAlts -- See Note [Shadowing in prepareAlts] in GHC.Core.Opt.Simplify.Utils - ; alts' <- mapM (simplAlt alt_env' (Just scrut') imposs_deflt_cons case_bndr' cont') in_alts + ; alts' <- forM in_alts $ + simplAlt alt_env' (Just scrut') imposs_deflt_cons + case_bndr' (scrutOkForBinderSwap scrut) cont' ; let alts_ty' = contResultType cont' -- See Note [Avoiding space leaks in OutType] @@ -3375,39 +3397,43 @@ improveSeq _ env scrut _ case_bndr1 _ ------------------------------------ simplAlt :: SimplEnv - -> Maybe OutExpr -- The scrutinee - -> [AltCon] -- These constructors can't be present when - -- matching the DEFAULT alternative - -> OutId -- The case binder + -> Maybe OutExpr -- The scrutinee + -> [AltCon] -- These constructors can't be present when + -- matching the DEFAULT alternative + -> OutId -- The case binder `bndr` + -> BinderSwapDecision -- DoBinderSwap v co <==> scrut = Just (v |> co), + -- add unfolding `v :-> bndr |> sym co` -> SimplCont -> InAlt -> SimplM OutAlt -simplAlt env scrut' imposs_deflt_cons case_bndr' cont' (Alt DEFAULT bndrs rhs) +simplAlt env _scrut' imposs_deflt_cons case_bndr' bndr_swap' cont' (Alt DEFAULT bndrs rhs) = assert (null bndrs) $ - do { let env' = addDefaultUnfoldings env scrut' case_bndr' imposs_deflt_cons + do { let env' = addDefaultUnfoldings env case_bndr' bndr_swap' imposs_deflt_cons ; rhs' <- simplExprC env' rhs cont' ; return (Alt DEFAULT [] rhs') } -simplAlt env scrut' _ case_bndr' cont' (Alt (LitAlt lit) bndrs rhs) +simplAlt env _scrut' _ case_bndr' bndr_swap' cont' (Alt (LitAlt lit) bndrs rhs) = assert (null bndrs) $ - do { let env' = addAltUnfoldings env scrut' case_bndr' (Lit lit) + do { let env' = addAltUnfoldings env case_bndr' bndr_swap' (Lit lit) ; rhs' <- simplExprC env' rhs cont' ; return (Alt (LitAlt lit) [] rhs') } -simplAlt env scrut' _ case_bndr' cont' (Alt (DataAlt con) vs rhs) - = do { -- See Note [Adding evaluatedness info to pattern-bound variables] - let vs_with_evals = addEvals scrut' con vs - ; (env', vs') <- simplBinders env vs_with_evals +simplAlt env scrut' _ case_bndr' bndr_swap' cont' (Alt (DataAlt con) vs rhs) + = do { + ; (env', vs') <- simplBinders env vs + -- See Note [Adding evaluatedness info to pattern-bound variables] + -- and Note [DataAlt occ info] + ; let vs_with_info' = adjustFieldIdInfo scrut' case_bndr' bndr_swap' con vs' -- Bind the case-binder to (con args) ; let inst_tys' = tyConAppArgs (idType case_bndr') con_app :: OutExpr - con_app = mkConApp2 con inst_tys' vs' - env'' = addAltUnfoldings env' scrut' case_bndr' con_app + con_app = mkConApp2 con inst_tys' vs_with_info' + env'' = addAltUnfoldings env' case_bndr' bndr_swap' con_app ; rhs' <- simplExprC env'' rhs cont' - ; return (Alt (DataAlt con) vs' rhs') } + ; return (Alt (DataAlt con) vs_with_info' rhs') } {- Note [Adding evaluatedness info to pattern-bound variables] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -3438,9 +3464,10 @@ do it here). The right thing is to do some kind of binder-swap; see #15226 for discussion. -} -addEvals :: Maybe OutExpr -> DataCon -> [Id] -> [Id] +adjustFieldIdInfo :: Maybe OutExpr -> OutId -> BinderSwapDecision -> DataCon -> [Id] -> [Id] -- See Note [Adding evaluatedness info to pattern-bound variables] -addEvals scrut con vs +-- and Note [DataAlt occ info] +adjustFieldIdInfo scrut case_bndr bndr_swap con vs -- Deal with seq# applications | Just scr <- scrut , isUnboxedTupleDataCon con @@ -3449,59 +3476,73 @@ addEvals scrut con vs -- a list of arguments only to throw it away immediately. , Just (Var f) <- stripNArgs 4 scr , f `hasKey` seqHashKey - , let x' = zapIdOccInfoAndSetEvald MarkedStrict x - = [s, x'] + , let x' = setCaseBndrEvald MarkedStrict x + = map (adjustFieldOccInfo case_bndr bndr_swap) [s, x'] -- Deal with banged datacon fields -addEvals _scrut con vs = go vs the_strs - where - the_strs = dataConRepStrictness con - - go [] [] = [] - go (v:vs') strs | isTyVar v = v : go vs' strs - go (v:vs') (str:strs) = zapIdOccInfoAndSetEvald str v : go vs' strs - go _ _ = pprPanic "Simplify.addEvals" - (ppr con $$ - ppr vs $$ - ppr_with_length (map strdisp the_strs) $$ - ppr_with_length (dataConRepArgTys con) $$ - ppr_with_length (dataConRepStrictness con)) - where - ppr_with_length list - = ppr list <+> parens (text "length =" <+> ppr (length list)) - strdisp :: StrictnessMark -> SDoc - strdisp MarkedStrict = text "MarkedStrict" - strdisp NotMarkedStrict = text "NotMarkedStrict" - -zapIdOccInfoAndSetEvald :: StrictnessMark -> Id -> Id -zapIdOccInfoAndSetEvald str v = - setCaseBndrEvald str $ -- Add eval'dness info - zapIdOccInfo v -- And kill occ info; - -- see Note [Case alternative occ info] - -addDefaultUnfoldings :: SimplEnv -> Maybe OutExpr -> OutId -> [AltCon] -> SimplEnv -addDefaultUnfoldings env mb_scrut case_bndr imposs_deflt_cons + -- This case is quite allocation sensitive to T9233 which has a large record + -- with strict fields. Hence we try not to update vs twice! +adjustFieldIdInfo _scrut case_bndr bndr_swap con vs + | Nothing <- dataConWrapId_maybe con + -- a common fast path; no need to allocate the_strs when they are all lazy anyway! + = map (adjustFieldOccInfo case_bndr bndr_swap) vs + | otherwise + = go vs the_strs + where + the_strs = dataConRepStrictness con + + go [] [] = [] + go (v:vs') strs | isTyVar v = v : go vs' strs + go (v:vs') (str:strs) = adjustFieldOccInfo case_bndr bndr_swap (setCaseBndrEvald str v) : go vs' strs + go _ _ = pprPanic "Simplify.adjustFieldIdInfo" + (ppr con $$ + ppr vs $$ + ppr_with_length (map strdisp the_strs) $$ + ppr_with_length (dataConRepArgTys con) $$ + ppr_with_length (dataConRepStrictness con)) + where + ppr_with_length list + = ppr list <+> parens (text "length =" <+> ppr (length list)) + strdisp :: StrictnessMark -> SDoc + strdisp MarkedStrict = text "MarkedStrict" + strdisp NotMarkedStrict = text "NotMarkedStrict" + +adjustFieldOccInfo :: OutId -> BinderSwapDecision -> CoreBndr -> CoreBndr +-- Kill occ info if we do binder swap and the case binder is alive; +-- see Note [DataAlt occ info] +adjustFieldOccInfo case_bndr bndr_swap field_bndr + | not (isDeadBinder case_bndr) -- (1) in the Note: If the case binder is alive, + = zapped_field_bndr -- the field binders might come back alive + + | DoBinderSwap{} <- bndr_swap -- (2) in the Note: If binder swap might take place, + = zapped_field_bndr -- the case binder might come back alive + + | otherwise + = field_bndr -- otherwise the field binders stay dead + where + zapped_field_bndr = if isTyVar field_bndr then field_bndr else zapIdOccInfo field_bndr + +addDefaultUnfoldings :: SimplEnv -> OutId -> BinderSwapDecision -> [AltCon] -> SimplEnv +addDefaultUnfoldings env case_bndr bndr_swap imposs_deflt_cons = env2 where unf = mkOtherCon imposs_deflt_cons -- Record the constructors that the case-binder *can't* be. env1 = addBinderUnfolding env case_bndr unf - env2 | Just scrut <- mb_scrut - , Just (v,_mco) <- scrutBinderSwap_maybe scrut + env2 | DoBinderSwap v _mco <- bndr_swap = addBinderUnfolding env1 v unf | otherwise = env1 -addAltUnfoldings :: SimplEnv -> Maybe OutExpr -> OutId -> OutExpr -> SimplEnv -addAltUnfoldings env mb_scrut case_bndr con_app +addAltUnfoldings :: SimplEnv -> OutId -> BinderSwapDecision -> OutExpr -> SimplEnv +addAltUnfoldings env case_bndr bndr_swap con_app = env2 where con_app_unf = mk_simple_unf con_app env1 = addBinderUnfolding env case_bndr con_app_unf -- See Note [Add unfolding for scrutinee] - env2 | Just scrut <- mb_scrut - , Just (v,mco) <- scrutBinderSwap_maybe scrut + env2 | DoBinderSwap v mco <- bndr_swap = addBinderUnfolding env1 v $ if isReflMCo mco -- isReflMCo: avoid calling mk_simple_unf then con_app_unf -- twice in the common case @@ -3580,7 +3621,7 @@ So instead we add the unfolding x -> Just a, and x -> Nothing in the respective RHSs. Since this transformation is tantamount to a binder swap, we use -GHC.Core.Opt.OccurAnal.scrutBinderSwap_maybe to do the check. +GHC.Core.Opt.OccurAnal.scrutOkForBinderSwap to do the check. Exactly the same issue arises in GHC.Core.Opt.SpecConstr; see Note [Add scrutinee to ValueEnv too] in GHC.Core.Opt.SpecConstr @@ -3884,8 +3925,9 @@ mkDupableContWithDmds env _ ; let cont_scaling = contHoleScaling cont -- See Note [Scaling in case-of-case] ; (alt_env', case_bndr') <- simplBinder alt_env (scaleIdBy cont_scaling case_bndr) - ; alts' <- mapM (simplAlt alt_env' Nothing [] case_bndr' alt_cont) (scaleAltsBy cont_scaling alts) - -- Safe to say that there are no handled-cons for the DEFAULT case + ; alts' <- forM (scaleAltsBy cont_scaling alts) $ + simplAlt alt_env' Nothing [] case_bndr' NoBinderSwap alt_cont + -- Safe to say that there are no handled-cons for the DEFAULT case -- NB: simplBinder does not zap deadness occ-info, so -- a dead case_bndr' will still advertise its deadness -- This is really important because in ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -36,7 +36,7 @@ import GHC.Core.Opt.Simplify.Inline import GHC.Core.FVs ( exprsFreeVarsList, exprFreeVars ) import GHC.Core.Opt.Monad import GHC.Core.Opt.WorkWrap.Utils -import GHC.Core.Opt.OccurAnal( scrutBinderSwap_maybe ) +import GHC.Core.Opt.OccurAnal( BinderSwapDecision(..), scrutOkForBinderSwap ) import GHC.Core.DataCon import GHC.Core.Class( classTyVars ) import GHC.Core.Coercion hiding( substCo ) @@ -1104,7 +1104,7 @@ extendCaseBndrs env scrut case_bndr con alt_bndrs = (env2, alt_bndrs') where live_case_bndr = not (isDeadBinder case_bndr) - env1 | Just (v, mco) <- scrutBinderSwap_maybe scrut + env1 | DoBinderSwap v mco <- scrutOkForBinderSwap scrut , isReflMCo mco = extendValEnv env v cval | otherwise = env -- See Note [Add scrutinee to ValueEnv too] env2 | live_case_bndr = extendValEnv env1 case_bndr cval @@ -1198,7 +1198,7 @@ though the simplifier has systematically replaced uses of 'x' with 'y' and 'b' with 'c' in the code. The use of 'b' in the ValueEnv came from outside the case. See #4908 for the live example. -It's very like the binder-swap story, so we use scrutBinderSwap_maybe +It's very like the binder-swap story, so we use scrutOkForBinderSwap to identify suitable scrutinees -- but only if there is no cast (isReflMCo) because that's all that the ValueEnv allows. ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -890,6 +890,29 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con [covar] _]) floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } +cpeRhsE env (Case scrut bndr _ [Alt (DataAlt dc) [token_out, res] rhs]) + -- See item (SEQ4) of Note [seq# magic]. We want to match + -- case seq# @a @RealWorld s of (# s', _ #) -> rhs[s'] + -- and simplify to rhs[s]. Triggers in T15226. + | isUnboxedTupleDataCon dc + , (Var f,[_ty1, _ty2, arg, Var token_in]) <- collectArgs scrut + , f `hasKey` seqHashKey + , exprOkToDiscard arg + -- ok-to-discard, because we want to discard the evaluation of `arg`. + -- ok-to-discard includes ok-for-spec, but *also* CanFail primops such as + -- `quotInt# 1# 0#`, but not ThrowsException primops. + -- See Note [Classifying primop effects] + -- and Note [Transformations affected by primop effects] for why this is + -- the correct choice. + , Var token_in' <- lookupCorePrepEnv env token_in + , isDeadBinder res, isDeadBinder bndr + -- Check that bndr and res are dead + -- We can rely on `isDeadBinder res`, despite the fact that the Simplifier + -- often zaps the OccInfo on case-alternative binders (see Note [DataAlt occ info] + -- in GHC.Core.Opt.Simplify.Iteration) because the scrutinee is not a + -- variable, and in that case the zapping doesn't happen; see that Note. + = cpeRhsE (extendCorePrepEnv env token_out token_in') rhs + cpeRhsE env (Case scrut bndr ty alts) = do { (floats, scrut') <- cpeBody env scrut ; (env', bndr2) <- cpCloneBndr env bndr ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -2295,9 +2295,16 @@ Things to note also we can attach an evaldUnfolding to x' to discard any subsequent evals such as the `case x' of __DEFAULT`. +(SEQ4) + T15226 demonstrates that we want to discard ok-for-discard seq#s. That is, + simplify `case seq# s of (# s', _ #) -> rhs[s']` to `rhs[s]`. + You might wonder whether the Simplifier could do this. But see the excellent + example in #24334 (immortalised as test T24334) for why it should be done in + CorePrep. + Implementing seq#. The compiler has magic for `seq#` in -- GHC.Core.Opt.ConstantFold.seqRule: eliminate (seq# s) +- GHC.CoreToStg.Prep.cpeRhsE: Implement (SEQ4). - Simplify.addEvals records evaluated-ness for the result (cf. (SEQ3)); see Note [Adding evaluatedness info to pattern-bound variables] ===================================== testsuite/tests/codeGen/should_compile/T24264.hs ===================================== @@ -24,12 +24,8 @@ fun3 :: a -> IO a {-# OPAQUE fun3 #-} fun3 x = do pure () - -- "evaluate $! x" - case x of !x' -> IO (noinline seq# x') - -- noinline to work around the bogus seqRule - -- This ideally also should not push a continuation to the stack - -- before entering 'x'. It currently does, but let's wait for - -- !11515 to land before worrying about that. + evaluate $! x + -- This should not push a continuation to the stack before entering 'x' funPair :: a -> IO (a, a) {-# OPAQUE funPair #-} ===================================== testsuite/tests/core-to-stg/T24334.hs ===================================== @@ -0,0 +1,20 @@ +import Control.Exception +import Data.IORef + +strictPrint :: Show a => a -> IO () +{-# OPAQUE strictPrint #-} +strictPrint x = print $! x + +f :: Show a => a -> IORef a -> IO () +{-# OPAQUE f #-} +f x r = do + x' <- evaluate $! x + writeIORef r x' + strictPrint x' + +main :: IO () +main = do + r <- newIORef (42 :: Int) + f (error "foo") r `catch` \(e :: SomeException) -> return () + n <- readIORef r + print n ===================================== testsuite/tests/core-to-stg/T24334.stdout ===================================== @@ -0,0 +1 @@ +42 ===================================== testsuite/tests/core-to-stg/all.T ===================================== @@ -5,4 +5,5 @@ test('T23270', [grep_errmsg(r'patError')], compile, ['-O0 -dsuppress-uniques -dd test('T23914', normal, compile, ['-O']) test('T14895', normal, compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-uniques']) test('T24124', normal, compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-uniques']) +test('T24334', normal, compile_and_run, ['-O']) test('T24463', normal, compile, ['-O']) ===================================== testsuite/tests/simplCore/should_compile/T21851.stderr ===================================== @@ -10,8 +10,12 @@ g' :: Int -> Int [GblId, Arity=1, Str=, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 30 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [0] 30 0}] g' - = \ (x :: Int) -> case T21851a.$w$sf x of { (# ww, ww1 #) -> ww } + = \ (x :: Int) -> + case T21851a.$w$sf x of { (# ww, _ [Occ=Dead] #) -> ww } + + ===================================== testsuite/tests/simplCore/should_compile/T24770.hs ===================================== @@ -0,0 +1,3 @@ +module T24770 where + +foo = getLine >> getLine ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -516,3 +516,4 @@ test('T24370', normal, compile, ['-O']) test('T24551', normal, compile, ['-O -dcore-lint']) test('T24726', normal, compile, ['-dcore-lint -dsuppress-uniques']) test('T24768', normal, compile, ['-O']) +test('T24770', [ grep_errmsg(r'Dead') ], compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/14656b5948b1a423c177c14a0e4320d74b19170d...350ea87e742c351a63672adf421acc57cf8e0b88 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/14656b5948b1a423c177c14a0e4320d74b19170d...350ea87e742c351a63672adf421acc57cf8e0b88 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 12:37:48 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Tue, 07 May 2024 08:37:48 -0400 Subject: [Git][ghc/ghc][wip/fendor/ghc-iface-sharing-avoid-reserialisation] Avoid unneccessarily re-serialising the `ModIface` Message-ID: <663a209cac003_3f1773185806c74236@gitlab.mail> Hannes Siebenhandl pushed to branch wip/fendor/ghc-iface-sharing-avoid-reserialisation at Glasgow Haskell Compiler / GHC Commits: dec1e9db by Fendor at 2024-05-07T14:07:07+02:00 Avoid unneccessarily re-serialising the `ModIface` To reduce memory usage of `ModIface`, we serialise `ModIface` to an in-memory byte array, which implicitly shares duplicated values. This serailised byte array can be reused to avoid work when we actually write the `ModIface` to disk. We introduce a new field to `ModIface` which allows us to save the byte array, and write it to disk if the `ModIface` wasn't changed after the initial serialisation. This requires us to change absolute offsets, for example to jump to the deduplication table for `Name` or `FastString` with relative offsets, as the deduplication byte array doesn't contain header information, such as fingerprints. To allow us to dump the binary blob to disk, we need to replace all absolute offsets with relative ones. This leads to new primitives for `ModIface`, which help to construct relative offsets. Bump Haddock submodule, to account for interface file changes. ------------------------- Metric Increase: MultiComponentModules MultiLayerModules T10421 T13035 T13701 T13719 T14697 T18730 T9198 mhu-perf ------------------------- These metric increases may look bad, but they are all completely benign. - - - - - 15 changed files: - compiler/GHC.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Ext/Fields.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Unit/Module/ModIface.hs - compiler/GHC/Utils/Binary.hs - testsuite/tests/plugins/simple-plugin/Simple/RemovePlugin.hs - utils/haddock Changes: ===================================== compiler/GHC.hs ===================================== @@ -98,7 +98,32 @@ module GHC ( lookupGlobalName, findGlobalAnns, mkNamePprCtxForModule, - ModIface, ModIface_(..), + ModIface, + mi_module, + mi_sig_of, + mi_hsc_src, + mi_src_hash, + mi_hi_bytes, + mi_deps, + mi_usages, + mi_exports, + mi_used_th, + mi_fixities, + mi_warns, + mi_anns, + mi_insts, + mi_fam_insts, + mi_rules, + mi_decls, + mi_extra_decls, + mi_globals, + mi_hpc, + mi_trust, + mi_trust_pkg, + mi_complete_matches, + mi_docs, + mi_final_exts, + mi_ext_fields, SafeHaskellMode(..), -- * Printing ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -63,6 +63,8 @@ import Data.Map.Strict (Map) import Data.Word import System.IO.Unsafe import Data.Typeable (Typeable) +import qualified GHC.Data.Strict as Strict +import Data.Function ((&)) -- --------------------------------------------------------------------------- @@ -160,21 +162,24 @@ readBinIface profile name_cache checkHiWay traceBinIface hi_path = do mod_iface <- getIfaceWithExtFields name_cache bh - return mod_iface - { mi_src_hash = src_hash - } + return $ mod_iface + & addSourceFingerprint src_hash + getIfaceWithExtFields :: NameCache -> ReadBinHandle -> IO ModIface getIfaceWithExtFields name_cache bh = do - extFields_p <- get bh + start <- tellBinReader bh + extFields_p_rel <- getRelBin bh mod_iface <- getWithUserData name_cache bh - seekBinReader bh extFields_p + seekBinReader bh start + seekBinReaderRel bh extFields_p_rel extFields <- get bh - pure mod_iface - { mi_ext_fields = extFields - } + modIfaceData <- freezeBinHandle2 bh start + pure $ mod_iface + & set_mi_ext_fields extFields + & set_mi_hi_bytes (FullIfaceBinHandle $ Strict.Just modIfaceData) -- | This performs a get action after reading the dictionary and symbol @@ -204,7 +209,7 @@ getTables name_cache bh = do -- add it to the 'ReaderUserData' of 'ReadBinHandle'. decodeReaderTable :: Typeable a => ReaderTable a -> ReadBinHandle -> IO ReadBinHandle decodeReaderTable tbl bh0 = do - table <- Binary.forwardGet bh (getTable tbl bh0) + table <- Binary.forwardGetRel bh (getTable tbl bh0) let binaryReader = mkReaderFromTable tbl table pure $ addReaderToUserData binaryReader bh0 @@ -241,11 +246,18 @@ writeBinIface profile traceBinIface compressionLevel hi_path mod_iface = do -- And send the result to the file writeBinMem bh hi_path --- | Puts the 'ModIface' +-- | Puts the 'ModIface' to the 'WriteBinHandle'. +-- +-- This avoids serialisation of the 'ModIface' if the fields 'mi_hi_bytes' contains a +-- 'Just' value. This fields can only be populated by reading the 'ModIface' using +-- 'getIfaceWithExtFields' and not modifying it in any way afterwards. putIfaceWithExtFields :: TraceBinIFace -> CompressionIFace -> WriteBinHandle -> ModIface -> IO () putIfaceWithExtFields traceBinIface compressionLevel bh mod_iface = - forwardPut_ bh (\_ -> put_ bh (mi_ext_fields mod_iface)) $ do - putWithUserData traceBinIface compressionLevel bh mod_iface + case mi_hi_bytes mod_iface of + FullIfaceBinHandle Strict.Nothing -> do + forwardPutRel_ bh (\_ -> put_ bh (mi_ext_fields mod_iface)) $ do + putWithUserData traceBinIface compressionLevel bh mod_iface + FullIfaceBinHandle (Strict.Just binData) -> putFullBinData bh binData -- | Put a piece of data with an initialised `UserData` field. This -- is necessary if you want to serialise Names or FastStrings. @@ -316,7 +328,7 @@ putAllTables _ [] act = do a <- act pure ([], a) putAllTables bh (x : xs) act = do - (r, (res, a)) <- forwardPut bh (const $ putTable x bh) $ do + (r, (res, a)) <- forwardPutRel bh (const $ putTable x bh) $ do putAllTables bh xs act pure (r : res, a) @@ -468,7 +480,7 @@ to the table we need to deserialise first. What deduplication tables exist and the order of serialisation is currently statically specified in 'putWithTables'. 'putWithTables' also takes care of the serialisation of used deduplication tables. The deserialisation of the deduplication tables happens 'getTables', using 'Binary' utility -functions such as 'forwardGet'. +functions such as 'forwardGetRel'. Here, a visualisation of the table structure we currently have (ignoring 'ExtensibleFields'): @@ -529,7 +541,6 @@ initWriteIfaceType compressionLevel = do putGenericSymTab sym_tab bh ty _ -> putIfaceType bh ty - fullIfaceTypeSerialiser sym_tab bh ty = do put_ bh ifaceTypeSharedByte putGenericSymTab sym_tab bh ty ===================================== compiler/GHC/Iface/Ext/Binary.hs ===================================== @@ -235,7 +235,7 @@ readHieFileContents bh0 name_cache = do get bh1 where get_dictionary tbl bin_handle = do - fsTable <- Binary.forwardGet bin_handle (getTable tbl bin_handle) + fsTable <- Binary.forwardGetRel bin_handle (getTable tbl bin_handle) let fsReader = mkReaderFromTable tbl fsTable bhFs = addReaderToUserData fsReader bin_handle ===================================== compiler/GHC/Iface/Ext/Fields.hs ===================================== @@ -41,7 +41,7 @@ instance Binary ExtensibleFields where -- to point to the start of each payload: forM_ header_entries $ \(field_p_p, dat) -> do field_p <- tellBinWriter bh - putAt bh field_p_p field_p + putAtRel bh field_p_p field_p seekBinWriter bh field_p put_ bh dat @@ -50,11 +50,11 @@ instance Binary ExtensibleFields where -- Get the names and field pointers: header_entries <- replicateM n $ - (,) <$> get bh <*> get bh + (,) <$> get bh <*> getRelBin bh -- Seek to and get each field's payload: fields <- forM header_entries $ \(name, field_p) -> do - seekBinReader bh field_p + seekBinReaderRel bh field_p dat <- get bh return (name, dat) ===================================== compiler/GHC/Iface/Load.hs ===================================== @@ -117,6 +117,7 @@ import System.FilePath import System.Directory import GHC.Driver.Env.KnotVars import GHC.Iface.Errors.Types +import Data.Function ((&)) {- ************************************************************************ @@ -515,14 +516,12 @@ loadInterface doc_str mod from ; new_eps_anns <- tcIfaceAnnotations (mi_anns iface) ; new_eps_complete_matches <- tcIfaceCompleteMatches (mi_complete_matches iface) - ; let { final_iface = iface { - mi_decls = panic "No mi_decls in PIT", - mi_insts = panic "No mi_insts in PIT", - mi_fam_insts = panic "No mi_fam_insts in PIT", - mi_rules = panic "No mi_rules in PIT", - mi_anns = panic "No mi_anns in PIT" - } - } + ; let final_iface = iface + & set_mi_decls (panic "No mi_decls in PIT") + & set_mi_insts (panic "No mi_insts in PIT") + & set_mi_fam_insts (panic "No mi_fam_insts in PIT") + & set_mi_rules (panic "No mi_rules in PIT") + & set_mi_anns (panic "No mi_anns in PIT") ; let bad_boot = mi_boot iface == IsBoot && isJust (lookupKnotVars (if_rec_types gbl_env) mod) @@ -1017,13 +1016,13 @@ readIface dflags name_cache wanted_mod file_path = do -- See Note [GHC.Prim] in primops.txt.pp. ghcPrimIface :: ModIface ghcPrimIface - = empty_iface { - mi_exports = ghcPrimExports, - mi_decls = [], - mi_fixities = fixities, - mi_final_exts = (mi_final_exts empty_iface){ mi_fix_fn = mkIfaceFixCache fixities }, - mi_docs = Just ghcPrimDeclDocs -- See Note [GHC.Prim Docs] - } + = empty_iface + & set_mi_exports ghcPrimExports + & set_mi_decls [] + & set_mi_fixities fixities + & set_mi_final_exts ((mi_final_exts empty_iface){ mi_fix_fn = mkIfaceFixCache fixities }) + & set_mi_docs (Just ghcPrimDeclDocs) -- See Note [GHC.Prim Docs] + where empty_iface = emptyFullModIface gHC_PRIM @@ -1107,7 +1106,7 @@ pprModIfaceSimple unit_state iface = -- -- The UnitState is used to pretty-print units pprModIface :: UnitState -> ModIface -> SDoc -pprModIface unit_state iface at ModIface{ mi_final_exts = exts } +pprModIface unit_state iface = vcat [ text "interface" <+> ppr (mi_module iface) <+> pp_hsc_src (mi_hsc_src iface) <+> (if mi_orphan exts then text "[orphan module]" else Outputable.empty) @@ -1148,6 +1147,7 @@ pprModIface unit_state iface at ModIface{ mi_final_exts = exts } , text "extensible fields:" $$ nest 2 (pprExtensibleFields (mi_ext_fields iface)) ] where + exts = mi_final_exts iface pp_hsc_src HsBootFile = text "[boot]" pp_hsc_src HsigFile = text "[hsig]" pp_hsc_src HsSrcFile = Outputable.empty ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -144,7 +144,7 @@ mkFullIface hsc_env partial_iface mb_stg_infos mb_cmm_infos = do full_iface <- {-# SCC "addFingerprints" #-} - addFingerprints hsc_env partial_iface{ mi_decls = decls } + addFingerprints hsc_env (set_mi_decls decls partial_iface) -- Debug printing let unit_state = hsc_units hsc_env @@ -153,8 +153,24 @@ mkFullIface hsc_env partial_iface mb_stg_infos mb_cmm_infos = do final_iface <- shareIface (hsc_NC hsc_env) (flagsToIfCompression $ hsc_dflags hsc_env) full_iface return final_iface +-- | Compress an 'ModIface' and share as many values as possible, depending on the 'CompressionIFace' level. +-- See Note [Sharing of ModIface]. +-- +-- We compress the 'ModIface' by serialising the 'ModIface' to an in-memory byte array, and then deserialising it. +-- The deserialisation will deduplicate certain values depending on the 'CompressionIFace' level. +-- See Note [Deduplication during iface binary serialisation] for how we do that. +-- +-- Additionally, we cache the serialised byte array, so if the 'ModIface' is not modified +-- after calling 'shareIface', 'writeBinIface' will reuse that buffer without serialising the 'ModIface' again. +-- Modifying the 'ModIface' forces us to re-serialise it again. shareIface :: NameCache -> CompressionIFace -> ModIface -> IO ModIface -shareIface _ NormalCompression mi = pure mi +shareIface _ NormalCompression mi = do + -- In 'NormalCompression', the sharing isn't reducing the memory usage, as 'Name's and 'FastString's are + -- already shared, and at this compression level, we don't compress/share anything else. + -- Thus, for a brief moment we simply double the memory residency for no reason. + -- Therefore, we only try to share expensive values if the compression mode is higher than + -- 'NormalCompression' + pure mi shareIface nc compressionLevel mi = do bh <- openBinMem (1024 * 1024) start <- tellBinWriter bh @@ -162,10 +178,7 @@ shareIface nc compressionLevel mi = do rbh <- shrinkBinBuffer bh seekBinReader rbh start res <- getIfaceWithExtFields nc rbh - let resiface = res - { mi_src_hash = mi_src_hash mi - , mi_globals = mi_globals mi - } + let resiface = restoreFromOldModIface mi res forceModIface resiface return resiface @@ -322,40 +335,40 @@ mkIface_ hsc_env icomplete_matches = map mkIfaceCompleteMatch complete_matches !rdrs = maybeGlobalRdrEnv rdr_env - ModIface { - mi_module = this_mod, + emptyPartialModIface this_mod -- Need to record this because it depends on the -instantiated-with flag -- which could change - mi_sig_of = if semantic_mod == this_mod + & set_mi_sig_of ( if semantic_mod == this_mod then Nothing - else Just semantic_mod, - mi_hsc_src = hsc_src, - mi_deps = deps, - mi_usages = usages, - mi_exports = mkIfaceExports exports, + else Just semantic_mod) + & set_mi_hsc_src ( hsc_src) + & set_mi_deps ( deps) + & set_mi_usages ( usages) + & set_mi_exports ( mkIfaceExports exports) -- Sort these lexicographically, so that -- the result is stable across compilations - mi_insts = sortBy cmp_inst iface_insts, - mi_fam_insts = sortBy cmp_fam_inst iface_fam_insts, - mi_rules = sortBy cmp_rule iface_rules, - - mi_fixities = fixities, - mi_warns = warns, - mi_anns = annotations, - mi_globals = rdrs, - mi_used_th = used_th, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_hpc = isHpcUsed hpc_info, - mi_trust = trust_info, - mi_trust_pkg = pkg_trust_req, - mi_complete_matches = icomplete_matches, - mi_docs = docs, - mi_final_exts = (), - mi_ext_fields = emptyExtensibleFields, - mi_src_hash = ms_hs_hash mod_summary - } + & set_mi_insts ( sortBy cmp_inst iface_insts) + & set_mi_fam_insts ( sortBy cmp_fam_inst iface_fam_insts) + & set_mi_rules ( sortBy cmp_rule iface_rules) + + & set_mi_fixities ( fixities) + & set_mi_warns ( warns) + & set_mi_anns ( annotations) + & set_mi_globals ( rdrs) + & set_mi_used_th ( used_th) + & set_mi_decls ( decls) + & set_mi_extra_decls ( extra_decls) + & set_mi_hpc ( isHpcUsed hpc_info) + & set_mi_trust ( trust_info) + & set_mi_trust_pkg ( pkg_trust_req) + & set_mi_complete_matches ( icomplete_matches) + & set_mi_docs ( docs) + & set_mi_final_exts ( ()) + & set_mi_ext_fields ( emptyExtensibleFields) + & set_mi_src_hash ( ms_hs_hash mod_summary) + & set_mi_hi_bytes ( PartialIfaceBinHandle) + where cmp_rule = lexicalCompareFS `on` ifRuleName -- Compare these lexicographically by OccName, *not* by unique, @@ -522,3 +535,22 @@ That is, in Y, In the result of mkIfaceExports, the names are grouped by defining module, so we may need to split up a single Avail into multiple ones. -} + +{- +Note [Sharing of ModIface] +~~~~~~~~~~~~~~~~~~~~~~~~~~ +A 'ModIface' contains many duplicated values such as 'Name', 'FastString' and 'IfaceType'. +'Name's and 'FastString's are already deduplicated by default using the 'NameCache' and +'FastStringTable' respectively. +However, 'IfaceType' can be quite expensive in terms of memory usage. +To improve the sharing of 'IfaceType', we introduced deduplication tables during +serialisation of 'ModIface', see Note [Deduplication during iface binary serialisation]. + +We can improve the sharing of 'ModIface' at run-time as well, by serialising the 'ModIface' to +an in-memory buffer, and then deserialising it again. +This implicitly shares duplicated values. + +To avoid re-serialising the 'ModIface' when writing it to disk, we save the serialised 'ModIface' buffer +in 'mi_hi_bytes_' field of said 'ModIface'. This buffer is written to disk directly in 'putIfaceWithExtFields'. +If we have to modify the 'ModIface' after 'shareIface' is called, the buffer needs to be discarded. +-} ===================================== compiler/GHC/Iface/Recomp.hs ===================================== @@ -83,6 +83,7 @@ import Data.Ord import Data.Containers.ListUtils import Data.Bifunctor import GHC.Iface.Errors.Ppr +import qualified GHC.Data.Strict as Strict {- ----------------------------------------------- @@ -1283,7 +1284,9 @@ addFingerprints hsc_env iface0 , mi_fix_fn = fix_fn , mi_hash_fn = lookupOccEnv local_env } - final_iface = iface0 { mi_decls = sorted_decls, mi_extra_decls = sorted_extra_decls, mi_final_exts = final_iface_exts } + final_iface = completePartialModIface iface0 + (sorted_decls) (sorted_extra_decls) (final_iface_exts) + (FullIfaceBinHandle Strict.Nothing) -- return final_iface ===================================== compiler/GHC/Iface/Rename.hs ===================================== @@ -44,6 +44,7 @@ import GHC.Utils.Panic import qualified Data.Traversable as T import Data.IORef +import Data.Function ((&)) tcRnMsgMaybe :: IO (Either (Messages TcRnMessage) a) -> TcM a tcRnMsgMaybe do_this = do @@ -108,13 +109,14 @@ rnModIface hsc_env insts nsubst iface = deps <- rnDependencies (mi_deps iface) -- TODO: -- mi_rules - return iface { mi_module = mod - , mi_sig_of = sig_of - , mi_insts = insts - , mi_fam_insts = fams - , mi_exports = exports - , mi_decls = decls - , mi_deps = deps } + return $ iface + & set_mi_module mod + & set_mi_sig_of sig_of + & set_mi_insts insts + & set_mi_fam_insts fams + & set_mi_exports exports + & set_mi_decls decls + & set_mi_deps deps -- | Rename just the exports of a 'ModIface'. Useful when we're doing -- shaping prior to signature merging. ===================================== compiler/GHC/Tc/Errors/Hole.hs ===================================== @@ -76,7 +76,7 @@ import GHC.Tc.Utils.Unify ( tcSubTypeSigma ) import GHC.HsToCore.Docs ( extractDocs ) import GHC.Hs.Doc -import GHC.Unit.Module.ModIface ( ModIface_(..) ) +import GHC.Unit.Module.ModIface ( mi_docs ) import GHC.Iface.Load ( loadInterfaceForName ) import GHC.Builtin.Utils (knownKeyNames) ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -1562,7 +1562,8 @@ lookupDeclDoc nm = do -- Wasn't in the current module. Try searching other external ones! mIface <- getExternalModIface nm case mIface of - Just ModIface { mi_docs = Just Docs{docs_decls = dmap} } -> + Just iface + | Just Docs{docs_decls = dmap} <- mi_docs iface -> pure $ renderHsDocStrings . map hsDocString <$> lookupUniqMap dmap nm _ -> pure Nothing @@ -1578,7 +1579,8 @@ lookupArgDoc i nm = do Nothing -> do mIface <- getExternalModIface nm case mIface of - Just ModIface { mi_docs = Just Docs{docs_args = amap} } -> + Just iface + | Just Docs{docs_args = amap} <- mi_docs iface-> pure $ renderHsDocString . hsDocString <$> (lookupUniqMap amap nm >>= IntMap.lookup i) _ -> pure Nothing ===================================== compiler/GHC/Tc/Utils/Backpack.hs ===================================== @@ -87,6 +87,7 @@ import Control.Monad import Data.List (find) import GHC.Iface.Errors.Types +import Data.Function ((&)) checkHsigDeclM :: ModIface -> TyThing -> TyThing -> TcRn () checkHsigDeclM sig_iface sig_thing real_thing = do @@ -369,8 +370,8 @@ tcRnMergeSignatures hsc_env hpm orig_tcg_env iface = thinModIface :: [AvailInfo] -> ModIface -> ModIface thinModIface avails iface = - iface { - mi_exports = avails, + iface + & set_mi_exports avails -- mi_fixities = ..., -- mi_warns = ..., -- mi_anns = ..., @@ -378,10 +379,9 @@ thinModIface avails iface = -- perhaps there might be two IfaceTopBndr that are the same -- OccName but different Name. Requires better understanding -- of invariants here. - mi_decls = exported_decls ++ non_exported_decls ++ dfun_decls + & set_mi_decls (exported_decls ++ non_exported_decls ++ dfun_decls) -- mi_insts = ..., -- mi_fam_insts = ..., - } where decl_pred occs decl = nameOccName (ifName decl) `elemOccSet` occs filter_decls occs = filter (decl_pred occs . snd) (mi_decls iface) ===================================== compiler/GHC/Unit/Module/ModIface.hs ===================================== @@ -7,7 +7,61 @@ module GHC.Unit.Module.ModIface ( ModIface - , ModIface_ (..) + , ModIface_ + , restoreFromOldModIface + , addSourceFingerprint + , mi_module + , mi_sig_of + , mi_hsc_src + , mi_src_hash + , mi_hi_bytes + , mi_deps + , mi_usages + , mi_exports + , mi_used_th + , mi_fixities + , mi_warns + , mi_anns + , mi_insts + , mi_fam_insts + , mi_rules + , mi_decls + , mi_extra_decls + , mi_globals + , mi_hpc + , mi_trust + , mi_trust_pkg + , mi_complete_matches + , mi_docs + , mi_final_exts + , mi_ext_fields + , set_mi_module + , set_mi_sig_of + , set_mi_hsc_src + , set_mi_src_hash + , set_mi_hi_bytes + , set_mi_deps + , set_mi_usages + , set_mi_exports + , set_mi_used_th + , set_mi_fixities + , set_mi_warns + , set_mi_anns + , set_mi_insts + , set_mi_fam_insts + , set_mi_rules + , set_mi_decls + , set_mi_extra_decls + , set_mi_globals + , set_mi_hpc + , set_mi_trust + , set_mi_trust_pkg + , set_mi_complete_matches + , set_mi_docs + , set_mi_final_exts + , set_mi_ext_fields + , completePartialModIface + , IfaceBinHandle(..) , PartialModIface , ModIfaceBackend (..) , IfaceDeclExts @@ -58,6 +112,7 @@ import GHC.Utils.Binary import Control.DeepSeq import Control.Exception +import qualified GHC.Data.Strict as Strict {- Note [Interface file stages] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -139,7 +194,9 @@ type family IfaceBackendExts (phase :: ModIfacePhase) = bk | bk -> phase where IfaceBackendExts 'ModIfaceCore = () IfaceBackendExts 'ModIfaceFinal = ModIfaceBackend - +data IfaceBinHandle (phase :: ModIfacePhase) where + PartialIfaceBinHandle :: IfaceBinHandle 'ModIfaceCore + FullIfaceBinHandle :: Strict.Maybe FullBinData -> IfaceBinHandle 'ModIfaceFinal -- | A 'ModIface' plus a 'ModDetails' summarises everything we know -- about a compiled module. The 'ModIface' is the stuff *before* linking, @@ -155,60 +212,60 @@ type family IfaceBackendExts (phase :: ModIfacePhase) = bk | bk -> phase where -- strict and others are not. data ModIface_ (phase :: ModIfacePhase) = ModIface { - mi_module :: !Module, -- ^ Name of the module we are for - mi_sig_of :: !(Maybe Module), -- ^ Are we a sig of another mod? + mi_module_ :: !Module, -- ^ Name of the module we are for + mi_sig_of_ :: !(Maybe Module), -- ^ Are we a sig of another mod? - mi_hsc_src :: !HscSource, -- ^ Boot? Signature? + mi_hsc_src_ :: !HscSource, -- ^ Boot? Signature? - mi_deps :: Dependencies, + mi_deps_ :: Dependencies, -- ^ The dependencies of the module. This is -- consulted for directly-imported modules, but not -- for anything else (hence lazy) - mi_usages :: [Usage], + mi_usages_ :: [Usage], -- ^ Usages; kept sorted so that it's easy to decide -- whether to write a new iface file (changing usages -- doesn't affect the hash of this module) -- NOT STRICT! we read this field lazily from the interface file -- It is *only* consulted by the recompilation checker - mi_exports :: ![IfaceExport], + mi_exports_ :: ![IfaceExport], -- ^ Exports -- Kept sorted by (mod,occ), to make version comparisons easier -- Records the modules that are the declaration points for things -- exported by this module, and the 'OccName's of those things - mi_used_th :: !Bool, + mi_used_th_ :: !Bool, -- ^ Module required TH splices when it was compiled. -- This disables recompilation avoidance (see #481). - mi_fixities :: [(OccName,Fixity)], + mi_fixities_ :: [(OccName,Fixity)], -- ^ Fixities -- NOT STRICT! we read this field lazily from the interface file - mi_warns :: IfaceWarnings, + mi_warns_ :: IfaceWarnings, -- ^ Warnings -- NOT STRICT! we read this field lazily from the interface file - mi_anns :: [IfaceAnnotation], + mi_anns_ :: [IfaceAnnotation], -- ^ Annotations -- NOT STRICT! we read this field lazily from the interface file - mi_decls :: [IfaceDeclExts phase], + mi_decls_ :: [IfaceDeclExts phase], -- ^ Type, class and variable declarations -- The hash of an Id changes if its fixity or deprecations change -- (as well as its type of course) -- Ditto data constructors, class operations, except that -- the hash of the parent class/tycon changes - mi_extra_decls :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo], + mi_extra_decls_ :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo], -- ^ Extra variable definitions which are **NOT** exposed but when -- combined with mi_decls allows us to restart code generation. -- See Note [Interface Files with Core Definitions] and Note [Interface File with Core: Sharing RHSs] - mi_globals :: !(Maybe IfGlobalRdrEnv), + mi_globals_ :: !(Maybe IfGlobalRdrEnv), -- ^ Binds all the things defined at the top level in -- the /original source/ code for this module. which -- is NOT the same as mi_exports, nor mi_decls (which @@ -224,36 +281,36 @@ data ModIface_ (phase :: ModIfacePhase) -- 'HomeModInfo', but that leads to more plumbing. -- Instance declarations and rules - mi_insts :: [IfaceClsInst], -- ^ Sorted class instance - mi_fam_insts :: [IfaceFamInst], -- ^ Sorted family instances - mi_rules :: [IfaceRule], -- ^ Sorted rules + mi_insts_ :: [IfaceClsInst], -- ^ Sorted class instance + mi_fam_insts_ :: [IfaceFamInst], -- ^ Sorted family instances + mi_rules_ :: [IfaceRule], -- ^ Sorted rules - mi_hpc :: !AnyHpcUsage, + mi_hpc_ :: !AnyHpcUsage, -- ^ True if this program uses Hpc at any point in the program. - mi_trust :: !IfaceTrustInfo, + mi_trust_ :: !IfaceTrustInfo, -- ^ Safe Haskell Trust information for this module. - mi_trust_pkg :: !Bool, + mi_trust_pkg_ :: !Bool, -- ^ Do we require the package this module resides in be trusted -- to trust this module? This is used for the situation where a -- module is Safe (so doesn't require the package be trusted -- itself) but imports some trustworthy modules from its own -- package (which does require its own package be trusted). -- See Note [Trust Own Package] in GHC.Rename.Names - mi_complete_matches :: ![IfaceCompleteMatch], + mi_complete_matches_ :: ![IfaceCompleteMatch], - mi_docs :: !(Maybe Docs), + mi_docs_ :: !(Maybe Docs), -- ^ Docstrings and related data for use by haddock, the ghci -- @:doc@ command, and other tools. -- -- @Just _@ @<=>@ the module was built with @-haddock at . - mi_final_exts :: !(IfaceBackendExts phase), + mi_final_exts_ :: !(IfaceBackendExts phase), -- ^ Either `()` or `ModIfaceBackend` for -- a fully instantiated interface. - mi_ext_fields :: !ExtensibleFields, + mi_ext_fields_ :: !ExtensibleFields, -- ^ Additional optional fields, where the Map key represents -- the field name, resulting in a (size, serialized data) pair. -- Because the data is intended to be serialized through the @@ -262,8 +319,13 @@ data ModIface_ (phase :: ModIfacePhase) -- chosen over `ByteString`s. -- - mi_src_hash :: !Fingerprint + mi_src_hash_ :: !Fingerprint, -- ^ Hash of the .hs source, used for recompilation checking. + mi_hi_bytes_ :: !(IfaceBinHandle phase) + -- ^ A serialised in-memory buffer of this 'ModIface'. + -- If this handle is given, we can avoid serialising the 'ModIface' + -- when writing this 'ModIface' to disk, and write this buffer to disk instead. + -- See Note [Sharing of ModIface]. } {- @@ -343,33 +405,34 @@ renameFreeHoles fhs insts = -- See Note [Strictness in ModIface] about where we use lazyPut vs put instance Binary ModIface where put_ bh (ModIface { - mi_module = mod, - mi_sig_of = sig_of, - mi_hsc_src = hsc_src, - mi_src_hash = _src_hash, -- Don't `put_` this in the instance + mi_module_ = mod, + mi_sig_of_ = sig_of, + mi_hsc_src_ = hsc_src, + mi_src_hash_ = _src_hash, -- Don't `put_` this in the instance -- because we are going to write it -- out separately in the actual file - mi_deps = deps, - mi_usages = usages, - mi_exports = exports, - mi_used_th = used_th, - mi_fixities = fixities, - mi_warns = warns, - mi_anns = anns, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_insts = insts, - mi_fam_insts = fam_insts, - mi_rules = rules, - mi_hpc = hpc_info, - mi_trust = trust, - mi_trust_pkg = trust_pkg, - mi_complete_matches = complete_matches, - mi_docs = docs, - mi_ext_fields = _ext_fields, -- Don't `put_` this in the instance so we + mi_hi_bytes_ = _hi_bytes, -- TODO: explain + mi_deps_ = deps, + mi_usages_ = usages, + mi_exports_ = exports, + mi_used_th_ = used_th, + mi_fixities_ = fixities, + mi_warns_ = warns, + mi_anns_ = anns, + mi_decls_ = decls, + mi_extra_decls_ = extra_decls, + mi_insts_ = insts, + mi_fam_insts_ = fam_insts, + mi_rules_ = rules, + mi_hpc_ = hpc_info, + mi_trust_ = trust, + mi_trust_pkg_ = trust_pkg, + mi_complete_matches_ = complete_matches, + mi_docs_ = docs, + mi_ext_fields_ = _ext_fields, -- Don't `put_` this in the instance so we -- can deal with it's pointer in the header -- when we write the actual file - mi_final_exts = ModIfaceBackend { + mi_final_exts_ = ModIfaceBackend { mi_iface_hash = iface_hash, mi_mod_hash = mod_hash, mi_flag_hash = flag_hash, @@ -444,33 +507,34 @@ instance Binary ModIface where complete_matches <- get bh docs <- lazyGetMaybe bh return (ModIface { - mi_module = mod, - mi_sig_of = sig_of, - mi_hsc_src = hsc_src, - mi_src_hash = fingerprint0, -- placeholder because this is dealt + mi_module_ = mod, + mi_sig_of_ = sig_of, + mi_hsc_src_ = hsc_src, + mi_src_hash_ = fingerprint0, -- placeholder because this is dealt -- with specially when the file is read - mi_deps = deps, - mi_usages = usages, - mi_exports = exports, - mi_used_th = used_th, - mi_anns = anns, - mi_fixities = fixities, - mi_warns = warns, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_globals = Nothing, - mi_insts = insts, - mi_fam_insts = fam_insts, - mi_rules = rules, - mi_hpc = hpc_info, - mi_trust = trust, - mi_trust_pkg = trust_pkg, + mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing, + mi_deps_ = deps, + mi_usages_ = usages, + mi_exports_ = exports, + mi_used_th_ = used_th, + mi_anns_ = anns, + mi_fixities_ = fixities, + mi_warns_ = warns, + mi_decls_ = decls, + mi_extra_decls_ = extra_decls, + mi_globals_ = Nothing, + mi_insts_ = insts, + mi_fam_insts_ = fam_insts, + mi_rules_ = rules, + mi_hpc_ = hpc_info, + mi_trust_ = trust, + mi_trust_pkg_ = trust_pkg, -- And build the cached values - mi_complete_matches = complete_matches, - mi_docs = docs, - mi_ext_fields = emptyExtensibleFields, -- placeholder because this is dealt + mi_complete_matches_ = complete_matches, + mi_docs_ = docs, + mi_ext_fields_ = emptyExtensibleFields, -- placeholder because this is dealt -- with specially when the file is read - mi_final_exts = ModIfaceBackend { + mi_final_exts_ = ModIfaceBackend { mi_iface_hash = iface_hash, mi_mod_hash = mod_hash, mi_flag_hash = flag_hash, @@ -487,42 +551,45 @@ instance Binary ModIface where mi_hash_fn = mkIfaceHashCache decls }}) + -- | The original names declared of a certain module that are exported type IfaceExport = AvailInfo emptyPartialModIface :: Module -> PartialModIface emptyPartialModIface mod - = ModIface { mi_module = mod, - mi_sig_of = Nothing, - mi_hsc_src = HsSrcFile, - mi_src_hash = fingerprint0, - mi_deps = noDependencies, - mi_usages = [], - mi_exports = [], - mi_used_th = False, - mi_fixities = [], - mi_warns = IfWarnSome [] [], - mi_anns = [], - mi_insts = [], - mi_fam_insts = [], - mi_rules = [], - mi_decls = [], - mi_extra_decls = Nothing, - mi_globals = Nothing, - mi_hpc = False, - mi_trust = noIfaceTrustInfo, - mi_trust_pkg = False, - mi_complete_matches = [], - mi_docs = Nothing, - mi_final_exts = (), - mi_ext_fields = emptyExtensibleFields + = ModIface { mi_module_ = mod, + mi_sig_of_ = Nothing, + mi_hsc_src_ = HsSrcFile, + mi_src_hash_ = fingerprint0, + mi_hi_bytes_ = PartialIfaceBinHandle, + mi_deps_ = noDependencies, + mi_usages_ = [], + mi_exports_ = [], + mi_used_th_ = False, + mi_fixities_ = [], + mi_warns_ = IfWarnSome [] [], + mi_anns_ = [], + mi_insts_ = [], + mi_fam_insts_ = [], + mi_rules_ = [], + mi_decls_ = [], + mi_extra_decls_ = Nothing, + mi_globals_ = Nothing, + mi_hpc_ = False, + mi_trust_ = noIfaceTrustInfo, + mi_trust_pkg_ = False, + mi_complete_matches_ = [], + mi_docs_ = Nothing, + mi_final_exts_ = (), + mi_ext_fields_ = emptyExtensibleFields } emptyFullModIface :: Module -> ModIface emptyFullModIface mod = (emptyPartialModIface mod) - { mi_decls = [] - , mi_final_exts = ModIfaceBackend + { mi_decls_ = [] + , mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing + , mi_final_exts_ = ModIfaceBackend { mi_iface_hash = fingerprint0, mi_mod_hash = fingerprint0, mi_flag_hash = fingerprint0, @@ -557,36 +624,36 @@ emptyIfaceHashCache _occ = Nothing instance ( NFData (IfaceBackendExts (phase :: ModIfacePhase)) , NFData (IfaceDeclExts (phase :: ModIfacePhase)) ) => NFData (ModIface_ phase) where - rnf (ModIface{ mi_module, mi_sig_of, mi_hsc_src, mi_deps, mi_usages - , mi_exports, mi_used_th, mi_fixities, mi_warns, mi_anns - , mi_decls, mi_extra_decls, mi_globals, mi_insts - , mi_fam_insts, mi_rules, mi_hpc, mi_trust, mi_trust_pkg - , mi_complete_matches, mi_docs, mi_final_exts - , mi_ext_fields, mi_src_hash }) - = rnf mi_module - `seq` rnf mi_sig_of - `seq` mi_hsc_src - `seq` mi_deps - `seq` mi_usages - `seq` mi_exports - `seq` rnf mi_used_th - `seq` mi_fixities - `seq` rnf mi_warns - `seq` rnf mi_anns - `seq` rnf mi_decls - `seq` rnf mi_extra_decls - `seq` rnf mi_globals - `seq` rnf mi_insts - `seq` rnf mi_fam_insts - `seq` rnf mi_rules - `seq` rnf mi_hpc - `seq` mi_trust - `seq` rnf mi_trust_pkg - `seq` rnf mi_complete_matches - `seq` rnf mi_docs - `seq` mi_final_exts - `seq` mi_ext_fields - `seq` rnf mi_src_hash + rnf (ModIface{ mi_module_, mi_sig_of_, mi_hsc_src_, mi_deps_, mi_usages_ + , mi_exports_, mi_used_th_, mi_fixities_, mi_warns_, mi_anns_ + , mi_decls_, mi_extra_decls_, mi_globals_, mi_insts_ + , mi_fam_insts_, mi_rules_, mi_hpc_, mi_trust_, mi_trust_pkg_ + , mi_complete_matches_, mi_docs_, mi_final_exts_ + , mi_ext_fields_, mi_src_hash_ }) + = rnf mi_module_ + `seq` rnf mi_sig_of_ + `seq` mi_hsc_src_ + `seq` mi_deps_ + `seq` mi_usages_ + `seq` mi_exports_ + `seq` rnf mi_used_th_ + `seq` mi_fixities_ + `seq` rnf mi_warns_ + `seq` rnf mi_anns_ + `seq` rnf mi_decls_ + `seq` rnf mi_extra_decls_ + `seq` rnf mi_globals_ + `seq` rnf mi_insts_ + `seq` rnf mi_fam_insts_ + `seq` rnf mi_rules_ + `seq` rnf mi_hpc_ + `seq` mi_trust_ + `seq` rnf mi_trust_pkg_ + `seq` rnf mi_complete_matches_ + `seq` rnf mi_docs_ + `seq` mi_final_exts_ + `seq` mi_ext_fields_ + `seq` rnf mi_src_hash_ `seq` () instance NFData (ModIfaceBackend) where @@ -626,5 +693,158 @@ type WhetherHasOrphans = Bool -- | Does this module define family instances? type WhetherHasFamInst = Bool +completePartialModIface :: PartialModIface + -> [(Fingerprint, IfaceDecl)] + -> Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] + -> ModIfaceBackend + -> IfaceBinHandle 'ModIfaceFinal + -> ModIface +completePartialModIface partial decls extra_decls final_exts hi_bytes = partial + { mi_decls_ = decls + , mi_extra_decls_ = extra_decls + , mi_final_exts_ = final_exts + , mi_hi_bytes_ = hi_bytes + } + +addSourceFingerprint :: Fingerprint -> ModIface_ 'ModIfaceFinal -> ModIface_ 'ModIfaceFinal +addSourceFingerprint val iface = iface { mi_src_hash_ = val } + +restoreFromOldModIface :: ModIface_ phase -> ModIface_ phase -> ModIface_ phase +restoreFromOldModIface old new = new + { mi_globals_ = mi_globals_ old + , mi_hsc_src_ = mi_hsc_src_ old + , mi_src_hash_ = mi_src_hash_ old + } + +set_mi_module :: Module -> ModIface_ phase -> ModIface_ phase +set_mi_module val iface = clear_mi_hi_bytes $ iface { mi_module_ = val } + +set_mi_sig_of :: Maybe Module -> ModIface_ phase -> ModIface_ phase +set_mi_sig_of val iface = clear_mi_hi_bytes $ iface { mi_sig_of_ = val } + +set_mi_hsc_src :: HscSource -> ModIface_ phase -> ModIface_ phase +set_mi_hsc_src val iface = clear_mi_hi_bytes $ iface { mi_hsc_src_ = val } + +set_mi_src_hash :: Fingerprint -> ModIface_ phase -> ModIface_ phase +set_mi_src_hash val iface = clear_mi_hi_bytes $ iface { mi_src_hash_ = val } + +set_mi_hi_bytes :: IfaceBinHandle phase -> ModIface_ phase -> ModIface_ phase +set_mi_hi_bytes val iface = iface { mi_hi_bytes_ = val } + +set_mi_deps :: Dependencies -> ModIface_ phase -> ModIface_ phase +set_mi_deps val iface = clear_mi_hi_bytes $ iface { mi_deps_ = val } + +set_mi_usages :: [Usage] -> ModIface_ phase -> ModIface_ phase +set_mi_usages val iface = clear_mi_hi_bytes $ iface { mi_usages_ = val } + +set_mi_exports :: [IfaceExport] -> ModIface_ phase -> ModIface_ phase +set_mi_exports val iface = clear_mi_hi_bytes $ iface { mi_exports_ = val } + +set_mi_used_th :: Bool -> ModIface_ phase -> ModIface_ phase +set_mi_used_th val iface = clear_mi_hi_bytes $ iface { mi_used_th_ = val } + +set_mi_fixities :: [(OccName, Fixity)] -> ModIface_ phase -> ModIface_ phase +set_mi_fixities val iface = clear_mi_hi_bytes $ iface { mi_fixities_ = val } +set_mi_warns :: IfaceWarnings -> ModIface_ phase -> ModIface_ phase +set_mi_warns val iface = clear_mi_hi_bytes $ iface { mi_warns_ = val } + +set_mi_anns :: [IfaceAnnotation] -> ModIface_ phase -> ModIface_ phase +set_mi_anns val iface = clear_mi_hi_bytes $ iface { mi_anns_ = val } + +set_mi_insts :: [IfaceClsInst] -> ModIface_ phase -> ModIface_ phase +set_mi_insts val iface = clear_mi_hi_bytes $ iface { mi_insts_ = val } + +set_mi_fam_insts :: [IfaceFamInst] -> ModIface_ phase -> ModIface_ phase +set_mi_fam_insts val iface = clear_mi_hi_bytes $ iface { mi_fam_insts_ = val } + +set_mi_rules :: [IfaceRule] -> ModIface_ phase -> ModIface_ phase +set_mi_rules val iface = clear_mi_hi_bytes $ iface { mi_rules_ = val } + +set_mi_decls :: [IfaceDeclExts phase] -> ModIface_ phase -> ModIface_ phase +set_mi_decls val iface = clear_mi_hi_bytes $ iface { mi_decls_ = val } + +set_mi_extra_decls :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] -> ModIface_ phase -> ModIface_ phase +set_mi_extra_decls val iface = clear_mi_hi_bytes $ iface { mi_extra_decls_ = val } + +set_mi_globals :: Maybe IfGlobalRdrEnv -> ModIface_ phase -> ModIface_ phase +set_mi_globals val iface = clear_mi_hi_bytes $ iface { mi_globals_ = val } + +set_mi_hpc :: AnyHpcUsage -> ModIface_ phase -> ModIface_ phase +set_mi_hpc val iface = clear_mi_hi_bytes $ iface { mi_hpc_ = val } + +set_mi_trust :: IfaceTrustInfo -> ModIface_ phase -> ModIface_ phase +set_mi_trust val iface = clear_mi_hi_bytes $ iface { mi_trust_ = val } + +set_mi_trust_pkg :: Bool -> ModIface_ phase -> ModIface_ phase +set_mi_trust_pkg val iface = clear_mi_hi_bytes $ iface { mi_trust_pkg_ = val } + +set_mi_complete_matches :: [IfaceCompleteMatch] -> ModIface_ phase -> ModIface_ phase +set_mi_complete_matches val iface = clear_mi_hi_bytes $ iface { mi_complete_matches_ = val } + +set_mi_docs :: Maybe Docs -> ModIface_ phase -> ModIface_ phase +set_mi_docs val iface = clear_mi_hi_bytes $ iface { mi_docs_ = val } + +set_mi_final_exts :: IfaceBackendExts phase -> ModIface_ phase -> ModIface_ phase +set_mi_final_exts val iface = clear_mi_hi_bytes $ iface { mi_final_exts_ = val } + +set_mi_ext_fields :: ExtensibleFields -> ModIface_ phase -> ModIface_ phase +set_mi_ext_fields val iface = clear_mi_hi_bytes $ iface { mi_ext_fields_ = val } + +clear_mi_hi_bytes :: ModIface_ phase -> ModIface_ phase +clear_mi_hi_bytes iface = iface + { mi_hi_bytes_ = case mi_hi_bytes iface of + PartialIfaceBinHandle -> PartialIfaceBinHandle + FullIfaceBinHandle _ -> FullIfaceBinHandle Strict.Nothing + } +mi_module :: ModIface_ phase -> Module +mi_module = mi_module_ +mi_sig_of :: ModIface_ phase -> Maybe Module +mi_sig_of = mi_sig_of_ +mi_hsc_src :: ModIface_ phase -> HscSource +mi_hsc_src = mi_hsc_src_ +mi_deps :: ModIface_ phase -> Dependencies +mi_deps = mi_deps_ +mi_usages :: ModIface_ phase -> [Usage] +mi_usages = mi_usages_ +mi_exports :: ModIface_ phase -> [IfaceExport] +mi_exports = mi_exports_ +mi_used_th :: ModIface_ phase -> Bool +mi_used_th = mi_used_th_ +mi_fixities :: ModIface_ phase -> [(OccName, Fixity)] +mi_fixities = mi_fixities_ +mi_warns :: ModIface_ phase -> IfaceWarnings +mi_warns = mi_warns_ +mi_anns :: ModIface_ phase -> [IfaceAnnotation] +mi_anns = mi_anns_ +mi_decls :: ModIface_ phase -> [IfaceDeclExts phase] +mi_decls = mi_decls_ +mi_extra_decls :: ModIface_ phase -> Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] +mi_extra_decls = mi_extra_decls_ +mi_globals :: ModIface_ phase -> Maybe IfGlobalRdrEnv +mi_globals = mi_globals_ +mi_insts :: ModIface_ phase -> [IfaceClsInst] +mi_insts = mi_insts_ +mi_fam_insts :: ModIface_ phase -> [IfaceFamInst] +mi_fam_insts = mi_fam_insts_ +mi_rules :: ModIface_ phase -> [IfaceRule] +mi_rules = mi_rules_ +mi_hpc :: ModIface_ phase -> AnyHpcUsage +mi_hpc = mi_hpc_ +mi_trust :: ModIface_ phase -> IfaceTrustInfo +mi_trust = mi_trust_ +mi_trust_pkg :: ModIface_ phase -> Bool +mi_trust_pkg = mi_trust_pkg_ +mi_complete_matches :: ModIface_ phase -> [IfaceCompleteMatch] +mi_complete_matches = mi_complete_matches_ +mi_docs :: ModIface_ phase -> Maybe Docs +mi_docs = mi_docs_ +mi_final_exts :: ModIface_ phase -> IfaceBackendExts phase +mi_final_exts = mi_final_exts_ +mi_ext_fields :: ModIface_ phase -> ExtensibleFields +mi_ext_fields = mi_ext_fields_ +mi_src_hash :: ModIface_ phase -> Fingerprint +mi_src_hash = mi_src_hash_ +mi_hi_bytes :: ModIface_ phase -> IfaceBinHandle phase +mi_hi_bytes = mi_hi_bytes_ ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -19,7 +19,7 @@ -- http://www.cs.york.ac.uk/fp/nhc98/ module GHC.Utils.Binary - ( {-type-} Bin, + ( {-type-} Bin, RelBin(..), getRelBin, {-class-} Binary(..), {-type-} ReadBinHandle, WriteBinHandle, SymbolTable, Dictionary, @@ -32,6 +32,7 @@ module GHC.Utils.Binary seekBinWriter, seekBinReader, + seekBinReaderRel, tellBinReader, tellBinWriter, castBin, @@ -47,7 +48,9 @@ module GHC.Utils.Binary readBinMemN, putAt, getAt, + putAtRel, forwardPut, forwardPut_, forwardGet, + forwardPutRel, forwardPutRel_, forwardGetRel, -- * For writing instances putByte, @@ -102,6 +105,9 @@ module GHC.Utils.Binary BindingName(..), simpleBindingNameWriter, simpleBindingNameReader, + FullBinData(..), freezeBinHandle, thawBinHandle, putFullBinData, + freezeBinHandle2, + BinArray, ) where import GHC.Prelude @@ -156,7 +162,6 @@ import GHC.ForeignPtr ( unsafeWithForeignPtr ) import Unsafe.Coerce (unsafeCoerce) import GHC.Data.TrieMap - type BinArray = ForeignPtr Word8 #if !MIN_VERSION_base(4,15,0) @@ -196,6 +201,51 @@ dataHandle (BinData size bin) = do handleData :: WriteBinHandle -> IO BinData handleData (WriteBinMem _ ixr _ binr) = BinData <$> readFastMutInt ixr <*> readIORef binr +--------------------------------------------------------------- +-- FullBinData +--------------------------------------------------------------- + +data FullBinData = FullBinData + { fbd_readerUserData :: ReaderUserData + , fbd_off_s :: {-# UNPACK #-} !Int + -- ^ start offset + , fbd_off_e :: {-# UNPACK #-} !Int + -- ^ end offset + , fbd_size :: {-# UNPACK #-} !Int + -- ^ total buffer size + , fbd_buffer :: {-# UNPACK #-} !BinArray + } + +-- Equality and Ord assume that two distinct buffers are different, even if they compare the same things. +instance Eq FullBinData where + (FullBinData _ b c d e) == (FullBinData _ b1 c1 d1 e1) = b == b1 && c == c1 && d == d1 && e == e1 + +instance Ord FullBinData where + compare (FullBinData _ b c d e) (FullBinData _ b1 c1 d1 e1) = + compare b b1 `mappend` compare c c1 `mappend` compare d d1 `mappend` compare e e1 + +putFullBinData :: WriteBinHandle -> FullBinData -> IO () +putFullBinData bh (FullBinData _ o1 o2 _sz ba) = do + let sz = o2 - o1 + putPrim bh sz $ \dest -> + unsafeWithForeignPtr (ba `plusForeignPtr` o1) $ \orig -> + copyBytes dest orig sz + +freezeBinHandle :: Bin () -> ReadBinHandle -> IO FullBinData +freezeBinHandle (BinPtr len) (ReadBinMem user_data ixr sz binr) = do + ix <- readFastMutInt ixr + pure (FullBinData user_data ix len sz binr) + +freezeBinHandle2 :: ReadBinHandle -> Bin () -> IO FullBinData +freezeBinHandle2 (ReadBinMem user_data ixr sz binr) (BinPtr start) = do + ix <- readFastMutInt ixr + pure (FullBinData user_data start ix sz binr) + +thawBinHandle :: FullBinData -> IO ReadBinHandle +thawBinHandle (FullBinData user_data ix _end sz ba) = do + ixr <- newFastMutInt ix + return $ ReadBinMem user_data ixr sz ba + --------------------------------------------------------------- -- BinHandle --------------------------------------------------------------- @@ -289,9 +339,30 @@ unsafeUnpackBinBuffer (BS.BS arr len) = do newtype Bin a = BinPtr Int deriving (Eq, Ord, Show, Bounded) +data RelBin a = RelBin !(Bin a) !(Bin a) + deriving (Eq, Ord, Show, Bounded) + +newtype RelBinPtr a = RelBinPtr (Bin a) + castBin :: Bin a -> Bin b castBin (BinPtr i) = BinPtr i +getRelBin :: ReadBinHandle -> IO (RelBin a) +getRelBin bh = do + start <- tellBinReader bh + off <- get bh + pure $ RelBin start off + +makeAbsoluteBin :: RelBin a -> Bin a +makeAbsoluteBin (RelBin (BinPtr !start) (BinPtr !offset)) = BinPtr (start + offset) + +makeRelativeBin :: RelBin a -> RelBinPtr a +makeRelativeBin (RelBin _ offset) = RelBinPtr offset + +toRelBin :: Bin (RelBinPtr a) -> Bin a -> RelBin a +toRelBin (BinPtr !start) (BinPtr !goal) = + RelBin (BinPtr start) (BinPtr $! goal - start) + --------------------------------------------------------------- -- class Binary --------------------------------------------------------------- @@ -312,6 +383,9 @@ class Binary a where putAt :: Binary a => WriteBinHandle -> Bin a -> a -> IO () putAt bh p x = do seekBinWriter bh p; put_ bh x; return () +putAtRel :: WriteBinHandle -> Bin (RelBinPtr a) -> Bin a -> IO () +putAtRel bh from to = putAt bh from (makeRelativeBin $ toRelBin from to) + getAt :: Binary a => ReadBinHandle -> Bin a -> IO a getAt bh p = do seekBinReader bh p; get bh @@ -393,12 +467,18 @@ seekBinNoExpandWriter (WriteBinMem _ ix_r sz_r _) (BinPtr !p) = do else writeFastMutInt ix_r p -- | SeekBin but without calling expandBin -seekBinReader :: ReadBinHandle -> Bin a -> IO () +seekBinReader :: HasCallStack => ReadBinHandle -> Bin a -> IO () seekBinReader (ReadBinMem _ ix_r sz_r _) (BinPtr !p) = do if (p > sz_r) then panic "seekBinReader: seek out of range" else writeFastMutInt ix_r p +seekBinReaderRel :: HasCallStack => ReadBinHandle -> RelBin a -> IO () +seekBinReaderRel (ReadBinMem _ ix_r sz_r _) (RelBin (BinPtr !start) (BinPtr !offset)) = do + if (start + offset > sz_r) + then panic "seekBinReaderRel: seek out of range" + else writeFastMutInt ix_r (start + offset) + writeBinMem :: WriteBinHandle -> FilePath -> IO () writeBinMem (WriteBinMem _ ix_r _ arr_r) fn = do h <- openBinaryFile fn WriteMode @@ -1119,6 +1199,11 @@ instance Binary (Bin a) where put_ bh (BinPtr i) = putWord32 bh (fromIntegral i :: Word32) get bh = do i <- getWord32 bh; return (BinPtr (fromIntegral (i :: Word32))) +-- Instance uses fixed-width encoding to allow inserting +-- Bin placeholders in the stream. +instance Binary (RelBinPtr a) where + put_ bh (RelBinPtr i) = put_ bh i + get bh = RelBinPtr <$> get bh -- ----------------------------------------------------------------------------- -- Forward reading/writing @@ -1147,7 +1232,7 @@ forwardPut_ :: WriteBinHandle -> (b -> IO a) -> IO b -> IO () forwardPut_ bh put_A put_B = void $ forwardPut bh put_A put_B -- | Read a value stored using a forward reference -forwardGet :: ReadBinHandle -> IO a -> IO a +forwardGet :: HasCallStack => ReadBinHandle -> IO a -> IO a forwardGet bh get_A = do -- read forward reference p <- get bh -- a BinPtr @@ -1159,6 +1244,43 @@ forwardGet bh get_A = do seekBinReader bh p_a pure r + +-- | "forwardPutRel put_A put_B" outputs A after B but allows A to be read before B +-- by using a forward reference. +forwardPutRel :: WriteBinHandle -> (b -> IO a) -> IO b -> IO (a,b) +forwardPutRel bh put_A put_B = do + -- write placeholder pointer to A + pre_a <- tellBinWriter bh + put_ bh pre_a + + -- write B + r_b <- put_B + + -- update A's pointer + a <- tellBinWriter bh + putAtRel bh pre_a a + seekBinNoExpandWriter bh a + + -- write A + r_a <- put_A r_b + pure (r_a,r_b) + +forwardPutRel_ :: WriteBinHandle -> (b -> IO a) -> IO b -> IO () +forwardPutRel_ bh put_A put_B = void $ forwardPutRel bh put_A put_B + +-- | Read a value stored using a forward reference +forwardGetRel :: ReadBinHandle -> IO a -> IO a +forwardGetRel bh get_A = do + -- read forward reference + p <- getRelBin bh + -- store current position + p_a <- tellBinReader bh + -- go read the forward value, then seek back + seekBinReader bh $ makeAbsoluteBin p + r <- get_A + seekBinReader bh p_a + pure r + -- ----------------------------------------------------------------------------- -- Lazy reading/writing @@ -1168,19 +1290,19 @@ lazyPut = lazyPut' put_ lazyGet :: Binary a => ReadBinHandle -> IO a lazyGet = lazyGet' get -lazyPut' :: HasDebugCallStack => (WriteBinHandle -> a -> IO ()) -> WriteBinHandle -> a -> IO () +lazyPut' :: (WriteBinHandle -> a -> IO ()) -> WriteBinHandle -> a -> IO () lazyPut' f bh a = do -- output the obj with a ptr to skip over it: pre_a <- tellBinWriter bh put_ bh pre_a -- save a slot for the ptr f bh a -- dump the object q <- tellBinWriter bh -- q = ptr to after object - putAt bh pre_a q -- fill in slot before a with ptr to q + putAtRel bh pre_a q -- fill in slot before a with ptr to q seekBinWriter bh q -- finally carry on writing at q lazyGet' :: HasDebugCallStack => (ReadBinHandle -> IO a) -> ReadBinHandle -> IO a lazyGet' f bh = do - p <- get bh -- a BinPtr + p <- getRelBin bh -- a BinPtr p_a <- tellBinReader bh a <- unsafeInterleaveIO $ do -- NB: Use a fresh rbm_off_r variable in the child thread, for thread @@ -1189,7 +1311,7 @@ lazyGet' f bh = do let bh' = bh { rbm_off_r = off_r } seekBinReader bh' p_a f bh' - seekBinReader bh p -- skip over the object for now + seekBinReader bh (makeAbsoluteBin p) -- skip over the object for now return a -- | Serialize the constructor strictly but lazily serialize a value inside a @@ -1483,13 +1605,13 @@ putGenericSymbolTable gen_sym_tab serialiser bh = do mapM_ (\n -> serialiser bh n) (reverse todo) loop snd <$> - (forwardPut bh (const $ readFastMutInt symtab_next >>= put_ bh) $ + (forwardPutRel bh (const $ readFastMutInt symtab_next >>= put_ bh) $ loop) -- | Read the elements of a 'GenericSymbolTable' from disk into a 'SymbolTable'. getGenericSymbolTable :: forall a . (ReadBinHandle -> IO a) -> ReadBinHandle -> IO (SymbolTable a) getGenericSymbolTable deserialiser bh = do - sz <- forwardGet bh (get bh) :: IO Int + sz <- forwardGetRel bh (get bh) :: IO Int mut_arr <- newArray_ (0, sz-1) :: IO (IOArray Int a) forM_ [0..(sz-1)] $ \i -> do f <- deserialiser bh ===================================== testsuite/tests/plugins/simple-plugin/Simple/RemovePlugin.hs ===================================== @@ -64,9 +64,10 @@ metaPlugin' _ meta = pprPanic "meta" (showAstData BlankSrcSpan BlankEpAnnotation interfaceLoadPlugin' :: [CommandLineOption] -> ModIface -> IfM lcl ModIface interfaceLoadPlugin' [name, "interface"] iface - = return $ iface { mi_exports = filter (availNotNamedAs name) - (mi_exports iface) - } + = return $ set_mi_exports (filter (availNotNamedAs name) + (mi_exports iface)) + iface + interfaceLoadPlugin' _ iface = return iface availNotNamedAs :: String -> AvailInfo -> Bool ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit c9bc29c6a708483d2abc3d8ec9262510ce87ca61 +Subproject commit 6f9e0cc9ae9f2dfbd671e5970ec9d7bbf9a9dcf1 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dec1e9db27abe78634da636691952a3348f5587c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dec1e9db27abe78634da636691952a3348f5587c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 12:38:30 2024 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 07 May 2024 08:38:30 -0400 Subject: [Git][ghc/ghc][wip/T24334] 2 commits: Simplifier: Preserve OccInfo on DataAlt fields when case binder is dead (#24770) Message-ID: <663a20c654051_3f177319491ec7653b@gitlab.mail> Sebastian Graf pushed to branch wip/T24334 at Glasgow Haskell Compiler / GHC Commits: ffffbe11 by Sebastian Graf at 2024-05-07T14:38:14+02:00 Simplifier: Preserve OccInfo on DataAlt fields when case binder is dead (#24770) See the adjusted `Note [DataAlt occ info]`. This change also has a positive repercussion on `Note [Combine case alts: awkward corner]`. Fixes #24770. - - - - - 214ab72d by Sebastian Graf at 2024-05-07T14:38:14+02:00 Kill seqRule, discard dead seq# in Prep (#24334) Discarding seq#s in Core land via `seqRule` was problematic; see #24334. So instead we discard certain dead, discardable seq#s in Prep now. See the updated `Note [seq# magic]`. This fixes the symptoms of #24334. - - - - - 15 changed files: - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Types/Id/Make.hs - testsuite/tests/codeGen/should_compile/T24264.hs - + testsuite/tests/core-to-stg/T24334.hs - + testsuite/tests/core-to-stg/T24334.stdout - testsuite/tests/core-to-stg/all.T - testsuite/tests/simplCore/should_compile/T21851.stderr - + testsuite/tests/simplCore/should_compile/T24770.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/CSE.hs ===================================== @@ -9,12 +9,8 @@ module GHC.Core.Opt.CSE (cseProgram, cseOneExpr) where import GHC.Prelude import GHC.Core.Subst -import GHC.Types.Var ( Var ) import GHC.Types.Var.Env ( mkInScopeSet ) -import GHC.Types.Id ( Id, idType, idHasRules, zapStableUnfolding - , idInlineActivation, setInlineActivation - , zapIdOccInfo, zapIdUsageInfo, idInlinePragma - , isJoinId, idJoinPointHood, idUnfolding ) +import GHC.Types.Id import GHC.Core.Utils ( mkAltExpr , exprIsTickedString , stripTicksE, stripTicksT, mkTicks ) @@ -754,7 +750,7 @@ combineAlts alts , Alt _ bndrs1 rhs1 <- alt1 , let filtered_alts = filterOut (identical_alt rhs1) rest_alts , not (equalLength rest_alts filtered_alts) - = assertPpr (null bndrs1) (ppr alts) $ + = assertPpr (all isDeadBinder bndrs1) (ppr alts) $ Alt DEFAULT [] rhs1 : filtered_alts | otherwise @@ -762,14 +758,13 @@ combineAlts alts where find_bndr_free_alt :: [CoreAlt] -> (Maybe CoreAlt, [CoreAlt]) - -- The (Just alt) is a binder-free alt - -- See Note [Combine case alts: awkward corner] + -- The (Just alt) is an alt where all fields are dead find_bndr_free_alt [] = (Nothing, []) find_bndr_free_alt (alt@(Alt _ bndrs _) : alts) - | null bndrs = (Just alt, alts) - | otherwise = case find_bndr_free_alt alts of - (mb_bf, alts) -> (mb_bf, alt:alts) + | all isDeadBinder bndrs = (Just alt, alts) + | otherwise = case find_bndr_free_alt alts of + (mb_bf, alts) -> (mb_bf, alt:alts) identical_alt rhs1 (Alt _ _ rhs) = eqCoreExpr rhs1 rhs -- Even if this alt has binders, they will have been cloned @@ -823,9 +818,9 @@ big for cheapEqExpr to catch it. Note [Combine case alts: awkward corner] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We would really like to check isDeadBinder on the binders in the -alternative. But alas, the simplifer zaps occ-info on binders in case -alternatives; see Note [Case alternative occ info] in GHC.Core.Opt.Simplify. +We check isDeadBinder on field binders in order to collapse into a DEFAULT alt. +But alas, the simplifer often zaps occ-info on field binders in DataAlts when +the case binder is alive; see Note [DataAlt occ info] in GHC.Core.Opt.Simplify. * One alternative (perhaps a good one) would be to do OccAnal just before CSE. Then perhaps we could get rid of combineIdenticalAlts @@ -833,14 +828,12 @@ alternatives; see Note [Case alternative occ info] in GHC.Core.Opt.Simplify. * Another would be for CSE to return free vars as it goes. -* But the current solution is to find a nullary alternative (including - the DEFAULT alt, if any). This will not catch - case x of - A y -> blah - B z p -> blah - where no alternative is nullary or DEFAULT. But the current - solution is at least cheap. - +* But the current solution is to accept that we do not catch cases such as + case x of c + A _ -> blah[c] + B _ _ -> blah[c] + where the case binder c is alive and no alternative is DEFAULT. + But the current solution is at least cheap. ************************************************************************ * * ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -2067,21 +2067,18 @@ unsafeEqualityProofRule {- ********************************************************************* * * - Rules for seq# and spark# + Rules for spark# * * ********************************************************************* -} -seqRule :: RuleM CoreExpr -seqRule = do +-- spark# :: forall a s . a -> State# s -> (# State# s, a #) +sparkRule :: RuleM CoreExpr +sparkRule = do -- reduce on HNF [Type _ty_a, Type _ty_s, a, s] <- getArgs guard $ exprIsHNF a return $ mkCoreUnboxedTuple [s, a] - --- spark# :: forall a s . a -> State# s -> (# State# s, a #) -sparkRule :: RuleM CoreExpr -sparkRule = seqRule -- reduce on HNF, just the same - -- XXX perhaps we shouldn't do this, because a spark eliminated by - -- this rule won't be counted as a dud at runtime? + -- XXX perhaps we shouldn't do this, because a spark eliminated by + -- this rule won't be counted as a dud at runtime? {- ************************************************************************ @@ -2158,9 +2155,7 @@ builtinRules platform <- getPlatform return $ Var (primOpId IntAndOp) `App` arg `App` mkIntVal platform (d - 1) - ], - - mkBasicRule seqHashName 4 seqRule + ] ] ++ builtinBignumRules {-# NOINLINE builtinRules #-} ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -26,7 +26,7 @@ core expression with (hopefully) improved usage information. module GHC.Core.Opt.OccurAnal ( occurAnalysePgm, occurAnalyseExpr, - zapLambdaBndrs, scrutBinderSwap_maybe + zapLambdaBndrs, BinderSwapDecision(..), scrutOkForBinderSwap ) where import GHC.Prelude hiding ( head, init, last, tail ) @@ -3262,7 +3262,7 @@ inline x, cancel the casts, and away we go. Note [Care with binder-swap on dictionaries] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -This Note explains why we need isDictId in scrutBinderSwap_maybe. +This Note explains why we need isDictId in scrutOkForBinderSwap. Consider this tricky example (#21229, #21470): class Sing (b :: Bool) where sing :: Bool @@ -3306,7 +3306,7 @@ Conclusion: for a /dictionary variable/ do not perform the clever cast version of the binder-swap -Hence the subtle isDictId in scrutBinderSwap_maybe. +Hence the subtle isDictId in scrutOkForBinderSwap. Note [Zap case binders in proxy bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -3328,7 +3328,7 @@ addBndrSwap :: OutExpr -> Id -> OccEnv -> OccEnv -- See Note [The binder-swap substitution] addBndrSwap scrut case_bndr env@(OccEnv { occ_bs_env = swap_env, occ_bs_rng = rng_vars }) - | Just (scrut_var, mco) <- scrutBinderSwap_maybe scrut + | DoBinderSwap scrut_var mco <- scrutOkForBinderSwap scrut , scrut_var /= case_bndr -- Consider: case x of x { ... } -- Do not add [x :-> x] to occ_bs_env, else lookupBndrSwap will loop @@ -3342,25 +3342,30 @@ addBndrSwap scrut case_bndr case_bndr' = zapIdOccInfo case_bndr -- See Note [Zap case binders in proxy bindings] -scrutBinderSwap_maybe :: OutExpr -> Maybe (OutVar, MCoercion) --- If (scrutBinderSwap_maybe e = Just (v, mco), then +-- | See bBinderSwaOk. +data BinderSwapDecision + = NoBinderSwap + | DoBinderSwap OutVar MCoercion + +scrutOkForBinderSwap :: OutExpr -> BinderSwapDecision +-- If (scrutOkForBinderSwap e = DoBinderSwap v mco, then -- v = e |> mco -- See Note [Case of cast] -- See Note [Care with binder-swap on dictionaries] -- -- We use this same function in SpecConstr, and Simplify.Iteration, -- when something binder-swap-like is happening -scrutBinderSwap_maybe (Var v) = Just (v, MRefl) -scrutBinderSwap_maybe (Cast (Var v) co) - | not (isDictId v) = Just (v, MCo (mkSymCo co)) +scrutOkForBinderSwap (Var v) = DoBinderSwap v MRefl +scrutOkForBinderSwap (Cast (Var v) co) + | not (isDictId v) = DoBinderSwap v (MCo (mkSymCo co)) -- Cast: see Note [Case of cast] -- isDictId: see Note [Care with binder-swap on dictionaries] -- The isDictId rejects a Constraint/Constraint binder-swap, perhaps -- over-conservatively. But I have never seen one, so I'm leaving -- the code as simple as possible. Losing the binder-swap in a -- rare case probably has very low impact. -scrutBinderSwap_maybe (Tick _ e) = scrutBinderSwap_maybe e -- Drop ticks -scrutBinderSwap_maybe _ = Nothing +scrutOkForBinderSwap (Tick _ e) = scrutOkForBinderSwap e -- Drop ticks +scrutOkForBinderSwap _ = NoBinderSwap lookupBndrSwap :: OccEnv -> Id -> (CoreExpr, Id) -- See Note [The binder-swap substitution] ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -1719,7 +1719,7 @@ extendCaseBndrEnv :: LevelEnv -> LevelEnv extendCaseBndrEnv le@(LE { le_subst = subst, le_env = id_env }) case_bndr (Var scrut_var) - -- We could use OccurAnal. scrutBinderSwap_maybe here, and perhaps + -- We could use OccurAnal. scrutOkForBinderSwap here, and perhaps -- get a bit more floating. But we didn't in the past and it's -- an unforced change, so I'm leaving it. = le { le_subst = extendSubstWithVar subst case_bndr scrut_var ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -23,7 +23,7 @@ import GHC.Core.TyCo.Compare( eqType ) import GHC.Core.Opt.Simplify.Env import GHC.Core.Opt.Simplify.Inline import GHC.Core.Opt.Simplify.Utils -import GHC.Core.Opt.OccurAnal ( occurAnalyseExpr, zapLambdaBndrs, scrutBinderSwap_maybe ) +import GHC.Core.Opt.OccurAnal ( occurAnalyseExpr, zapLambdaBndrs, scrutOkForBinderSwap, BinderSwapDecision (..) ) import GHC.Core.Make ( FloatBind, mkImpossibleExpr, castBottomExpr ) import qualified GHC.Core.Make import GHC.Core.Coercion hiding ( substCo, substCoVar ) @@ -33,7 +33,7 @@ import GHC.Core.FamInstEnv ( FamInstEnv, topNormaliseType_maybe ) import GHC.Core.DataCon ( DataCon, dataConWorkId, dataConRepStrictness , dataConRepArgTys, isUnboxedTupleDataCon - , StrictnessMark (..) ) + , StrictnessMark (..), dataConWrapId_maybe ) import GHC.Core.Opt.Stats ( Tick(..) ) import GHC.Core.Ppr ( pprCoreExpr ) import GHC.Core.Unfold @@ -3234,16 +3234,36 @@ The point is that we bring into the envt a binding after the outer case, and that makes (a,b) alive. At least we do unless the case binder is guaranteed dead. -Note [Case alternative occ info] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -When we are simply reconstructing a case (the common case), we always -zap the occurrence info on the binders in the alternatives. Even -if the case binder is dead, the scrutinee is usually a variable, and *that* -can bring the case-alternative binders back to life. -See Note [Add unfolding for scrutinee] +Note [DataAlt occ info] +~~~~~~~~~~~~~~~~~~~~~~~ +Our general goal is to preserve dead-ness occ-info on the field binders of a +case alternative. Why? It's generally a good idea, but one specific reason is to +support (SEQ4) of Note [seq# magic]. + +But we have to be careful: even if the field binder is not mentioned in the case +alternative and thus annotated IAmDead by OccurAnal, it might "come back to +life" in one of two ways: + + 1. If the case binder is alive, its unfolding might bring back the field + binder, as in Note [knownCon occ info]: + case blah of y { I# _ -> $wf (case y of I# v -> v) } + ==> + case blah of y { I# v -> $wf v } + 2. Even if the case binder appears to be dead, there is the scenario in + Note [Add unfolding for scrutinee], in which the fields come back to live + through the unfolding of variable scrutinee, as follows: + join j = case x of Just v -> blah v; Nothing -> ... in + case x of Just _ -> jump j; Nothing -> ... + ==> { inline j, unfold x to Just v, simplify } + join j = case x of Just v -> blah v; Nothing -> ... in + case x of Just v -> blah v; Nothing -> ... + +Thus, when we are simply reconstructing a case (the common case), and the +case binder is not dead, or the scrutinee is a variable, we zap the +occurrence info on DataAlt field binders. See `adjustFieldOccInfo`. Note [Improving seq] -~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~ Consider type family F :: * -> * type instance F Int = Int @@ -3349,7 +3369,9 @@ simplAlts env0 scrut case_bndr alts cont' -- NB: pass case_bndr::InId, not case_bndr' :: OutId, to prepareAlts -- See Note [Shadowing in prepareAlts] in GHC.Core.Opt.Simplify.Utils - ; alts' <- mapM (simplAlt alt_env' (Just scrut') imposs_deflt_cons case_bndr' cont') in_alts + ; alts' <- forM in_alts $ + simplAlt alt_env' (Just scrut') imposs_deflt_cons + case_bndr' (scrutOkForBinderSwap scrut) cont' ; let alts_ty' = contResultType cont' -- See Note [Avoiding space leaks in OutType] @@ -3375,39 +3397,43 @@ improveSeq _ env scrut _ case_bndr1 _ ------------------------------------ simplAlt :: SimplEnv - -> Maybe OutExpr -- The scrutinee - -> [AltCon] -- These constructors can't be present when - -- matching the DEFAULT alternative - -> OutId -- The case binder + -> Maybe OutExpr -- The scrutinee + -> [AltCon] -- These constructors can't be present when + -- matching the DEFAULT alternative + -> OutId -- The case binder `bndr` + -> BinderSwapDecision -- DoBinderSwap v co <==> scrut = Just (v |> co), + -- add unfolding `v :-> bndr |> sym co` -> SimplCont -> InAlt -> SimplM OutAlt -simplAlt env scrut' imposs_deflt_cons case_bndr' cont' (Alt DEFAULT bndrs rhs) +simplAlt env _scrut' imposs_deflt_cons case_bndr' bndr_swap' cont' (Alt DEFAULT bndrs rhs) = assert (null bndrs) $ - do { let env' = addDefaultUnfoldings env scrut' case_bndr' imposs_deflt_cons + do { let env' = addDefaultUnfoldings env case_bndr' bndr_swap' imposs_deflt_cons ; rhs' <- simplExprC env' rhs cont' ; return (Alt DEFAULT [] rhs') } -simplAlt env scrut' _ case_bndr' cont' (Alt (LitAlt lit) bndrs rhs) +simplAlt env _scrut' _ case_bndr' bndr_swap' cont' (Alt (LitAlt lit) bndrs rhs) = assert (null bndrs) $ - do { let env' = addAltUnfoldings env scrut' case_bndr' (Lit lit) + do { let env' = addAltUnfoldings env case_bndr' bndr_swap' (Lit lit) ; rhs' <- simplExprC env' rhs cont' ; return (Alt (LitAlt lit) [] rhs') } -simplAlt env scrut' _ case_bndr' cont' (Alt (DataAlt con) vs rhs) - = do { -- See Note [Adding evaluatedness info to pattern-bound variables] - let vs_with_evals = addEvals scrut' con vs - ; (env', vs') <- simplBinders env vs_with_evals +simplAlt env scrut' _ case_bndr' bndr_swap' cont' (Alt (DataAlt con) vs rhs) + = do { + ; (env', vs') <- simplBinders env vs + -- See Note [Adding evaluatedness info to pattern-bound variables] + -- and Note [DataAlt occ info] + ; let vs_with_info' = adjustFieldsIdInfo scrut' case_bndr' bndr_swap' con vs' -- Bind the case-binder to (con args) ; let inst_tys' = tyConAppArgs (idType case_bndr') con_app :: OutExpr - con_app = mkConApp2 con inst_tys' vs' - env'' = addAltUnfoldings env' scrut' case_bndr' con_app + con_app = mkConApp2 con inst_tys' vs_with_info' + env'' = addAltUnfoldings env' case_bndr' bndr_swap' con_app ; rhs' <- simplExprC env'' rhs cont' - ; return (Alt (DataAlt con) vs' rhs') } + ; return (Alt (DataAlt con) vs_with_info' rhs') } {- Note [Adding evaluatedness info to pattern-bound variables] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -3438,9 +3464,10 @@ do it here). The right thing is to do some kind of binder-swap; see #15226 for discussion. -} -addEvals :: Maybe OutExpr -> DataCon -> [Id] -> [Id] +adjustFieldsIdInfo :: Maybe OutExpr -> OutId -> BinderSwapDecision -> DataCon -> [Id] -> [Id] -- See Note [Adding evaluatedness info to pattern-bound variables] -addEvals scrut con vs +-- and Note [DataAlt occ info] +adjustFieldsIdInfo scrut case_bndr bndr_swap con vs -- Deal with seq# applications | Just scr <- scrut , isUnboxedTupleDataCon con @@ -3449,59 +3476,73 @@ addEvals scrut con vs -- a list of arguments only to throw it away immediately. , Just (Var f) <- stripNArgs 4 scr , f `hasKey` seqHashKey - , let x' = zapIdOccInfoAndSetEvald MarkedStrict x - = [s, x'] + , let x' = setCaseBndrEvald MarkedStrict x + = map (adjustFieldOccInfo case_bndr bndr_swap) [s, x'] -- Deal with banged datacon fields -addEvals _scrut con vs = go vs the_strs - where - the_strs = dataConRepStrictness con - - go [] [] = [] - go (v:vs') strs | isTyVar v = v : go vs' strs - go (v:vs') (str:strs) = zapIdOccInfoAndSetEvald str v : go vs' strs - go _ _ = pprPanic "Simplify.addEvals" - (ppr con $$ - ppr vs $$ - ppr_with_length (map strdisp the_strs) $$ - ppr_with_length (dataConRepArgTys con) $$ - ppr_with_length (dataConRepStrictness con)) - where - ppr_with_length list - = ppr list <+> parens (text "length =" <+> ppr (length list)) - strdisp :: StrictnessMark -> SDoc - strdisp MarkedStrict = text "MarkedStrict" - strdisp NotMarkedStrict = text "NotMarkedStrict" - -zapIdOccInfoAndSetEvald :: StrictnessMark -> Id -> Id -zapIdOccInfoAndSetEvald str v = - setCaseBndrEvald str $ -- Add eval'dness info - zapIdOccInfo v -- And kill occ info; - -- see Note [Case alternative occ info] - -addDefaultUnfoldings :: SimplEnv -> Maybe OutExpr -> OutId -> [AltCon] -> SimplEnv -addDefaultUnfoldings env mb_scrut case_bndr imposs_deflt_cons + -- This case is quite allocation sensitive to T9233 which has a large record + -- with strict fields. Hence we try not to update vs twice! +adjustFieldsIdInfo _scrut case_bndr bndr_swap con vs + | Nothing <- dataConWrapId_maybe con + -- a common fast path; no need to allocate the_strs when they are all lazy anyway! + = map (adjustFieldOccInfo case_bndr bndr_swap) vs + | otherwise + = go vs the_strs + where + the_strs = dataConRepStrictness con + + go [] [] = [] + go (v:vs') strs | isTyVar v = v : go vs' strs + go (v:vs') (str:strs) = adjustFieldOccInfo case_bndr bndr_swap (setCaseBndrEvald str v) : go vs' strs + go _ _ = pprPanic "Simplify.adjustFieldsIdInfo" + (ppr con $$ + ppr vs $$ + ppr_with_length (map strdisp the_strs) $$ + ppr_with_length (dataConRepArgTys con) $$ + ppr_with_length (dataConRepStrictness con)) + where + ppr_with_length list + = ppr list <+> parens (text "length =" <+> ppr (length list)) + strdisp :: StrictnessMark -> SDoc + strdisp MarkedStrict = text "MarkedStrict" + strdisp NotMarkedStrict = text "NotMarkedStrict" + +adjustFieldOccInfo :: OutId -> BinderSwapDecision -> CoreBndr -> CoreBndr +-- Kill occ info if we do binder swap and the case binder is alive; +-- see Note [DataAlt occ info] +adjustFieldOccInfo case_bndr bndr_swap field_bndr + | not (isDeadBinder case_bndr) -- (1) in the Note: If the case binder is alive, + = zapped_field_bndr -- the field binders might come back alive + + | DoBinderSwap{} <- bndr_swap -- (2) in the Note: If binder swap might take place, + = zapped_field_bndr -- the case binder might come back alive + + | otherwise + = field_bndr -- otherwise the field binders stay dead + where + zapped_field_bndr = if isTyVar field_bndr then field_bndr else zapIdOccInfo field_bndr + +addDefaultUnfoldings :: SimplEnv -> OutId -> BinderSwapDecision -> [AltCon] -> SimplEnv +addDefaultUnfoldings env case_bndr bndr_swap imposs_deflt_cons = env2 where unf = mkOtherCon imposs_deflt_cons -- Record the constructors that the case-binder *can't* be. env1 = addBinderUnfolding env case_bndr unf - env2 | Just scrut <- mb_scrut - , Just (v,_mco) <- scrutBinderSwap_maybe scrut + env2 | DoBinderSwap v _mco <- bndr_swap = addBinderUnfolding env1 v unf | otherwise = env1 -addAltUnfoldings :: SimplEnv -> Maybe OutExpr -> OutId -> OutExpr -> SimplEnv -addAltUnfoldings env mb_scrut case_bndr con_app +addAltUnfoldings :: SimplEnv -> OutId -> BinderSwapDecision -> OutExpr -> SimplEnv +addAltUnfoldings env case_bndr bndr_swap con_app = env2 where con_app_unf = mk_simple_unf con_app env1 = addBinderUnfolding env case_bndr con_app_unf -- See Note [Add unfolding for scrutinee] - env2 | Just scrut <- mb_scrut - , Just (v,mco) <- scrutBinderSwap_maybe scrut + env2 | DoBinderSwap v mco <- bndr_swap = addBinderUnfolding env1 v $ if isReflMCo mco -- isReflMCo: avoid calling mk_simple_unf then con_app_unf -- twice in the common case @@ -3580,7 +3621,7 @@ So instead we add the unfolding x -> Just a, and x -> Nothing in the respective RHSs. Since this transformation is tantamount to a binder swap, we use -GHC.Core.Opt.OccurAnal.scrutBinderSwap_maybe to do the check. +GHC.Core.Opt.OccurAnal.scrutOkForBinderSwap to do the check. Exactly the same issue arises in GHC.Core.Opt.SpecConstr; see Note [Add scrutinee to ValueEnv too] in GHC.Core.Opt.SpecConstr @@ -3884,8 +3925,9 @@ mkDupableContWithDmds env _ ; let cont_scaling = contHoleScaling cont -- See Note [Scaling in case-of-case] ; (alt_env', case_bndr') <- simplBinder alt_env (scaleIdBy cont_scaling case_bndr) - ; alts' <- mapM (simplAlt alt_env' Nothing [] case_bndr' alt_cont) (scaleAltsBy cont_scaling alts) - -- Safe to say that there are no handled-cons for the DEFAULT case + ; alts' <- forM (scaleAltsBy cont_scaling alts) $ + simplAlt alt_env' Nothing [] case_bndr' NoBinderSwap alt_cont + -- Safe to say that there are no handled-cons for the DEFAULT case -- NB: simplBinder does not zap deadness occ-info, so -- a dead case_bndr' will still advertise its deadness -- This is really important because in ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -36,7 +36,7 @@ import GHC.Core.Opt.Simplify.Inline import GHC.Core.FVs ( exprsFreeVarsList, exprFreeVars ) import GHC.Core.Opt.Monad import GHC.Core.Opt.WorkWrap.Utils -import GHC.Core.Opt.OccurAnal( scrutBinderSwap_maybe ) +import GHC.Core.Opt.OccurAnal( BinderSwapDecision(..), scrutOkForBinderSwap ) import GHC.Core.DataCon import GHC.Core.Class( classTyVars ) import GHC.Core.Coercion hiding( substCo ) @@ -1104,7 +1104,7 @@ extendCaseBndrs env scrut case_bndr con alt_bndrs = (env2, alt_bndrs') where live_case_bndr = not (isDeadBinder case_bndr) - env1 | Just (v, mco) <- scrutBinderSwap_maybe scrut + env1 | DoBinderSwap v mco <- scrutOkForBinderSwap scrut , isReflMCo mco = extendValEnv env v cval | otherwise = env -- See Note [Add scrutinee to ValueEnv too] env2 | live_case_bndr = extendValEnv env1 case_bndr cval @@ -1198,7 +1198,7 @@ though the simplifier has systematically replaced uses of 'x' with 'y' and 'b' with 'c' in the code. The use of 'b' in the ValueEnv came from outside the case. See #4908 for the live example. -It's very like the binder-swap story, so we use scrutBinderSwap_maybe +It's very like the binder-swap story, so we use scrutOkForBinderSwap to identify suitable scrutinees -- but only if there is no cast (isReflMCo) because that's all that the ValueEnv allows. ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -890,6 +890,29 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con [covar] _]) floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } +cpeRhsE env (Case scrut bndr _ [Alt (DataAlt dc) [token_out, res] rhs]) + -- See item (SEQ4) of Note [seq# magic]. We want to match + -- case seq# @a @RealWorld s of (# s', _ #) -> rhs[s'] + -- and simplify to rhs[s]. Triggers in T15226. + | isUnboxedTupleDataCon dc + , (Var f,[_ty1, _ty2, arg, Var token_in]) <- collectArgs scrut + , f `hasKey` seqHashKey + , exprOkToDiscard arg + -- ok-to-discard, because we want to discard the evaluation of `arg`. + -- ok-to-discard includes ok-for-spec, but *also* CanFail primops such as + -- `quotInt# 1# 0#`, but not ThrowsException primops. + -- See Note [Classifying primop effects] + -- and Note [Transformations affected by primop effects] for why this is + -- the correct choice. + , Var token_in' <- lookupCorePrepEnv env token_in + , isDeadBinder res, isDeadBinder bndr + -- Check that bndr and res are dead + -- We can rely on `isDeadBinder res`, despite the fact that the Simplifier + -- often zaps the OccInfo on case-alternative binders (see Note [DataAlt occ info] + -- in GHC.Core.Opt.Simplify.Iteration) because the scrutinee is not a + -- variable, and in that case the zapping doesn't happen; see that Note. + = cpeRhsE (extendCorePrepEnv env token_out token_in') rhs + cpeRhsE env (Case scrut bndr ty alts) = do { (floats, scrut') <- cpeBody env scrut ; (env', bndr2) <- cpCloneBndr env bndr ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -2295,9 +2295,16 @@ Things to note also we can attach an evaldUnfolding to x' to discard any subsequent evals such as the `case x' of __DEFAULT`. +(SEQ4) + T15226 demonstrates that we want to discard ok-for-discard seq#s. That is, + simplify `case seq# s of (# s', _ #) -> rhs[s']` to `rhs[s]`. + You might wonder whether the Simplifier could do this. But see the excellent + example in #24334 (immortalised as test T24334) for why it should be done in + CorePrep. + Implementing seq#. The compiler has magic for `seq#` in -- GHC.Core.Opt.ConstantFold.seqRule: eliminate (seq# s) +- GHC.CoreToStg.Prep.cpeRhsE: Implement (SEQ4). - Simplify.addEvals records evaluated-ness for the result (cf. (SEQ3)); see Note [Adding evaluatedness info to pattern-bound variables] ===================================== testsuite/tests/codeGen/should_compile/T24264.hs ===================================== @@ -24,12 +24,8 @@ fun3 :: a -> IO a {-# OPAQUE fun3 #-} fun3 x = do pure () - -- "evaluate $! x" - case x of !x' -> IO (noinline seq# x') - -- noinline to work around the bogus seqRule - -- This ideally also should not push a continuation to the stack - -- before entering 'x'. It currently does, but let's wait for - -- !11515 to land before worrying about that. + evaluate $! x + -- This should not push a continuation to the stack before entering 'x' funPair :: a -> IO (a, a) {-# OPAQUE funPair #-} ===================================== testsuite/tests/core-to-stg/T24334.hs ===================================== @@ -0,0 +1,20 @@ +import Control.Exception +import Data.IORef + +strictPrint :: Show a => a -> IO () +{-# OPAQUE strictPrint #-} +strictPrint x = print $! x + +f :: Show a => a -> IORef a -> IO () +{-# OPAQUE f #-} +f x r = do + x' <- evaluate $! x + writeIORef r x' + strictPrint x' + +main :: IO () +main = do + r <- newIORef (42 :: Int) + f (error "foo") r `catch` \(e :: SomeException) -> return () + n <- readIORef r + print n ===================================== testsuite/tests/core-to-stg/T24334.stdout ===================================== @@ -0,0 +1 @@ +42 ===================================== testsuite/tests/core-to-stg/all.T ===================================== @@ -5,4 +5,5 @@ test('T23270', [grep_errmsg(r'patError')], compile, ['-O0 -dsuppress-uniques -dd test('T23914', normal, compile, ['-O']) test('T14895', normal, compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-uniques']) test('T24124', normal, compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-uniques']) +test('T24334', normal, compile_and_run, ['-O']) test('T24463', normal, compile, ['-O']) ===================================== testsuite/tests/simplCore/should_compile/T21851.stderr ===================================== @@ -10,8 +10,12 @@ g' :: Int -> Int [GblId, Arity=1, Str=, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 30 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [0] 30 0}] g' - = \ (x :: Int) -> case T21851a.$w$sf x of { (# ww, ww1 #) -> ww } + = \ (x :: Int) -> + case T21851a.$w$sf x of { (# ww, _ [Occ=Dead] #) -> ww } + + ===================================== testsuite/tests/simplCore/should_compile/T24770.hs ===================================== @@ -0,0 +1,3 @@ +module T24770 where + +foo = getLine >> getLine ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -516,3 +516,4 @@ test('T24370', normal, compile, ['-O']) test('T24551', normal, compile, ['-O -dcore-lint']) test('T24726', normal, compile, ['-dcore-lint -dsuppress-uniques']) test('T24768', normal, compile, ['-O']) +test('T24770', [ grep_errmsg(r'Dead') ], compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/350ea87e742c351a63672adf421acc57cf8e0b88...214ab72dddb9a839448d61156f5f072717b778a5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/350ea87e742c351a63672adf421acc57cf8e0b88...214ab72dddb9a839448d61156f5f072717b778a5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 12:52:16 2024 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 07 May 2024 08:52:16 -0400 Subject: [Git][ghc/ghc][wip/andreask/expose-overloaded-unfoldings] 56 commits: Refactor the Binary serialisation interface Message-ID: <663a240013812_3f17731ba6da483054@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/expose-overloaded-unfoldings at Glasgow Haskell Compiler / GHC Commits: fa03b1fb by Fendor at 2024-04-26T18:03:13-04:00 Refactor the Binary serialisation interface The goal is simplifiy adding deduplication tables to `ModIface` interface serialisation. We identify two main points of interest that make this difficult: 1. UserData hardcodes what `Binary` instances can have deduplication tables. Moreover, it heavily uses partial functions. 2. GHC.Iface.Binary hardcodes the deduplication tables for 'Name' and 'FastString', making it difficult to add more deduplication. Instead of having a single `UserData` record with fields for all the types that can have deduplication tables, we allow to provide custom serialisers for any `Typeable`. These are wrapped in existentials and stored in a `Map` indexed by their respective `TypeRep`. The `Binary` instance of the type to deduplicate still needs to explicitly look up the decoder via `findUserDataReader` and `findUserDataWriter`, which is no worse than the status-quo. `Map` was chosen as microbenchmarks indicate it is the fastest for a small number of keys (< 10). To generalise the deduplication table serialisation mechanism, we introduce the types `ReaderTable` and `WriterTable` which provide a simple interface that is sufficient to implement a general purpose deduplication mechanism for `writeBinIface` and `readBinIface`. This allows us to provide a list of deduplication tables for serialisation that can be extended more easily, for example for `IfaceTyCon`, see the issue https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for more motivation. In addition to this refactoring, we split `UserData` into `ReaderUserData` and `WriterUserData`, to avoid partial functions and reduce overall memory usage, as we need fewer mutable variables. Bump haddock submodule to accomodate for `UserData` split. ------------------------- Metric Increase: MultiLayerModulesTH_Make MultiLayerModulesRecomp T21839c ------------------------- - - - - - bac57298 by Fendor at 2024-04-26T18:03:13-04:00 Split `BinHandle` into `ReadBinHandle` and `WriteBinHandle` A `BinHandle` contains too much information for reading data. For example, it needs to keep a `FastMutInt` and a `IORef BinData`, when the non-mutable variants would suffice. Additionally, this change has the benefit that anyone can immediately tell whether the `BinHandle` is used for reading or writing. Bump haddock submodule BinHandle split. - - - - - 4d6394dd by Simon Peyton Jones at 2024-04-26T18:03:49-04:00 Fix missing escaping-kind check in tcPatSynSig Note [Escaping kind in type signatures] explains how we deal with escaping kinds in type signatures, e.g. f :: forall r (a :: TYPE r). a where the kind of the body is (TYPE r), but `r` is not in scope outside the forall-type. I had missed this subtlety in tcPatSynSig, leading to #24686. This MR fixes it; and a similar bug in tc_top_lhs_type. (The latter is tested by T24686a.) - - - - - 981c2c2c by Alan Zimmerman at 2024-04-26T18:04:25-04:00 EPA: check-exact: check that the roundtrip reproduces the source Closes #24670 - - - - - a8616747 by Andrew Lelechenko at 2024-04-26T18:05:01-04:00 Document that setEnv is not thread-safe - - - - - 1e41de83 by Bryan Richter at 2024-04-26T18:05:37-04:00 CI: Work around frequent Signal 9 errors - - - - - a6d5f9da by Naïm Favier at 2024-04-27T17:52:40-04:00 ghc-internal: add MonadFix instance for (,) Closes https://gitlab.haskell.org/ghc/ghc/-/issues/24288, implements CLC proposal https://github.com/haskell/core-libraries-committee/issues/238. Adds a MonadFix instance for tuples, permitting value recursion in the "native" writer monad and bringing consistency with the existing instance for transformers's WriterT (and, to a lesser extent, for Solo). - - - - - 64feadcd by Rodrigo Mesquita at 2024-04-27T17:53:16-04:00 bindist: Fix xattr cleaning The original fix (725343aa) was incorrect because it used the shell bracket syntax which is the quoting syntax in autoconf, making the test for existence be incorrect and therefore `xattr` was never run. Fixes #24554 - - - - - e2094df3 by damhiya at 2024-04-28T23:52:00+09:00 Make read accepts binary integer formats CLC proposal : https://github.com/haskell/core-libraries-committee/issues/177 - - - - - 1c2fd963 by Alan Zimmerman at 2024-04-29T23:17:00-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 - - - - - 4189d17e by Sylvain Henry at 2024-04-29T23:17:42-04:00 LLVM: better unreachable default destination in Switch (#24717) See added note. Co-authored-by: Siddharth Bhat <siddu.druid at gmail.com> - - - - - a3725c88 by Cheng Shao at 2024-04-29T23:18:20-04:00 ci: enable wasm jobs for MRs with wasm label This patch enables wasm jobs for MRs with wasm label. Previously the wasm label didn't actually have any effect on the CI pipeline, and full-ci needed to be applied to run wasm jobs which was a waste of runners when working on the wasm backend, hence the fix here. - - - - - 702f7964 by Matthew Pickering at 2024-04-29T23:18:56-04:00 Make interface files and object files depend on inplace .conf file A potential fix for #24737 - - - - - 728af21e by Cheng Shao at 2024-04-30T05:30:23-04:00 utils: remove obsolete vagrant scripts Vagrantfile has long been removed in !5288. This commit further removes the obsolete vagrant scripts in the tree. - - - - - 36f2c342 by Cheng Shao at 2024-04-30T05:31:00-04:00 Update autoconf scripts Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 - - - - - ecbf22a6 by Ben Gamari at 2024-04-30T05:31:36-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 7eab4e01 by Alan Zimmerman at 2024-05-04T16:14:55+01:00 EPA: Widen stmtslist to include last semicolon Closes #24754 - - - - - 06f7db40 by Teo Camarasu at 2024-05-05T00:19:38-04:00 doc: Fix type error in hs_try_putmvar example - - - - - af000532 by Moritz Schuler at 2024-05-05T06:30:58-04:00 Fix parsing of module names in CLI arguments closes issue #24732 - - - - - da74e9c9 by Ben Gamari at 2024-05-05T06:31:34-04:00 ghc-platform: Add Setup.hs The Hadrian bootstrapping script relies upon `Setup.hs` to drive its build. Addresses #24761. - - - - - 35d34fde by Alan Zimmerman at 2024-05-05T12:52:40-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 - - - - - 03c5dfbf by Simon Peyton Jones at 2024-05-05T12:53:15-04:00 Fix a float-out error Ticket #24768 showed that the Simplifier was accidentally destroying a join point. It turned out to be that we were sending a bottoming join point to the top, accidentally abstracting over /other/ join points. Easily fixed. - - - - - adba68e7 by John Ericson at 2024-05-05T19:35:56-04:00 Substitute bindist files with Hadrian not configure The `ghc-toolchain` overhaul will eventually replace all this stuff with something much more cleaned up, but I think it is still worth making this sort of cleanup in the meantime so other untanglings and dead code cleaning can procede. I was able to delete a fair amount of dead code doing this too. `LLVMTarget_CPP` is renamed to / merged with `LLVMTarget` because it wasn't actually turned into a valid CPP identifier. (Original to 1345c7cc42c45e63ab1726a8fd24a7e4d4222467, actually.) Progress on #23966 Co-Authored-By: Sylvain Henry <hsyl20 at gmail.com> - - - - - 18f4ff84 by Alan Zimmerman at 2024-05-05T19:36:32-04:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 - - - - - a19201d4 by Matthew Craven at 2024-05-06T19:54:29-04:00 Add test cases for #24664 ...since none are present in the original MR !12463 fixing this issue. - - - - - 46328a49 by Alan Zimmerman at 2024-05-06T19:55:05-04:00 EPA: preserve comments in data decls Closes #24771 - - - - - 9d19b87a by Andreas Klebinger at 2024-05-07T14:36:15+02:00 Tidy: Add flag to expose unfoldings if they take dictionary arguments. Add the flag `-fexpose-overloaded-unfoldings` to be able to control this behaviour. For ghc's boot libraries file size grew by less than 1% when it was enabled. However I refrained from enabling it by default for now. I've also added a section on specialization more broadly to the users guide. ------------------------- Metric Decrease: MultiLayerModulesTH_OneShot Metric Increase: T12425 T13386 hard_hole_fits ------------------------- - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - compiler/GHC.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Driver/Config/Tidy.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline/Execute.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/26b7ddaeea1aae5950bd8979e2cfe6a5c69b9d06...9d19b87a111fecad87cef8ee89eb7ebc9ca4a0fa -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/26b7ddaeea1aae5950bd8979e2cfe6a5c69b9d06...9d19b87a111fecad87cef8ee89eb7ebc9ca4a0fa You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 12:57:51 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Tue, 07 May 2024 08:57:51 -0400 Subject: [Git][ghc/ghc][wip/T24477] 84 commits: Put the newline after errors instead of before them Message-ID: <663a254f78c74_3f17731d54188838fc@gitlab.mail> Jade pushed to branch wip/T24477 at Glasgow Haskell Compiler / GHC Commits: 275e41a9 by Jade at 2024-04-20T11:10:40-04:00 Put the newline after errors instead of before them This mainly has consequences for GHCi but also slightly alters how the output of GHC on the commandline looks. Fixes: #22499 - - - - - dd339c7a by Teo Camarasu at 2024-04-20T11:11:16-04:00 Remove unecessary stage0 packages Historically quite a few packages had to be stage0 as they depended on `template-haskell` and that was stage0. In #23536 we made it so that was no longer the case. This allows us to remove a bunch of packages from this list. A few still remain. A new version of `Win32` is required by `semaphore-compat`. Including `Win32` in the stage0 set requires also including `filepath` because otherwise Hadrian's dependency logic gets confused. Once our boot compiler has a newer version of `Win32` all of these will be able to be dropped. Resolves #24652 - - - - - 2f8e3a25 by Alan Zimmerman at 2024-04-20T11:11:52-04:00 EPA: Avoid duplicated comments in splice decls Contributes to #24669 - - - - - c70b9ddb by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fix typos and namings (fixes #24602) You may noted that I've also changed term of ``` , global "h$vt_double" ||= toJExpr IntV ``` See "IntV" and ``` WaitReadOp -> \[] [fd] -> pure $ PRPrimCall $ returnS (app "h$waidRead" [fd]) ``` See "h$waidRead" - - - - - 3db54f9b by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: trivial checks for variable presence (fixes #24602) - - - - - 777f108f by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fs module imported twice (by emscripten and by ghc-internal). ghc-internal import wrapped in a closure to prevent conflict with emscripten (fixes #24602) Better solution is to use some JavaScript module system like AMD, CommonJS or even UMD. It will be investigated at other issues. At first glance we should try UMD (See https://github.com/umdjs/umd) - - - - - a45a5712 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: thread.js requires h$fds and h$fdReady to be declared for static code analysis, minimal code copied from GHCJS (fixes #24602) I've just copied some old pieces of GHCJS from publicly available sources (See https://github.com/Taneb/shims/blob/a6dd0202dcdb86ad63201495b8b5d9763483eb35/src/io.js#L607). Also I didn't put details to h$fds. I took minimal and left only its object initialization: `var h$fds = {};` - - - - - ad90bf12 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: heap and stack overflows reporting defined as js hard failure (fixes #24602) These errors were treated as a hard failure for browser application. The fix is trivial: just throw error. - - - - - 5962fa52 by Serge S. Gulin at 2024-04-21T16:33:44+03:00 JS: Stubs for code without actual implementation detected by Google Closure Compiler (fixes #24602) These errors were fixed just by introducing stubbed functions with throw for further implementation. - - - - - a0694298 by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add externs to linker (fixes #24602) After enabling jsdoc and built-in google closure compiler types I was needed to deal with the following: 1. Define NodeJS-environment types. I've just copied minimal set of externs from semi-official repo (see https://github.com/externs/nodejs/blob/6c6882c73efcdceecf42e7ba11f1e3e5c9c041f0/v8/nodejs.js#L8). 2. Define Emscripten-environment types: `HEAP8`. Emscripten already provides some externs in our code but it supposed to be run in some module system. And its definitions do not work well in plain bundle. 3. We have some functions which purpose is to add to functions some contextual information via function properties. These functions should be marked as `modifies` to let google closure compiler remove calls if these functions are not used actually by call graph. Such functions are: `h$o`, `h$sti`, `h$init_closure`, `h$setObjInfo`. 4. STG primitives such as registries and stuff from `GHC.StgToJS`. `dXX` properties were already present at externs generator function but they are started from `7`, not from `1`. This message is related: `// fixme does closure compiler bite us here?` - - - - - e58bb29f by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: added both tests: for size and for correctness (fixes #24602) By some reason MacOS builds add to stderr messages like: Ignoring unexpected archive entry: __.SYMDEF ... However I left stderr to `/dev/null` for compatibility with linux CI builds. - - - - - 909f3a9c by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Disable js linker warning for empty symbol table to make js tests running consistent across environments - - - - - 83eb10da by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add special preprocessor for js files due of needing to keep jsdoc comments (fixes #24602) Our js files have defined google closure compiler types at jsdoc entries but these jsdoc entries are removed by cpp preprocessor. I considered that reusing them in javascript-backend would be a nice thing. Right now haskell processor uses `-traditional` option to deal with comments and `//` operators. But now there are following compiler options: `-C` and `-CC`. You can read about them at GCC (see https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#index-CC) and CLang (see https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-CC). It seems that `-CC` works better for javascript jsdoc than `-traditional`. At least it leaves `/* ... */` comments w/o changes. - - - - - e1cf8dc2 by brandon s allbery kf8nh at 2024-04-22T03:48:26-04:00 fix link in CODEOWNERS It seems that our local Gitlab no longer has documentation for the `CODEOWNERS` file, but the master documentation still does. Use that instead. - - - - - 593f4e04 by Fendor at 2024-04-23T10:19:14-04:00 Add performance regression test for '-fwrite-simplified-core' - - - - - 1ba39b05 by Fendor at 2024-04-23T10:19:14-04:00 Typecheck corebindings lazily during bytecode generation This delays typechecking the corebindings until the bytecode generation happens. We also avoid allocating a thunk that is retained by `unsafeInterleaveIO`. In general, we shouldn't retain values of the hydrated `Type`, as not evaluating the bytecode object keeps it alive. It is better if we retain the unhydrated `IfaceType`. See Note [Hydrating Modules] - - - - - e916fc92 by Alan Zimmerman at 2024-04-23T10:19:50-04:00 EPA: Keep comments in a CaseAlt match The comments now live in the surrounding location, not inside the Match. Make sure we keep them. Closes #24707 - - - - - d2b17f32 by Cheng Shao at 2024-04-23T15:01:22-04:00 driver: force merge objects when building dynamic objects This patch forces the driver to always merge objects when building dynamic objects even when ar -L is supported. It is an oversight of !8887: original rationale of that patch is favoring the relatively cheap ar -L operation over object merging when ar -L is supported, which makes sense but only if we are building static objects! Omitting check for whether we are building dynamic objects will result in broken .so files with undefined reference errors at executable link time when building GHC with llvm-ar. Fixes #22210. - - - - - 209d09f5 by Julian Ospald at 2024-04-23T15:02:03-04:00 Allow non-absolute values for bootstrap GHC variable Fixes #24682 - - - - - 3fff0977 by Matthew Pickering at 2024-04-23T15:02:38-04:00 Don't depend on registerPackage function in Cabal More recent versions of Cabal modify the behaviour of libAbiHash which breaks our usage of registerPackage. It is simpler to inline the part of registerPackage that we need and avoid any additional dependency and complication using the higher-level function introduces. - - - - - c62dc317 by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: remove obsolete ln script This commit removes an obsolete ln script in ghc-bignum/gmp. See 060251c24ad160264ae8553efecbb8bed2f06360 for its original intention, but it's been obsolete for a long time, especially since the removal of the make build system. Hence the house cleaning. - - - - - 6399d52b by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: update gmp to 6.3.0 This patch bumps the gmp-tarballs submodule and updates gmp to 6.3.0. The tarball format is now xz, and gmpsrc.patch has been patched into the tarball so hadrian no longer needs to deal with patching logic when building in-tree GMP. - - - - - 65b4b92f by Cheng Shao at 2024-04-25T01:32:02-04:00 hadrian: remove obsolete Patch logic This commit removes obsolete Patch logic from hadrian, given we no longer need to patch the gmp tarball when building in-tree GMP. - - - - - 71f28958 by Cheng Shao at 2024-04-25T01:32:02-04:00 autoconf: remove obsolete patch detection This commit removes obsolete deletection logic of the patch command from autoconf scripts, given we no longer need to patch anything in the GHC build process. - - - - - daeda834 by Sylvain Henry at 2024-04-25T01:32:43-04:00 JS: correctly handle RUBBISH literals (#24664) - - - - - 8a06ddf6 by Matthew Pickering at 2024-04-25T11:16:16-04:00 Linearise ghc-internal and base build This is achieved by requesting the final package database for ghc-internal, which mandates it is fully built as a dependency of configuring the `base` package. This is at the expense of cross-package parrallelism between ghc-internal and the base package. Fixes #24436 - - - - - 94da9365 by Andrei Borzenkov at 2024-04-25T11:16:54-04:00 Fix tuple puns renaming (24702) Move tuple renaming short cutter from `isBuiltInOcc_maybe` to `isPunOcc_maybe`, so we consider incoming module. I also fixed some hidden bugs that raised after the change was done. - - - - - fa03b1fb by Fendor at 2024-04-26T18:03:13-04:00 Refactor the Binary serialisation interface The goal is simplifiy adding deduplication tables to `ModIface` interface serialisation. We identify two main points of interest that make this difficult: 1. UserData hardcodes what `Binary` instances can have deduplication tables. Moreover, it heavily uses partial functions. 2. GHC.Iface.Binary hardcodes the deduplication tables for 'Name' and 'FastString', making it difficult to add more deduplication. Instead of having a single `UserData` record with fields for all the types that can have deduplication tables, we allow to provide custom serialisers for any `Typeable`. These are wrapped in existentials and stored in a `Map` indexed by their respective `TypeRep`. The `Binary` instance of the type to deduplicate still needs to explicitly look up the decoder via `findUserDataReader` and `findUserDataWriter`, which is no worse than the status-quo. `Map` was chosen as microbenchmarks indicate it is the fastest for a small number of keys (< 10). To generalise the deduplication table serialisation mechanism, we introduce the types `ReaderTable` and `WriterTable` which provide a simple interface that is sufficient to implement a general purpose deduplication mechanism for `writeBinIface` and `readBinIface`. This allows us to provide a list of deduplication tables for serialisation that can be extended more easily, for example for `IfaceTyCon`, see the issue https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for more motivation. In addition to this refactoring, we split `UserData` into `ReaderUserData` and `WriterUserData`, to avoid partial functions and reduce overall memory usage, as we need fewer mutable variables. Bump haddock submodule to accomodate for `UserData` split. ------------------------- Metric Increase: MultiLayerModulesTH_Make MultiLayerModulesRecomp T21839c ------------------------- - - - - - bac57298 by Fendor at 2024-04-26T18:03:13-04:00 Split `BinHandle` into `ReadBinHandle` and `WriteBinHandle` A `BinHandle` contains too much information for reading data. For example, it needs to keep a `FastMutInt` and a `IORef BinData`, when the non-mutable variants would suffice. Additionally, this change has the benefit that anyone can immediately tell whether the `BinHandle` is used for reading or writing. Bump haddock submodule BinHandle split. - - - - - 4d6394dd by Simon Peyton Jones at 2024-04-26T18:03:49-04:00 Fix missing escaping-kind check in tcPatSynSig Note [Escaping kind in type signatures] explains how we deal with escaping kinds in type signatures, e.g. f :: forall r (a :: TYPE r). a where the kind of the body is (TYPE r), but `r` is not in scope outside the forall-type. I had missed this subtlety in tcPatSynSig, leading to #24686. This MR fixes it; and a similar bug in tc_top_lhs_type. (The latter is tested by T24686a.) - - - - - 981c2c2c by Alan Zimmerman at 2024-04-26T18:04:25-04:00 EPA: check-exact: check that the roundtrip reproduces the source Closes #24670 - - - - - a8616747 by Andrew Lelechenko at 2024-04-26T18:05:01-04:00 Document that setEnv is not thread-safe - - - - - 1e41de83 by Bryan Richter at 2024-04-26T18:05:37-04:00 CI: Work around frequent Signal 9 errors - - - - - a6d5f9da by Naïm Favier at 2024-04-27T17:52:40-04:00 ghc-internal: add MonadFix instance for (,) Closes https://gitlab.haskell.org/ghc/ghc/-/issues/24288, implements CLC proposal https://github.com/haskell/core-libraries-committee/issues/238. Adds a MonadFix instance for tuples, permitting value recursion in the "native" writer monad and bringing consistency with the existing instance for transformers's WriterT (and, to a lesser extent, for Solo). - - - - - 64feadcd by Rodrigo Mesquita at 2024-04-27T17:53:16-04:00 bindist: Fix xattr cleaning The original fix (725343aa) was incorrect because it used the shell bracket syntax which is the quoting syntax in autoconf, making the test for existence be incorrect and therefore `xattr` was never run. Fixes #24554 - - - - - e2094df3 by damhiya at 2024-04-28T23:52:00+09:00 Make read accepts binary integer formats CLC proposal : https://github.com/haskell/core-libraries-committee/issues/177 - - - - - 1c2fd963 by Alan Zimmerman at 2024-04-29T23:17:00-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 - - - - - 4189d17e by Sylvain Henry at 2024-04-29T23:17:42-04:00 LLVM: better unreachable default destination in Switch (#24717) See added note. Co-authored-by: Siddharth Bhat <siddu.druid at gmail.com> - - - - - a3725c88 by Cheng Shao at 2024-04-29T23:18:20-04:00 ci: enable wasm jobs for MRs with wasm label This patch enables wasm jobs for MRs with wasm label. Previously the wasm label didn't actually have any effect on the CI pipeline, and full-ci needed to be applied to run wasm jobs which was a waste of runners when working on the wasm backend, hence the fix here. - - - - - 702f7964 by Matthew Pickering at 2024-04-29T23:18:56-04:00 Make interface files and object files depend on inplace .conf file A potential fix for #24737 - - - - - 728af21e by Cheng Shao at 2024-04-30T05:30:23-04:00 utils: remove obsolete vagrant scripts Vagrantfile has long been removed in !5288. This commit further removes the obsolete vagrant scripts in the tree. - - - - - 36f2c342 by Cheng Shao at 2024-04-30T05:31:00-04:00 Update autoconf scripts Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 - - - - - ecbf22a6 by Ben Gamari at 2024-04-30T05:31:36-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 7eab4e01 by Alan Zimmerman at 2024-05-04T16:14:55+01:00 EPA: Widen stmtslist to include last semicolon Closes #24754 - - - - - 06f7db40 by Teo Camarasu at 2024-05-05T00:19:38-04:00 doc: Fix type error in hs_try_putmvar example - - - - - af000532 by Moritz Schuler at 2024-05-05T06:30:58-04:00 Fix parsing of module names in CLI arguments closes issue #24732 - - - - - da74e9c9 by Ben Gamari at 2024-05-05T06:31:34-04:00 ghc-platform: Add Setup.hs The Hadrian bootstrapping script relies upon `Setup.hs` to drive its build. Addresses #24761. - - - - - 35d34fde by Alan Zimmerman at 2024-05-05T12:52:40-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 - - - - - 03c5dfbf by Simon Peyton Jones at 2024-05-05T12:53:15-04:00 Fix a float-out error Ticket #24768 showed that the Simplifier was accidentally destroying a join point. It turned out to be that we were sending a bottoming join point to the top, accidentally abstracting over /other/ join points. Easily fixed. - - - - - adba68e7 by John Ericson at 2024-05-05T19:35:56-04:00 Substitute bindist files with Hadrian not configure The `ghc-toolchain` overhaul will eventually replace all this stuff with something much more cleaned up, but I think it is still worth making this sort of cleanup in the meantime so other untanglings and dead code cleaning can procede. I was able to delete a fair amount of dead code doing this too. `LLVMTarget_CPP` is renamed to / merged with `LLVMTarget` because it wasn't actually turned into a valid CPP identifier. (Original to 1345c7cc42c45e63ab1726a8fd24a7e4d4222467, actually.) Progress on #23966 Co-Authored-By: Sylvain Henry <hsyl20 at gmail.com> - - - - - 18f4ff84 by Alan Zimmerman at 2024-05-05T19:36:32-04:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 - - - - - a19201d4 by Matthew Craven at 2024-05-06T19:54:29-04:00 Add test cases for #24664 ...since none are present in the original MR !12463 fixing this issue. - - - - - 46328a49 by Alan Zimmerman at 2024-05-06T19:55:05-04:00 EPA: preserve comments in data decls Closes #24771 - - - - - f65ff6db by Jade at 2024-05-07T14:54:53+02:00 Improve suggestions for language extensions - When suggesting Language extensions, also suggest Extensions which imply them - Suggest ExplicitForAll and GADTSyntax instead of more specific extensions - Rephrase suggestion to include the term 'Extension' - Also moves some flag specific definitions out of Session.hs into Flags.hs (#24478) Fixes: #24477 Fixes: #24448 Fixes: #10893 - - - - - f963cfcd by Jade at 2024-05-07T14:54:54+02:00 WIP - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - CODEOWNERS - compiler/GHC.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Driver/DynFlags.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f745c0b85128b84901660f3e9df12e23b28a4958...f963cfcd9f18cd4a3c42918b47851e285ae3f7b2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f745c0b85128b84901660f3e9df12e23b28a4958...f963cfcd9f18cd4a3c42918b47851e285ae3f7b2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 13:03:32 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Tue, 07 May 2024 09:03:32 -0400 Subject: [Git][ghc/ghc][wip/T24477] wip Message-ID: <663a26a41c76_3f17731e8ddc4887ca@gitlab.mail> Jade pushed to branch wip/T24477 at Glasgow Haskell Compiler / GHC Commits: 5964db25 by Jade at 2024-05-07T15:02:56+02:00 wip - - - - - 1 changed file: - compiler/GHC/Driver/Flags.hs Changes: ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -91,9 +91,11 @@ data ExtensionDeprecation | ExtensionFlagDeprecated String deriving Eq -deprecation :: ExtensionDeprecation -> Deprecation -deprecation ExtensionNotDeprecated = NotDeprecated -deprecation _ = Deprecated +deprecation :: ExtensionDeprecation -> TurnOnFlag -> Deprecation +deprecation ExtensionNotDeprecated _ = NotDeprecated +deprecation (ExtensionFlagDeprecatedCond f _) flag + | flag /= f = NotDeprecated +deprecation _ _ = Deprecated extensionDeprecation :: LangExt.Extension -> ExtensionDeprecation extensionDeprecation = \case @@ -110,9 +112,141 @@ extensionDeprecation = \case _ -> ExtensionNotDeprecated +-- JADE_TODO extensionName :: LangExt.Extension -> String -extensionName LangExt.Cpp = "CPP" -extensionName ext = show ext +extensionName = \case + LangExt.Cpp -> "CPP" + LangExt.OverlappingInstances -> "OverlappingInstances" + LangExt.UndecidableInstances -> "UndecidableInstances" + LangExt.IncoherentInstances -> "IncoherentInstances" + LangExt.UndecidableSuperClasses -> "UndecidableSuperClasses" + LangExt.MonomorphismRestriction -> "MonomorphismRestriction" + LangExt.MonoLocalBinds -> "MonoLocalBinds" + LangExt.DeepSubsumption -> "DeepSubsumption" + LangExt.RelaxedPolyRec -> "RelaxedPolyRec" -- Deprecated + LangExt.ExtendedDefaultRules -> "ExtendedDefaultRules" -- Use GHC's extended rules for defaulting + LangExt.ForeignFunctionInterface -> "ForeignFunctionInterface" + LangExt.UnliftedFFITypes -> "UnliftedFFITypes" + LangExt.InterruptibleFFI -> "InterruptibleFFI" + LangExt.CApiFFI -> "CApiFFI" + LangExt.GHCForeignImportPrim -> "GHCForeignImportPrim" + LangExt.JavaScriptFFI -> "JavaScriptFFI" + LangExt.ParallelArrays -> "ParallelArrays" -- Syntactic support for parallel arrays + LangExt.Arrows -> "Arrows" -- Arrow-notation syntax + LangExt.TemplateHaskell -> "TemplateHaskell" + LangExt.TemplateHaskellQuotes -> "TemplateHaskellQuotes" -- subset of TH supported by stage1, no splice + LangExt.QualifiedDo -> "QualifiedDo" + LangExt.QuasiQuotes -> "QuasiQuotes" + LangExt.ImplicitParams -> "ImplicitParams" + LangExt.ImplicitPrelude -> "ImplicitPrelude" + LangExt.ScopedTypeVariables -> "ScopedTypeVariables" + LangExt.AllowAmbiguousTypes -> "AllowAmbiguousTypes" + LangExt.UnboxedTuples -> "UnboxedTuples" + LangExt.UnboxedSums -> "UnboxedSums" + LangExt.UnliftedNewtypes -> "UnliftedNewtypes" + LangExt.UnliftedDatatypes -> "UnliftedDatatypes" + LangExt.BangPatterns -> "BangPatterns" + LangExt.TypeFamilies -> "TypeFamilies" + LangExt.TypeFamilyDependencies -> "TypeFamilyDependencies" + LangExt.TypeInType -> "TypeInType" -- Deprecated + LangExt.OverloadedStrings -> "OverloadedStrings" + LangExt.OverloadedLists -> "OverloadedLists" + LangExt.NumDecimals -> "NumDecimals" + LangExt.DisambiguateRecordFields -> "DisambiguateRecordFields" + LangExt.RecordWildCards -> "RecordWildCards" + LangExt.NamedFieldPuns -> "NamedFieldPuns" + LangExt.ViewPatterns -> "ViewPatterns" + LangExt.GADTs -> "GADTs" + LangExt.GADTSyntax -> "GADTSyntax" + LangExt.NPlusKPatterns -> "NPlusKPatterns" + LangExt.DoAndIfThenElse -> "DoAndIfThenElse" + LangExt.BlockArguments -> "BlockArguments" + LangExt.RebindableSyntax -> "RebindableSyntax" + LangExt.ConstraintKinds -> "ConstraintKinds" + LangExt.PolyKinds -> "PolyKinds" -- Kind polymorphism + LangExt.DataKinds -> "DataKinds" -- Datatype promotion + LangExt.TypeData -> "TypeData" -- allow @type data@ definitions + LangExt.InstanceSigs -> "InstanceSigs" + LangExt.ApplicativeDo -> "ApplicativeDo" + LangExt.LinearTypes -> "LinearTypes" + LangExt.RequiredTypeArguments -> "RequiredTypeArguments" -- Visible forall (VDQ) in types of terms + + LangExt.StandaloneDeriving -> "StandaloneDeriving" + LangExt.DeriveDataTypeable -> "DeriveDataTypeable" + LangExt.AutoDeriveTypeable -> "AutoDeriveTypeable" -- Automatic derivation of Typeable + LangExt.DeriveFunctor -> "DeriveFunctor" + LangExt.DeriveTraversable -> "DeriveTraversable" + LangExt.DeriveFoldable -> "DeriveFoldable" + LangExt.DeriveGeneric -> "DeriveGeneric" -- Allow deriving Generic/1 + LangExt.DefaultSignatures -> "DefaultSignatures" -- Allow extra signatures for defmeths + LangExt.DeriveAnyClass -> "DeriveAnyClass" -- Allow deriving any class + LangExt.DeriveLift -> "DeriveLift" -- Allow deriving Lift + LangExt.DerivingStrategies -> "DerivingStrategies" + LangExt.DerivingVia -> "DerivingVia" -- Derive through equal representation + + LangExt.TypeSynonymInstances -> "TypeSynonymInstances" + LangExt.FlexibleContexts -> "FlexibleContexts" + LangExt.FlexibleInstances -> "FlexibleInstances" + LangExt.ConstrainedClassMethods -> "ConstrainedClassMethods" + LangExt.MultiParamTypeClasses -> "MultiParamTypeClasses" + LangExt.NullaryTypeClasses -> "NullaryTypeClasses" + LangExt.FunctionalDependencies -> "FunctionalDependencies" + LangExt.UnicodeSyntax -> "UnicodeSyntax" + LangExt.ExistentialQuantification -> "ExistentialQuantification" + LangExt.MagicHash -> "MagicHash" + LangExt.EmptyDataDecls -> "EmptyDataDecls" + LangExt.KindSignatures -> "KindSignatures" + LangExt.RoleAnnotations -> "RoleAnnotations" + LangExt.ParallelListComp -> "ParallelListComp" + LangExt.TransformListComp -> "TransformListComp" + LangExt.MonadComprehensions -> "MonadComprehensions" + LangExt.GeneralizedNewtypeDeriving -> "GeneralizedNewtypeDeriving" + LangExt.RecursiveDo -> "RecursiveDo" + LangExt.PostfixOperators -> "PostfixOperators" + LangExt.TupleSections -> "TupleSections" + LangExt.PatternGuards -> "PatternGuards" + LangExt.LiberalTypeSynonyms -> "LiberalTypeSynonyms" + LangExt.RankNTypes -> "RankNTypes" + LangExt.ImpredicativeTypes -> "ImpredicativeTypes" + LangExt.TypeOperators -> "TypeOperators" + LangExt.ExplicitNamespaces -> "ExplicitNamespaces" + LangExt.PackageImports -> "PackageImports" + LangExt.ExplicitForAll -> "ExplicitForAll" + LangExt.AlternativeLayoutRule -> "AlternativeLayoutRule" + LangExt.AlternativeLayoutRuleTransitional -> "AlternativeLayoutRuleTransitional" + LangExt.DatatypeContexts -> "DatatypeContexts" + LangExt.NondecreasingIndentation -> "NondecreasingIndentation" + LangExt.RelaxedLayout -> "RelaxedLayout" + LangExt.TraditionalRecordSyntax -> "TraditionalRecordSyntax" + LangExt.LambdaCase -> "LambdaCase" + LangExt.MultiWayIf -> "MultiWayIf" + LangExt.BinaryLiterals -> "BinaryLiterals" + LangExt.NegativeLiterals -> "NegativeLiterals" + LangExt.HexFloatLiterals -> "HexFloatLiterals" + LangExt.DuplicateRecordFields -> "DuplicateRecordFields" + LangExt.OverloadedLabels -> "OverloadedLabels" + LangExt.EmptyCase -> "EmptyCase" + LangExt.PatternSynonyms -> "PatternSynonyms" + LangExt.PartialTypeSignatures -> "PartialTypeSignatures" + LangExt.NamedWildCards -> "NamedWildCards" + LangExt.StaticPointers -> "StaticPointers" + LangExt.TypeApplications -> "TypeApplications" + LangExt.Strict -> "Strict" + LangExt.StrictData -> "StrictData" + LangExt.EmptyDataDeriving -> "EmptyDataDeriving" + LangExt.NumericUnderscores -> "NumericUnderscores" + LangExt.QuantifiedConstraints -> "QuantifiedConstraints" + LangExt.StarIsType -> "StarIsType" + LangExt.ImportQualifiedPost -> "ImportQualifiedPost" + LangExt.CUSKs -> "CUSKs" + LangExt.StandaloneKindSignatures -> "StandaloneKindSignatures" + LangExt.LexicalNegation -> "LexicalNegation" + LangExt.FieldSelectors -> "FieldSelectors" + LangExt.OverloadedRecordDot -> "OverloadedRecordDot" + LangExt.OverloadedRecordUpdate -> "OverloadedRecordUpdate" + LangExt.TypeAbstractions -> "TypeAbstractions" + LangExt.ExtendedLiterals -> "ExtendedLiterals" + LangExt.ListTuplePuns -> "ListTuplePuns" -- | Is this extension known by any other names? For example -- -XGeneralizedNewtypeDeriving is accepted View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5964db258e6526aa9086201ea9a93fd16046ff40 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5964db258e6526aa9086201ea9a93fd16046ff40 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 13:08:22 2024 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Tue, 07 May 2024 09:08:22 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/ghc-heap-typo Message-ID: <663a27c61e399_3f1773202db709251@gitlab.mail> Cheng Shao pushed new branch wip/ghc-heap-typo at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ghc-heap-typo You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 13:28:04 2024 From: gitlab at gitlab.haskell.org (Serge S. Gulin (@gulin.serge)) Date: Tue, 07 May 2024 09:28:04 -0400 Subject: [Git][ghc/ghc][wip/T24504] IPE: WIP: Replace closure_desc string representation in logs output on Word32 Message-ID: <663a2c64d393_3f1773233ebc010728c@gitlab.mail> Serge S. Gulin pushed to branch wip/T24504 at Glasgow Haskell Compiler / GHC Commits: 9d881007 by Serge S. Gulin at 2024-05-07T16:27:21+03:00 IPE: WIP: Replace closure_desc string representation in logs output on Word32 - - - - - 5 changed files: - rts/Trace.c - rts/eventlog/EventLog.c - testsuite/tests/rts/ipe/ipeEventLog.stderr - testsuite/tests/rts/ipe/ipeEventLog_fromMap.stderr - testsuite/tests/rts/ipe/ipeMap.c Changes: ===================================== rts/Trace.c ===================================== @@ -689,7 +689,7 @@ void traceIPE(const InfoProvEnt *ipe) ACQUIRE_LOCK(&trace_utx); tracePreface(); - debugBelch("IPE: table_name %s, closure_desc %d, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", + debugBelch("IPE: table_name %s, closure_desc %u, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", ipe->prov.table_name, ipe->prov.closure_desc, ipe->prov.ty_desc, ipe->prov.label, ipe->prov.unit_id, ipe->prov.module, ipe->prov.src_file, ipe->prov.src_span); ===================================== rts/eventlog/EventLog.c ===================================== @@ -1445,7 +1445,6 @@ void postIPE(const InfoProvEnt *ipe) const StgWord MAX_IPE_STRING_LEN = 65535; ACQUIRE_LOCK(&eventBufMutex); StgWord table_name_len = MIN(strlen(ipe->prov.table_name), MAX_IPE_STRING_LEN); - StgWord closure_desc_len = MIN(strlen(ipe->prov.closure_desc), MAX_IPE_STRING_LEN); StgWord ty_desc_len = MIN(strlen(ipe->prov.ty_desc), MAX_IPE_STRING_LEN); StgWord label_len = MIN(strlen(ipe->prov.label), MAX_IPE_STRING_LEN); StgWord module_len = MIN(strlen(ipe->prov.module), MAX_IPE_STRING_LEN); @@ -1455,14 +1454,15 @@ void postIPE(const InfoProvEnt *ipe) // 8 for the info word // 1 null after each string // 1 colon between src_file and src_span + // 4 for the closure_desc, 4 = uint32 StgWord extra_comma = 1; - StgWord len = 8+table_name_len+1+closure_desc_len+1+ty_desc_len+1+label_len+1+module_len+1+src_file_len+1+extra_comma+src_span_len+1; + StgWord len = 8+table_name_len+1+4+1+ty_desc_len+1+label_len+1+module_len+1+src_file_len+1+extra_comma+src_span_len+1; CHECK(!ensureRoomForVariableEvent(&eventBuf, len)); postEventHeader(&eventBuf, EVENT_IPE); postPayloadSize(&eventBuf, len); postWord64(&eventBuf, (StgWord) INFO_PTR_TO_STRUCT(ipe->info)); postStringLen(&eventBuf, ipe->prov.table_name, table_name_len); - postStringLen(&eventBuf, ipe->prov.closure_desc, closure_desc_len); + postWord32(&eventBuf, ipe->prov.closure_desc); postStringLen(&eventBuf, ipe->prov.ty_desc, ty_desc_len); postStringLen(&eventBuf, ipe->prov.label, label_len); postStringLen(&eventBuf, ipe->prov.module, module_len); ===================================== testsuite/tests/rts/ipe/ipeEventLog.stderr ===================================== @@ -1,20 +1,20 @@ -7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 -7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 -7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 -7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 -7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 -7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 -7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 -7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 -7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 -7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 -7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 -7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 -7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 -7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 -7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 -7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 -7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 -7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 -7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 -7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc 38, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc 118, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc 198, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc 278, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc 358, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc 438, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc 518, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc 598, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc 678, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc 758, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc 38, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc 118, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc 198, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc 278, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc 358, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc 438, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc 518, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc 598, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc 678, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc 758, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 ===================================== testsuite/tests/rts/ipe/ipeEventLog_fromMap.stderr ===================================== @@ -1,20 +1,20 @@ -7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 -7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 -7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 -7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 -7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 -7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 -7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 -7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 -7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 -7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 -7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 -7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 -7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 -7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 -7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 -7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 -7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 -7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 -7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 -7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc 758, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc 678, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc 598, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc 518, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc 438, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc 358, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc 278, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc 198, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc 118, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc 38, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc 758, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc 678, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc 598, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc 518, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc 438, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc 358, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc 278, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc 198, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc 118, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc 38, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 ===================================== testsuite/tests/rts/ipe/ipeMap.c ===================================== @@ -71,7 +71,7 @@ HaskellObj shouldFindOneIfItHasBeenRegistered(Capability *cap) { InfoProvEnt result = lookupIPE_("shouldFindOneIfItHasBeenRegistered", get_itbl(fortyTwo)); assertStringsEqual(result.prov.table_name, "table_name_042"); - assertStringsEqual(result.prov.closure_desc, "closure_desc_042"); + assertUInt32Equal(result.prov.closure_desc, 42); assertStringsEqual(result.prov.ty_desc, "ty_desc_042"); assertStringsEqual(result.prov.label, "label_042"); assertStringsEqual(result.prov.unit_id, "unit-id"); @@ -163,3 +163,10 @@ void assertStringsEqual(const char *s1, const char *s2) { exit(1); } } + +void assertUInt32Equal(const uint32_t u1, const uint32_t u2) { + if (u1 != u2) { + errorBelch("%u != %u", u1, u2); + exit(1); + } +} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9d88100783861abecb3a8d6543a45786bb72669b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9d88100783861abecb3a8d6543a45786bb72669b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 13:29:44 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Tue, 07 May 2024 09:29:44 -0400 Subject: [Git][ghc/ghc][wip/T24477] wip Message-ID: <663a2cc8830e3_3f1773242983c10807a@gitlab.mail> Jade pushed to branch wip/T24477 at Glasgow Haskell Compiler / GHC Commits: 34f91e0f by Jade at 2024-05-07T15:34:51+02:00 wip - - - - - 2 changed files: - compiler/GHC/Driver/Flags.hs - testsuite/tests/ffi/should_fail/ccfail001.stderr Changes: ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -91,11 +91,11 @@ data ExtensionDeprecation | ExtensionFlagDeprecated String deriving Eq -deprecation :: ExtensionDeprecation -> TurnOnFlag -> Deprecation -deprecation ExtensionNotDeprecated _ = NotDeprecated -deprecation (ExtensionFlagDeprecatedCond f _) flag - | flag /= f = NotDeprecated -deprecation _ _ = Deprecated +-- | Always returns 'Deprecated' even when the flag is +-- only conditionally deprecated. +deprecation :: ExtensionDeprecation -> Deprecation +deprecation ExtensionNotDeprecated = NotDeprecated +deprecation _ = Deprecated extensionDeprecation :: LangExt.Extension -> ExtensionDeprecation extensionDeprecation = \case @@ -170,7 +170,6 @@ extensionName = \case LangExt.ApplicativeDo -> "ApplicativeDo" LangExt.LinearTypes -> "LinearTypes" LangExt.RequiredTypeArguments -> "RequiredTypeArguments" -- Visible forall (VDQ) in types of terms - LangExt.StandaloneDeriving -> "StandaloneDeriving" LangExt.DeriveDataTypeable -> "DeriveDataTypeable" LangExt.AutoDeriveTypeable -> "AutoDeriveTypeable" -- Automatic derivation of Typeable @@ -183,7 +182,6 @@ extensionName = \case LangExt.DeriveLift -> "DeriveLift" -- Allow deriving Lift LangExt.DerivingStrategies -> "DerivingStrategies" LangExt.DerivingVia -> "DerivingVia" -- Derive through equal representation - LangExt.TypeSynonymInstances -> "TypeSynonymInstances" LangExt.FlexibleContexts -> "FlexibleContexts" LangExt.FlexibleInstances -> "FlexibleInstances" ===================================== testsuite/tests/ffi/should_fail/ccfail001.stderr ===================================== @@ -1,8 +1,9 @@ - ccfail001.hs:10:1: error: [GHC-10964] • Unacceptable result type in foreign declaration: ‘State# RealWorld’ cannot be marshalled in a foreign call UnliftedFFITypes is required to marshal unlifted types • When checking declaration: foreign import ccall safe foo :: Int -> State# RealWorld - Suggested fix: Perhaps you intended to use UnliftedFFITypes + Suggested fix: + Perhaps you intended to use the ‘UnliftedFFITypes’ extension + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/34f91e0f88fe0df0cf4ae9d55f36a623e5dacc8e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/34f91e0f88fe0df0cf4ae9d55f36a623e5dacc8e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 13:48:28 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Tue, 07 May 2024 09:48:28 -0400 Subject: [Git][ghc/ghc][wip/T24477] remove todo Message-ID: <663a312cc9af2_3f1773276de081173b4@gitlab.mail> Jade pushed to branch wip/T24477 at Glasgow Haskell Compiler / GHC Commits: 095e0689 by Jade at 2024-05-07T15:53:30+02:00 remove todo - - - - - 1 changed file: - compiler/GHC/Driver/Flags.hs Changes: ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -112,7 +112,6 @@ extensionDeprecation = \case _ -> ExtensionNotDeprecated --- JADE_TODO extensionName :: LangExt.Extension -> String extensionName = \case LangExt.Cpp -> "CPP" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/095e06891dd1f9352d4edc33d2fde0e4edf81f79 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/095e06891dd1f9352d4edc33d2fde0e4edf81f79 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 13:55:27 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Tue, 07 May 2024 09:55:27 -0400 Subject: [Git][ghc/ghc][wip/T24477] Improve suggestions for language extensions Message-ID: <663a32cfc89fb_3f1773293f9981223ed@gitlab.mail> Jade pushed to branch wip/T24477 at Glasgow Haskell Compiler / GHC Commits: 768ac580 by Jade at 2024-05-07T16:00:17+02:00 Improve suggestions for language extensions - When suggesting Language extensions, also suggest Extensions which imply them - Suggest ExplicitForAll and GADTSyntax instead of more specific extensions - Rephrase suggestion to include the term 'Extension' - Also moves some flag specific definitions out of Session.hs into Flags.hs (#24478) Fixes: #24477 Fixes: #24448 Fixes: #10893 - - - - - 30 changed files: - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Utils/Outputable.hs - testsuite/tests/dependent/should_fail/T15215.stderr - testsuite/tests/dependent/should_fail/T15859.stderr - testsuite/tests/dependent/should_fail/T16326_Fail1.stderr - testsuite/tests/dependent/should_fail/T16326_Fail10.stderr - testsuite/tests/dependent/should_fail/T16326_Fail11.stderr - testsuite/tests/dependent/should_fail/T16326_Fail2.stderr - testsuite/tests/dependent/should_fail/T16326_Fail3.stderr - testsuite/tests/dependent/should_fail/T16326_Fail4.stderr - testsuite/tests/dependent/should_fail/T16326_Fail5.stderr - testsuite/tests/dependent/should_fail/T16326_Fail7.stderr - testsuite/tests/dependent/should_fail/T16326_Fail9.stderr - testsuite/tests/dependent/should_fail/T17687.stderr - testsuite/tests/deriving/should_compile/T16179.stderr - testsuite/tests/deriving/should_fail/T10598_fail2.stderr - testsuite/tests/deriving/should_fail/T10598_fail4.stderr - testsuite/tests/deriving/should_fail/T10598_fail5.stderr - testsuite/tests/deriving/should_fail/T1133A.stderr - testsuite/tests/deriving/should_fail/T12512.stderr - testsuite/tests/deriving/should_fail/T19692.stderr - testsuite/tests/deriving/should_fail/T3833.stderr - testsuite/tests/deriving/should_fail/T3834.stderr - testsuite/tests/deriving/should_fail/T7401_fail.stderr - testsuite/tests/deriving/should_fail/T7959.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/768ac58088813866622b73b2e42d94cc102cbe5c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/768ac58088813866622b73b2e42d94cc102cbe5c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 14:23:28 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Tue, 07 May 2024 10:23:28 -0400 Subject: [Git][ghc/ghc][wip/romes/fixes-4] Apply 1 suggestion(s) to 1 file(s) Message-ID: <663a39603d05a_3f17732d8d2e81359e3@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/fixes-4 at Glasgow Haskell Compiler / GHC Commits: ef39e9a1 by Andreas Klebinger at 2024-05-07T14:23:22+00:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 1 changed file: - compiler/GHC/CmmToAsm/AArch64/RegInfo.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/RegInfo.hs ===================================== @@ -14,7 +14,7 @@ data JumpDest = DestBlockId BlockId instance Outputable JumpDest where ppr (DestBlockId bid) = text "jd:" <> ppr bid --- Instances the methods of the same name in 'NgcImpl' +-- Implementations of the methods of 'NgcImpl' getJumpDestBlockId :: JumpDest -> Maybe BlockId getJumpDestBlockId (DestBlockId bid) = Just bid View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ef39e9a1e2faf2f01588dad9b046acecc2a5c465 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ef39e9a1e2faf2f01588dad9b046acecc2a5c465 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 14:23:33 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Tue, 07 May 2024 10:23:33 -0400 Subject: [Git][ghc/ghc][wip/romes/fixes-4] Apply 1 suggestion(s) to 1 file(s) Message-ID: <663a39653ce15_3f17732d3bc90136135@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/fixes-4 at Glasgow Haskell Compiler / GHC Commits: 751bda48 by Andreas Klebinger at 2024-05-07T14:23:29+00:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 1 changed file: - compiler/GHC/CmmToAsm/Monad.hs Changes: ===================================== compiler/GHC/CmmToAsm/Monad.hs ===================================== @@ -84,7 +84,7 @@ data NcgImpl statics instr jumpDest = NcgImpl { generateJumpTableForInstr :: instr -> Maybe (NatCmmDecl statics instr), -- | Given a jump destination, if it refers to a block, return the block id of the destination. getJumpDestBlockId :: jumpDest -> Maybe BlockId, - -- | Determine whether the given instruction is a jump to some destination. + -- | Determine whether the given instruction is a shortcutable jump to some destination. -- The function is named as such because we use this predicate only in -- order to shortcut redundant jumps, such as a jump to @b@ in the following program: -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/751bda48607000ae27c02de7b94712d6c364c30e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/751bda48607000ae27c02de7b94712d6c364c30e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 14:23:51 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Tue, 07 May 2024 10:23:51 -0400 Subject: [Git][ghc/ghc][wip/romes/fixes-4] Apply 1 suggestion(s) to 1 file(s) Message-ID: <663a3977d7959_3f17732d902401369e9@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/fixes-4 at Glasgow Haskell Compiler / GHC Commits: 6668042e by Andreas Klebinger at 2024-05-07T14:23:41+00:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 1 changed file: - compiler/GHC/CmmToAsm/Monad.hs Changes: ===================================== compiler/GHC/CmmToAsm/Monad.hs ===================================== @@ -85,17 +85,7 @@ data NcgImpl statics instr jumpDest = NcgImpl { -- | Given a jump destination, if it refers to a block, return the block id of the destination. getJumpDestBlockId :: jumpDest -> Maybe BlockId, -- | Determine whether the given instruction is a shortcutable jump to some destination. - -- The function is named as such because we use this predicate only in - -- order to shortcut redundant jumps, such as a jump to @b@ in the following program: - -- - -- @ - -- a: - -- goto b - -- b: - -- goto c - -- c: - -- ... - -- @ +See Note [supporting shortcutting] canShortcut :: instr -> Maybe jumpDest, shortcutStatics :: (BlockId -> Maybe jumpDest) -> statics -> statics, -- | Rewrite the jump destination of a jump instruction to another View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6668042ecf9bc09554062426afa5fee6a48456bd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6668042ecf9bc09554062426afa5fee6a48456bd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 14:24:11 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Tue, 07 May 2024 10:24:11 -0400 Subject: [Git][ghc/ghc][wip/reinstallable-th] 30 commits: Expose constructors of SNat, SChar and SSymbol in ghc-internal Message-ID: <663a398bc6120_3f17732ea5dec1389bc@gitlab.mail> Teo Camarasu pushed to branch wip/reinstallable-th at Glasgow Haskell Compiler / GHC Commits: 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 7eab4e01 by Alan Zimmerman at 2024-05-04T16:14:55+01:00 EPA: Widen stmtslist to include last semicolon Closes #24754 - - - - - 06f7db40 by Teo Camarasu at 2024-05-05T00:19:38-04:00 doc: Fix type error in hs_try_putmvar example - - - - - af000532 by Moritz Schuler at 2024-05-05T06:30:58-04:00 Fix parsing of module names in CLI arguments closes issue #24732 - - - - - da74e9c9 by Ben Gamari at 2024-05-05T06:31:34-04:00 ghc-platform: Add Setup.hs The Hadrian bootstrapping script relies upon `Setup.hs` to drive its build. Addresses #24761. - - - - - 35d34fde by Alan Zimmerman at 2024-05-05T12:52:40-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 - - - - - 03c5dfbf by Simon Peyton Jones at 2024-05-05T12:53:15-04:00 Fix a float-out error Ticket #24768 showed that the Simplifier was accidentally destroying a join point. It turned out to be that we were sending a bottoming join point to the top, accidentally abstracting over /other/ join points. Easily fixed. - - - - - adba68e7 by John Ericson at 2024-05-05T19:35:56-04:00 Substitute bindist files with Hadrian not configure The `ghc-toolchain` overhaul will eventually replace all this stuff with something much more cleaned up, but I think it is still worth making this sort of cleanup in the meantime so other untanglings and dead code cleaning can procede. I was able to delete a fair amount of dead code doing this too. `LLVMTarget_CPP` is renamed to / merged with `LLVMTarget` because it wasn't actually turned into a valid CPP identifier. (Original to 1345c7cc42c45e63ab1726a8fd24a7e4d4222467, actually.) Progress on #23966 Co-Authored-By: Sylvain Henry <hsyl20 at gmail.com> - - - - - 18f4ff84 by Alan Zimmerman at 2024-05-05T19:36:32-04:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 - - - - - a19201d4 by Matthew Craven at 2024-05-06T19:54:29-04:00 Add test cases for #24664 ...since none are present in the original MR !12463 fixing this issue. - - - - - 46328a49 by Alan Zimmerman at 2024-05-06T19:55:05-04:00 EPA: preserve comments in data decls Closes #24771 - - - - - a58c1d23 by Teo Camarasu at 2024-05-07T13:50:10+01:00 Make template-haskell reinstallable - - - - - 10453598 by Teo Camarasu at 2024-05-07T15:15:30+01:00 Split out GHC.Internal.TH.Lift - - - - - 1da609dc by Teo Camarasu at 2024-05-07T15:15:55+01:00 Move MonadIO to ghc-internal - - - - - 3589e3de by Teo Camarasu at 2024-05-07T15:23:33+01:00 Move GHC.Internal.Syntax into ghc-internal - - - - - 30 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Plugins.hs - compiler/GHC/Rename/Splice.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ee64ebcf2cb80276ffcc08868fd094e026e9afe6...3589e3de39b39307861d38cd207703c8f24d3f34 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ee64ebcf2cb80276ffcc08868fd094e026e9afe6...3589e3de39b39307861d38cd207703c8f24d3f34 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 14:24:15 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Tue, 07 May 2024 10:24:15 -0400 Subject: [Git][ghc/ghc][wip/romes/fixes-4] Apply 1 suggestion(s) to 1 file(s) Message-ID: <663a398f5baeb_3f17732f1d4a01394ea@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/fixes-4 at Glasgow Haskell Compiler / GHC Commits: 54321d78 by Andreas Klebinger at 2024-05-07T14:23:49+00:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 1 changed file: - compiler/GHC/CmmToAsm/Monad.hs Changes: ===================================== compiler/GHC/CmmToAsm/Monad.hs ===================================== @@ -88,23 +88,12 @@ data NcgImpl statics instr jumpDest = NcgImpl { See Note [supporting shortcutting] canShortcut :: instr -> Maybe jumpDest, shortcutStatics :: (BlockId -> Maybe jumpDest) -> statics -> statics, - -- | Rewrite the jump destination of a jump instruction to another + -- | Rewrite the destination of a jump instruction to another -- destination, if the given function returns a new jump destination for -- the 'BlockId' of the original destination. -- - -- For instance, if @goto b@, from the following program - -- - -- @ - -- a: - -- goto b - -- b: - -- goto c - -- c: - -- ... - -- @ - -- - -- is the given instruction, and the function maps @b@ to @c@, - -- 'shortcutJump' returns @goto c@ + -- For instance, for a mapping @block_a -> dest_b@ and a instruction @goto block_a@ we would + -- rewrite the instruction to @goto dest_b@ shortcutJump :: (BlockId -> Maybe jumpDest) -> instr -> instr, -- | 'Module' is only for printing internal labels. See Note [Internal proc -- labels] in CLabel. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/54321d785de2af7a23ace4f0069fa283f1134985 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/54321d785de2af7a23ace4f0069fa283f1134985 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 14:33:30 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Tue, 07 May 2024 10:33:30 -0400 Subject: [Git][ghc/ghc][wip/romes/fixes-4] 752 commits: Move function checks to RTS configure Message-ID: <663a3bba80d1f_3f1773314d7e814639a@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/fixes-4 at Glasgow Haskell Compiler / GHC Commits: 02efc181 by John Ericson at 2023-10-22T02:48:55-04:00 Move function checks to RTS configure Some of these functions are used in `base` too, but we can copy the checks over to its configure if that's an issue. - - - - - 5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00 Move over a number of C-style checks to RTS configure - - - - - 5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00 Move/Copy more `AC_DEFINE` to RTS config Only exception is the LLVM version macros, which are used for GHC itself. - - - - - b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00 Define `TABLES_NEXT_TO_CODE` in the RTS configure We create a new cabal flag to facilitate this. - - - - - 4a40271e by John Ericson at 2023-10-22T02:48:55-04:00 Configure scripts: `checkOS`: Make a bit more robust `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This allows us to cope with configs/triples that we haven't normalized extra being what GNU `config.sub` does. - - - - - 16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00 Generate `ghcplatform.h` from RTS configure We create a new cabal flag to facilitate this. - - - - - 7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00 Get rid of all mention of `mk/config.h` The RTS configure script is now solely responsible for managing its headers; the top level configure script does not help. - - - - - c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00 rts: drop stale mentions of MIN_UPD_SIZE We used to have MIN_UPD_SIZE macro that describes the minimum reserved size for thunks, so that the thunk can be overwritten in place as indirections or blackholes. However, this macro has not been actually defined or used anywhere since a long time ago; StgThunkHeader already reserves a padding word for this purpose. Hence this patch which drops stale mentions of MIN_UPD_SIZE. - - - - - d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00 base changelog: move non-backported entries from 4.19 section to 4.20 Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational) nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip) were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section. Also minor stylistic changes to other entries, bringing them to a uniform form. - - - - - de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00 EPA Some tweaks to annotations - Fix span for GRHS - Move TrailingAnns from last match to FunBind - Fix GADT 'where' clause span - Capture full range for a CaseAlt Match - - - - - d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00 Update primitives.rst - - - - - 4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00 JS/userguide: add explanation of writing jsbits - - - - - 07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00 testsuite: increase timeout of ghc-api tests for wasm32 ghc-api tests for wasm32 are more likely to timeout due to the large wasm module sizes, especially when testing with wasm native tail calls, given wasmtime's handling of tail call opcodes are suboptimal at the moment. It makes sense to increase timeout specifically for these tests on wasm32. This doesn't affect other targets, and for wasm32 we don't increase timeout for all tests, so not to risk letting major performance regressions slip through the testsuite. - - - - - 0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00 Explicitly require RLIMIT_AS before use in OSMem.c This is done elsewhere in the source tree. It also suddenly is required on OpenBSD. - - - - - 9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00 Modularity: modularize external linker Decouple runLink from DynFlags to allow calling runLink more easily. This is preliminary work for calling Emscripten's linker (emcc) from our JavaScript linker. - - - - - e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00 js: add JStg IR, remove unsaturated constructor - Major step towards #22736 and adding the optimizer in #22261 - - - - - 35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00 Fix a bug in tail calls with ticks See #24078 for the diagnosis. The change affects only the Tick case of occurrence analysis. It's a bit hard to test, so no regression test (yet anyway). - - - - - 9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00 Teach tag-inference about SeqOp/seq# Fixes the STG/tag-inference analogue of #15226. Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00 [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra 48e391952c17ff7eab10b0b1456e3f2a2af28a9b introduced `SYM_TYPE_DUP_DISCARD` to the bitfield. The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value. Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions. - - - - - 5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00 Fix and test for issue #24111, TH.Ppr output of pattern synonyms - - - - - 723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00 EPA: print doc comments as normal comments And ignore the ones allocated in haddock processing. It does not guarantee that every original haddock-like comment appears in the output, as it discards ones that have no legal attachment point. closes #23459 - - - - - 21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00 Fix non-termination bug in equality solver constraint left-to-right then right to left, forever. Easily fixed. - - - - - 270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00 ghc-toolchain: build with `-package-env=-` (#24131) Otherwise globally installed libraries (via `cabal install --lib`) break the build. Fixes #24131. - - - - - 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - cc1c7c54 by Duncan Coutts at 2023-11-05T00:23:44-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 2e448f98 by Cheng Shao at 2023-11-05T00:23:44-04:00 Skip the IOManager test on wasm32 arch. The test relies on the sockets API which are not (yet) available. - - - - - fe50eb35 by Cheng Shao at 2023-11-05T00:24:20-04:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - af771148 by Cheng Shao at 2023-11-05T00:24:20-04:00 testsuite: fix optasm tests for wasm32 - - - - - 1b90735c by Matthew Pickering at 2023-11-05T00:24:20-04:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - db9a6496 by Alan Zimmerman at 2023-11-05T00:24:55-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 833e250c by Simon Peyton Jones at 2023-11-05T00:25:31-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - e451139f by Andreas Klebinger at 2023-11-05T00:26:07-04:00 Remove an accidental git conflict marker from a comment. - - - - - 30baac7a by Tobias Haslop at 2023-11-06T10:50:32+00:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - df626f00 by Tobias Haslop at 2023-11-07T02:20:37-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 8217acb8 by Alan Zimmerman at 2023-11-07T02:21:12-05:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - dd88a260 by Luite Stegeman at 2023-11-07T02:21:53-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - 455524a2 by Matthew Craven at 2023-11-09T08:41:59-05:00 Create specially-solved DataToTag class Closes #20532. This implements CLC proposal 104: https://github.com/haskell/core-libraries-committee/issues/104 The design is explained in Note [DataToTag overview] in GHC.Tc.Instance.Class. This replaces the existing `dataToTag#` primop. These metric changes are not "real"; they represent Unique-related flukes triggering on a different set of jobs than they did previously. See also #19414. Metric Decrease: T13386 T8095 Metric Increase: T13386 T8095 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - a05f4554 by Alan Zimmerman at 2023-11-09T08:42:35-05:00 EPA: get rid of glRR and friends in GHC/Parser.y With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead Metric Decrease: MultiLayerModulesTH_Make - - - - - 18498538 by Cheng Shao at 2023-11-09T16:58:12+00:00 ci: bump ci-images for wasi-sdk upgrade - - - - - 52c0fc69 by PHO at 2023-11-09T19:16:22-05:00 Don't assume the current locale is *.UTF-8, set the encoding explicitly primops.txt contains Unicode characters: > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226) Hadrian must also avoid using readFile' to read primops.txt because it tries to decode the file with a locale-specific encoding. - - - - - 7233b3b1 by PHO at 2023-11-09T19:17:01-05:00 Use '[' instead of '[[' because the latter is a Bash-ism It doesn't work on platforms where /bin/sh is something other than Bash. - - - - - 6dbab180 by Simon Peyton Jones at 2023-11-09T19:17:36-05:00 Add an extra check in kcCheckDeclHeader_sig Fix #24083 by checking for a implicitly-scoped type variable that is not actually bound. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures. Metric Decrease: MultiLayerModulesTH_Make - - - - - 22551364 by Sven Tennie at 2023-11-11T06:35:22-05:00 AArch64: Delete unused LDATA pseudo-instruction Though there were consuming functions for LDATA, there were no producers. Thus, the removed code was "dead". - - - - - 2a0ec8eb by Alan Zimmerman at 2023-11-11T06:35:59-05:00 EPA: harmonise acsa and acsA in GHC/Parser.y With the HasLoc class, we can remove the acsa helper function, using acsA instead. - - - - - 7ae517a0 by Teo Camarasu at 2023-11-12T08:04:12-05:00 nofib: bump submodule This includes changes that: - fix building a benchmark with HEAD - remove a Makefile-ism that causes errors in bash scripts Resolves #24178 - - - - - 3f0036ec by Alan Zimmerman at 2023-11-12T08:04:47-05:00 EPA: Replace Anchor with EpaLocation An Anchor has a location and an operation, which is either that it is unchanged or that it has moved with a DeltaPos data Anchor = Anchor { anchor :: RealSrcSpan , anchor_op :: AnchorOperation } An EpaLocation also has either a location or a DeltaPos data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] Now that we do not care about always having a location in the anchor, we remove Anchor and replace it with EpaLocation We do this with a type alias initially, to ease the transition. The alias will be removed in time. We also have helpers to reconstruct the AnchorOperation from an EpaLocation. This is also temporary. Updates Haddock submodule - - - - - a7492048 by Alan Zimmerman at 2023-11-12T13:43:07+00:00 EPA: get rid of AnchorOperation Now that the Anchor type is an alias for EpaLocation, remove AnchorOperation. Updates haddock submodule - - - - - 0745c34d by Andrew Lelechenko at 2023-11-13T16:25:07-05:00 Add since annotation for showHFloat - - - - - e98051a5 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 Suppress duplicate librares linker warning of new macOS linker Fixes #24167 XCode 15 introduced a new linker which warns on duplicate libraries being linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as suggested by Brad King in CMake issue #25297. This flag isn't necessarily available to other linkers on darwin, so we must only configure it into the CC linker arguments if valid. - - - - - c411c431 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Encoding test witnesses recent iconv bug is fragile A regression in the new iconv() distributed with XCode 15 and MacOS Sonoma causes the test 'encoding004' to fail in the CP936 roundrip. We mark this test as fragile until this is fixed upstream (rather than broken, since previous versions of iconv pass the test) See #24161 - - - - - ce7fe5a9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Update to LC_ALL=C no longer being ignored in darwin MacOS seems to have fixed an issue where it used to ignore the variable `LC_ALL` in program invocations and default to using Unicode. Since the behaviour seems to be fixed to account for the locale variable, we mark tests that were previously broken in spite of it as fragile (since they now pass in recent macOS distributions) See #24161 - - - - - e6c803f7 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 929ba2f9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Skip MultiLayerModulesTH_Make on darwin The recent toolchain upgrade on darwin machines resulted in the MultiLayerModulesTH_Make test metrics varying too much from the baseline, ultimately blocking the CI pipelines. This commit skips the test on darwin to temporarily avoid failures due to the environment change in the runners. However, the metrics divergence is being investigated still (tracked in #24177) - - - - - af261ccd by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 configure: check target (not build) understands -no_compact_unwind Previously, we were branching on whether the build system was darwin to shortcut this check, but we really want to branch on whether the target system (which is what we are configuring ld_prog for) is darwin. - - - - - 2125c176 by Luite Stegeman at 2023-11-15T13:19:38-05:00 JS: Fix missing variable declarations The JStg IR update was missing some local variable declarations that were present earlier, causing global variables to be used implicitly (or an error in JavaScript strict mode). This adds the local variable declarations again. - - - - - 99ced73b by Krzysztof Gogolewski at 2023-11-15T13:20:14-05:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - 2aff2361 by Zubin Duggal at 2023-11-15T13:20:50-05:00 users-guide: Fix links to libraries from the users-guide. The unit-ids generated in c1a3ecde720b3bddc2c8616daaa06ee324e602ab include the package name, so we don't need to explicitly add it to the links. Fixes #24151 - - - - - 27981fac by Alan Zimmerman at 2023-11-15T13:21:25-05:00 EPA: splitLHsForAllTyInvis does not return ann We did not use the annotations returned from splitLHsForAllTyInvis, so do not return them. - - - - - a6467834 by Krzysztof Gogolewski at 2023-11-15T22:22:59-05:00 Document defaulting of RuntimeReps Fixes #24099 - - - - - 2776920e by Simon Peyton Jones at 2023-11-15T22:23:35-05:00 Second fix to #24083 My earlier fix turns out to be too aggressive for data/type families See wrinkle (DTV1) in Note [Disconnected type variables] - - - - - cee81370 by Sylvain Henry at 2023-11-16T09:57:46-05:00 Fix unusable units and module reexport interaction (#21097) This commit fixes an issue with ModUnusable introduced in df0f148feae. In mkUnusableModuleNameProvidersMap we traverse the list of unusable units and generate ModUnusable origin for all the modules they contain: exposed modules, hidden modules, and also re-exported modules. To do this we have a two-level map: ModuleName -> Unit:ModuleName (aka Module) -> ModuleOrigin So for each module name "M" in broken unit "u" we have: "M" -> u:M -> ModUnusable reason However in the case of module reexports we were using the *target* module as a key. E.g. if "u:M" is a reexport for "X" from unit "o": "M" -> o:X -> ModUnusable reason Case 1: suppose a reexport without module renaming (u:M -> o:M) from unusable unit u: "M" -> o:M -> ModUnusable reason Here it's claiming that the import of M is unusable because a reexport from u is unusable. But if unit o isn't unusable we could also have in the map: "M" -> o:M -> ModOrigin ... Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModOrigin) Case 2: similarly we could have 2 unusable units reexporting the same module without renaming, say (u:M -> o:M) and (v:M -> o:M) with u and v unusable. It gives: "M" -> o:M -> ModUnusable ... (for u) "M" -> o:M -> ModUnusable ... (for v) Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModUnusable). This led to #21097, #16996, #11050. To fix this, in this commit we make ModUnusable track whether the module used as key is a reexport or not (for better error messages) and we use the re-export module as key. E.g. if "u:M" is a reexport for "o:X" and u is unusable, we now record: "M" -> u:M -> ModUnusable reason reexported=True So now, we have two cases for a reexport u:M -> o:X: - u unusable: "M" -> u:M -> ModUnusable ... reexported=True - u usable: "M" -> o:X -> ModOrigin ... reexportedFrom=u:M The second case is indexed with o:X because in this case the Semigroup instance of ModOrigin is used to combine valid expositions of a module (directly or via reexports). Note that module lookup functions select usable modules first (those who have a ModOrigin value), so it doesn't matter if we add new ModUnusable entries in the map like this: "M" -> { u:M -> ModUnusable ... reexported=True o:M -> ModOrigin ... } The ModOrigin one will be used. Only if there is no ModOrigin or ModHidden entry will the ModUnusable error be printed. See T21097 for an example printing several reasons why an import is unusable. - - - - - 3e606230 by Krzysztof Gogolewski at 2023-11-16T09:58:22-05:00 Fix IPE test A helper function was defined in a different module than used. To reproduce: ./hadrian/build test --test-root-dirs=testsuite/tests/rts/ipe - - - - - 49f5264b by Andreas Klebinger at 2023-11-16T20:52:11-05:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Use rep size rather than rep count to compute the size. Fixes #22309 - - - - - b4f84e4b by James Henri Haydon at 2023-11-16T20:52:53-05:00 Explicit methods for Alternative Compose Explicitly define some and many in Alternative instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/181 - - - - - 9bc0dd1f by Ignat Insarov at 2023-11-16T20:53:34-05:00 Add permutations for non-empty lists. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 5643ecf9 by Andrew Lelechenko at 2023-11-16T20:53:34-05:00 Update changelog and since annotations for Data.List.NonEmpty.permutations Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 94ff2134 by Oleg Alexander at 2023-11-16T20:54:15-05:00 Update doc string for traceShow Updated doc string for traceShow. - - - - - faff671a by Luite Stegeman at 2023-11-17T14:12:51+01:00 JS: clean up some foreign imports - - - - - 856e0a4e by Sven Tennie at 2023-11-18T06:54:11-05:00 AArch64: Remove unused instructions As these aren't ever emitted, we don't even know if they work or will ever be used. If one of them is needed in future, we may easily re-add it. Deleted instructions are: - CMN - ANDS - BIC - BICS - EON - ORN - ROR - TST - STP - LDP - DMBSY - - - - - 615441ef by Alan Zimmerman at 2023-11-18T06:54:46-05:00 EPA: Replace Monoid with NoAnn Remove the final Monoid instances in the exact print infrastructure. For Windows CI Metric Decrease: T5205 - - - - - 5a6c49d4 by David Feuer at 2023-11-20T18:53:18-05:00 Speed up stimes in instance Semigroup Endo As discussed at https://github.com/haskell/core-libraries-committee/issues/4 - - - - - cf9da4b3 by Andrew Lelechenko at 2023-11-20T18:53:18-05:00 base: reflect latest changes in the changelog - - - - - 48bf364e by Alan Zimmerman at 2023-11-20T18:53:54-05:00 EPA: Use SrcSpan in EpaSpan This is more natural, since we already need to deal with invalid RealSrcSpans, and that is exactly what SrcSpan.UnhelpfulSpan is for. Updates haddock submodule. - - - - - 97ec37cc by Sebastian Graf at 2023-11-20T18:54:31-05:00 Add regression test for #6070 Fixes #6070. - - - - - e9d5ae41 by Owen Shepherd at 2023-11-21T18:32:23-05:00 chore: Correct typo in the gitlab MR template [skip ci] - - - - - f158a8d0 by Rodrigo Mesquita at 2023-11-21T18:32:59-05:00 Improve error message when reading invalid `.target` files A `.target` file generated by ghc-toolchain or by configure can become invalid if the target representation (`Toolchain.Target`) is changed while the files are not re-generated by calling `./configure` or `ghc-toolchain` again. There is also the issue of hadrian caching the dependencies on `.target` files, which makes parsing fail when reading reading the cached value if the representation has been updated. This patch provides a better error message in both situations, moving away from a terrible `Prelude.read: no parse` error that you would get otherwise. Fixes #24199 - - - - - 955520c6 by Ben Gamari at 2023-11-21T18:33:34-05:00 users guide: Note that QuantifiedConstraints implies ExplicitForAll Fixes #24025. - - - - - 17ec3e97 by Owen Shepherd at 2023-11-22T09:37:28+01:00 fix: Change type signatures in NonEmpty export comments to reflect reality This fixes several typos in the comments of Data.List.NonEmpty export list items. - - - - - 2fd78f9f by Samuel Thibault at 2023-11-22T11:49:13-05:00 Fix the platform string for GNU/Hurd As commited in Cargo https://github.com/haskell/cabal/pull/9434 there is confusion between "gnu" and "hurd". This got fixed in Cargo, we need the converse in Hadrian. Fixes #24180 - - - - - a79960fe by Alan Zimmerman at 2023-11-22T11:49:48-05:00 EPA: Tuple Present no longer has annotation The Present constructor for a Tuple argument will never have an exact print annotation. So make this impossible. - - - - - 121c9ab7 by David Binder at 2023-11-22T21:12:29-05:00 Unify the hpc testsuites The hpc testsuite was split between testsuite/tests/hpc and the submodule libraries/hpc/test. This commit unifies the two testsuites in the GHC repository in the directory testsuite/tests/hpc. - - - - - d2733a05 by Alan Zimmerman at 2023-11-22T21:13:05-05:00 EPA: empty tup_tail has noAnn In Parser.y, the tup_tail rule had the following option | {- empty -} %shift { return [Left noAnn] } Once this works through PostProcess.hs, it means we add an extra Missing constructor if the last item was a comma. Change the annotation type to a Bool to indicate this, and use the EpAnn Anchor for the print location for the others. - - - - - fa576eb8 by Andreas Klebinger at 2023-11-24T08:29:13-05:00 Fix FMA primops generating broken assembly on x86. `genFMA3Code` assumed that we had to take extra precations to avoid overwriting the result of `getNonClobberedReg`. One of these special cases caused a bug resulting in broken assembly. I believe we don't need to hadle these cases specially at all, which means this MR simply deletes the special cases to fix the bug. Fixes #24160 - - - - - 34d86315 by Alan Zimmerman at 2023-11-24T08:29:49-05:00 EPA: Remove parenthesizeHsType This is called from PostProcess.hs, and adds spurious parens. With the looser version of exact printing we had before we could tolerate this, as they would be swallowed by the original at the same place. But with the next change (remove EpAnnNotUsed) they result in duplicates in the output. For Darwin build: Metric Increase: MultiLayerModulesTH_OneShot - - - - - 3ede659d by Vladislav Zavialov at 2023-11-26T06:43:32-05:00 Add name for -Wdeprecated-type-abstractions (#24154) This warning had no name or flag and was triggered unconditionally. Now it is part of -Wcompat. - - - - - 7902ebf8 by Alan Zimmerman at 2023-11-26T06:44:08-05:00 EPA: Remove EpAnnNotUsed We no longer need the EpAnnNotUsed constructor for EpAnn, as we can represent an unused annotation with an anchor having a EpaDelta of zero, and empty comments and annotations. This simplifies code handling annotations considerably. Updates haddock submodule Metric Increase: parsing001 - - - - - 471b2672 by Mario Blažević at 2023-11-26T06:44:48-05:00 Bumped the upper bound of text to <2.2 - - - - - d1bf25c7 by Vladislav Zavialov at 2023-11-26T11:45:49-05:00 Term variable capture (#23740) This patch changes type variable lookup rules (lookupTypeOccRn) and implicit quantification rules (filterInScope) so that variables bound in the term namespace can be captured at the type level {-# LANGUAGE RequiredTypeArguments #-} f1 x = g1 @x -- `x` used in a type application f2 x = g2 (undefined :: x) -- `x` used in a type annotation f3 x = g3 (type x) -- `x` used in an embedded type f4 x = ... where g4 :: x -> x -- `x` used in a type signature g4 = ... This change alone does not allow us to accept examples shown above, but at least it gets them past the renamer. - - - - - da863d15 by Vladislav Zavialov at 2023-11-26T11:46:26-05:00 Update Note [hsScopedTvs and visible foralls] The Note was written before GHC gained support for visible forall in types of terms. Rewrite a few sentences and use a better example. - - - - - b5213542 by Matthew Pickering at 2023-11-27T12:53:59-05:00 testsuite: Add mechanism to collect generic metrics * Generalise the metric logic by adding an additional field which allows you to specify how to query for the actual value. Previously the method of querying the baseline value was abstracted (but always set to the same thing). * This requires rejigging how the stat collection works slightly but now it's more uniform and hopefully simpler. * Introduce some new "generic" helper functions for writing generic stats tests. - collect_size ( deviation, path ) Record the size of the file as a metric - stat_from_file ( metric, deviation, path ) Read a value from the given path, and store that as a metric - collect_generic_stat ( metric, deviation, get_stat) Provide your own `get_stat` function, `lambda way: <Int>`, which can be used to establish the current value of the metric. - collect_generic_stats ( metric_info ): Like collect_generic_stat but provide the whole dictionary of metric definitions. { metric: { deviation: <Int> current: lambda way: <Int> } } * Introduce two new "size" metrics for keeping track of build products. - `size_hello_obj` - The size of `hello.o` from compiling hello.hs - `libdir` - The total size of the `libdir` folder. * Track the number of modules in the AST tests - CountDepsAst - CountDepsParser This lays the infrastructure for #24191 #22256 #17129 - - - - - 7d9a2e44 by ARATA Mizuki at 2023-11-27T12:54:39-05:00 x86: Don't require -mavx2 when using 256-bit floating-point SIMD primitives Fixes #24222 - - - - - 4e5ff6a4 by Alan Zimmerman at 2023-11-27T12:55:15-05:00 EPA: Remove SrcSpanAnn Now that we only have a single constructor for EpAnn, And it uses a SrcSpan for its location, we can do away with SrcSpanAnn completely. It only existed to wrap the original SrcSpan in a location, and provide a place for the exact print annotation. For darwin only: Metric Increase: MultiLayerModulesTH_OneShot Updates haddock submodule - - - - - e05bca39 by Krzysztof Gogolewski at 2023-11-28T08:00:55-05:00 testsuite: don't initialize testdir to '.' The test directory is removed during cleanup, if there's an interrupt that could remove the entire repository. Fixes #24219 - - - - - af881674 by Alan Zimmerman at 2023-11-28T08:01:30-05:00 EPA: Clean up mkScope in Ast.hs Now that we have HasLoc we can get rid of all the custom variants of mkScope For deb10-numa Metric Increase: libdir - - - - - 292983c8 by Ben Gamari at 2023-11-28T22:44:28-05:00 distrib: Rediscover otool and install_name_tool on Darwin In the bindist configure script we must rediscover the `otool` and `install_name_tool`s since they may be different from the build environment. Fixes #24211. - - - - - dfe1c354 by Stefan Schulze Frielinghaus at 2023-11-28T22:45:04-05:00 llvmGen: Align objects in the data section Objects in the data section may be referenced via tagged pointers. Thus, align those objects to a 4- or 8-byte boundary for 32- or 64-bit platforms, respectively. Note, this may need to be reconsidered if objects with a greater natural alignment requirement are emitted as e.g. 128-bit atomics. Fixes #24163. - - - - - f6c486c3 by Matthew Pickering at 2023-11-29T11:08:13-05:00 metrics: Widen libdir and size_hello_obj acceptance window af8816740d9b8759be1a22af8adcb5f13edeb61d shows that the libdir size can fluctuate quite significantly even when the change is quite small. Therefore we widen the acceptance window to 10%. - - - - - 99a6a49c by Alan Zimmerman at 2023-11-29T11:08:49-05:00 EPA: Clean up TC Monad Utils We no longer need the alternative variant of addLocM (addLocMA) nor wrapLocAM, wrapLocSndMA. aarch64-darwin Metric Increase: MultiLayerModulesTH_OneShot deb10-numa-slow Metric Decrease: libdir - - - - - cbc03fa0 by Sebastian Graf at 2023-11-30T12:37:21-05:00 perf tests: Move comments into new `Note [Sensitivity to unique increment]` (#19414) And additionally to T12545, link from T8095, T13386 to this new Note. - - - - - c7623b22 by Alan Zimmerman at 2023-11-30T12:37:56-05:00 EPA: EpaDelta for comment has no comments EpaLocation is used to position things. It has two constructors, EpaSpan holding a SrcSpan, and EpaDelta with a delta position and a possible list of comments. The comment list is needed because the location in EpaDelta has no absolute information to decide which comments should be emitted before them when printing. But it is also used for specifying the position of a comment. To prevent the absurdity of a comment position having a list of comments in it, we make EpaLocation parameterisable, using comments for the normal case and a constant for within comments. Updates haddock submodule. aarch64-darwin Metric Decrease: MultiLayerModulesTH_OneShot - - - - - bd8acc0c by Krzysztof Gogolewski at 2023-11-30T12:38:32-05:00 Kind-check body of a required forall We now require that in 'forall a -> ty', ty has kind TYPE r for some r. Fixes #24176 - - - - - 010fb784 by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Remove incorrect haddock link quotes in code block - - - - - cda9c12d by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Remove cycle from group haddock example - - - - - 495265b9 by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Use repl haddock syntax in group docs - - - - - d134d1de by Owen Shepherd at 2023-12-03T00:10:09-05:00 docs(NonEmpty/group): Use list [] notation in group haddock - - - - - dfcf629c by Owen Shepherd at 2023-12-03T00:10:10-05:00 docs(NonEmpty/group): Specify final property of group function in haddock - - - - - cad3b734 by Owen Shepherd at 2023-12-03T00:10:10-05:00 fix: Add missing property of List.group - - - - - bad37656 by Matthew Pickering at 2023-12-03T00:10:46-05:00 testsuite: Fix T21097b test with make 4.1 (deb9) cee81370cd6ef256f66035e3116878d4cb82e28b recently added a test which failed on deb9 because the version of make was emitting the recipe failure to stdout rather than stderr. One way to fix this is to be more precise in the test about which part of the output we care about inspecting. - - - - - 5efdf421 by Matthew Pickering at 2023-12-03T00:11:21-05:00 testsuite: Track size of libdir in bytes For consistency it's better if we track all size metrics in bytes. Metric Increase: libdir - - - - - f5eb0f29 by Matthew Pickering at 2023-12-03T00:11:22-05:00 testsuite: Remove rogue trace in testsuite I accidentally left a trace in the generics metric patch. - - - - - d5610737 by Claudio Bley at 2023-12-06T16:13:33-05:00 Only exit ghci in -e mode when :add command fails Previously, when running `ghci -e ':add Sample.hs'` the process would exit with exit code 1 if the file exists and could be loaded. Fixes #24115 - - - - - 0f0c53a5 by Vladislav Zavialov at 2023-12-06T16:14:09-05:00 T2T in Patterns (#23739) This patch implements the T2T (term-to-type) transformation in patterns. Patterns that are checked against a visible forall can now be written without the `type` keyword: \(type t) (x :: t) -> ... -- old \t (x :: t) -> ... -- new The `t` binder is parsed and renamed as a term pattern (Pat), but then undergoes a conversion to a type pattern (HsTyPat). See the new function pat_to_type_pat in compiler/GHC/Tc/Gen/Pat.hs - - - - - 10a1a6c6 by Sebastian Graf at 2023-12-06T16:14:45-05:00 Pmc: Fix SrcLoc and warning for incomplete irrefutable pats (#24234) Before, the source location would point at the surrounding function definition, causing the confusion in #24234. I also took the opportunity to introduce a new `LazyPatCtx :: HsMatchContext _` to make the warning message say "irrefutable pattern" instead of "pattern binding". - - - - - 36b9a38c by Matthew Pickering at 2023-12-06T16:15:21-05:00 libraries: Bump filepath to 1.4.200.1 and unix to 2.8.4.0 Updates filepath submodule Updates unix submodule Fixes #24240 - - - - - 91ff0971 by Matthew Pickering at 2023-12-06T16:15:21-05:00 Submodule linter: Allow references to tags We modify the submodule linter so that if the bumped commit is a specific tag then the commit is accepted. Fixes #24241 - - - - - 86f652dc by Zubin Duggal at 2023-12-06T16:15:21-05:00 hadrian: set -Wno-deprecations for directory and Win32 The filepath bump to 1.4.200.1 introduces a deprecation warning. See https://gitlab.haskell.org/ghc/ghc/-/issues/24240 https://github.com/haskell/filepath/pull/206 - - - - - 7ac6006e by Sylvain Henry at 2023-12-06T16:16:02-05:00 Zap OccInfo on case binders during StgCse #14895 #24233 StgCse can revive dead binders: case foo of dead { Foo x y -> Foo x y; ... } ===> case foo of dead { Foo x y -> dead; ... } -- dead is no longer dead So we must zap occurrence information on case binders. Fix #14895 and #24233 - - - - - 57c391c4 by Sebastian Graf at 2023-12-06T16:16:37-05:00 Cpr: Turn an assertion into a check to deal with some dead code (#23862) See the new `Note [Dead code may contain type confusions]`. Fixes #23862. - - - - - c1c8abf8 by Zubin Duggal at 2023-12-08T02:25:07-05:00 testsuite: add test for #23944 - - - - - 6329d308 by Zubin Duggal at 2023-12-08T02:25:07-05:00 driver: Only run a dynamic-too pipeline if object files are going to be generated Otherwise we run into a panic in hscMaybeWriteIface: "Unexpected DT_Dyn state when writing simple interface" when dynamic-too is enabled We could remove the panic and just write the interface even if the state is `DT_Dyn`, but it seems pointless to run the pipeline twice when `hscMaybeWriteIface` is already designed to write both `hi` and `dyn_hi` files if dynamic-too is enabled. Fixes #23944. - - - - - 28811f88 by Simon Peyton Jones at 2023-12-08T05:47:18-05:00 Improve duplicate elimination in SpecConstr This partially fixes #24229. See the new Note [Pattern duplicate elimination] in SpecConstr - - - - - fec7894f by Simon Peyton Jones at 2023-12-08T05:47:18-05:00 Make SpecConstr deal with casts better This patch does two things, to fix #23209: * It improves SpecConstr so that it no longer quantifies over coercion variables. See Note [SpecConstr and casts] * It improves the rule matcher to deal nicely with the case where the rule does not quantify over coercion variables, but the the template has a cast in it. See Note [Casts in the template] - - - - - 8db8d2fd by Zubin Duggal at 2023-12-08T05:47:54-05:00 driver: Don't lose track of nodes when we fail to resolve cycles The nodes that take part in a cycle should include both hs-boot and hs files, but when we fail to resolve a cycle, we were only counting the nodes from the graph without boot files. Fixes #24196 - - - - - c5b4efd3 by Zubin Duggal at 2023-12-08T05:48:30-05:00 testsuite: Skip MultiLayerModulesTH_OneShot on darwin See #24177 - - - - - fae472a9 by Wendao Lee at 2023-12-08T05:49:12-05:00 docs(Data.Char):Add more detailed descriptions for some functions Related changed function's docs: -GHC.Unicode.isAlpha -GHC.Unicode.isPrint -GHC.Unicode.isAlphaNum Add more details for what the function will return. Co-authored-by: Bodigrim <andrew.lelechenko at gmail.com> - - - - - ca7510e4 by Malik Ammar Faisal at 2023-12-08T05:49:55-05:00 Fix float parsing in GHC Cmm Lexer Add test case for bug #24224 - - - - - d8baa1bd by Simon Peyton Jones at 2023-12-08T15:40:37+00:00 Take care when simplifying unfoldings This MR fixes a very subtle bug exposed by #24242. See Note [Environment for simplLetUnfolding]. I also updated a bunch of Notes on shadowing - - - - - 03ca551d by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Comments only in FloatIn Relevant to #3458 - - - - - 50c78779 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Comments only in SpecConstr - - - - - 9431e195 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00 Add test for #22238 - - - - - d9e4c597 by Vladislav Zavialov at 2023-12-11T04:19:34-05:00 Make forall a keyword (#23719) Before this change, GHC used to accept `forall` as a term-level identifier: -- from constraints-0.13 forall :: forall p. (forall a. Dict (p a)) -> Dict (Forall p) forall d = ... Now it is a parse error. The -Wforall-identifier warning has served its purpose and is now a deprecated no-op. - - - - - 58d56644 by Zubin Duggal at 2023-12-11T04:20:10-05:00 driver: Ensure we actually clear the interactive context before reloading Previously we called discardIC, but immediately after set the session back to an old HscEnv that still contained the IC Partially addresses #24107 Fixes #23405 - - - - - 8e5745a0 by Zubin Duggal at 2023-12-11T04:20:10-05:00 driver: Ensure we force the lookup of old build artifacts before returning the build plan This prevents us from retaining all previous build artifacts in memory until a recompile finishes, instead only retaining the exact artifacts we need. Fixes #24118 - - - - - 105c370c by Zubin Duggal at 2023-12-11T04:20:10-05:00 testsuite: add test for #24118 and #24107 MultiLayerModulesDefsGhci was not able to catch the leak because it uses :l which discards the previous environment. Using :r catches both of these leaks - - - - - e822ff88 by Zubin Duggal at 2023-12-11T04:20:10-05:00 compiler: Add some strictness annotations to ImportSpec and related constructors This prevents us from retaining entire HscEnvs. Force these ImportSpecs when forcing the GlobalRdrEltX Adds an NFData instance for Bag Fixes #24107 - - - - - 522c12a4 by Zubin Duggal at 2023-12-11T04:20:10-05:00 compiler: Force IfGlobalRdrEnv in NFData instance. - - - - - 188b280d by Arnaud Spiwack at 2023-12-11T15:33:31+01:00 LinearTypes => MonoLocalBinds - - - - - 8e0446df by Arnaud Spiwack at 2023-12-11T15:44:28+01:00 Linear let and where bindings For expediency, the initial implementation of linear types in GHC made it so that let and where binders would always be considered unrestricted. This was rather unpleasant, and probably a big obstacle to adoption. At any rate, this was not how the proposal was designed. This patch fixes this infelicity. It was surprisingly difficult to build, which explains, in part, why it took so long to materialise. As of this patch, let or where bindings marked with %1 will be linear (respectively %p for an arbitrary multiplicity p). Unmarked let will infer their multiplicity. Here is a prototypical example of program that used to be rejected and is accepted with this patch: ```haskell f :: A %1 -> B g :: B %1 -> C h :: A %1 -> C h x = g y where y = f x ``` Exceptions: - Recursive let are unrestricted, as there isn't a clear semantics of what a linear recursive binding would be. - Destructive lets with lazy bindings are unrestricted, as their desugaring isn't linear (see also #23461). - (Strict) destructive lets with inferred polymorphic type are unrestricted. Because the desugaring isn't linear (See #18461 down-thread). Closes #18461 and #18739 Co-authored-by: @jackohughes - - - - - effa7e2d by Matthew Craven at 2023-12-12T04:37:20-05:00 Introduce `dataToTagSmall#` primop (closes #21710) ...and use it to generate slightly better code when dataToTag# is used at a "small data type" where there is no need to mess with "is_too_big_tag" or potentially look at an info table. Metric Decrease: T18304 - - - - - 35c7aef6 by Matthew Craven at 2023-12-12T04:37:20-05:00 Fix formatting of Note [alg-alt heap check] - - - - - 7397c784 by Oleg Grenrus at 2023-12-12T04:37:56-05:00 Allow untyped brackets in typed splices and vice versa. Resolves #24190 Apparently the check was essentially always (as far as I can trace back: d0d47ba76f8f0501cf3c4966bc83966ab38cac27), and while it does catch some mismatches, the type-checker will catch them too. OTOH, it prevents writing completely reasonable programs. - - - - - a3ee3b99 by Moritz Angermann at 2023-12-12T19:50:58-05:00 Drop hard Xcode dependency XCODE_VERSION calls out to `xcodebuild`, which is only available when having `Xcode` installed. The CommandLineTools are not sufficient. To install Xcode, you must have an apple id to download the Xcode.xip from apple. We do not use xcodebuild anywhere in our build explicilty. At best it appears to be a proxy for checking the linker or the compiler. These should rather be done with ``` xcrun ld -version ``` or similar, and not by proxy through Xcode. The CLR should be sufficient for building software on macOS. - - - - - 1c9496e0 by Vladislav Zavialov at 2023-12-12T19:51:34-05:00 docs: update information on RequiredTypeArguments Update the User's Guide and Release Notes to account for the recent progress in the implementation of RequiredTypeArguments. - - - - - d0b17576 by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Fix off-by-one in assertion Previously we failed to account for the NULL terminator `postString` asserted that there is enough room in the buffer for the string. - - - - - a10f9b9b by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Honor result of ensureRoomForVariableEvent is Previously we would keep plugging along, even if isn't enough room for the event. - - - - - 0e0f41c0 by Ben Gamari at 2023-12-13T06:33:37-05:00 rts/eventlog: Avoid truncating event sizes Previously ensureRoomForVariableEvent would truncate the desired size to 16-bits, resulting in #24197. Fixes #24197. - - - - - 64e724c8 by Artin Ghasivand at 2023-12-13T06:34:20-05:00 Remove the "Derived Constraint" argument of TcPluginSolver, docs - - - - - fe6d97dd by Vladislav Zavialov at 2023-12-13T06:34:56-05:00 EPA: Move tokens into GhcPs extension fields (#23447) Summary of changes * Remove Language.Haskell.Syntax.Concrete * Move all tokens into GhcPs extension fields (LHsToken -> EpToken) * Create new TTG extension fields as needed * Drop the MultAnn wrapper Updates the haddock submodule. Co-authored-by: Alan Zimmerman <alan.zimm at gmail.com> - - - - - 8106e695 by Zubin Duggal at 2023-12-13T06:35:34-05:00 testsuite: use copy_files in T23405 This prevents the tree from being dirtied when the file is modified. - - - - - ed0e4099 by Bryan Richter at 2023-12-14T04:30:53-05:00 Document ghc package's PVP-noncompliance This changes nothing, it just makes the status quo explicit. - - - - - 8bef8d9f by Luite Stegeman at 2023-12-14T04:31:33-05:00 JS: Mark spurious CI failures js_fragile(24259) This marks the spurious test failures on the JS platform as js_fragile(24259), so we don't hold up merge requests while fixing the underlying issues. See #24259 - - - - - 1c79526a by Finley McIlwaine at 2023-12-15T12:24:40-08:00 Late plugins - - - - - 000c3302 by Finley McIlwaine at 2023-12-15T12:24:40-08:00 withTiming on LateCCs and late plugins - - - - - be4551ac by Finley McIlwaine at 2023-12-15T12:24:40-08:00 add test for late plugins - - - - - 7c29da9f by Finley McIlwaine at 2023-12-15T12:24:40-08:00 Document late plugins - - - - - 9a52ae46 by Ben Gamari at 2023-12-20T07:07:26-05:00 Fix thunk update ordering Previously we attempted to ensure soundness of concurrent thunk update by synchronizing on the access of the thunk's info table pointer field. This was believed to be sufficient since the indirectee (which may expose a closure allocated by another core) would not be examined until the info table pointer update is complete. However, it turns out that this can result in data races in the presence of multiple threads racing a update a single thunk. For instance, consider this interleaving under the old scheme: Thread A Thread B --------- --------- t=0 Enter t 1 Push update frame 2 Begin evaluation 4 Pause thread 5 t.indirectee=tso 6 Release t.info=BLACKHOLE 7 ... (e.g. GC) 8 Resume thread 9 Finish evaluation 10 Relaxed t.indirectee=x 11 Load t.info 12 Acquire fence 13 Inspect t.indirectee 14 Release t.info=BLACKHOLE Here Thread A enters thunk `t` but is soon paused, resulting in `t` being lazily blackholed at t=6. Then, at t=10 Thread A finishes evaluation and updates `t.indirectee` with a relaxed store. Meanwhile, Thread B enters the blackhole. Under the old scheme this would introduce an acquire-fence but this would only synchronize with Thread A at t=6. Consequently, the result of the evaluation, `x`, is not visible to Thread B, introducing a data race. We fix this by treating the `indirectee` field as we do all other mutable fields. This means we must always access this field with acquire-loads and release-stores. See #23185. - - - - - f4b53538 by Vladislav Zavialov at 2023-12-20T07:08:02-05:00 docs: Fix link to 051-ghc-base-libraries.rst The proposal is no longer available at the previous URL. - - - - - f7e21fab by Matthew Pickering at 2023-12-21T14:57:40+00:00 hadrian: Build all executables in bin/ folder In the end the bindist creation logic copies them all into the bin folder. There is no benefit to building a specific few binaries in the lib/bin folder anymore. This also removes the ad-hoc logic to copy the touchy and unlit executables from stage0 into stage1. It takes <1s to build so we might as well just build it. - - - - - 0038d052 by Zubin Duggal at 2023-12-22T23:28:00-05:00 testsuite: mark jspace as fragile on i386. This test has been flaky for some time and has been failing consistently on i386-linux since 8e0446df landed. See #24261 - - - - - dfd670a0 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 609e6225 by Ben Bellick at 2023-12-24T10:10:31-05:00 Deprecate -ddump-json and introduce -fdiagnostics-as-json Addresses #19278 This commit deprecates the underspecified -ddump-json flag and introduces a newer, well-specified flag -fdiagnostics-as-json. Also included is a JSON schema as part of the documentation. The -ddump-json flag will be slated for removal shortly after this merge. - - - - - 865513b2 by Ömer Sinan Ağacan at 2023-12-24T10:11:13-05:00 Fix BNF in user manual 6.6.8.2: formal syntax for instance declarations - - - - - c247b6be by Zubin Duggal at 2023-12-25T16:01:23-05:00 docs: document permissibility of -XOverloadedLabels (#24249) Document the permissibility introduced by https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - e5b7eb59 by Ömer Sinan Ağacan at 2023-12-25T16:02:03-05:00 Fix a code block syntax in user manual sec. 6.8.8.6 - - - - - 2db11c08 by Ben Gamari at 2023-12-29T15:35:48-05:00 genSym: Reimplement via CAS on 32-bit platforms Previously the remaining use of the C implementation on 32-bit platforms resulted in a subtle bug, #24261. This was due to the C object (which used the RTS's `atomic_inc64` macro) being compiled without `-threaded` yet later being used in a threaded compiler. Side-step this issue by using the pure Haskell `genSym` implementation on all platforms. This required implementing `fetchAddWord64Addr#` in terms of CAS on 64-bit platforms. - - - - - 19328a8c by Xiaoyan Ren at 2023-12-29T15:36:30-05:00 Do not color the diagnostic code in error messages (#24172) - - - - - 685b467c by Krzysztof Gogolewski at 2023-12-29T15:37:06-05:00 Enforce that bindings of implicit parameters are lifted Fixes #24298 - - - - - bc4d67b7 by Matthew Craven at 2023-12-31T06:15:42-05:00 StgToCmm: Detect some no-op case-continuations ...and generate no code for them. Fixes #24264. - - - - - 5b603139 by Krzysztof Gogolewski at 2023-12-31T06:16:18-05:00 Revert "testsuite: mark jspace as fragile on i386." This reverts commit 0038d052c8c80b4b430bb2aa1c66d5280be1aa95. The atomicity bug should be fixed by !11802. - - - - - d55216ad by Krzysztof Gogolewski at 2024-01-01T12:05:49-05:00 Refactor: store [[PrimRep]] rather than [Type] in STG StgConApp stored a list of types. This list was used exclusively during unarisation of unboxed sums (mkUbxSum). However, this is at a wrong level of abstraction: STG shouldn't be concerned with Haskell types, only PrimReps. Update the code to store a [[PrimRep]]. Also, there's no point in storing this list when we're not dealing with an unboxed sum. - - - - - 8b340bc7 by Ömer Sinan Ağacan at 2024-01-01T12:06:29-05:00 Kind signatures docs: mention that they're allowed in newtypes - - - - - 989bf8e5 by Zubin Duggal at 2024-01-03T20:08:47-05:00 ci: Ensure we use the correct bindist name for the test artifact when generating release ghcup metadata Fixes #24268 - - - - - 89299a89 by Krzysztof Gogolewski at 2024-01-03T20:09:23-05:00 Refactor: remove calls to typePrimRepArgs The function typePrimRepArgs is just a thin wrapper around typePrimRep, adding a VoidRep if the list is empty. However, in StgToByteCode, we were discarding that VoidRep anyway, so there's no point in calling it. - - - - - c7be0c68 by mmzk1526 at 2024-01-03T20:10:07-05:00 Use "-V" for alex version check for better backward compatibility Fixes #24302. In recent versions of alex, "-v" is used for "--verbose" instead of "-version". - - - - - 67dbcc0a by Krzysztof Gogolewski at 2024-01-05T02:07:18-05:00 Fix VoidRep handling in ghci debugger 'go' inside extractSubTerms was giving a bad result given a VoidRep, attempting to round towards the next multiple of 0. I don't understand much about the debugger but the code should be better than it was. Fixes #24306 - - - - - 90ea574e by Krzysztof Gogolewski at 2024-01-05T02:07:54-05:00 VoidRep-related refactor * In GHC.StgToByteCode, replace bcIdPrimId with idPrimRep, bcIdArgRep with idArgRep, atomPrimRep with stgArgRep1. All of them were duplicates. * In GHC.Stg.Unarise, we were converting a PrimRep to a Type and back to PrimRep. Remove the calls to primRepToType and typePrimRep1 which cancel out. * In GHC.STG.Lint, GHC.StgToCmm, GHC.Types.RepType we were filtering out VoidRep from the result of typePrimRep. But typePrimRep never returns VoidRep - remove the filtering. - - - - - eaf72479 by brian at 2024-01-06T23:03:09-05:00 Add unaligned Addr# primops Implements CLC proposal #154: https://github.com/haskell/core-libraries-committee/issues/154 * add unaligned addr primops * add tests * accept tests * add documentation * fix js primops * uncomment in access ops * use Word64 in tests * apply suggestions * remove extra file * move docs * remove random options * use setByteArray# primop * better naming * update base-exports test * add base-exports for other architectures - - - - - d471d445 by Krzysztof Gogolewski at 2024-01-06T23:03:47-05:00 Remove VoidRep from PrimRep, introduce PrimOrVoidRep This introduces data PrimOrVoidRep = VoidRep | NVRep PrimRep changes typePrimRep1 to return PrimOrVoidRep, and adds a new function typePrimRepU to be used when the argument is definitely non-void. Details in Note [VoidRep] in GHC.Types.RepType. Fixes #19520 - - - - - 48720a07 by Matthew Craven at 2024-01-08T18:57:36-05:00 Apply Note [Sensitivity to unique increment] to LargeRecord - - - - - 9e2e180f by Sebastian Graf at 2024-01-08T18:58:13-05:00 Debugging: Add diffUFM for convenient diffing between UniqFMs - - - - - 948f3e35 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Rename Opt_D_dump_stranal to Opt_D_dump_dmdanal ... and Opt_D_dump_str_signatures to Opt_D_dump_dmd_signatures - - - - - 4e217e3e by Sebastian Graf at 2024-01-08T18:58:13-05:00 Deprecate -ddump-stranal and -ddump-str-signatures ... and suggest -ddump-dmdanal and -ddump-dmd-signatures instead - - - - - 6c613c90 by Sebastian Graf at 2024-01-08T18:58:13-05:00 Move testsuite/tests/stranal to testsuite/tests/dmdanal A separate commit so that the rename is obvious to Git(Lab) - - - - - c929f02b by Sebastian Graf at 2024-01-08T18:58:13-05:00 CoreSubst: Stricten `substBndr` and `cloneBndr` Doing so reduced allocations of `cloneBndr` by about 25%. ``` T9233(normal) ghc/alloc 672,488,656 663,083,216 -1.4% GOOD T9675(optasm) ghc/alloc 423,029,256 415,812,200 -1.7% geo. mean -0.1% minimum -1.7% maximum +0.1% ``` Metric Decrease: T9233 - - - - - e3ca78f3 by Krzysztof Gogolewski at 2024-01-10T17:35:59-05:00 Deprecate -Wsemigroup This warning was used to prepare for Semigroup becoming a superclass of Monoid, and for (<>) being exported from Prelude. This happened in GHC 8.4 in 8ae263ceb3566 and feac0a3bc69fd3. The leftover logic for (<>) has been removed in GHC 9.8, 4d29ecdfcc79. Now the warning does nothing at all and can be deprecated. - - - - - 08d14925 by amesgen at 2024-01-10T17:36:42-05:00 WASM metadata: use correct GHC version - - - - - 7a808419 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Allow SCC declarations in TH (#24081) - - - - - 28827c51 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00 Fix prettyprinting of SCC pragmas - - - - - ae9cc1a8 by Matthew Craven at 2024-01-10T17:38:01-05:00 Fix loopification in the presence of void arguments This also removes Note [Void arguments in self-recursive tail calls], which was just misleading. It's important to count void args both in the function's arity and at the call site. Fixes #24295. - - - - - b718b145 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: Teach testsuite driver about c++ sources - - - - - 09cb57ad by Zubin Duggal at 2024-01-10T17:38:36-05:00 driver: Set -DPROFILING when compiling C++ sources with profiling Earlier, we used to pass all preprocessor flags to the c++ compiler. This meant that -DPROFILING was passed to the c++ compiler because it was a part of C++ flags However, this was incorrect and the behaviour was changed in 8ff3134ed4aa323b0199ad683f72165e51a59ab6. See #21291. But that commit exposed this bug where -DPROFILING was no longer being passed when compiling c++ sources. The fix is to explicitly include -DPROFILING in `opt_cxx` when profiling is enabled to ensure we pass the correct options for the way to both C and C++ compilers Fixes #24286 - - - - - 2cf9dd96 by Zubin Duggal at 2024-01-10T17:38:36-05:00 testsuite: rename objcpp -> objcxx To avoid confusion with C Pre Processsor - - - - - af6932d6 by Simon Peyton Jones at 2024-01-10T17:39:12-05:00 Make TYPE and CONSTRAINT not-apart Issue #24279 showed up a bug in the logic in GHC.Core.Unify.unify_ty which is supposed to make TYPE and CONSTRAINT be not-apart. Easily fixed. - - - - - 4a39b5ff by Zubin Duggal at 2024-01-10T17:39:48-05:00 ci: Fix typo in mk_ghcup_metadata.py There was a missing colon in the fix to #24268 in 989bf8e53c08eb22de716901b914b3607bc8dd08 - - - - - 13503451 by Zubin Duggal at 2024-01-10T17:40:24-05:00 release-ci: remove release-x86_64-linux-deb11-release+boot_nonmoving_gc job There is no reason to have this release build or distribute this variation. This configuration is for testing purposes only. - - - - - afca46a4 by Sebastian Graf at 2024-01-10T17:41:00-05:00 Parser: Add a Note detailing why we need happy's `error` to implement layout - - - - - eaf8a06d by Krzysztof Gogolewski at 2024-01-11T00:43:17+01:00 Turn -Wtype-equality-out-of-scope on by default Also remove -Wnoncanonical-{monoid,monad}-instances from -Wcompat, since they are enabled by default. Refresh wcompat-warnings/ test with new -Wcompat warnings. Part of #24267 Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 42bee5aa by Sebastian Graf at 2024-01-12T21:16:21-05:00 Arity: Require called *exactly once* for eta exp with -fpedantic-bottoms (#24296) In #24296, we had a program in which we eta expanded away an error despite the presence of `-fpedantic-bottoms`. This was caused by turning called *at least once* lambdas into one-shot lambdas, while with `-fpedantic-bottoms` it is only sound to eta expand over lambdas that are called *exactly* once. An example can be found in `Note [Combining arity type with demand info]`. Fixes #24296. - - - - - 7e95f738 by Andreas Klebinger at 2024-01-12T21:16:57-05:00 Aarch64: Enable -mfma by default. Fixes #24311 - - - - - e43788d0 by Jason Shipman at 2024-01-14T12:47:38-05:00 Add more instances for Compose: Fractional, RealFrac, Floating, RealFloat CLC proposal #226 https://github.com/haskell/core-libraries-committee/issues/226 - - - - - ae6d8cd2 by Sebastian Graf at 2024-01-14T12:48:15-05:00 Pmc: COMPLETE pragmas associated with Family TyCons should apply to representation TyCons as well (#24326) Fixes #24326. - - - - - c5fc7304 by sheaf at 2024-01-15T14:15:29-05:00 Use lookupOccRn_maybe in TH.lookupName When looking up a value, we want to be able to find both variables and record fields. So we should not use the lookupSameOccRn_maybe function, as we can't know ahead of time which record field namespace a record field with the given textual name will belong to. Fixes #24293 - - - - - da908790 by Krzysztof Gogolewski at 2024-01-15T14:16:05-05:00 Make the build more strict on documentation errors * Detect undefined labels. This can be tested by adding :ref:`nonexistent` to a documentation rst file; attempting to build docs will fail. Fixed the undefined label in `9.8.1-notes.rst`. * Detect errors. While we have plenty of warnings, we can at least enforce that Sphinx does not report errors. Fixed the error in `required_type_arguments.rst`. Unrelated change: I have documented that the `-dlint` enables `-fcatch-nonexhaustive-cases`, as can be verified by checking `enableDLint`. - - - - - 5077416e by Javier Sagredo at 2024-01-16T15:40:06-05:00 Profiling: Adds an option to not start time profiling at startup Using the functionality provided by d89deeba47ce04a5198a71fa4cbc203fe2c90794, this patch creates a new rts flag `--no-automatic-time-samples` which disables the time profiling when starting a program. It is then expected that the user starts it whenever it is needed. Fixes #24337 - - - - - 5776008c by Matthew Pickering at 2024-01-16T15:40:42-05:00 eventlog: Fix off-by-one error in postIPE We were missing the extra_comma from the calculation of the size of the payload of postIPE. This was causing assertion failures when the event would overflow the buffer by one byte, as ensureRoomForVariable event would report there was enough space for `n` bytes but then we would write `n + 1` bytes into the buffer. Fixes #24287 - - - - - 66dc09b1 by Simon Peyton Jones at 2024-01-16T15:41:18-05:00 Improve SpecConstr (esp nofib/spectral/ansi) This MR makes three improvements to SpecConstr: see #24282 * It fixes an outright (and recently-introduced) bug in `betterPat`, which was wrongly forgetting to compare the lengths of the argument lists. * It enhances ConVal to inclue a boolean for work-free-ness, so that the envt can contain non-work-free constructor applications, so that we can do more: see Note [ConVal work-free-ness] * It rejigs `subsumePats` so that it doesn't reverse the list. This can make a difference because, when patterns overlap, we arbitrarily pick the first. There is no "right" way, but this retains the old pre-subsumePats behaviour, thereby "fixing" the regression in #24282. Nofib results +======================================== | spectral/ansi -21.14% | spectral/hartel/comp_lab_zift -0.12% | spectral/hartel/parstof +0.09% | spectral/last-piece -2.32% | spectral/multiplier +6.03% | spectral/para +0.60% | spectral/simple -0.26% +======================================== | geom mean -0.18% +---------------------------------------- The regression in `multiplier` is sad, but it simply replicates GHC's previous behaviour (e.g. GHC 9.6). - - - - - 65da79b3 by Matthew Pickering at 2024-01-16T15:41:54-05:00 hadrian: Reduce Cabal verbosity The comment claims that `simpleUserHooks` decrease verbosity, and it does, but only for the `postConf` phase. The other phases are too verbose with `-V`. At the moment > 5000 lines of the build log are devoted to output from `cabal copy`. So I take the simple approach and just decrease the verbosity level again. If the output of `postConf` is essential then it would be better to implement our own `UserHooks` which doesn't decrease the verbosity for `postConf`. Fixes #24338 - - - - - 16414d7d by Matthew Pickering at 2024-01-17T10:54:59-05:00 Stop retaining old ModGuts throughout subsequent simplifier phases Each phase of the simplifier typically rewrites the majority of ModGuts, so we want to be able to release the old ModGuts as soon as possible. `name_ppr_ctxt` lives throught the whole optimiser phase and it was retaining a reference to `ModGuts`, so we were failing to release the old `ModGuts` until the end of the phase (potentially doubling peak memory usage for that particular phase). This was discovered using eras profiling (#24332) Fixes #24328 - - - - - 7f0879e1 by Matthew Pickering at 2024-01-17T10:55:35-05:00 Update nofib submodule - - - - - 320454d3 by Cheng Shao at 2024-01-17T23:02:40+00:00 ci: bump ci-images for updated wasm image - - - - - 2eca52b4 by Cheng Shao at 2024-01-17T23:06:44+00:00 base: treat all FDs as "nonblocking" on wasm On posix platforms, when performing read/write on FDs, we check the nonblocking flag first. For FDs without this flag (e.g. stdout), we call fdReady() first, which in turn calls poll() to wait for I/O to be available on that FD. This is problematic for wasm32-wasi: although select()/poll() is supported via the poll_oneoff() wasi syscall, that syscall is rather heavyweight and runtime behavior differs in different wasi implementations. The issue is even worse when targeting browsers, given there's no satisfactory way to implement async I/O as a synchronous syscall, so existing JS polyfills for wasi often give up and simply return ENOSYS. Before we have a proper I/O manager that avoids poll_oneoff() for async I/O on wasm, this patch improves the status quo a lot by merely pretending all FDs are "nonblocking". Read/write on FDs will directly invoke read()/write(), which are much more reliably handled in existing wasi implementations, especially those in browsers. Fixes #23275 and the following test cases: T7773 isEOF001 openFile009 T4808 cgrun025 Approved by CLC proposal #234: https://github.com/haskell/core-libraries-committee/issues/234 - - - - - 83c6c710 by Andrew Lelechenko at 2024-01-18T05:21:49-05:00 base: clarify how to disable warnings about partiality of Data.List.{head,tail} - - - - - c4078f2f by Simon Peyton Jones at 2024-01-18T05:22:25-05:00 Fix four bug in handling of (forall cv. body_ty) These bugs are all described in #24335 It's not easy to provoke the bug, hence no test case. - - - - - 119586ea by Alexis King at 2024-01-19T00:08:00-05:00 Always refresh profiling CCSes after running pending initializers Fixes #24171. - - - - - 9718d970 by Oleg Grenrus at 2024-01-19T00:08:36-05:00 Set default-language: GHC2021 in ghc library Go through compiler/ sources, and remove all BangPatterns (and other GHC2021 enabled extensions in these files). - - - - - 3ef71669 by Matthew Pickering at 2024-01-19T21:55:16-05:00 testsuite: Remove unused have_library function Also remove the hence unused testsuite option `--test-package-db`. Fixes #24342 - - - - - 5b7fa20c by Jade at 2024-01-19T21:55:53-05:00 Fix Spelling in the compiler Tracking: #16591 - - - - - 09875f48 by Matthew Pickering at 2024-01-20T12:20:44-05:00 testsuite: Implement `isInTreeCompiler` in a more robust way Just a small refactoring to avoid redundantly specifying the same strings in two different places. - - - - - 0d12b987 by Jade at 2024-01-20T12:21:20-05:00 Change maintainer email from cvs-ghc at haskell.org to ghc-devs at haskell.org. Fixes #22142 - - - - - 1fa1c00c by Jade at 2024-01-23T19:17:03-05:00 Enhance Documentation of functions exported by Data.Function This patch aims to improve the documentation of functions exported in Data.Function Tracking: #17929 Fixes: #10065 - - - - - ab47a43d by Jade at 2024-01-23T19:17:39-05:00 Improve documentation of hGetLine. - Add explanation for whether a newline is returned - Add examples Fixes #14804 - - - - - dd4af0e5 by Cheng Shao at 2024-01-23T19:18:17-05:00 Fix genapply for cross-compilation by nuking fragile CPP logic This commit fixes incorrectly built genapply when cross compiling (#24347) by nuking all fragile CPP logic in it from the orbit. All target-specific info are now read from DerivedConstants.h at runtime, see added note for details. Also removes a legacy Makefile and adds haskell language server support for genapply. - - - - - 0cda2b8b by Cheng Shao at 2024-01-23T19:18:17-05:00 rts: enable wasm32 register mapping The wasm backend didn't properly make use of all Cmm global registers due to #24347. Now that it is fixed, this patch re-enables full register mapping for wasm32, and we can now generate smaller & faster wasm modules that doesn't always spill arguments onto the stack. Fixes #22460 #24152. - - - - - 0325a6e5 by Greg Steuck at 2024-01-24T01:29:44-05:00 Avoid utf8 in primops.txt.pp comments They don't make it through readFile' without explicitly setting the encoding. See https://gitlab.haskell.org/ghc/ghc/-/issues/17755 - - - - - 1aaf0bd8 by David Binder at 2024-01-24T01:30:20-05:00 Bump hpc and hpc-bin submodule Bump hpc to 0.7.0.1 Bump hpc-bin to commit d1780eb2 - - - - - e693a4e8 by Ben Gamari at 2024-01-24T01:30:56-05:00 testsuite: Ignore stderr in T8089 Otherwise spurious "Killed: 9" messages to stderr may cause the test to fail. Fixes #24361. - - - - - a40f4ab2 by sheaf at 2024-01-24T14:04:33-05:00 Fix FMA instruction on LLVM We were emitting the wrong instructions for fused multiply-add operations on LLVM: - the instruction name is "llvm.fma.f32" or "llvm.fma.f64", not "fmadd" - LLVM does not support other instructions such as "fmsub"; instead we implement these by flipping signs of some arguments - the instruction is an LLVM intrinsic, which requires handling it like a normal function call instead of a machine instruction Fixes #24223 - - - - - 69abc786 by Andrei Borzenkov at 2024-01-24T14:05:09-05:00 Add changelog entry for renaming tuples from (,,...,,) to Tuple<n> (24291) - - - - - 0ac8f385 by Cheng Shao at 2024-01-25T00:27:48-05:00 compiler: remove unused GHC.Linker module The GHC.Linker module is empty and unused, other than as a hack for the make build system. We can remove it now that make is long gone; the note is moved to GHC.Linker.Loader instead. - - - - - 699da01b by Hécate Moonlight at 2024-01-25T00:28:27-05:00 Clarification for newtype constructors when using `coerce` - - - - - b2d8cd85 by Matt Walker at 2024-01-26T09:50:08-05:00 Fix #24308 Add tests for semicolon separated where clauses - - - - - 0da490a1 by Ben Gamari at 2024-01-26T17:34:41-05:00 hsc2hs: Bump submodule - - - - - 3f442fd2 by Ben Gamari at 2024-01-26T17:34:41-05:00 Bump containers submodule to 0.7 - - - - - 82a1c656 by Sebastian Nagel at 2024-01-29T02:32:40-05:00 base: with{Binary}File{Blocking} only annotates own exceptions Fixes #20886 This ensures that inner, unrelated exceptions are not misleadingly annotated with the opened file. - - - - - 9294a086 by Andreas Klebinger at 2024-01-29T02:33:15-05:00 Fix fma warning when using llvm on aarch64. On aarch64 fma is always on so the +fma flag doesn't exist for that target. Hence no need to try and pass +fma to llvm. Fixes #24379 - - - - - ced2e731 by sheaf at 2024-01-29T17:27:12-05:00 No shadowing warnings for NoFieldSelector fields This commit ensures we don't emit shadowing warnings when a user shadows a field defined with NoFieldSelectors. Fixes #24381 - - - - - 8eeadfad by Patrick at 2024-01-29T17:27:51-05:00 Fix bug wrong span of nested_doc_comment #24378 close #24378 1. Update the start position of span in `nested_doc_comment` correctly. and hence the spans of identifiers of haddoc can be computed correctly. 2. add test `HaddockSpanIssueT24378`. - - - - - a557580f by Alexey Radkov at 2024-01-30T19:41:52-05:00 Fix irrelevant dodgy-foreign-imports warning on import f-pointers by value A test *сс018* is attached (not sure about the naming convention though). Note that without the fix, the test fails with the *dodgy-foreign-imports* warning passed to stderr. The warning disappears after the fix. GHC shouldn't warn on imports of natural function pointers from C by value (which is feasible with CApiFFI), such as ```haskell foreign import capi "cc018.h value f" f :: FunPtr (Int -> IO ()) ``` where ```c void (*f)(int); ``` See a related real-world use-case [here](https://gitlab.com/daniel-casanueva/pcre-light/-/merge_requests/17). There, GHC warns on import of C function pointer `pcre_free`. - - - - - ca99efaf by Alexey Radkov at 2024-01-30T19:41:53-05:00 Rename test cc018 -> T24034 - - - - - 88c38dd5 by Ben Gamari at 2024-01-30T19:42:28-05:00 rts/TraverseHeap.c: Ensure that PosixSource.h is included first - - - - - ca2e919e by Simon Peyton Jones at 2024-01-31T09:29:45+00:00 Make decomposeRuleLhs a bit more clever This fixes #24370 by making decomposeRuleLhs undertand dictionary /functions/ as well as plain /dictionaries/ - - - - - 94ce031d by Teo Camarasu at 2024-02-01T05:49:49-05:00 doc: Add -Dn flag to user guide Resolves #24394 - - - - - 31553b11 by Ben Gamari at 2024-02-01T12:21:29-05:00 cmm: Introduce MO_RelaxedRead In hand-written Cmm it can sometimes be necessary to atomically load from memory deep within an expression (e.g. see the `CHECK_GC` macro). This MachOp provides a convenient way to do so without breaking the expression into multiple statements. - - - - - 0785cf81 by Ben Gamari at 2024-02-01T12:21:29-05:00 codeGen: Use relaxed accesses in ticky bumping - - - - - be423dda by Ben Gamari at 2024-02-01T12:21:29-05:00 base: use atomic write when updating timer manager - - - - - 8a310e35 by Ben Gamari at 2024-02-01T12:21:29-05:00 Use relaxed atomics to manipulate TSO status fields - - - - - d6809ee4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Add necessary barriers when manipulating TSO owner - - - - - 39e3ac5d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Use `switch` to branch on why_blocked This is a semantics-preserving refactoring. - - - - - 515eb33d by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix synchronization on thread blocking state We now use a release barrier whenever we update a thread's blocking state. This required widening StgTSO.why_blocked as AArch64 does not support atomic writes on 16-bit values. - - - - - eb38812e by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadPaused This only affects an assertion in the debug RTS and only needs relaxed ordering. - - - - - 26c48dd6 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in threadStatus# - - - - - 6af43ab4 by Ben Gamari at 2024-02-01T12:21:29-05:00 rts: Fix data race in Interpreter's preemption check - - - - - 9502ad3c by Ben Gamari at 2024-02-01T12:21:29-05:00 rts/Messages: Fix data race - - - - - 60802db5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts/Prof: Fix data race - - - - - ef8ccef5 by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use relaxed ordering on dirty/clean info tables updates When changing the dirty/clean state of a mutable object we needn't have any particular ordering. - - - - - 76fe2b75 by Ben Gamari at 2024-02-01T12:21:30-05:00 codeGen: Use relaxed-read in closureInfoPtr - - - - - a6316eb4 by Ben Gamari at 2024-02-01T12:21:30-05:00 STM: Use acquire loads when possible Full sequential consistency is not needed here. - - - - - 6bddfd3d by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Use fence rather than redundant load Previously we would use an atomic load to ensure acquire ordering. However, we now have `ACQUIRE_FENCE_ON`, which allows us to express this more directly. - - - - - 55c65dbc by Ben Gamari at 2024-02-01T12:21:30-05:00 rts: Fix data races in profiling timer - - - - - 856b5e75 by Ben Gamari at 2024-02-01T12:21:30-05:00 Add Note [C11 memory model] - - - - - 6534da24 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: move generic cmm optimization logic in NCG to a standalone module This commit moves GHC.CmmToAsm.cmmToCmm to a standalone module, GHC.Cmm.GenericOpt. The main motivation is enabling this logic to be run in the wasm backend NCG code, which is defined in other modules that's imported by GHC.CmmToAsm, causing a cyclic dependency issue. - - - - - 87e34888 by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: explicitly disable PIC in wasm32 NCG This commit explicitly disables the ncgPIC flag for the wasm32 target. The wasm backend doesn't support PIC for the time being. - - - - - c6ce242e by Cheng Shao at 2024-02-01T12:22:07-05:00 compiler: enable generic cmm optimizations in wasm backend NCG This commit enables the generic cmm optimizations in other NCGs to be run in the wasm backend as well, followed by a late cmm control-flow optimization pass. The added optimizations do catch some corner cases not handled by the pre-NCG cmm pipeline and are useful in generating smaller CFGs. - - - - - 151dda4e by Andrei Borzenkov at 2024-02-01T12:22:43-05:00 Namespacing for WARNING/DEPRECATED pragmas (#24396) New syntax for WARNING and DEPRECATED pragmas was added, namely namespace specifierss: namespace_spec ::= 'type' | 'data' | {- empty -} warning ::= warning_category namespace_spec namelist strings deprecation ::= namespace_spec namelist strings A new data type was introduced to represent these namespace specifiers: data NamespaceSpecifier = NoSpecifier | TypeNamespaceSpecifier (EpToken "type") | DataNamespaceSpecifier (EpToken "data") Extension field XWarning now contains this NamespaceSpecifier. lookupBindGroupOcc function was changed: it now takes NamespaceSpecifier and checks that the namespace of the found names matches the passed flag. With this change {-# WARNING data D "..." #-} pragma will only affect value namespace and {-# WARNING type D "..." #-} will only affect type namespace. The same logic is applicable to DEPRECATED pragmas. Finding duplicated warnings inside rnSrcWarnDecls now takes into consideration NamespaceSpecifier flag to allow warnings with the same names that refer to different namespaces. - - - - - 38c3afb6 by Bryan Richter at 2024-02-01T12:23:19-05:00 CI: Disable the test-cabal-reinstall job Fixes #24363 - - - - - 27020458 by Matthew Craven at 2024-02-03T01:53:26-05:00 Bump bytestring submodule to something closer to 0.12.1 ...mostly so that 16d6b7e835ffdcf9b894e79f933dd52348dedd0c (which reworks unaligned writes in Builder) and the stuff in https://github.com/haskell/bytestring/pull/631 can see wider testing. The less-terrible code for unaligned writes used in Builder on hosts not known to be ulaigned-friendly also takes less effort for GHC to compile, resulting in a metric decrease for T21839c on some platforms. The metric increase on T21839r is caused by the unrelated commit 750dac33465e7b59100698a330b44de7049a345c. It perhaps warrants further analysis and discussion (see #23822) but is not critical. Metric Decrease: T21839c Metric Increase: T21839r - - - - - cdddeb0f by Rodrigo Mesquita at 2024-02-03T01:54:02-05:00 Work around autotools setting C11 standard in CC/CXX In autoconf >=2.70, C11 is set by default for $CC and $CXX via the -std=...11 flag. In this patch, we split the "-std" flag out of the $CC and $CXX variables, which we traditionally assume to be just the executable name/path, and move it to $CFLAGS/$CXXFLAGS instead. Fixes #24324 - - - - - 5ff7cc26 by Apoorv Ingle at 2024-02-03T13:14:46-06:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - The change is detailed in - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` - Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - Adds new datatypes: - `GHC.Hs.Expr.XXExprGhcRn`: new datatype makes this expansion work easier 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - Ensures warnings such as 1. Pattern match checks 2. Failable patterns 3. non-() return in body statements are preserved - Kill `HsMatchCtxt` in favor of `TcMatchAltChecker` - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) Also repoint haddock to the right submodule so that the test (haddockHypsrcTest) pass Metric Increase 'compile_time/bytes allocated': T9020 The testcase is a pathalogical example of a `do`-block with many statements that do nothing. Given that we are expanding the statements into function binds, we will have to bear a (small) 2% cost upfront in the compiler to unroll the statements. - - - - - 0df8ce27 by Vladislav Zavialov at 2024-02-04T03:55:14-05:00 Reduce parser allocations in allocateCommentsP In the most common case, the comment queue is empty, so we can skip the work of processing it. This reduces allocations by about 10% in the parsing001 test. Metric Decrease: MultiLayerModulesRecomp parsing001 - - - - - cfd68290 by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Stop dropping a case whose binder is demanded This MR fixes #24251. See Note [Case-to-let for strictly-used binders] in GHC.Core.Opt.Simplify.Iteration, plus #24251, for lots of discussion. Final Nofib changes over 0.1%: +----------------------------------------- | imaginary/digits-of-e2 -2.16% | imaginary/rfib -0.15% | real/fluid -0.10% | real/gamteb -1.47% | real/gg -0.20% | real/maillist +0.19% | real/pic -0.23% | real/scs -0.43% | shootout/n-body -0.41% | shootout/spectral-norm -0.12% +======================================== | geom mean -0.05% Pleasingly, overall executable size is down by just over 1%. Compile times (in perf/compiler) wobble around a bit +/- 0.5%, but the geometric mean is -0.1% which seems good. - - - - - e4d137bb by Simon Peyton Jones at 2024-02-05T17:58:33-05:00 Add Note [Bangs in Integer functions] ...to document the bangs in the functions in GHC.Num.Integer - - - - - ce90f12f by Andrei Borzenkov at 2024-02-05T17:59:09-05:00 Hide WARNING/DEPRECATED namespacing under -XExplicitNamespaces (#24396) - - - - - e2ea933f by Simon Peyton Jones at 2024-02-06T10:12:04-05:00 Refactoring in preparation for lazy skolemisation * Make HsMatchContext and HsStmtContext be parameterised over the function name itself, rather than over the pass. See [mc_fun field of FunRhs] in Language.Haskell.Syntax.Expr - Replace types HsMatchContext GhcPs --> HsMatchContextPs HsMatchContext GhcRn --> HsMatchContextRn HsMatchContext GhcTc --> HsMatchContextRn (sic! not Tc) HsStmtContext GhcRn --> HsStmtContextRn - Kill off convertHsMatchCtxt * Split GHC.Tc.Type.BasicTypes.TcSigInfo so that TcCompleteSig (describing a complete user-supplied signature) is its own data type. - Split TcIdSigInfo(CompleteSig, PartialSig) into TcCompleteSig(CSig) TcPartialSig(PSig) - Use TcCompleteSig in tcPolyCheck, CheckGen - Rename types and data constructors: TcIdSigInfo --> TcIdSig TcPatSynInfo(TPSI) --> TcPatSynSig(PatSig) - Shuffle around helper functions: tcSigInfoName (moved to GHC.Tc.Types.BasicTypes) completeSigPolyId_maybe (moved to GHC.Tc.Types.BasicTypes) tcIdSigName (inlined and removed) tcIdSigLoc (introduced) - Rearrange the pattern match in chooseInferredQuantifiers * Rename functions and types: tcMatchesCase --> tcCaseMatches tcMatchesFun --> tcFunBindMatches tcMatchLambda --> tcLambdaMatches tcPats --> tcMatchPats matchActualFunTysRho --> matchActualFunTys matchActualFunTySigma --> matchActualFunTy * Add HasDebugCallStack constraints to: mkBigCoreVarTupTy, mkBigCoreTupTy, boxTy, mkPiTy, mkPiTys, splitAppTys, splitTyConAppNoView_maybe * Use `penv` from the outer context in the inner loop of GHC.Tc.Gen.Pat.tcMultiple * Move tcMkVisFunTy, tcMkInvisFunTy, tcMkScaledFunTys down the file, factor out and export tcMkScaledFunTy. * Move isPatSigCtxt down the file. * Formatting and comments Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - f5d3e03c by Andrei Borzenkov at 2024-02-06T10:12:04-05:00 Lazy skolemisation for @a-binders (#17594) This patch is a preparation for @a-binders implementation. The main changes are: * Skolemisation is now prepared to deal with @binders. See Note [Skolemisation overview] in GHC.Tc.Utils.Unify. Most of the action is in - Utils.Unify.matchExpectedFunTys - Gen.Pat.tcMatchPats - Gen.Expr.tcPolyExprCheck - Gen.Binds.tcPolyCheck Some accompanying refactoring: * I found that funTyConAppTy_maybe was doing a lot of allocation, and rejigged userTypeError_maybe to avoid calling it. - - - - - 532993c8 by Zubin Duggal at 2024-02-06T10:12:41-05:00 driver: Really don't lose track of nodes when we fail to resolve cycles This fixes a bug in 8db8d2fd1c881032b1b360c032b6d9d072c11723, where we could lose track of acyclic components at the start of an unresolved cycle. We now ensure we never loose track of any of these components. As T24275 demonstrates, a "cyclic" SCC might not really be a true SCC: When viewed without boot files, we have a single SCC ``` [REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A [main:T24275A {-# SOURCE #-}]] ``` But with boot files this turns into ``` [NONREC main:T24275B {-# SOURCE #-} [], REC main:T24275B [main:T24275B {-# SOURCE #-}, main:T24275A {-# SOURCE #-}] main:T24275A {-# SOURCE #-} [main:T24275B], NONREC main:T24275A [main:T24275A {-# SOURCE #-}]] ``` Note that this is truly not an SCC, as no nodes are reachable from T24275B.hs-boot. However, we treat this entire group as a single "SCC" because it seems so when we analyse the graph without taking boot files into account. Indeed, we must return a single ResolvedCycle element in the BuildPlan for this as described in Note [Upsweep]. However, since after resolving this is not a true SCC anymore, `findCycle` fails to find a cycle and we have a sub-optimal error message as a result. To handle this, I extended `findCycle` to not assume its input is an SCC, and to try harder to find cycles in its input. Fixes #24275 - - - - - b35dd613 by Zubin Duggal at 2024-02-06T10:13:17-05:00 GHCi: Lookup breakpoint CCs in the correct module We need to look up breakpoint CCs in the module that the breakpoint points to, and not the current module. Fixes #24327 - - - - - b09e6958 by Zubin Duggal at 2024-02-06T10:13:17-05:00 testsuite: Add test for #24327 - - - - - 569b4c10 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add compile_artifact, ignore_extension flag In b521354216f2821e00d75f088d74081d8b236810 the testsuite gained the capability to collect generic metrics. But this assumed that the test was not linking and producing artifacts and we only wanted to track object files, interface files, or build artifacts from the compiler build. However, some backends, such as the JS backend, produce artifacts when compiling, such as the jsexe directory which we want to track. This patch: - tweaks the testsuite to collect generic metrics on any build artifact in the test directory. - expands the exe_extension function to consider windows and adds the ignore_extension flag. - Modifies certain tests to add the ignore_extension flag. Tests such as heaprof002 expect a .ps file, but on windows without ignore_extensions the testsuite will look for foo.exe.ps. Hence the flag. - adds the size_hello_artifact test - - - - - 75a31379 by doyougnu at 2024-02-07T03:06:26-05:00 ts: add wasm_arch, heapprof002 wasm extension - - - - - c9731d6d by Rodrigo Mesquita at 2024-02-07T03:07:03-05:00 Synchronize bindist configure for #24324 In cdddeb0f1280b40cc194028bbaef36e127175c4c, we set up a workaround for #24324 in the in-tree configure script, but forgot to update the bindist configure script accordingly. This updates it. - - - - - d309f4e7 by Matthew Pickering at 2024-02-07T03:07:38-05:00 distrib/configure: Fix typo in CONF_GCC_LINKER_OPTS_STAGE2 variable Instead we were setting CONF_GCC_LINK_OPTS_STAGE2 which meant that we were missing passing `--target` when invoking the linker. Fixes #24414 - - - - - 77db84ab by Ben Gamari at 2024-02-08T00:35:22-05:00 llvmGen: Adapt to allow use of new pass manager. We now must use `-passes` in place of `-O<n>` due to #21936. Closes #21936. - - - - - 3c9ddf97 by Matthew Pickering at 2024-02-08T00:35:59-05:00 testsuite: Mark length001 as fragile on javascript Modifying the timeout multiplier is not a robust way to get this test to reliably fail. Therefore we mark it as fragile until/if javascript ever supports the stack limit. - - - - - 20b702b5 by Matthew Pickering at 2024-02-08T00:35:59-05:00 Javascript: Don't filter out rtsDeps list This logic appears to be incorrect as it would drop any dependency which was not in a direct dependency of the package being linked. In the ghc-internals split this started to cause errors because `ghc-internal` is not a direct dependency of most packages, and hence important symbols to keep which are hard coded into the js runtime were getting dropped. - - - - - 2df96366 by Ben Gamari at 2024-02-08T00:35:59-05:00 base: Cleanup whitespace in cbits - - - - - 44f6557a by Ben Gamari at 2024-02-08T00:35:59-05:00 Move `base` to `ghc-internal` Here we move a good deal of the implementation of `base` into a new package, `ghc-internal` such that it can be evolved independently from the user-visible interfaces of `base`. While we want to isolate implementation from interfaces, naturally, we would like to avoid turning `base` into a mere set of module re-exports. However, this is a non-trivial undertaking for a variety of reasons: * `base` contains numerous known-key and wired-in things, requiring corresponding changes in the compiler * `base` contains a significant amount of C code and corresponding autoconf logic, which is very fragile and difficult to break apart * `base` has numerous import cycles, which are currently dealt with via carefully balanced `hs-boot` files * We must not break existing users To accomplish this migration, I tried the following approaches: * [Split-GHC.Base]: Break apart the GHC.Base knot to allow incremental migration of modules into ghc-internal: this knot is simply too intertwined to be easily pulled apart, especially given the rather tricky import cycles that it contains) * [Move-Core]: Moving the "core" connected component of base (roughly 150 modules) into ghc-internal. While the Haskell side of this seems tractable, the C dependencies are very subtle to break apart. * [Move-Incrementally]: 1. Move all of base into ghc-internal 2. Examine the module structure and begin moving obvious modules (e.g. leaves of the import graph) back into base 3. Examine the modules remaining in ghc-internal, refactor as necessary to facilitate further moves 4. Go to (2) iterate until the cost/benefit of further moves is insufficient to justify continuing 5. Rename the modules moved into ghc-internal to ensure that they don't overlap with those in base 6. For each module moved into ghc-internal, add a shim module to base with the declarations which should be exposed and any requisite Haddocks (thus guaranteeing that base will be insulated from changes in the export lists of modules in ghc-internal Here I am using the [Move-Incrementally] approach, which is empirically the least painful of the unpleasant options above Bumps haddock submodule. Metric Decrease: haddock.Cabal haddock.base Metric Increase: MultiComponentModulesRecomp T16875 size_hello_artifact - - - - - e8fb2451 by Vladislav Zavialov at 2024-02-08T00:36:36-05:00 Haddock comments on infix constructors (#24221) Rewrite the `HasHaddock` instance for `ConDecl GhcPs` to account for infix constructors. This change fixes a Haddock regression (introduced in 19e80b9af252) that affected leading comments on infix data constructor declarations: -- | Docs for infix constructor | Int :* Bool The comment should be associated with the data constructor (:*), not with its left-hand side Int. - - - - - 9060d55b by Ben Gamari at 2024-02-08T00:37:13-05:00 Add os-string as a boot package Introduces `os-string` submodule. This will be necessary for `filepath-1.5`. - - - - - 9d65235a by Ben Gamari at 2024-02-08T00:37:13-05:00 gitignore: Ignore .hadrian_ghci_multi/ - - - - - d7ee12ea by Ben Gamari at 2024-02-08T00:37:13-05:00 hadrian: Set -this-package-name When constructing the GHC flags for a package Hadrian must take care to set `-this-package-name` in addition to `-this-unit-id`. This hasn't broken until now as we have not had any uses of qualified package imports. However, this will change with `filepath-1.5` and the corresponding `unix` bump, breaking `hadrian/multi-ghci`. - - - - - f2dffd2e by Ben Gamari at 2024-02-08T00:37:13-05:00 Bump filepath to 1.5.0.0 Required bumps of the following submodules: * `directory` * `filepath` * `haskeline` * `process` * `unix` * `hsc2hs` * `Win32` * `semaphore-compat` and the addition of `os-string` as a boot package. - - - - - ab533e71 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Use specific clang assembler when compiling with -fllvm There are situations where LLVM will produce assembly which older gcc toolchains can't handle. For example on Deb10, it seems that LLVM >= 13 produces assembly which the default gcc doesn't support. A more robust solution in the long term is to require a specific LLVM compatible assembler when using -fllvm. Fixes #16354 - - - - - c32b6426 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update CI images with LLVM 15, ghc-9.6.4 and cabal-install-3.10.2.0 - - - - - 5fcd58be by Matthew Pickering at 2024-02-08T00:37:50-05:00 Update bootstrap plans for 9.4.8 and 9.6.4 - - - - - 707a32f5 by Matthew Pickering at 2024-02-08T00:37:50-05:00 Add alpine 3_18 release job This is mainly experimental and future proofing to enable a smooth transition to newer alpine releases once 3_12 is too old. - - - - - c37931b3 by John Ericson at 2024-02-08T06:39:05-05:00 Generate LLVM min/max bound policy via Hadrian Per #23966, I want the top-level configure to only generate configuration data for Hadrian, not do any "real" tasks on its own. This is part of that effort --- one less file generated by it. (It is still done with a `.in` file, so in a future world non-Hadrian also can easily create this file.) Split modules: - GHC.CmmToLlvm.Config - GHC.CmmToLlvm.Version - GHC.CmmToLlvm.Version.Bounds - GHC.CmmToLlvm.Version.Type This also means we can get rid of the silly `unused.h` introduced in !6803 / 7dfcab2f4bcb7206174ea48857df1883d05e97a2 as temporary kludge. Part of #23966 - - - - - 9f987235 by Apoorv Ingle at 2024-02-08T06:39:42-05:00 Enable mdo statements to use HsExpansions Fixes: #24411 Added test T24411 for regression - - - - - 762b2120 by Jade at 2024-02-08T15:17:15+00:00 Improve Monad, Functor & Applicative docs This patch aims to improve the documentation of Functor, Applicative, Monad and related symbols. The main goal is to make it more consistent and make accessible. See also: !10979 (closed) and !10985 (closed) Ticket #17929 Updates haddock submodule - - - - - 151770ca by Josh Meredith at 2024-02-10T14:28:15-05:00 JavaScript codegen: Use GHC's tag inference where JS backend-specific evaluation inference was previously used (#24309) - - - - - 2e880635 by Zubin Duggal at 2024-02-10T14:28:51-05:00 ci: Allow release-hackage-lint to fail Otherwise it blocks the ghcup metadata pipeline from running. - - - - - b0293f78 by Matthew Pickering at 2024-02-10T14:29:28-05:00 rts: eras profiling mode The eras profiling mode is useful for tracking the life-time of closures. When a closure is written, the current era is recorded in the profiling header. This records the era in which the closure was created. * Enable with -he * User mode: Use functions ghc-experimental module GHC.Profiling.Eras to modify the era * Automatically: --automatic-era-increment, increases the user era on major collections * The first era is era 1 * -he<era> can be used with other profiling modes to select a specific era If you just want to record the era but not to perform heap profiling you can use `-he --no-automatic-heap-samples`. https://well-typed.com/blog/2024/01/ghc-eras-profiling/ Fixes #24332 - - - - - be674a2c by Jade at 2024-02-10T14:30:04-05:00 Adjust error message for trailing whitespace in as-pattern. Fixes #22524 - - - - - 53ef83f9 by doyougnu at 2024-02-10T14:30:47-05:00 gitlab: js: add codeowners Fixes: - #24409 Follow on from: - #21078 and MR !9133 - When we added the JS backend this was forgotten. This patch adds the rightful codeowners. - - - - - 8bbe12f2 by Matthew Pickering at 2024-02-10T14:31:23-05:00 Bump CI images so that alpine3_18 image includes clang15 The only changes here are that clang15 is now installed on the alpine-3_18 image. - - - - - df9fd9f7 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: handle stored null StablePtr Some Haskell codes unsafely cast StablePtr into ptr to compare against NULL. E.g. in direct-sqlite: if castStablePtrToPtr aggStPtr /= nullPtr then where `aggStPtr` is read (`peek`) from zeroed memory initially. We fix this by giving these StablePtr the same representation as other null pointers. It's safe because StablePtr at offset 0 is unused (for this exact reason). - - - - - 55346ede by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: disable MergeObjsMode test This isn't implemented for JS backend objects. - - - - - aef587f6 by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: add support for linking C sources Support linking C sources with JS output of the JavaScript backend. See the added documentation in the users guide. The implementation simply extends the JS linker to use the objects (.o) that were already produced by the emcc compiler and which were filtered out previously. I've also added some options to control the link with C functions (see the documentation about pragmas). With this change I've successfully compiled the direct-sqlite package which embeds the sqlite.c database code. Some wrappers are still required (see the documentation about wrappers) but everything generic enough to be reused for other libraries have been integrated into rts/js/mem.js. - - - - - b71b392f by Sylvain Henry at 2024-02-12T12:18:42-05:00 JS: avoid EMCC logging spurious failure emcc would sometime output messages like: cache:INFO: generating system asset: symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json" for subsequent builds) cache:INFO: - ok Cf https://github.com/emscripten-core/emscripten/issues/18607 This breaks our tests matching the stderr output. We avoid this by setting EMCC_LOGGING=0 - - - - - ff2c0cc9 by Simon Peyton Jones at 2024-02-12T12:19:17-05:00 Remove a dead comment Just remove an out of date block of commented-out code, and tidy up the relevant Notes. See #8317. - - - - - bedb4f0d by Teo Camarasu at 2024-02-12T18:50:33-05:00 nonmoving: Add support for heap profiling Add support for heap profiling while using the nonmoving collector. We greatly simply the implementation by disabling concurrent collection for GCs when heap profiling is enabled. This entails that the marked objects on the nonmoving heap are exactly the live objects. Note that we match the behaviour for live bytes accounting by taking the size of objects on the nonmoving heap to be that of the segment's block rather than the object itself. Resolves #22221 - - - - - d0d5acb5 by Teo Camarasu at 2024-02-12T18:51:09-05:00 doc: Add requires prof annotation to options that require it Resolves #24421 - - - - - 57bb8c92 by Cheng Shao at 2024-02-13T14:07:49-05:00 deriveConstants: add needed constants for wasm backend This commit adds needed constants to deriveConstants. They are used by RTS code in the wasm backend to support the JSFFI logic. - - - - - 615eb855 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms The pure Haskell implementation causes i386 regression in unrelated work that can be fixed by using C-based atomic increment, see added comment for details. - - - - - a9918891 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow JSFFI for wasm32 This commit allows the javascript calling convention to be used when the target platform is wasm32. - - - - - 8771a53b by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: allow boxed JSVal as a foreign type This commit allows the boxed JSVal type to be used as a foreign argument/result type. - - - - - 053c92b3 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: ensure ctors have the right priority on wasm32 This commit fixes the priorities of ctors generated by GHC codegen on wasm32, see the referred note for details. - - - - - b7942e0a by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JSFFI desugar logic for wasm32 This commit adds JSFFI desugar logic for the wasm backend. - - - - - 2c1dca76 by Cheng Shao at 2024-02-13T14:07:49-05:00 compiler: add JavaScriptFFI to supported extension list on wasm32 This commit adds JavaScriptFFI as a supported extension when the target platform is wasm32. - - - - - 9ad0e2b4 by Cheng Shao at 2024-02-13T14:07:49-05:00 rts/ghc-internal: add JSFFI support logic for wasm32 This commit adds rts/ghc-internal logic to support the wasm backend's JSFFI functionality. - - - - - e9ebea66 by Cheng Shao at 2024-02-13T14:07:49-05:00 ghc-internal: fix threadDelay for wasm in browsers This commit fixes broken threadDelay for wasm when it runs in browsers, see added note for detailed explanation. - - - - - f85f3fdb by Cheng Shao at 2024-02-13T14:07:49-05:00 utils: add JSFFI utility code This commit adds JavaScript util code to utils to support the wasm backend's JSFFI functionality: - jsffi/post-link.mjs, a post-linker to process the linked wasm module and emit a small complement JavaScript ESM module to be used with it at runtime - jsffi/prelude.js, a tiny bit of prelude code as the JavaScript side of runtime logic - jsffi/test-runner.mjs, run the jsffi test cases Co-authored-by: amesgen <amesgen at amesgen.de> - - - - - 77e91500 by Cheng Shao at 2024-02-13T14:07:49-05:00 hadrian: distribute jsbits needed for wasm backend's JSFFI support The post-linker.mjs/prelude.js files are now distributed in the bindist libdir, so when using the wasm backend's JSFFI feature, the user wouldn't need to fetch them from a ghc checkout manually. - - - - - c47ba1c3 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add opts.target_wrapper This commit adds opts.target_wrapper which allows overriding the target wrapper on a per test case basis when testing a cross target. This is used when testing the wasm backend's JSFFI functionality; the rest of the cases are tested using wasmtime, though the jsffi cases are tested using the node.js based test runner. - - - - - 8e048675 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: T22774 should work for wasm JSFFI T22774 works since the wasm backend now supports the JSFFI feature. - - - - - 1d07f9a6 by Cheng Shao at 2024-02-13T14:07:49-05:00 testsuite: add JSFFI test cases for wasm backend This commit adds a few test cases for the wasm backend's JSFFI functionality, as well as a simple README to instruct future contributors to add new test cases. - - - - - b8997080 by Cheng Shao at 2024-02-13T14:07:49-05:00 docs: add documentation for wasm backend JSFFI This commit adds changelog and user facing documentation for the wasm backend's JSFFI feature. - - - - - ffeb000d by David Binder at 2024-02-13T14:08:30-05:00 Add tests from libraries/process/tests and libraries/Win32/tests to GHC These tests were previously part of the libraries, which themselves are submodules of the GHC repository. This commit moves the tests directly to the GHC repository. - - - - - 5a932cf2 by David Binder at 2024-02-13T14:08:30-05:00 Do not execute win32 tests on non-windows runners - - - - - 500d8cb8 by Jade at 2024-02-13T14:09:07-05:00 prevent GHCi (and runghc) from suggesting other symbols when not finding main Fixes: #23996 - - - - - b19ec331 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: update xxHash to v0.8.2 - - - - - 4a97bdb8 by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: use XXH3_64bits hash on all 64-bit platforms This commit enables XXH3_64bits hash to be used on all 64-bit platforms. Previously it was only enabled on x86_64, so platforms like aarch64 silently falls back to using XXH32 which degrades the hashing function quality. - - - - - ee01de7d by Cheng Shao at 2024-02-13T14:09:46-05:00 rts: define XXH_INLINE_ALL This commit cleans up how we include the xxhash.h header and only define XXH_INLINE_ALL, which is sufficient to inline the xxHash functions without symbol collision. - - - - - 0e01e1db by Alan Zimmerman at 2024-02-14T02:13:22-05:00 EPA: Move EpAnn out of extension points Leaving a few that are too tricky, maybe some other time. Also - remove some unneeded helpers from Parser.y - reduce allocations with strictness annotations Updates haddock submodule Metric Decrease: parsing001 - - - - - de589554 by Andreas Klebinger at 2024-02-14T02:13:59-05:00 Fix ffi callbacks with >6 args and non-64bit args. Check for ptr/int arguments rather than 64-bit width arguments when counting integer register arguments. The old approach broke when we stopped using exclusively W64-sized types to represent sub-word sized integers. Fixes #24314 - - - - - 325b7613 by Ben Gamari at 2024-02-14T14:27:45-05:00 rts/EventLog: Place eliminate duplicate strlens Previously many of the `post*` implementations would first compute the length of the event's strings in order to determine the event length. Later we would then end up computing the length yet again in `postString`. Now we instead pass the string length to `postStringLen`, avoiding the repeated work. - - - - - 8aafa51c by Ben Gamari at 2024-02-14T14:27:46-05:00 rts/eventlog: Place upper bound on IPE string field lengths The strings in IPE events may be of unbounded length. Limit the lengths of these fields to 64k characters to ensure that we don't exceed the maximum event length. - - - - - 0e60d52c by Zubin Duggal at 2024-02-14T14:27:46-05:00 rts: drop unused postString function - - - - - d8d1333a by Cheng Shao at 2024-02-14T14:28:23-05:00 compiler/rts: fix wasm unreg regression This commit fixes two wasm unreg regressions caught by a nightly pipeline: - Unknown stg_scheduler_loopzh symbol when compiling scheduler.cmm - Invalid _hs_constructor(101) function name when handling ctor - - - - - 264a4fa9 by Owen Shepherd at 2024-02-15T09:41:06-05:00 feat: Add sortOn to Data.List.NonEmpty Adds `sortOn` to `Data.List.NonEmpty`, and adds comments describing when to use it, compared to `sortWith` or `sortBy . comparing`. The aim is to smooth out the API between `Data.List`, and `Data.List.NonEmpty`. This change has been discussed in the [clc issue](https://github.com/haskell/core-libraries-committee/issues/227). - - - - - b57200de by Fendor at 2024-02-15T09:41:47-05:00 Prefer RdrName over OccName for looking up locations in doc renaming step Looking up by OccName only does not take into account when functions are only imported in a qualified way. Fixes issue #24294 Bump haddock submodule to include regression test - - - - - 8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00 JS: add simple optimizer The simple optimizer reduces the size of the code generated by the JavaScript backend without the complexity and performance penalty of the optimizer in GHCJS. Also see #22736 Metric Decrease: libdir size_hello_artifact - - - - - 20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00 base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and modifies the base API to reflect the new RTS flag. CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243 Fixes #24337 - - - - - 08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00 base: export System.Mem.performBlockingMajorGC The corresponding C function was introduced in ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264. Resolves #24228 The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230 Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00 Fix C output for modern C initiative GCC 14 on aarch64 rejects the C code written by GHC with this kind of error: error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion] 68 | *(ffi_arg*)resp = cret; | ^ Add the correct cast. For more information on this see: https://fedoraproject.org/wiki/Changes/PortingToModernC Tested-by: Richard W.M. Jones <rjones at redhat.com> - - - - - 5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00 Bump bytestring submodule to 0.12.1.0 - - - - - 902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00 Add missing BCO handling in scavenge_one. - - - - - 97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Make cast between words and floats real primops (#24331) First step towards fixing #24331. Replace foreign prim imports with real primops. - - - - - a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: add constant folding for bitcast between float and word (#24331) - - - - - 5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00 Perf: replace stack checks with assertions in casting primops There are RESERVED_STACK_WORDS free words (currently 21) on the stack, so omit the checks. Suggested by Cheng Shao. - - - - - 401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00 Reexport primops from GHC.Float + add deprecation - - - - - 4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00 rts/Hash: Don't iterate over chunks if we don't need to free data When freeing a `HashTable` there is no reason to walk over the hash list before freeing it if the user has not given us a `dataFreeFun`. Noticed while looking at #24410. - - - - - bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00 compiler: add SEQ_CST fence support In addition to existing Acquire/Release fences, this commit adds SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a fence that enforces total memory ordering. The following logic is added: - The MO_SeqCstFence callish MachOp - The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h - MO_SeqCstFence lowering logic in every single GHC codegen backend - - - - - 2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00 testsuite: fix hs_try_putmvar002 for targets without pthread.h hs_try_putmvar002 includes pthread.h and doesn't work on targets without this header (e.g. wasm32). It doesn't need to include this header at all. This was previously unnoticed by wasm CI, though recent toolchain upgrade brought in upstream changes that completely removes pthread.h in the single-threaded wasm32-wasi sysroot, therefore we need to handle that change. - - - - - 1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00 ci: bump ci-images to use updated wasm image This commit bumps our ci-images revision to use updated wasm image. - - - - - 56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00 Bump submodule text to 2.1.1 T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a. Metric Decrease: T17123 - - - - - a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00 rts: remove redundant rCCCS initialization This commit removes the redundant logic of initializing each Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before initProfiling() is called during RTS startup, each Capability's rCCCS has already been assigned CCS_SYSTEM when they're first initialized. - - - - - 7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00 Parser, renamer, type checker for @a-binders (#17594) GHC Proposal 448 introduces binders for invisible type arguments (@a-binders) in various contexts. This patch implements @-binders in lambda patterns and function equations: {-# LANGUAGE TypeAbstractions #-} id1 :: a -> a id1 @t x = x :: t -- @t-binder on the LHS of a function equation higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16) higherRank f = (f 42, f 42) ex :: (Int8, Int16) ex = higherRank (\ @a x -> maxBound @a - x ) -- @a-binder in a lambda pattern in an argument -- to a higher-order function Syntax ------ To represent those @-binders in the AST, the list of patterns in Match now uses ArgPat instead of Pat: data Match p body = Match { ... - m_pats :: [LPat p], + m_pats :: [LArgPat p], ... } + data ArgPat pass + = VisPat (XVisPat pass) (LPat pass) + | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass)) + | XArgPat !(XXArgPat pass) The VisPat constructor represents patterns for visible arguments, which include ordinary value-level arguments and required type arguments (neither is prefixed with a @), while InvisPat represents invisible type arguments (prefixed with a @). Parser ------ In the grammar (Parser.y), the lambda and lambda-cases productions of aexp non-terminal were updated to accept argpats instead of apats: aexp : ... - | '\\' apats '->' exp + | '\\' argpats '->' exp ... - | '\\' 'lcases' altslist(apats) + | '\\' 'lcases' altslist(argpats) ... + argpat : apat + | PREFIX_AT atype Function left-hand sides did not require any changes to the grammar, as they were already parsed with productions capable of parsing @-binders. Those binders were being rejected in post-processing (isFunLhs), and now we accept them. In Parser.PostProcess, patterns are constructed with the help of PatBuilder, which is used as an intermediate data structure when disambiguating between FunBind and PatBind. In this patch we define ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived data structure produced in isFunLhs and consumed in checkFunBind. Renamer ------- Renaming of @-binders builds upon prior work on type patterns, implemented in 2afbddb0f24, which guarantees proper scoping and shadowing behavior of bound type variables. This patch merely defines rnLArgPatsAndThen to process a mix of visible and invisible patterns: + rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn] + rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where + rnArgPatAndThen (VisPat x p) = ... rnLPatAndThen ... + rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ... Common logic between rnArgPats and rnPats is factored out into the rn_pats_general helper. Type checker ------------ Type-checking of @-binders builds upon prior work on lazy skolemisation, implemented in f5d3e03c56f. This patch extends tcMatchPats to handle @-binders. Now it takes and returns a list of LArgPat rather than LPat: tcMatchPats :: ... - -> [LPat GhcRn] + -> [LArgPat GhcRn] ... - -> TcM ([LPat GhcTc], a) + -> TcM ([LArgPat GhcTc], a) Invisible binders in the Match are matched up with invisible (Specified) foralls in the type. This is done with a new clause in the `loop` worker of tcMatchPats: loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a) loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys) ... -- NEW CLAUSE: | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis = ... In addition to that, tcMatchPats no longer discards type patterns. This is done by filterOutErasedPats in the desugarer instead. x86_64-linux-deb10-validate+debug_info Metric Increase: MultiLayerModulesTH_OneShot - - - - - 486979b0 by Jade at 2024-02-19T07:12:13-05:00 Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246 Fixes: #24346 - - - - - 17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00 Fix reST in users guide It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax. - - - - - 35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00 Fix searching for errors in sphinx build - - - - - 4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00 hadrian: fix wasm backend post linker script permissions The post-link.mjs script was incorrectly copied and installed as a regular data file without executable permission, this commit fixes it. - - - - - a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00 testsuite: mark T23540 as fragile on i386 See #24449 for details. - - - - - 249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00 Add @since annotation to Data.Data.mkConstrTag - - - - - cdd939e7 by Jade at 2024-02-19T20:36:46-05:00 Enhance documentation of Data.Complex - - - - - d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00 hadrian: Generate HSC2HS_EXTRAS variable in bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. The solution here is to substitute these variables in the configure script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in the install rules. Fixes #24050. - - - - - c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00 ci: Show --info for installed compiler - - - - - ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00 configure: Correctly set --target flag for linker opts Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4 arguments, when it only takes 3 arguments. Instead we need to use the `FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags. Actually fixes #24414 - - - - - 9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00 configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS - - - - - 77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00 Namespacing for fixity signatures (#14032) Namespace specifiers were added to syntax of fixity signatures: - sigdecl ::= infix prec ops | ... + sigdecl ::= infix prec namespace_spec ops | ... To preserve namespace during renaming MiniFixityEnv type now has separate FastStringEnv fields for names that should be on the term level and for name that should be on the type level. makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way: - signatures without namespace specifiers fill both fields - signatures with 'data' specifier fill data field only - signatures with 'type' specifier fill type field only Was added helper function lookupMiniFixityEnv that takes care about looking for a name in an appropriate namespace. Updates haddock submodule. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00 rts: only collect live words in nonmoving census when non-concurrent This avoids segfaults when the mutator modifies closures as we examine them. Resolves #24393 - - - - - 9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00 mutex wrap in refreshProfilingCCSs - - - - - 1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00 rts: remove unused HAVE_C11_ATOMICS macro This commit removes the unused HAVE_C11_ATOMICS macro. We used to have a few places that have fallback paths when HAVE_C11_ATOMICS is not defined, but that is completely redundant, since the FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler doesn't support C11 style atomics. There are also many places (e.g. in unreg backend, SMP.h, library cbits, etc) where we unconditionally use C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the oldest distro we test in our CI, so there's no value in keeping HAVE_C11_ATOMICS. - - - - - 0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00 RTS: -Ds - make sure incall is non-zero before dereferencing it. Fixes #24445 - - - - - e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00 rts/AdjustorPool: Use ExecPage abstraction This is just a minor cleanup I found while reviewing the implementation. - - - - - 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 8a8ac65a by Matthew Craven at 2024-03-23T00:20:52-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 0c48f2b9 by Apoorv Ingle at 2024-03-23T00:21:28-04:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - b72705e9 by Simon Peyton Jones at 2024-03-23T00:22:04-04:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 8f7cfc7e by Tristan Cacqueray at 2024-03-23T00:22:44-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - 5bd8ed53 by Andreas Klebinger at 2024-03-23T16:18:33-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8d67f247 by Ben Gamari at 2024-03-23T16:19:09-04:00 docs: Drop old release notes, add for 9.12.1 - - - - - 7db8c992 by Cheng Shao at 2024-03-25T13:45:46-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. - - - - - 237194ce by Sylvain Henry at 2024-03-25T13:46:27-04:00 Lexer: fix imports for Alex 3.5.1 (#24583) - - - - - 810660b7 by Cheng Shao at 2024-03-25T22:19:16-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - d2ba41e8 by Alan Zimmerman at 2024-03-25T22:19:51-04:00 EPA: do not duplicate comments in signature RHS - - - - - 32a8103f by Rodrigo Mesquita at 2024-03-26T21:16:12-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. - - - - - bf65a7c3 by Rodrigo Mesquita at 2024-03-26T21:16:48-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 - - - - - cfeb70d3 by Rodrigo Mesquita at 2024-03-26T21:17:24-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 13223f6d by Serge S. Gulin at 2024-03-27T07:28:51-04:00 JS: `h$rts_isProfiled` is removed from `profiling` and left its version at `rts/js/config.js` - - - - - 0acfe391 by Alan Zimmerman at 2024-03-27T07:29:27-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. - - - - - cd0fb82f by Alan Zimmerman at 2024-03-27T19:33:08+00:00 EPA: Fix FamDecl range The span was incorrect if opt_datafam_kind_sig was empty - - - - - f8f384a8 by Ben Gamari at 2024-03-29T01:23:03-04:00 Fix type of _get_osfhandle foreign import Fixes #24601. - - - - - 00d3ecf0 by Alan Zimmerman at 2024-03-29T12:19:10+00:00 EPA: Extend StringLiteral range to include trailing commas This goes slightly against the exact printing philosophy where trailing decorations should be in an annotation, but the practicalities of adding it to the WarningTxt environment, and the problems caused by deviating do not make a more principles approach worthwhile. - - - - - efab3649 by brandon s allbery kf8nh at 2024-03-31T20:04:01-04:00 clarify Note [Preproccesing invocations] - - - - - c8a4c050 by Ben Gamari at 2024-04-02T12:50:35-04:00 rts: Fix TSAN_ENABLED CPP guard This should be `#if defined(TSAN_ENABLED)`, not `#if TSAN_ENABLED`, lest we suffer warnings. - - - - - e91dad93 by Cheng Shao at 2024-04-02T12:50:35-04:00 rts: fix errors when compiling with TSAN This commit fixes rts compilation errors when compiling with TSAN: - xxx_FENCE macros are redefined and trigger CPP warnings. - Use SIZEOF_W. WORD_SIZE_IN_BITS is provided by MachDeps.h which Cmm.h doesn't include by default. - - - - - a9ab9455 by Cheng Shao at 2024-04-02T12:50:35-04:00 rts: fix clang-specific errors when compiling with TSAN This commit fixes clang-specific rts compilation errors when compiling with TSAN: - clang doesn't have -Wtsan flag - Fix prototype of ghc_tsan_* helper functions - __tsan_atomic_* functions aren't clang built-ins and sanitizer/tsan_interface_atomic.h needs to be included - On macOS, TSAN runtime library is libclang_rt.tsan_osx_dynamic.dylib, not libtsan. -fsanitize-thread as a link-time flag will take care of linking the TSAN runtime library anyway so remove tsan as an rts extra library - - - - - 865bd717 by Cheng Shao at 2024-04-02T12:50:35-04:00 compiler: fix github link to __tsan_memory_order in a comment - - - - - 07cb627c by Cheng Shao at 2024-04-02T12:50:35-04:00 ci: improve TSAN CI jobs - Run TSAN jobs with +thread_sanitizer_cmm which enables Cmm instrumentation as well. - Run TSAN jobs in deb12 which ships gcc-12, a reasonably recent gcc that @bgamari confirms he's using in #GHC:matrix.org. Ideally we should be using latest clang release for latest improvements in sanitizers, though that's left as future work. - Mark TSAN jobs as manual+allow_failure in validate pipelines. The purpose is to demonstrate that we have indeed at least fixed building of TSAN mode in CI without blocking the patch to land, and once merged other people can begin playing with TSAN using their own dev setups and feature branches. - - - - - a1c18c7b by Andrei Borzenkov at 2024-04-02T12:51:11-04:00 Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy (#24299, #23639) This patch implements refactoring which is a prerequisite to updating kind checking of type patterns. This is a huge simplification of the main worker that checks kind of HsType. It also fixes the issues caused by previous code duplication, e.g. that we didn't add module finalizers from splices in inference mode. - - - - - 817e8936 by Rodrigo Mesquita at 2024-04-02T20:13:05-04:00 th: Hide the Language.Haskell.TH.Lib.Internal module from haddock Fixes #24562 - - - - - b36ee57b by Sylvain Henry at 2024-04-02T20:13:46-04:00 JS: reenable h$appendToHsString optimization (#24495) The optimization introducing h$appendToHsString wasn't kicking in anymore (while it did in 9.8.1) because of the changes introduced in #23270 (7e0c8b3bab30). This patch reenables the optimization by matching on case-expression, as done in Cmm for unpackCString# standard thunks. The test is also T24495 added in the next commits (two commits for ease of backporting to 9.8). - - - - - 527616e9 by Sylvain Henry at 2024-04-02T20:13:46-04:00 JS: fix h$appendToHsString implementation (#24495) h$appendToHsString needs to wrap its argument in an updatable thunk to behave like unpackAppendCString#. Otherwise if a SingleEntry thunk is passed, it is stored as-is in a CONS cell, making the resulting list impossible to deepseq (forcing the thunk doesn't update the contents of the CONS cell)! The added test checks that the optimization kicks in and that h$appendToHsString works as intended. Fix #24495 - - - - - faa30b41 by Simon Peyton Jones at 2024-04-02T20:14:22-04:00 Deal with duplicate tyvars in type declarations GHC was outright crashing before this fix: #24604 - - - - - e0b0c717 by Simon Peyton Jones at 2024-04-02T20:14:58-04:00 Try using MCoercion in exprIsConApp_maybe This is just a simple refactor that makes exprIsConApp_maybe a little bit more direct, simple, and efficient. Metrics: compile_time/bytes allocated geo. mean -0.1% minimum -2.0% maximum -0.0% Not a big gain, but worthwhile given that the code is, if anything, easier to grok. - - - - - 15f4d867 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Initial ./configure support for selecting I/O managers In this patch we just define new CPP vars, but don't yet use them or replace the existing approach. That will follow. The intention here is that every I/O manager can be enabled/disabled at GHC build time (subject to some constraints). More than one I/O manager can be enabled to be built. At least one I/O manager supporting the non-threaded RTS must be enabled as well as at least one supporting the non-threaded RTS. The I/O managers enabled here will become the choices available at runtime at RTS startup (in later patches). The choice can be made with RTS flags. There are separate sets of choices for the threaded and non-threaded RTS ways, because most I/O managers are specific to these ways. Furthermore we must establish a default I/O manager for the threaded and non-threaded RTS. Most I/O managers are platform-specific so there are checks to ensure each one can be enabled on the platform. Such checks are also where (in future) any system dependencies (e.g. libraries) can be checked. The output is a set of CPP flags (in the mk/config.h file), with one flag per named I/O manager: * IOMGR_BUILD_<name> : which ones should be built (some) * IOMGR_DEFAULT_NON_THREADED_<name> : which one is default (exactly one) * IOMGR_DEFAULT_THREADED_<name> : which one is default (exactly one) and a set of derived flags in IOManager.h * IOMGR_ENABLED_<name> : enabled for the current RTS way Note that IOMGR_BUILD_<name> just says that an I/O manager will be built for _some_ RTS way (i.e. threaded or non-threaded). The derived flags IOMGR_ENABLED_<name> in IOManager.h say if each I/O manager is enabled in the "current" RTS way. These are the ones that can be used for conditional compilation of the I/O manager code. Co-authored-by: Pi Delport <pi at well-typed.com> - - - - - 85b0f87a by Duncan Coutts at 2024-04-03T01:27:17-04:00 Change the handling of the RTS flag --io-manager= Now instead of it being just used on Windows to select between the WinIO vs the MIO or Win32-legacy I/O managers, it is now used on all platforms for selecting the I/O manager to use. Right now it remains the case that there is only an actual choice on Windows, but that will change later. Document the --io-manager flag in the user guide. This change is also reflected in the RTS flags types in the base library. Deprecate the export of IoSubSystem from GHC.RTS.Flags with a message to import it from GHC.IO.Subsystem. The way the 'IoSubSystem' is detected also changes. Instead of looking at the RTS flag, there is now a C bool global var in the RTS which gets set on startup when the I/O manager is selected. This bool var says whether the selected I/O manager classifies as "native" on Windows, which in practice means the WinIO I/O manager has been selected. Similarly, the is_io_mng_native_p RTS helper function is re-implemented in terms of the selected I/O manager, rather than based on the RTS flags. We do however remove the ./configure --native-io-manager flag because we're bringing the WinIO/MIO/Win32-legacy choice under the new general scheme for selecting I/O managers, and that new scheme involves no ./configure time user choices, just runtime RTS flag choices. - - - - - 1a8f020f by Duncan Coutts at 2024-04-03T01:27:17-04:00 Convert {init,stop,exit}IOManager to switch style Rather than ad-hoc cpp conitionals on THREADED_RTS and mingw32_HOST_OS, we use a style where we switch on the I/O manager impl, with cases for each I/O manager impl. - - - - - a5bad3d2 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Split up the CapIOManager content by I/O manager Using the new IOMGR_ENABLED_<name> CPP defines. - - - - - 1d36e609 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Convert initIOManagerAfterFork and wakeupIOManager to switch style - - - - - c2f26f36 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move most of waitRead#/Write# from cmm to C Moves it into the IOManager.c where we can follow the new pattern of switching on the selected I/O manager. - - - - - 457705a8 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move most of the delay# impl from cmm to C Moves it into the IOManager.c where we can follow the new pattern of switching on the selected I/O manager. Uses a new IOManager API: syncDelay, following the naming convention of sync* for thread-synchronous I/O & timer/delay operations. As part of porting from cmm to C, we maintain the rule that the why_blocked gets accessed using load acquire and store release atomic memory operations. There was one exception to this rule: in the delay# primop cmm code on posix (not win32), the why_blocked was being updated using a store relaxed, not a store release. I've no idea why. In this convesion I'm playing it safe here and using store release consistently. - - - - - e93058e0 by Duncan Coutts at 2024-04-03T01:27:18-04:00 insertIntoSleepingQueue is no longer public No longer defined in IOManager.h, just a private function in IOManager.c. Since it is no longer called from cmm code, just from syncDelay. It ought to get moved further into the select() I/O manager impl, rather than living in IOManager.c. On the other hand appendToIOBlockedQueue is still called from cmm code in the win32-legacy I/O manager primops async{Read,Write}#, and it is also used by the select() I/O manager. Update the CPP and comments to reflect this. - - - - - 60ce9910 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move anyPendingTimeoutsOrIO impl from .h to .c The implementation is eventually going to need to use more private things, which will drag in unwanted includes into IOManager.h, so it's better to move the impl out of the header file and into the .c file, at the slight cost of it no longer being inline. At the same time, change to the "switch (iomgr_type)" style. - - - - - f70b8108 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Take a simpler approach to gcc warnings in IOManager.c We have lots of functions with conditional implementations for different I/O managers. Some functions, for some I/O managers, naturally have implementations that do nothing or barf. When only one such I/O manager is enabled then the whole function implementation will have an implementation that does nothing or barfs. This then results in warnings from gcc that parameters are unused, or that the function should be marked with attribute noreturn (since barf does not return). The USED_IF_THREADS trick for fine-grained warning supression is fine for just two cases, but an equivalent here would need USED_IF_THE_ONLY_ENABLED_IOMGR_IS_X_OR_Y which would have combinitorial blowup. So we take a coarse grained approach and simply disable these two warnings for the whole file. So we use a GCC pragma, with its handy push/pop support: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsuggest-attribute=noreturn" #pragma GCC diagnostic ignored "-Wunused-parameter" ... #pragma GCC diagnostic pop - - - - - b48805b9 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add a new trace class for the iomanager It makes sense now for it to be separate from the scheduler class of tracers. Enabled with +RTS -Do. Document the -Do debug flag in the user guide. - - - - - f0c1f862 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Have the throwTo impl go via (new) IOManager APIs rather than directly operating on the IO manager's data structures. Specifically, when thowing an async exception to a thread that is blocked waiting for I/O or waiting for a timer, then we want to cancel that I/O waiting or cancel the timer. Currently this is done directly in removeFromQueues() in RaiseAsync.c. We want it to go via proper APIs both for modularity but also to let us support multiple I/O managers. So add sync{IO,Delay}Cancel, which is the cancellation for the corresponding sync{IO,Delay}. The implementations of these use the usual "switch (iomgr_type)" style. - - - - - 4f9e9c4e by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move awaitEvent into a proper IOManager API and have the scheduler use it. Previously the scheduler calls awaitEvent directly, and awaitEvent is implemented directly in the RTS I/O managers (select, win32). This relies on the old scheme where there's a single active I/O manager for each platform and RTS way. We want to move that to go via an API in IOManager.{h,c} which can then call out to the active I/O manager. Also take the opportunity to split awaitEvent into two. The existing awaitEvent has a bool wait parameter, to say if the call should be blocking or non-blocking. We split this into two separate functions: pollCompletedTimeoutsOrIO and awaitCompletedTimeoutsOrIO. We split them for a few reasons: they have different post-conditions (specifically the await version is supposed to guarantee that there are threads runnable when it completes). Secondly, it is also anticipated that in future I/O managers the implementations of the two cases will be simpler if they are separated. - - - - - 5ad4b30f by Duncan Coutts at 2024-04-03T01:27:18-04:00 Rename awaitEvent in select and win32 I/O managers These are now just called from IOManager.c and are the per-I/O manager backend impls (whereas previously awaitEvent was the entry point). Follow the new naming convention in the IOManager.{h,c} of awaitCompletedTimeoutsOrIO, with the I/O manager's name as a suffix: so awaitCompletedTimeoutsOrIO{Select,Win32}. - - - - - d30c6bc6 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Tidy up a couple things in Select.{h,c} Use the standard #include {Begin,End}Private.h style rather than RTS_PRIVATE on individual decls. And conditionally build the code for the select I/O manager based on the new CPP IOMGR_ENABLED_SELECT rather than on THREADED_RTS. - - - - - 4161f516 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add an IOManager API for scavenging TSO blocked_info When the GC scavenges a TSO it needs to scavenge the tso->blocked_info but the blocked_info is a big union and what lives there depends on the two->why_blocked, which for I/O-related reasons is something that in principle is the responsibility of the I/O manager and not the GC. So the right thing to do is for the GC to ask the I/O manager to sscavenge the blocked_info if it encounters any I/O-related why_blocked reasons. So we add scavengeTSOIOManager in IOManager.{h,c} with the usual style. Now as it happens, right now, there is no special scavenging to do, so the implementation of scavengeTSOIOManager is a fancy no-op. That's because the select I/O manager uses only the fd and target members, which are not GC pointers, and the win32-legacy I/O manager _ought_ to be using GC-managed heap objects for the StgAsyncIOResult but it is actually usingthe C heap, so again no GC pointers. If the win32-legacy were doing this more sensibly, then scavengeTSOIOManager would be the right place to do the GC magic. Future I/O managers will need GC heap objects in the tso->blocked_info and will make use of this functionality. - - - - - 94a87d21 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add I/O manager API notifyIOManagerCapabilitiesChanged Used in setNumCapabilities. It only does anything for MIO on Posix. Previously it always invoked Haskell code, but that code only did anything on non-Windows (and non-JS), and only threaded. That currently effectively means the MIO I/O manager on Posix. So now it only invokes it for the MIO Posix case. - - - - - 3be6d591 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Select an I/O manager early in RTS startup We need to select the I/O manager to use during startup before the per-cap I/O manager initialisation. - - - - - aaa294d0 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Make struct CapIOManager be fully opaque Provide an opaque (forward) definition in Capability.h (since the cap contains a *CapIOManager) and then only provide a full definition in a new file IOManagerInternals.h. This new file is only supposed to be included by the IOManager implementation, not by its users. So that means IOManager.c and individual I/O manager implementations. The posix/Signals.c still needs direct access, but that should be eliminated. Anything that needs direct access either needs to be clearly part of an I/O manager (e.g. the sleect() one) or go via a proper API. - - - - - 877a2a80 by Duncan Coutts at 2024-04-03T01:27:18-04:00 The select() I/O manager does have some global initialisation It's just to make sure an exception CAF is a GC root. - - - - - 9c51473b by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add tracing for the main I/O manager actions Using the new tracer class. Note: The unconditional definition of showIOManager should be compatible with the debugTrace change in 7c7d1f6. Co-authored-by: Pi Delport <pi at well-typed.com> - - - - - c7d3e3a3 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Include the default I/O manager in the +RTS --info output Document the extra +RTS --info output in the user guide - - - - - 8023bad4 by Duncan Coutts at 2024-04-03T01:27:18-04:00 waitRead# / waitWrite# do not work for win32-legacy I/O manager Previously it was unclear that they did not work because the code path was shared with other I/O managers (in particular select()). Following the code carefully shows that what actually happens is that the calling thread would block forever: the thread will be put into the blocked queue, but no other action is scheduled that will ever result in it getting unblocked. It's better to just fail loudly in case anyone accidentally calls it, also it's less confusing code. - - - - - 83a74d20 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Conditionally ignore some GCC warnings Some GCC versions don't know about some warnings, and they complain that we're ignoring unknown warnings. So we try to ignore the warning based on the GCC version. - - - - - 1adc6fa4 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Accept changes to base-exports All the changes are in fact not changes at all. Previously, the IoSubSystem data type was defined in GHC.RTS.Flags and exported from both GHC.RTS.Flags and GHC.IO.SubSystem. Now, the data type is defined in GHC.IO.SubSystem and still exported from both modules. Therefore, the same exports and same instances are still available from both modules. But the base-exports records only the defining module, and so it looks like a change when it is fully compatible. Related: we do add a deprecation to the export of the type via GHC.RTS.Flags, telling people to use the export from GHC.IO.SubSystem. Also the sort order for some unrelated Show instances changed. No idea why. The same changes apply in the other versions, with a few more changes due to sort order weirdness. - - - - - 8d950968 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Accept metric decrease in T12227 I can't think of any good reason that anything in this MR should have changed the number of allocations, up or down. (Yes this is an empty commit.) Metric Decrease: T12227 - - - - - e869605e by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Several improvements to the handling of coercions * Make `mkSymCo` and `mkInstCo` smarter Fixes #23642 * Fix return role of `SelCo` in the coercion optimiser. Fixes #23617 * Make the coercion optimiser `opt_trans_rule` work better for newtypes Fixes #23619 - - - - - 1efd0714 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 FloatOut: improve floating for join point See the new Note [Floating join point bindings]. * Completely get rid of the complicated join_ceiling nonsense, which I have never understood. * Do not float join points at all, except perhaps to top level. * Some refactoring around wantToFloat, to treat Rec and NonRec more uniformly - - - - - 9c00154d by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Improve eta-expansion through call stacks See Note [Eta expanding through CallStacks] in GHC.Core.Opt.Arity This is a one-line change, that fixes an inconsistency - || isCallStackPredTy ty + || isCallStackPredTy ty || isCallStackTy ty - - - - - 95a9a172 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Spelling, layout, pretty-printing only - - - - - bdf1660f by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Improve exprIsConApp_maybe a little Eliminate a redundant case at birth. This sometimes reduces Simplifier iterations. See Note [Case elim in exprIsConApp_maybe]. - - - - - 609cd32c by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Inline GHC.HsToCore.Pmc.Solver.Types.trvVarInfo When exploring compile-time regressions after meddling with the Simplifier, I discovered that GHC.HsToCore.Pmc.Solver.Types.trvVarInfo was very delicately balanced. It's a small, heavily used, overloaded function and it's important that it inlines. By a fluke it was before, but at various times in my journey it stopped doing so. So I just added an INLINE pragma to it; no sense in depending on a delicately-balanced fluke. - - - - - ae24c9bc by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Slight improvement in WorkWrap Ensure that WorkWrap preserves lambda binders, in case of join points. Sadly I have forgotten why I made this change (it was while I was doing a lot of meddling in the Simplifier, but * it does no harm, * it is slightly more efficient, and * presumably it made something better! Anyway I have kept it in a separate commit. - - - - - e9297181 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Use named record fields for the CastIt { ... } data constructor This is a pure refactor - - - - - b4581e23 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Remove a long-commented-out line Pure refactoring - - - - - e026bdf2 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The main changes are below. There are also many new or rewritten Notes. Avoiding simplifying repeatedly ~~~~~~~~~~~~~~~ See Note [Avoiding simplifying repeatedly] * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env. Currently used only for the next point: avoiding repeatedly simplifying coercions. * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] * Improve the case-merge transformation: - Move the main code to `GHC.Core.Utils.mergeCaseAlts`, to join `filterAlts` and friends. See Note [Merge Nested Cases] in GHC.Core.Utils. - Add a new case for `tagToEnum#`; see wrinkle (MC3). - Add a new case to look through join points: see wrinkle (MC4) postInlineUnconditionally ~~~~~~~~~~~~~~~~~~~~~~~~~ * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. * Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. * Improve occurrence analyis for bottoming function calls, to help postInlineUnconditionally. See Note [Bottoming function calls] in GHC.Core.Opt.OccurAnal Inlining generally ~~~~~~~~~~~~~~~~~~ * In GHC.Core.Opt.Simplify.Utils.interestingCallContext, use RhsCtxt NonRecursive (not BoringCtxt) for a plain-seq case. See Note [Seq is boring] Also, wrinkle (SB1), inline in that `seq` context only for INLINE functions (UnfWhen guidance). * In GHC.Core.Opt.Simplify.Utils.interestingArg, - return ValueArg for OtherCon [c1,c2, ...], but - return NonTrivArg for OtherCon [] This makes a function a little less likely to inline if all we know is that the argument is evaluated, but nothing else. * isConLikeUnfolding is no longer true for OtherCon {}. This propagates to exprIsConLike. Con-like-ness has /positive/ information. Join points ~~~~~~~~~~~ * Be very careful about inlining join points. See these two long Notes Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline * When making join points, don't do so if the join point is so small it will immediately be inlined; check uncondInlineJoin. * In GHC.Core.Opt.Simplify.Inline.tryUnfolding, improve the inlining heuristics for join points. In general we /do not/ want to inline join points /even if they are small/. See Note [Duplicating join points] GHC.Core.Opt.Simplify.Iteration. But sometimes we do: see Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline; and the new `isBetterUnfoldingThan` function. * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * In GHC.Core.Unfold.sizeExpr, make jumps small, so that we don't penalise having a non-inlined join point. Performance changes ~~~~~~~~~~~~~~~~~~~ * Binary sizes fall by around 2.6%, according to nofib. * Compile times improve slightly. Here are the figures over 1%. I investiate the biggest differnce in T18304. It's a very small module, just a few hundred nodes. The large percentage difffence is due to a single function that didn't quite inline before, and does now, making code size a bit bigger. I decided gains outweighed the losses. Metrics: compile_time/bytes allocated (changes over +/- 1%) ------------------------------------------------ CoOpt_Singletons(normal) -9.2% GOOD LargeRecord(normal) -23.5% GOOD MultiComponentModulesRecomp(normal) +1.2% MultiLayerModulesTH_OneShot(normal) +4.1% BAD PmSeriesS(normal) -3.8% PmSeriesV(normal) -1.5% T11195(normal) -1.3% T12227(normal) -20.4% GOOD T12545(normal) -3.2% T12707(normal) -2.1% GOOD T13253(normal) -1.2% T13253-spj(normal) +8.1% BAD T13386(normal) -3.1% GOOD T14766(normal) -2.6% GOOD T15164(normal) -1.4% T15304(normal) +1.2% T15630(normal) -8.2% T15630a(normal) NEW T15703(normal) -14.7% GOOD T16577(normal) -2.3% GOOD T17516(normal) -39.7% GOOD T18140(normal) +1.2% T18223(normal) -17.1% GOOD T18282(normal) -5.0% GOOD T18304(normal) +10.8% BAD T18923(normal) -2.9% GOOD T1969(normal) +1.0% T19695(normal) -1.5% T20049(normal) -12.7% GOOD T21839c(normal) -4.1% GOOD T3064(normal) -1.5% T3294(normal) +1.2% BAD T4801(normal) +1.2% T5030(normal) -15.2% GOOD T5321Fun(normal) -2.2% GOOD T6048(optasm) -16.8% GOOD T783(normal) -1.2% T8095(normal) -6.0% GOOD T9630(normal) -4.7% GOOD T9961(normal) +1.9% BAD WWRec(normal) -1.4% info_table_map_perf(normal) -1.3% parsing001(normal) +1.5% geo. mean -2.0% minimum -39.7% maximum +10.8% * Runtimes generally improve. In the testsuite perf/should_run gives: Metrics: runtime/bytes allocated ------------------------------------------ Conversions(normal) -0.3% T13536a(optasm) -41.7% GOOD T4830(normal) -0.1% haddock.Cabal(normal) -0.1% haddock.base(normal) -0.1% haddock.compiler(normal) -0.1% geo. mean -0.8% minimum -41.7% maximum +0.0% * For runtime, nofib is a better test. The news is mostly good. Here are the number more than +/- 0.1%: # bytes allocated ==========================++========== imaginary/digits-of-e1 || -14.40% imaginary/digits-of-e2 || -4.41% imaginary/paraffins || -0.17% imaginary/rfib || -0.15% imaginary/wheel-sieve2 || -0.10% real/compress || -0.47% real/fluid || -0.10% real/fulsom || +0.14% real/gamteb || -1.47% real/gg || -0.20% real/infer || +0.24% real/pic || -0.23% real/prolog || -0.36% real/scs || -0.46% real/smallpt || +4.03% shootout/k-nucleotide || -20.23% shootout/n-body || -0.42% shootout/spectral-norm || -0.13% spectral/boyer2 || -3.80% spectral/constraints || -0.27% spectral/hartel/ida || -0.82% spectral/mate || -20.34% spectral/para || +0.46% spectral/rewrite || +1.30% spectral/sphere || -0.14% ==========================++========== geom mean || -0.59% real/smallpt has a huge nest of local definitions, and I could not pin down a reason for a regression. But there are three big wins! Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12707 T13386 T13536a T14766 T15703 T16577 T17516 T18223 T18282 T18923 T21839c T20049 T5321Fun T5030 T6048 T8095 T9630 T783 Metric Increase: MultiLayerModulesTH_OneShot T13253-spj T18304 T18698a T9961 T3294 - - - - - 27db3c5e by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Testsuite message changes from simplifier improvements - - - - - 271a7812 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Account for bottoming functions in OccurAnal This fixes #24582, a small but long-standing bug - - - - - 0fde229f by Ben Gamari at 2024-04-04T07:04:58-04:00 testsuite: Introduce template-haskell-exports test - - - - - 0c4a9686 by Luite Stegeman at 2024-04-04T07:05:39-04:00 Update correct counter in bumpTickyAllocd - - - - - 5f085d3a by Fendor at 2024-04-04T14:47:33-04:00 Replace `SizedSeq` with `FlatBag` for flattened structure LinkedLists are notoriously memory ineffiecient when all we do is traversing a structure. As 'UnlinkedBCO' has been identified as a data structure that impacts the overall memory usage of GHCi sessions, we avoid linked lists and prefer flattened structure for storing. We introduce a new memory efficient representation of sequential elements that has special support for the cases: * Empty * Singleton * Tuple Elements This improves sharing in the 'Empty' case and avoids the overhead of 'Array' until its constant overhead is justified. - - - - - 82cfe10c by Fendor at 2024-04-04T14:47:33-04:00 Compact FlatBag array representation `Array` contains three additional `Word`'s we do not need in `FlatBag`. Move `FlatBag` to `SmallArray`. Expand the API of SmallArray by `sizeofSmallArray` and add common traversal functions, such as `mapSmallArray` and `foldMapSmallArray`. Additionally, allow users to force the elements of a `SmallArray` via `rnfSmallArray`. - - - - - 36a75b80 by Andrei Borzenkov at 2024-04-04T14:48:10-04:00 Change how invisible patterns represented in haskell syntax and TH AST (#24557) Before this patch: data ArgPat p = InvisPat (LHsType p) | VisPat (LPat p) With this patch: data Pat p = ... | InvisPat (LHsType p) ... And the same transformation in the TH land. The rest of the changes is just updating code to handle new AST and writing tests to check if it is possible to create invalid states using TH. Metric Increase: MultiLayerModulesTH_OneShot - - - - - 28009fbc by Matthew Pickering at 2024-04-04T14:48:46-04:00 Fix off by one error in seekBinNoExpand and seekBin - - - - - 9b9e031b by Ben Gamari at 2024-04-04T21:30:08-04:00 compiler: Allow more types in GHCForeignImportPrim For many, many years `GHCForeignImportPrim` has suffered from the rather restrictive limitation of not allowing any non-trivial types in arguments or results. This limitation was justified by the code generator allegely barfing in the presence of such types. However, this restriction appears to originate well before the NCG rewrite and the new NCG does not appear to have any trouble with such types (see the added `T24598` test). Lift this restriction. Fixes #24598. - - - - - 1324b862 by Alan Zimmerman at 2024-04-04T21:30:44-04:00 EPA: Use EpaLocation not SrcSpan in ForeignDecls This allows us to update them for makeDeltaAst in ghc-exactprint - - - - - 19883a23 by Alan Zimmerman at 2024-04-05T16:58:17-04:00 EPA: Use EpaLocation for RecFieldsDotDot So we can update it to a delta position in makeDeltaAst if needed. - - - - - e8724327 by Matthew Pickering at 2024-04-05T16:58:53-04:00 Remove accidentally committed test.hs - - - - - 88cb3e10 by Fendor at 2024-04-08T09:03:34-04:00 Avoid UArray when indexing is not required `UnlinkedBCO`'s can occur many times in the heap. Each `UnlinkedBCO` references two `UArray`'s but never indexes them. They are only needed to encode the elements into a `ByteArray#`. The three words for the lower bound, upper bound and number of elements are essentially unused, thus we replace `UArray` with a wrapper around `ByteArray#`. This saves us up to three words for each `UnlinkedBCO`. Further, to avoid re-allocating these words for `ResolvedBCO`, we repeat the procedure for `ResolvedBCO` and add custom `Binary` and `Show` instances. For example, agda's repl session has around 360_000 UnlinkedBCO's, so avoiding these three words is already saving us around 8MB residency. - - - - - f2cc1107 by Fendor at 2024-04-08T09:04:11-04:00 Never UNPACK `FastMutInt` for counting z-encoded `FastString`s In `FastStringTable`, we count the number of z-encoded FastStrings that exist in a GHC session. We used to UNPACK the counters to not waste memory, but live retainer analysis showed that we allocate a lot of `FastMutInt`s, retained by `mkFastZString`. We lazily compute the `FastZString`, only incrementing the counter when the `FastZString` is forced. The function `mkFastStringWith` calls `mkZFastString` and boxes the `FastMutInt`, leading to the following core: mkFastStringWith = \ mk_fs _ -> = case stringTable of { FastStringTable _ n_zencs segments# _ -> ... case ((mk_fs (I# ...) (FastMutInt n_zencs)) `cast` <Co:2> :: ...) ... Marking this field as `NOUNPACK` avoids this reboxing, eliminating the allocation of a fresh `FastMutInt` on every `FastString` allocation. - - - - - c6def949 by Matthew Pickering at 2024-04-08T16:06:51-04:00 Force in_multi to avoid retaining entire hsc_env - - - - - fbb91a63 by Fendor at 2024-04-08T16:06:51-04:00 Eliminate name thunk in declaration fingerprinting Thunk analysis showed that we have about 100_000 thunks (in agda and `-fwrite-simplified-core`) pointing to the name of the name decl. Forcing this thunk fixes this issue. The thunk created here is retained by the thunk created by forkM, it is better to eagerly force this because the result (a `Name`) is already retained indirectly via the `IfaceDecl`. - - - - - 3b7b0c1c by Alan Zimmerman at 2024-04-08T16:07:27-04:00 EPA: Use EpaLocation in WarningTxt This allows us to use an EpDelta if needed when using makeDeltaAst. - - - - - 12b997df by Alan Zimmerman at 2024-04-08T16:07:27-04:00 EPA: Move DeltaPos and EpaLocation' into GHC.Types.SrcLoc This allows us to use a NoCommentsLocation for the possibly trailing comma location in a StringLiteral. This in turn allows us to correctly roundtrip via makeDeltaAst. - - - - - 868c8a78 by Fendor at 2024-04-09T08:51:50-04:00 Prefer packed representation for CompiledByteCode As there are many 'CompiledByteCode' objects alive during a GHCi session, representing its element in a more packed manner improves space behaviour at a minimal cost. When running GHCi on the agda codebase, we find around 380 live 'CompiledByteCode' objects. Packing their respective 'UnlinkedByteCode' can save quite some pointers. - - - - - be3bddde by Alan Zimmerman at 2024-04-09T08:52:26-04:00 EPA: Capture all comments in a ClassDecl Hopefully the final fix needed for #24533 - - - - - 3d0806fc by Jade at 2024-04-10T05:39:53-04:00 Validate -main-is flag using parseIdentifier Fixes #24368 - - - - - dd530bb7 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: free error message before returning Fixes a memory leak in rts/linker/PEi386.c - - - - - e008a19a by Alexis King at 2024-04-10T05:40:29-04:00 linker: Avoid linear search when looking up Haskell symbols via dlsym See the primary Note [Looking up symbols in the relevant objects] for a more in-depth explanation. When dynamically loading a Haskell symbol (typical when running a splice or GHCi expression), before this commit we would search for the symbol in all dynamic libraries that were loaded. However, this could be very inefficient when too many packages are loaded (which can happen if there are many package dependencies) because the time to lookup the would be linear in the number of packages loaded. This commit drastically improves symbol loading performance by introducing a mapping from units to the handles of corresponding loaded dlls. These handles are returned by dlopen when we load a dll, and can then be used to look up in a specific dynamic library. Looking up a given Name is now much more precise because we can get lookup its unit in the mapping and lookup the symbol solely in the handles of the dynamic libraries loaded for that unit. In one measurement, the wait time before the expression was executed went from +-38 seconds down to +-2s. This commit also includes Note [Symbols may not be found in pkgs_loaded], explaining the fallback to the old behaviour in case no dll can be found in the unit mapping for a given Name. Fixes #23415 Co-authored-by: Rodrigo Mesquita (@alt-romes) - - - - - dcfaa190 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: Make addDLL a wrapper around loadNativeObj Rewrite the implementation of `addDLL` as a wrapper around the more principled `loadNativeObj` rts linker function. The latter should be preferred while the former is preserved for backwards compatibility. `loadNativeObj` was previously only available on ELF platforms, so this commit further refactors the rts linker to transform loadNativeObj_ELF into loadNativeObj_POSIX, which is available in ELF and MachO platforms. The refactor made it possible to remove the `dl_mutex` mutex in favour of always using `linker_mutex` (rather than a combination of both). Lastly, we implement `loadNativeObj` for Windows too. - - - - - 12931698 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 Use symbol cache in internal interpreter too This commit makes the symbol cache that was used by the external interpreter available for the internal interpreter too. This follows from the analysis in #23415 that suggests the internal interpreter could benefit from this cache too, and that there is no good reason not to have the cache for it too. It also makes it a bit more uniform to have the symbol cache range over both the internal and external interpreter. This commit also refactors the cache into a function which is used by both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the caching logic to `lookupSymbolInDLL` too. - - - - - dccd3ea1 by Ben Gamari at 2024-04-10T05:40:29-04:00 testsuite: Add test for lookupSymbolInNativeObj - - - - - 1b1a92bd by Alan Zimmerman at 2024-04-10T05:41:05-04:00 EPA: Remove unnecessary XRec in CompleteMatchSig The XRec for [LIdP pass] is not needed for exact printing, remove it. - - - - - 6e18ce2b by Ben Gamari at 2024-04-12T08:16:09-04:00 users-guide: Clarify language extension documentation Over the years the users guide's language extension documentation has gone through quite a few refactorings. In the process some of the descriptions have been rendered non-sensical. For instance, the description of `NoImplicitPrelude` actually describes the semantics of `ImplicitPrelude`. To fix this we: * ensure that all extensions are named in their "positive" sense (e.g. `ImplicitPrelude` rather than `NoImplicitPrelude`). * rework the documentation to avoid flag-oriented wording like "enable" and "disable" * ensure that the polarity of the documentation is consistent with reality. Fixes #23895. - - - - - a933aff3 by Zubin Duggal at 2024-04-12T08:16:45-04:00 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - 23c3e624 by Andreas Klebinger at 2024-04-12T08:17:21-04:00 RTS: Emit warning when -M < -H Fixes #24487 - - - - - d23afb8c by Ben Gamari at 2024-04-12T08:17:56-04:00 testsuite: Add broken test for CApiFFI with -fprefer-bytecode See #24634. - - - - - a4bb3a51 by Ben Gamari at 2024-04-12T08:18:32-04:00 base: Deprecate GHC.Pack As proposed in #21461. Closes #21540. - - - - - 55eb8c98 by Ben Gamari at 2024-04-12T08:19:08-04:00 ghc-internal: Fix mentions of ghc-internal in deprecation warnings Closes #24609. - - - - - b0fbd181 by Ben Gamari at 2024-04-12T08:19:44-04:00 rts: Implement set_initial_registers for AArch64 Fixes #23680. - - - - - 14c9ec62 by Ben Gamari at 2024-04-12T08:20:20-04:00 ghcup-metadata: Use Debian 9 binaries on Ubuntu 16, 17 Closes #24646. - - - - - 35a1621e by Ben Gamari at 2024-04-12T08:20:55-04:00 Bump unix submodule to 2.8.5.1 Closes #24640. - - - - - a1c24df0 by Finley McIlwaine at 2024-04-12T08:21:31-04:00 Correct default -funfolding-use-threshold in docs - - - - - 0255d03c by Oleg Grenrus at 2024-04-12T08:22:07-04:00 FastString is a __Modified__ UTF-8 - - - - - c3489547 by Matthew Pickering at 2024-04-12T13:13:44-04:00 rts: Improve tracing message when nursery is resized It is sometimes more useful to know how much bigger or smaller the nursery got when it is resized. In particular I am trying to investigate situations where we end up with fragmentation due to the nursery (#24577) - - - - - 5e4f4ba8 by Simon Peyton Jones at 2024-04-12T13:14:20-04:00 Don't generate wrappers for `type data` constructors with StrictData Previously, the logic for checking if a data constructor needs a wrapper or not would take into account whether the constructor's fields have explicit strictness (e.g., `data T = MkT !Int`), but the logic would _not_ take into account whether `StrictData` was enabled. This meant that something like `type data T = MkT Int` would incorrectly generate a wrapper for `MkT` if `StrictData` was enabled, leading to the horrible errors seen in #24620. To fix this, we disable generating wrappers for `type data` constructors altogether. Fixes #24620. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - dbdf1995 by Alex Mason at 2024-04-15T15:28:26+10:00 Implements MO_S_Mul2 and MO_U_Mul2 using the UMULH, UMULL and SMULH instructions for AArch64 Also adds a test for MO_S_Mul2 - - - - - 42bd0407 by Teo Camarasu at 2024-04-16T20:06:39-04:00 Make template-haskell a stage1 package Promoting template-haskell from a stage0 to a stage1 package means that we can much more easily refactor template-haskell. We implement this by duplicating the in-tree `template-haskell`. A new `template-haskell-next` library is autogenerated to mirror `template-haskell` `stage1:ghc` to depend on the new interface of the library including the `Binary` instances without adding an explicit dependency on `template-haskell`. This is controlled by the `bootstrap-th` cabal flag When building `template-haskell` modules as part of this vendoring we do not have access to quote syntax, so we cannot use variable quote notation (`'Just`). So we either replace these with hand-written `Name`s or hide the code behind CPP. We can remove the `th_hack` from hadrian, which was required when building stage0 packages using the in-tree `template-haskell` library. For more details see Note [Bootstrapping Template Haskell]. Resolves #23536 Co-Authored-By: Sebastian Graf <sgraf1337 at gmail.com> Co-Authored-By: Matthew Craven <5086-clyring at users.noreply.gitlab.haskell.org> - - - - - 3d973e47 by Ben Gamari at 2024-04-16T20:07:15-04:00 Bump parsec submodule to 3.1.17.0 - - - - - 9d38bfa0 by Simon Peyton Jones at 2024-04-16T20:07:51-04:00 Clone CoVars in CorePrep This MR addresses #24463. It's all explained in the new Note [Cloning CoVars and TyVars] - - - - - 0fe2b410 by Andreas Klebinger at 2024-04-16T20:08:27-04:00 NCG: Fix a bug where we errounously removed a required jump instruction. Add a new method to the Instruction class to check if we can eliminate a jump in favour of fallthrough control flow. Fixes #24507 - - - - - 9f99126a by Teo Camarasu at 2024-04-16T20:09:04-04:00 Fix documentation preview from doc-tarball job - Include all the .html files and assets in the job artefacts - Include all the .pdf files in the job artefacts - Mark the artefact as an "exposed" artefact meaning it turns up in the UI. Resolves #24651 - - - - - 3a0642ea by Ben Gamari at 2024-04-16T20:09:39-04:00 rts: Ignore EINTR while polling in timerfd itimer implementation While the RTS does attempt to mask signals, it may be that a foreign library unmasks them. This previously caused benign warnings which we now ignore. See #24610. - - - - - 9a53cd3f by Alan Zimmerman at 2024-04-16T20:10:15-04:00 EPA: Add additional comments field to AnnsModule This is used in exact printing to store comments coming after the `where` keyword but before any comments allocated to imports or decls. It is used in ghc-exactprint, see https://github.com/alanz/ghc-exactprint/commit/44bbed311fd8f0d053053fef195bf47c17d34fa7 - - - - - e5c43259 by Bryan Richter at 2024-04-16T20:10:51-04:00 Remove unrunnable FreeBSD CI jobs FreeBSD runner supply is inelastic. Currently there is only one, and it's unavailable because of a hardware issue. - - - - - 914eb49a by Ben Gamari at 2024-04-16T20:11:27-04:00 rel-eng: Fix mktemp usage in recompress-all We need a temporary directory, not a file. - - - - - f30e4984 by Teo Camarasu at 2024-04-16T20:12:03-04:00 Fix ghc API link in docs/index.html This was missing part of the unit ID meaning it would 404. Resolves #24674 - - - - - d7a3d6b5 by Ben Gamari at 2024-04-16T20:12:39-04:00 template-haskell: Declare TH.Lib.Internal as not-home Rather than `hide`. Closes #24659. - - - - - 5eaa46e7 by Matthew Pickering at 2024-04-19T02:14:55-04:00 testsuite: Rename isCross() predicate to needsTargetWrapper() isCross() was a misnamed because it assumed that all cross targets would provide a target wrapper, but the two most common cross targets (javascript, wasm) don't need a target wrapper. Therefore we rename this predicate to `needsTargetWrapper()` so situations in the testsuite where we can check whether running executables requires a target wrapper or not. - - - - - 55a9d699 by Simon Peyton Jones at 2024-04-19T02:15:32-04:00 Do not float HNFs out of lambdas This MR adjusts SetLevels so that it is less eager to float a HNF (lambda or constructor application) out of a lambda, unless it gets to top level. Data suggests that this change is a small net win: * nofib bytes-allocated falls by -0.09% (but a couple go up) * perf/should_compile bytes-allocated falls by -0.5% * perf/should_run bytes-allocated falls by -0.1% See !12410 for more detail. When fiddling elsewhere, I also found that this patch had a huge positive effect on the (very delicate) test perf/should_run/T21839r But that improvement doesn't show up in this MR by itself. Metric Decrease: MultiLayerModulesRecomp T15703 parsing001 - - - - - f0701585 by Alan Zimmerman at 2024-04-19T02:16:08-04:00 EPA: Fix comments in mkListSyntaxTy0 Also extend the test to confirm. Addresses #24669, 1 of 4 - - - - - b01c01d4 by Serge S. Gulin at 2024-04-19T02:16:51-04:00 JS: set image `x86_64-linux-deb11-emsdk-closure` for build - - - - - c90c6039 by Alan Zimmerman at 2024-04-19T02:17:27-04:00 EPA: Provide correct span for PatBind And remove unused parameter in checkPatBind Contributes to #24669 - - - - - 26036f96 by Alan Zimmerman at 2024-04-19T13:11:08-04:00 EPA: Fix span for PatBuilderAppType Include the location of the prefix @ in the span for InVisPat. Also removes unnecessary annotations from HsTP. Contributes to #24669 - - - - - dba03aab by Matthew Craven at 2024-04-19T13:11:44-04:00 testsuite: Give the pre_cmd for mhu-perf more time - - - - - d31fbf6c by Krzysztof Gogolewski at 2024-04-19T21:04:09-04:00 Fix quantification order for a `op` b and a %m -> b Fixes #23764 Implements https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0640-tyop-quantification-order.rst Updates haddock submodule. - - - - - 385cd1c4 by Sebastian Graf at 2024-04-19T21:04:45-04:00 Make `seq#` a magic Id and inline it in CorePrep (#24124) We can save much code and explanation in Tag Inference and StgToCmm by making `seq#` a known-key Magic Id in `GHC.Internal.IO` and inline this definition in CorePrep. See the updated `Note [seq# magic]`. I also implemented a new `Note [Flatten case-bind]` to get better code for otherwise nested case scrutinees. I renamed the contructors of `ArgInfo` to use an `AI` prefix in order to resolve the clash between `type CpeApp = CoreExpr` and the data constructor of `ArgInfo`, as well as fixed typos in `Note [CorePrep invariants]`. Fixes #24252 and #24124. - - - - - 275e41a9 by Jade at 2024-04-20T11:10:40-04:00 Put the newline after errors instead of before them This mainly has consequences for GHCi but also slightly alters how the output of GHC on the commandline looks. Fixes: #22499 - - - - - dd339c7a by Teo Camarasu at 2024-04-20T11:11:16-04:00 Remove unecessary stage0 packages Historically quite a few packages had to be stage0 as they depended on `template-haskell` and that was stage0. In #23536 we made it so that was no longer the case. This allows us to remove a bunch of packages from this list. A few still remain. A new version of `Win32` is required by `semaphore-compat`. Including `Win32` in the stage0 set requires also including `filepath` because otherwise Hadrian's dependency logic gets confused. Once our boot compiler has a newer version of `Win32` all of these will be able to be dropped. Resolves #24652 - - - - - 2f8e3a25 by Alan Zimmerman at 2024-04-20T11:11:52-04:00 EPA: Avoid duplicated comments in splice decls Contributes to #24669 - - - - - c70b9ddb by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fix typos and namings (fixes #24602) You may noted that I've also changed term of ``` , global "h$vt_double" ||= toJExpr IntV ``` See "IntV" and ``` WaitReadOp -> \[] [fd] -> pure $ PRPrimCall $ returnS (app "h$waidRead" [fd]) ``` See "h$waidRead" - - - - - 3db54f9b by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: trivial checks for variable presence (fixes #24602) - - - - - 777f108f by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fs module imported twice (by emscripten and by ghc-internal). ghc-internal import wrapped in a closure to prevent conflict with emscripten (fixes #24602) Better solution is to use some JavaScript module system like AMD, CommonJS or even UMD. It will be investigated at other issues. At first glance we should try UMD (See https://github.com/umdjs/umd) - - - - - a45a5712 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: thread.js requires h$fds and h$fdReady to be declared for static code analysis, minimal code copied from GHCJS (fixes #24602) I've just copied some old pieces of GHCJS from publicly available sources (See https://github.com/Taneb/shims/blob/a6dd0202dcdb86ad63201495b8b5d9763483eb35/src/io.js#L607). Also I didn't put details to h$fds. I took minimal and left only its object initialization: `var h$fds = {};` - - - - - ad90bf12 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: heap and stack overflows reporting defined as js hard failure (fixes #24602) These errors were treated as a hard failure for browser application. The fix is trivial: just throw error. - - - - - 5962fa52 by Serge S. Gulin at 2024-04-21T16:33:44+03:00 JS: Stubs for code without actual implementation detected by Google Closure Compiler (fixes #24602) These errors were fixed just by introducing stubbed functions with throw for further implementation. - - - - - a0694298 by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add externs to linker (fixes #24602) After enabling jsdoc and built-in google closure compiler types I was needed to deal with the following: 1. Define NodeJS-environment types. I've just copied minimal set of externs from semi-official repo (see https://github.com/externs/nodejs/blob/6c6882c73efcdceecf42e7ba11f1e3e5c9c041f0/v8/nodejs.js#L8). 2. Define Emscripten-environment types: `HEAP8`. Emscripten already provides some externs in our code but it supposed to be run in some module system. And its definitions do not work well in plain bundle. 3. We have some functions which purpose is to add to functions some contextual information via function properties. These functions should be marked as `modifies` to let google closure compiler remove calls if these functions are not used actually by call graph. Such functions are: `h$o`, `h$sti`, `h$init_closure`, `h$setObjInfo`. 4. STG primitives such as registries and stuff from `GHC.StgToJS`. `dXX` properties were already present at externs generator function but they are started from `7`, not from `1`. This message is related: `// fixme does closure compiler bite us here?` - - - - - e58bb29f by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: added both tests: for size and for correctness (fixes #24602) By some reason MacOS builds add to stderr messages like: Ignoring unexpected archive entry: __.SYMDEF ... However I left stderr to `/dev/null` for compatibility with linux CI builds. - - - - - 909f3a9c by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Disable js linker warning for empty symbol table to make js tests running consistent across environments - - - - - 83eb10da by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add special preprocessor for js files due of needing to keep jsdoc comments (fixes #24602) Our js files have defined google closure compiler types at jsdoc entries but these jsdoc entries are removed by cpp preprocessor. I considered that reusing them in javascript-backend would be a nice thing. Right now haskell processor uses `-traditional` option to deal with comments and `//` operators. But now there are following compiler options: `-C` and `-CC`. You can read about them at GCC (see https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#index-CC) and CLang (see https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-CC). It seems that `-CC` works better for javascript jsdoc than `-traditional`. At least it leaves `/* ... */` comments w/o changes. - - - - - e1cf8dc2 by brandon s allbery kf8nh at 2024-04-22T03:48:26-04:00 fix link in CODEOWNERS It seems that our local Gitlab no longer has documentation for the `CODEOWNERS` file, but the master documentation still does. Use that instead. - - - - - 593f4e04 by Fendor at 2024-04-23T10:19:14-04:00 Add performance regression test for '-fwrite-simplified-core' - - - - - 1ba39b05 by Fendor at 2024-04-23T10:19:14-04:00 Typecheck corebindings lazily during bytecode generation This delays typechecking the corebindings until the bytecode generation happens. We also avoid allocating a thunk that is retained by `unsafeInterleaveIO`. In general, we shouldn't retain values of the hydrated `Type`, as not evaluating the bytecode object keeps it alive. It is better if we retain the unhydrated `IfaceType`. See Note [Hydrating Modules] - - - - - e916fc92 by Alan Zimmerman at 2024-04-23T10:19:50-04:00 EPA: Keep comments in a CaseAlt match The comments now live in the surrounding location, not inside the Match. Make sure we keep them. Closes #24707 - - - - - d2b17f32 by Cheng Shao at 2024-04-23T15:01:22-04:00 driver: force merge objects when building dynamic objects This patch forces the driver to always merge objects when building dynamic objects even when ar -L is supported. It is an oversight of !8887: original rationale of that patch is favoring the relatively cheap ar -L operation over object merging when ar -L is supported, which makes sense but only if we are building static objects! Omitting check for whether we are building dynamic objects will result in broken .so files with undefined reference errors at executable link time when building GHC with llvm-ar. Fixes #22210. - - - - - 209d09f5 by Julian Ospald at 2024-04-23T15:02:03-04:00 Allow non-absolute values for bootstrap GHC variable Fixes #24682 - - - - - 3fff0977 by Matthew Pickering at 2024-04-23T15:02:38-04:00 Don't depend on registerPackage function in Cabal More recent versions of Cabal modify the behaviour of libAbiHash which breaks our usage of registerPackage. It is simpler to inline the part of registerPackage that we need and avoid any additional dependency and complication using the higher-level function introduces. - - - - - c62dc317 by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: remove obsolete ln script This commit removes an obsolete ln script in ghc-bignum/gmp. See 060251c24ad160264ae8553efecbb8bed2f06360 for its original intention, but it's been obsolete for a long time, especially since the removal of the make build system. Hence the house cleaning. - - - - - 6399d52b by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: update gmp to 6.3.0 This patch bumps the gmp-tarballs submodule and updates gmp to 6.3.0. The tarball format is now xz, and gmpsrc.patch has been patched into the tarball so hadrian no longer needs to deal with patching logic when building in-tree GMP. - - - - - 65b4b92f by Cheng Shao at 2024-04-25T01:32:02-04:00 hadrian: remove obsolete Patch logic This commit removes obsolete Patch logic from hadrian, given we no longer need to patch the gmp tarball when building in-tree GMP. - - - - - 71f28958 by Cheng Shao at 2024-04-25T01:32:02-04:00 autoconf: remove obsolete patch detection This commit removes obsolete deletection logic of the patch command from autoconf scripts, given we no longer need to patch anything in the GHC build process. - - - - - daeda834 by Sylvain Henry at 2024-04-25T01:32:43-04:00 JS: correctly handle RUBBISH literals (#24664) - - - - - 8a06ddf6 by Matthew Pickering at 2024-04-25T11:16:16-04:00 Linearise ghc-internal and base build This is achieved by requesting the final package database for ghc-internal, which mandates it is fully built as a dependency of configuring the `base` package. This is at the expense of cross-package parrallelism between ghc-internal and the base package. Fixes #24436 - - - - - 94da9365 by Andrei Borzenkov at 2024-04-25T11:16:54-04:00 Fix tuple puns renaming (24702) Move tuple renaming short cutter from `isBuiltInOcc_maybe` to `isPunOcc_maybe`, so we consider incoming module. I also fixed some hidden bugs that raised after the change was done. - - - - - fa03b1fb by Fendor at 2024-04-26T18:03:13-04:00 Refactor the Binary serialisation interface The goal is simplifiy adding deduplication tables to `ModIface` interface serialisation. We identify two main points of interest that make this difficult: 1. UserData hardcodes what `Binary` instances can have deduplication tables. Moreover, it heavily uses partial functions. 2. GHC.Iface.Binary hardcodes the deduplication tables for 'Name' and 'FastString', making it difficult to add more deduplication. Instead of having a single `UserData` record with fields for all the types that can have deduplication tables, we allow to provide custom serialisers for any `Typeable`. These are wrapped in existentials and stored in a `Map` indexed by their respective `TypeRep`. The `Binary` instance of the type to deduplicate still needs to explicitly look up the decoder via `findUserDataReader` and `findUserDataWriter`, which is no worse than the status-quo. `Map` was chosen as microbenchmarks indicate it is the fastest for a small number of keys (< 10). To generalise the deduplication table serialisation mechanism, we introduce the types `ReaderTable` and `WriterTable` which provide a simple interface that is sufficient to implement a general purpose deduplication mechanism for `writeBinIface` and `readBinIface`. This allows us to provide a list of deduplication tables for serialisation that can be extended more easily, for example for `IfaceTyCon`, see the issue https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for more motivation. In addition to this refactoring, we split `UserData` into `ReaderUserData` and `WriterUserData`, to avoid partial functions and reduce overall memory usage, as we need fewer mutable variables. Bump haddock submodule to accomodate for `UserData` split. ------------------------- Metric Increase: MultiLayerModulesTH_Make MultiLayerModulesRecomp T21839c ------------------------- - - - - - bac57298 by Fendor at 2024-04-26T18:03:13-04:00 Split `BinHandle` into `ReadBinHandle` and `WriteBinHandle` A `BinHandle` contains too much information for reading data. For example, it needs to keep a `FastMutInt` and a `IORef BinData`, when the non-mutable variants would suffice. Additionally, this change has the benefit that anyone can immediately tell whether the `BinHandle` is used for reading or writing. Bump haddock submodule BinHandle split. - - - - - 4d6394dd by Simon Peyton Jones at 2024-04-26T18:03:49-04:00 Fix missing escaping-kind check in tcPatSynSig Note [Escaping kind in type signatures] explains how we deal with escaping kinds in type signatures, e.g. f :: forall r (a :: TYPE r). a where the kind of the body is (TYPE r), but `r` is not in scope outside the forall-type. I had missed this subtlety in tcPatSynSig, leading to #24686. This MR fixes it; and a similar bug in tc_top_lhs_type. (The latter is tested by T24686a.) - - - - - 981c2c2c by Alan Zimmerman at 2024-04-26T18:04:25-04:00 EPA: check-exact: check that the roundtrip reproduces the source Closes #24670 - - - - - a8616747 by Andrew Lelechenko at 2024-04-26T18:05:01-04:00 Document that setEnv is not thread-safe - - - - - 1e41de83 by Bryan Richter at 2024-04-26T18:05:37-04:00 CI: Work around frequent Signal 9 errors - - - - - a6d5f9da by Naïm Favier at 2024-04-27T17:52:40-04:00 ghc-internal: add MonadFix instance for (,) Closes https://gitlab.haskell.org/ghc/ghc/-/issues/24288, implements CLC proposal https://github.com/haskell/core-libraries-committee/issues/238. Adds a MonadFix instance for tuples, permitting value recursion in the "native" writer monad and bringing consistency with the existing instance for transformers's WriterT (and, to a lesser extent, for Solo). - - - - - 64feadcd by Rodrigo Mesquita at 2024-04-27T17:53:16-04:00 bindist: Fix xattr cleaning The original fix (725343aa) was incorrect because it used the shell bracket syntax which is the quoting syntax in autoconf, making the test for existence be incorrect and therefore `xattr` was never run. Fixes #24554 - - - - - e2094df3 by damhiya at 2024-04-28T23:52:00+09:00 Make read accepts binary integer formats CLC proposal : https://github.com/haskell/core-libraries-committee/issues/177 - - - - - 1c2fd963 by Alan Zimmerman at 2024-04-29T23:17:00-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 - - - - - 4189d17e by Sylvain Henry at 2024-04-29T23:17:42-04:00 LLVM: better unreachable default destination in Switch (#24717) See added note. Co-authored-by: Siddharth Bhat <siddu.druid at gmail.com> - - - - - a3725c88 by Cheng Shao at 2024-04-29T23:18:20-04:00 ci: enable wasm jobs for MRs with wasm label This patch enables wasm jobs for MRs with wasm label. Previously the wasm label didn't actually have any effect on the CI pipeline, and full-ci needed to be applied to run wasm jobs which was a waste of runners when working on the wasm backend, hence the fix here. - - - - - 702f7964 by Matthew Pickering at 2024-04-29T23:18:56-04:00 Make interface files and object files depend on inplace .conf file A potential fix for #24737 - - - - - 728af21e by Cheng Shao at 2024-04-30T05:30:23-04:00 utils: remove obsolete vagrant scripts Vagrantfile has long been removed in !5288. This commit further removes the obsolete vagrant scripts in the tree. - - - - - 36f2c342 by Cheng Shao at 2024-04-30T05:31:00-04:00 Update autoconf scripts Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 - - - - - ecbf22a6 by Ben Gamari at 2024-04-30T05:31:36-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 7eab4e01 by Alan Zimmerman at 2024-05-04T16:14:55+01:00 EPA: Widen stmtslist to include last semicolon Closes #24754 - - - - - 06f7db40 by Teo Camarasu at 2024-05-05T00:19:38-04:00 doc: Fix type error in hs_try_putmvar example - - - - - af000532 by Moritz Schuler at 2024-05-05T06:30:58-04:00 Fix parsing of module names in CLI arguments closes issue #24732 - - - - - da74e9c9 by Ben Gamari at 2024-05-05T06:31:34-04:00 ghc-platform: Add Setup.hs The Hadrian bootstrapping script relies upon `Setup.hs` to drive its build. Addresses #24761. - - - - - 35d34fde by Alan Zimmerman at 2024-05-05T12:52:40-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 - - - - - 03c5dfbf by Simon Peyton Jones at 2024-05-05T12:53:15-04:00 Fix a float-out error Ticket #24768 showed that the Simplifier was accidentally destroying a join point. It turned out to be that we were sending a bottoming join point to the top, accidentally abstracting over /other/ join points. Easily fixed. - - - - - adba68e7 by John Ericson at 2024-05-05T19:35:56-04:00 Substitute bindist files with Hadrian not configure The `ghc-toolchain` overhaul will eventually replace all this stuff with something much more cleaned up, but I think it is still worth making this sort of cleanup in the meantime so other untanglings and dead code cleaning can procede. I was able to delete a fair amount of dead code doing this too. `LLVMTarget_CPP` is renamed to / merged with `LLVMTarget` because it wasn't actually turned into a valid CPP identifier. (Original to 1345c7cc42c45e63ab1726a8fd24a7e4d4222467, actually.) Progress on #23966 Co-Authored-By: Sylvain Henry <hsyl20 at gmail.com> - - - - - 18f4ff84 by Alan Zimmerman at 2024-05-05T19:36:32-04:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 - - - - - a19201d4 by Matthew Craven at 2024-05-06T19:54:29-04:00 Add test cases for #24664 ...since none are present in the original MR !12463 fixing this issue. - - - - - 46328a49 by Alan Zimmerman at 2024-05-06T19:55:05-04:00 EPA: preserve comments in data decls Closes #24771 - - - - - 15f0d003 by Rodrigo Mesquita at 2024-05-07T15:33:13+01:00 Document NcgImpl methods Fixes #19914 - - - - - 19 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/merge_request_templates/Default.md - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - .gitmodules - CODEOWNERS - compiler/GHC.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/54321d785de2af7a23ace4f0069fa283f1134985...15f0d0039b402d9ec5fb52d1834b788838ee6b6b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/54321d785de2af7a23ace4f0069fa283f1134985...15f0d0039b402d9ec5fb52d1834b788838ee6b6b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 14:57:49 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Tue, 07 May 2024 10:57:49 -0400 Subject: [Git][ghc/ghc][wip/romes/fixes-4] Apply 1 suggestion(s) to 1 file(s) Message-ID: <663a416d23ad7_3f177335da14416368c@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/fixes-4 at Glasgow Haskell Compiler / GHC Commits: 32b96637 by Andreas Klebinger at 2024-05-07T14:57:45+00:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 1 changed file: - compiler/GHC/CmmToAsm/X86/Instr.hs Changes: ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -1033,7 +1033,7 @@ instance Outputable JumpDest where ppr (DestBlockId bid) = text "jd:" <> ppr bid ppr (DestImm _imm) = text "jd:noShow" --- Instances the methods of the same name in 'NgcImpl' +-- Implementations of the methods of 'NgcImpl' getJumpDestBlockId :: JumpDest -> Maybe BlockId getJumpDestBlockId (DestBlockId bid) = Just bid View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/32b9663796f08dc844e5821b056f79bb1a8b03c6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/32b9663796f08dc844e5821b056f79bb1a8b03c6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 15:11:41 2024 From: gitlab at gitlab.haskell.org (Serge S. Gulin (@gulin.serge)) Date: Tue, 07 May 2024 11:11:41 -0400 Subject: [Git][ghc/ghc][wip/T24504] IPE: WIP: Replace closure_desc string representation in logs output on Word32 Message-ID: <663a44ad34e17_3f17733816b9c1695be@gitlab.mail> Serge S. Gulin pushed to branch wip/T24504 at Glasgow Haskell Compiler / GHC Commits: a9badfdd by Serge S. Gulin at 2024-05-07T18:08:29+03:00 IPE: WIP: Replace closure_desc string representation in logs output on Word32 - - - - - 5 changed files: - rts/Trace.c - rts/eventlog/EventLog.c - testsuite/tests/rts/ipe/ipeEventLog.stderr - testsuite/tests/rts/ipe/ipeEventLog_fromMap.stderr - testsuite/tests/rts/ipe/ipeMap.c Changes: ===================================== rts/Trace.c ===================================== @@ -689,7 +689,7 @@ void traceIPE(const InfoProvEnt *ipe) ACQUIRE_LOCK(&trace_utx); tracePreface(); - debugBelch("IPE: table_name %s, closure_desc %d, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", + debugBelch("IPE: table_name %s, closure_desc %u, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", ipe->prov.table_name, ipe->prov.closure_desc, ipe->prov.ty_desc, ipe->prov.label, ipe->prov.unit_id, ipe->prov.module, ipe->prov.src_file, ipe->prov.src_span); ===================================== rts/eventlog/EventLog.c ===================================== @@ -1445,7 +1445,6 @@ void postIPE(const InfoProvEnt *ipe) const StgWord MAX_IPE_STRING_LEN = 65535; ACQUIRE_LOCK(&eventBufMutex); StgWord table_name_len = MIN(strlen(ipe->prov.table_name), MAX_IPE_STRING_LEN); - StgWord closure_desc_len = MIN(strlen(ipe->prov.closure_desc), MAX_IPE_STRING_LEN); StgWord ty_desc_len = MIN(strlen(ipe->prov.ty_desc), MAX_IPE_STRING_LEN); StgWord label_len = MIN(strlen(ipe->prov.label), MAX_IPE_STRING_LEN); StgWord module_len = MIN(strlen(ipe->prov.module), MAX_IPE_STRING_LEN); @@ -1455,14 +1454,15 @@ void postIPE(const InfoProvEnt *ipe) // 8 for the info word // 1 null after each string // 1 colon between src_file and src_span + // 4 for the closure_desc, 4 = uint32 StgWord extra_comma = 1; - StgWord len = 8+table_name_len+1+closure_desc_len+1+ty_desc_len+1+label_len+1+module_len+1+src_file_len+1+extra_comma+src_span_len+1; + StgWord len = 8+table_name_len+1+4+1+ty_desc_len+1+label_len+1+module_len+1+src_file_len+1+extra_comma+src_span_len+1; CHECK(!ensureRoomForVariableEvent(&eventBuf, len)); postEventHeader(&eventBuf, EVENT_IPE); postPayloadSize(&eventBuf, len); postWord64(&eventBuf, (StgWord) INFO_PTR_TO_STRUCT(ipe->info)); postStringLen(&eventBuf, ipe->prov.table_name, table_name_len); - postStringLen(&eventBuf, ipe->prov.closure_desc, closure_desc_len); + postWord32(&eventBuf, ipe->prov.closure_desc); postStringLen(&eventBuf, ipe->prov.ty_desc, ty_desc_len); postStringLen(&eventBuf, ipe->prov.label, label_len); postStringLen(&eventBuf, ipe->prov.module, module_len); ===================================== testsuite/tests/rts/ipe/ipeEventLog.stderr ===================================== @@ -1,20 +1,20 @@ -7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 -7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 -7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 -7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 -7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 -7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 -7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 -7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 -7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 -7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 -7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 -7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 -7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 -7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 -7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 -7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 -7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 -7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 -7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 -7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc 38, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc 118, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc 198, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc 278, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc 358, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc 438, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc 518, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc 598, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc 678, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc 758, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc 38, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc 118, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc 198, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc 278, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc 358, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc 438, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc 518, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc 598, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc 678, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc 758, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 ===================================== testsuite/tests/rts/ipe/ipeEventLog_fromMap.stderr ===================================== @@ -1,20 +1,20 @@ -7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 -7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 -7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 -7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 -7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 -7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 -7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 -7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 -7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 -7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 -7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 -7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 -7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 -7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 -7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 -7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 -7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 -7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 -7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 -7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc 758, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc 678, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc 598, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc 518, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc 438, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc 358, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc 278, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc 198, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc 118, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc 38, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc 758, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc 678, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc 598, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc 518, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc 438, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc 358, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc 278, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc 198, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc 118, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc 38, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 ===================================== testsuite/tests/rts/ipe/ipeMap.c ===================================== @@ -5,6 +5,7 @@ #include "ipe_lib.h" void assertStringsEqual(const char *s1, const char *s2); +void assertUInt32Equal(const uint32_t u1, const uint32_t u2); void shouldFindNothingInAnEmptyIPEMap(Capability *cap); HaskellObj shouldFindOneIfItHasBeenRegistered(Capability *cap); void shouldFindTwoIfTwoHaveBeenRegistered(Capability *cap, HaskellObj fortyTwo); @@ -71,7 +72,7 @@ HaskellObj shouldFindOneIfItHasBeenRegistered(Capability *cap) { InfoProvEnt result = lookupIPE_("shouldFindOneIfItHasBeenRegistered", get_itbl(fortyTwo)); assertStringsEqual(result.prov.table_name, "table_name_042"); - assertStringsEqual(result.prov.closure_desc, "closure_desc_042"); + assertUInt32Equal(result.prov.closure_desc, 33); assertStringsEqual(result.prov.ty_desc, "ty_desc_042"); assertStringsEqual(result.prov.label, "label_042"); assertStringsEqual(result.prov.unit_id, "unit-id"); @@ -163,3 +164,10 @@ void assertStringsEqual(const char *s1, const char *s2) { exit(1); } } + +void assertUInt32Equal(const uint32_t u1, const uint32_t u2) { + if (u1 != u2) { + errorBelch("%u != %u", u1, u2); + exit(1); + } +} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a9badfdd0784db9f36611ecfeac841f8c44a004b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a9badfdd0784db9f36611ecfeac841f8c44a004b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 15:32:03 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Tue, 07 May 2024 11:32:03 -0400 Subject: [Git][ghc/ghc][wip/fendor/ifacetype-deduplication] 2 commits: Add run-time configurability of .hi file compression Message-ID: <663a497373d53_3f17733b999e017896a@gitlab.mail> Hannes Siebenhandl pushed to branch wip/fendor/ifacetype-deduplication at Glasgow Haskell Compiler / GHC Commits: dcf53bdb by Matthew Pickering at 2024-05-07T17:31:50+02:00 Add run-time configurability of .hi file compression Introduce the flag `-fwrite-if-compression=<n>` which allows to configure the compression level of writing .hi files. The motivation is that some deduplication operations are too expensive for the average use case. Hence, we introduce multiple compression levels that have a minimal impact on performance, but still reduce the memory residency and `.hi` file size on disk considerably. We introduce three compression levels: * `1`: `Normal` mode. This is the least amount of compression. It deduplicates only `Name` and `FastString`s, and is naturally the fastest compression mode. * `2`: `Safe` mode. It has a noticeable impact on .hi file size and is marginally slower than `Normal` mode. In general, it should be safe to always use `Safe` mode. * `3`: `Full` deduplication mode. Deduplicate as much as we can, resulting in minimal .hi files, but at the cost of additional compilation time. Reading .hi files doesn't need to know the initial compression level, and can always deserialise a `ModIface`. This allows users to experiment with different compression levels for packages, without recompilation of dependencies. Note, the deduplication also has an additional side effect of reduced memory consumption to implicit sharing of deduplicated elements. See https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for example where that matters. ------------------------- Metric Decrease: MultiLayerModulesDefsGhciWithCore T16875 T21839c T24471 hard_hole_fits ------------------------- - - - - - 33f6125f by Matthew Pickering at 2024-05-07T17:31:50+02:00 Introduce regression tests for `.hi` file sizes Add regression tests to track how `-fwrite-if-compression` levels affect the size of `.hi` files. - - - - - 16 changed files: - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Type.hs - docs/users_guide/using-optimisation.rst - + testsuite/tests/iface/IfaceSharingIfaceType.hs - + testsuite/tests/iface/IfaceSharingName.hs - + testsuite/tests/iface/Lib.hs - + testsuite/tests/iface/Makefile - + testsuite/tests/iface/all.T - + testsuite/tests/iface/if_faststring.hs - + testsuite/tests/iface/if_ifacetype.hs - + testsuite/tests/iface/if_name.hs Changes: ===================================== compiler/GHC/Driver/DynFlags.hs ===================================== @@ -207,6 +207,7 @@ data DynFlags = DynFlags { dmdUnboxWidth :: !Int, -- ^ Whether DmdAnal should optimistically put an -- Unboxed demand on returned products with at most -- this number of fields + ifCompression :: Int, specConstrThreshold :: Maybe Int, -- ^ Threshold for SpecConstr specConstrCount :: Maybe Int, -- ^ Max number of specialisations for any one function specConstrRecursive :: Int, -- ^ Max number of specialisations for recursive types @@ -546,6 +547,7 @@ defaultDynFlags mySettings = maxPmCheckModels = 30, simplTickFactor = 100, dmdUnboxWidth = 3, -- Default: Assume an unboxed demand on function bodies returning a triple + ifCompression = 2, -- Default: Apply safe compressions specConstrThreshold = Just 2000, specConstrCount = Just 3, specConstrRecursive = 3, ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -163,7 +163,7 @@ import GHC.JS.Syntax import GHC.IfaceToCore ( typecheckIface, typecheckWholeCoreBindings ) -import GHC.Iface.Load ( ifaceStats, writeIface ) +import GHC.Iface.Load ( ifaceStats, writeIface, flagsToIfCompression ) import GHC.Iface.Make import GHC.Iface.Recomp import GHC.Iface.Tidy @@ -612,7 +612,7 @@ extract_renamed_stuff mod_summary tc_result = do -- enables the option which keeps the renamed source. hieFile <- mkHieFile mod_summary tc_result (fromJust rn_info) let out_file = ml_hie_file $ ms_location mod_summary - liftIO $ writeHieFile out_file hieFile + liftIO $ writeHieFile (flagsToIfCompression dflags) out_file hieFile liftIO $ putDumpFileMaybe logger Opt_D_dump_hie "HIE AST" FormatHaskell (ppr $ hie_asts hieFile) -- Validate HIE files @@ -1207,7 +1207,7 @@ hscMaybeWriteIface logger dflags is_simple iface old_iface mod_location = do withTiming logger (text "WriteIface"<+>brackets (text iface_name)) (const ()) - (writeIface logger profile iface_name iface) + (writeIface logger profile (flagsToIfCompression dflags) iface_name iface) if (write_interface || force_write_interface) then do ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -1695,6 +1695,9 @@ dynamic_flags_deps = [ , make_ord_flag defFlag "fno-refinement-level-hole-fits" (noArg (\d -> d { refLevelHoleFits = Nothing })) + , make_ord_flag defFlag "fwrite-if-compression" + (intSuffix (\n d -> d { ifCompression = n })) + , make_dep_flag defGhcFlag "fllvm-pass-vectors-in-regs" (noArg id) "vectors registers are now passed in registers by default." ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -14,6 +14,7 @@ module GHC.Iface.Binary ( writeBinIface, readBinIface, readBinIfaceHeader, + CompressionIFace(..), getSymtabName, CheckHiWay(..), TraceBinIFace(..), @@ -48,7 +49,7 @@ import GHC.Types.SrcLoc import GHC.Platform import GHC.Settings.Constants import GHC.Utils.Fingerprint -import GHC.Iface.Type (IfaceType, getIfaceType, putIfaceType) +import GHC.Iface.Type (IfaceType(..), getIfaceType, putIfaceType, ifaceTypeSharedByte) import Control.Monad import Data.Array @@ -73,6 +74,21 @@ data TraceBinIFace = TraceBinIFace (SDoc -> IO ()) | QuietBinIFace +data CompressionIFace + = NormalCompression + -- ^ Perform the normal compression operations, + -- such as deduplicating 'Name's and 'FastString's + | SafeExtraCompression + -- ^ Perform some extra compression steps that have minimal impact + -- on the run-time of 'ghc'. + -- + -- This reduces the size of '.hi' files significantly in some cases + -- and reduces overall memory usage in certain scenarios. + | MaximalCompression + -- ^ Try to compress as much as possible. + -- + -- Yields the smallest '.hi' files but at the cost of additional run-time. + -- | Read an interface file header, checking the magic number, version, and -- way. Returns the hash of the source file and a BinHandle which points at the -- start of the rest of the interface file data. @@ -199,8 +215,8 @@ getTables name_cache bh = do -- | Write an interface file. -- -- See Note [Deduplication during iface binary serialisation] for details. -writeBinIface :: Profile -> TraceBinIFace -> FilePath -> ModIface -> IO () -writeBinIface profile traceBinIface hi_path mod_iface = do +writeBinIface :: Profile -> TraceBinIFace -> CompressionIFace -> FilePath -> ModIface -> IO () +writeBinIface profile traceBinIface compressionLevel hi_path mod_iface = do bh <- openBinMem initBinMemSize let platform = profilePlatform profile put_ bh (binaryInterfaceMagic platform) @@ -214,7 +230,7 @@ writeBinIface profile traceBinIface hi_path mod_iface = do extFields_p_p <- tellBinWriter bh put_ bh extFields_p_p - putWithUserData traceBinIface bh mod_iface + putWithUserData traceBinIface compressionLevel bh mod_iface extFields_p <- tellBinWriter bh putAt bh extFields_p_p extFields_p @@ -228,9 +244,9 @@ writeBinIface profile traceBinIface hi_path mod_iface = do -- is necessary if you want to serialise Names or FastStrings. -- It also writes a symbol table and the dictionary. -- This segment should be read using `getWithUserData`. -putWithUserData :: Binary a => TraceBinIFace -> WriteBinHandle -> a -> IO () -putWithUserData traceBinIface bh payload = do - (name_count, fs_count, _b) <- putWithTables bh (\bh' -> put bh' payload) +putWithUserData :: Binary a => TraceBinIFace -> CompressionIFace -> WriteBinHandle -> a -> IO () +putWithUserData traceBinIface compressionLevel bh payload = do + (name_count, fs_count, _b) <- putWithTables compressionLevel bh (\bh' -> put bh' payload) case traceBinIface of QuietBinIFace -> return () @@ -253,12 +269,12 @@ putWithUserData traceBinIface bh payload = do -- It returns (number of names, number of FastStrings, payload write result) -- -- See Note [Order of deduplication tables during iface binary serialisation] -putWithTables :: WriteBinHandle -> (WriteBinHandle -> IO b) -> IO (Int, Int, b) -putWithTables bh' put_payload = do +putWithTables :: CompressionIFace -> WriteBinHandle -> (WriteBinHandle -> IO b) -> IO (Int, Int, b) +putWithTables compressionLevel bh' put_payload = do -- Initialise deduplicating tables. (fast_wt, fsWriter) <- initFastStringWriterTable (name_wt, nameWriter) <- initNameWriterTable - (ifaceType_wt, ifaceTypeWriter) <- initWriteIfaceType + (ifaceType_wt, ifaceTypeWriter) <- initWriteIfaceType compressionLevel -- Initialise the 'WriterUserData'. let writerUserData = mkWriterUserData @@ -485,15 +501,33 @@ initReadIfaceTypeTable ud = do , mkReaderFromTable = \tbl -> mkReader (getGenericSymtab tbl) } -initWriteIfaceType :: IO (WriterTable, BinaryWriter IfaceType) -initWriteIfaceType = do +initWriteIfaceType :: CompressionIFace -> IO (WriterTable, BinaryWriter IfaceType) +initWriteIfaceType compressionLevel = do sym_tab <- initGenericSymbolTable @(Map IfaceType) pure ( WriterTable { putTable = putGenericSymbolTable sym_tab (lazyPut' putIfaceType) } - , mkWriter $ putGenericSymTab sym_tab + , mkWriter $ ifaceWriter sym_tab ) + where + ifaceWriter sym_tab = case compressionLevel of + NormalCompression -> literalIfaceTypeSerialiser + SafeExtraCompression -> ifaceTyConAppSerialiser sym_tab + MaximalCompression -> fullIfaceTypeSerialiser sym_tab + + ifaceTyConAppSerialiser sym_tab bh ty = case ty of + IfaceTyConApp {} -> do + put_ bh ifaceTypeSharedByte + putGenericSymTab sym_tab bh ty + _ -> putIfaceType bh ty + + + fullIfaceTypeSerialiser sym_tab bh ty = do + put_ bh ifaceTypeSharedByte + putGenericSymTab sym_tab bh ty + + literalIfaceTypeSerialiser = putIfaceType initNameReaderTable :: NameCache -> IO (ReaderTable Name) ===================================== compiler/GHC/Iface/Ext/Binary.hs ===================================== @@ -43,7 +43,7 @@ import System.Directory ( createDirectoryIfMissing ) import System.FilePath ( takeDirectory ) import GHC.Iface.Ext.Types -import GHC.Iface.Binary (initWriteIfaceType, putAllTables, initReadIfaceTypeTable) +import GHC.Iface.Binary (initWriteIfaceType, putAllTables, initReadIfaceTypeTable, CompressionIFace) import GHC.Iface.Type (IfaceType) import System.IO.Unsafe (unsafeInterleaveIO) import qualified GHC.Utils.Binary as Binary @@ -73,8 +73,8 @@ putBinLine bh xs = do -- | Write a `HieFile` to the given `FilePath`, with a proper header and -- symbol tables for `Name`s and `FastString`s -writeHieFile :: FilePath -> HieFile -> IO () -writeHieFile hie_file_path hiefile = do +writeHieFile :: CompressionIFace -> FilePath -> HieFile -> IO () +writeHieFile compression hie_file_path hiefile = do bh0 <- openBinMem initBinMemSize -- Write the header: hieHeader followed by the @@ -85,7 +85,7 @@ writeHieFile hie_file_path hiefile = do (fs_tbl, fs_w) <- initFastStringWriterTable (name_tbl, name_w) <- initWriteNameTable - (iface_tbl, iface_w) <- initWriteIfaceType + (iface_tbl, iface_w) <- initWriteIfaceType compression let bh = setWriterUserData bh0 $ mkWriterUserData [ mkSomeBinaryWriter @IfaceType iface_w ===================================== compiler/GHC/Iface/Load.hs ===================================== @@ -26,6 +26,7 @@ module GHC.Iface.Load ( loadInterface, loadSysInterface, loadUserInterface, loadPluginInterface, findAndReadIface, readIface, writeIface, + flagsToIfCompression, moduleFreeHolesPrecise, needWiredInHomeIface, loadWiredInHomeIface, @@ -965,11 +966,19 @@ read_file logger name_cache unit_state dflags wanted_mod file_path = do -- | Write interface file -writeIface :: Logger -> Profile -> FilePath -> ModIface -> IO () -writeIface logger profile hi_file_path new_iface +writeIface :: Logger -> Profile -> CompressionIFace -> FilePath -> ModIface -> IO () +writeIface logger profile compression_level hi_file_path new_iface = do createDirectoryIfMissing True (takeDirectory hi_file_path) let printer = TraceBinIFace (debugTraceMsg logger 3) - writeBinIface profile printer hi_file_path new_iface + writeBinIface profile printer compression_level hi_file_path new_iface + +flagsToIfCompression :: DynFlags -> CompressionIFace +flagsToIfCompression dflags + | n <= 1 = NormalCompression + | n == 2 = SafeExtraCompression + -- n >= 3 + | otherwise = MaximalCompression + where n = ifCompression dflags -- | @readIface@ tries just the one file. -- ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -34,7 +34,7 @@ module GHC.Iface.Type ( ifTyConBinderVar, ifTyConBinderName, -- Binary utilities - putIfaceType, getIfaceType, + putIfaceType, getIfaceType, ifaceTypeSharedByte, -- Equality testing isIfaceLiftedTypeKind, @@ -92,12 +92,13 @@ import GHC.Utils.Misc import GHC.Utils.Panic import {-# SOURCE #-} GHC.Tc.Utils.TcType ( isMetaTyVar, isTyConableTyVar ) -import Control.DeepSeq +import Data.Maybe (isJust) import Data.Proxy -import Control.Monad ((<$!>)) -import Control.Arrow (first) import qualified Data.Semigroup as Semi -import Data.Maybe (isJust) +import Data.Word (Word8) +import Control.Arrow (first) +import Control.DeepSeq +import Control.Monad ((<$!>)) {- ************************************************************************ @@ -2197,12 +2198,35 @@ ppr_parend_preds :: [IfacePredType] -> SDoc ppr_parend_preds preds = parens (fsep (punctuate comma (map ppr preds))) instance Binary IfaceType where - put_ bh tyCon = case findUserDataWriter Proxy bh of - tbl -> putEntry tbl bh tyCon + put_ bh ty = + case findUserDataWriter Proxy bh of + tbl -> putEntry tbl bh ty - get bh = case findUserDataReader Proxy bh of - tbl -> getEntry tbl bh + get bh = getIfaceTypeShared bh +-- | This is the byte tag we expect to read when the next +-- value is not an 'IfaceType' value, but an offset into a +-- lookup value. +-- +-- Must not overlap with any byte tag in 'getIfaceType'. +ifaceTypeSharedByte :: Word8 +ifaceTypeSharedByte = 99 + +-- | Like 'getIfaceType' but checks for a specific byte tag +-- that indicates that we won't be able to read a 'IfaceType' value +-- but rather an offset into a lookup table. Consequentially, +-- we look up the value for the 'IfaceType' in the look up table. +-- +-- See Note [Deduplication during iface binary serialisation] +-- for details. +getIfaceTypeShared :: ReadBinHandle -> IO IfaceType +getIfaceTypeShared bh = do + start <- tellBinReader bh + tag <- getByte bh + if ifaceTypeSharedByte == tag + then case findUserDataReader Proxy bh of + tbl -> getEntry tbl bh + else seekBinReader bh start >> getIfaceType bh putIfaceType :: WriteBinHandle -> IfaceType -> IO () putIfaceType _ (IfaceFreeTyVar tv) ===================================== docs/users_guide/using-optimisation.rst ===================================== @@ -1777,3 +1777,23 @@ as such you shouldn't need to set any of them explicitly. A flag This flag sets the size (in bytes) threshold above which the second approach is used. You can disable the second approach entirely by setting the threshold to 0. + +.. ghc-flag:: -fwrite-if-compression=⟨n⟩ + :shortdesc: *default: 2.* Tweak the level of interface file compression. + :type: dynamic + :category: optimization + + :default: 2 + + This flag defines the level of compression of interface files when writing to disk. + The higher the flag, the more we deduplicate the interface file, at the cost of a higher compilation time. + Deduplication (when applied to :ghc-flag:`--make` mode and :ghc-flag:`--interactive` mode) decreases the size of interface files as well as reducing + the overall memory usage of GHC. + + Compression cannot be fully turned off, GHC always compresses interface files to a certain degree. + Currently, we support values of ``1``, ``2`` and ``3``. + Lower or higher values are clamped to ``1`` and ``3`` respectively. + + * ``1``: Compress as little as possible. No run-time impact, at the cost of interface file size and memory usage. + * ``2``: Apply compression with minimal run-time overhead, reducing the interface file size and memory usage. + * ``3``: Apply all possible compressions, minimal interface file sizes and memory usage, at the cost of run-time overhead. ===================================== testsuite/tests/iface/IfaceSharingIfaceType.hs ===================================== @@ -0,0 +1,44 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE OverloadedStrings #-} + +module IfaceSharingIfaceType (types) where + +import GHC.Data.FastString +import GHC.Builtin.Uniques +import GHC.Builtin.Names +import GHC.Builtin.Types +import GHC.Types.Name +import GHC.Types.SrcLoc +import GHC.Iface.Type +import GHC.CoreToIface +import GHC.Core.TyCo.Rep +import GHC + +[f1,f2,f3,f4,f5] = map mkVarOcc ["a", "b","c","d","e"] + +[u1,u2,u3,u4,u5] = map mkPreludeMiscIdUnique [10000..10004] + +names = [ mkExternalName u1 pRELUDE f1 noSrcSpan + , mkExternalName u2 pRELUDE f2 noSrcSpan + , mkExternalName u3 pRELUDE f3 noSrcSpan + , mkExternalName u4 pRELUDE f4 noSrcSpan + , mkExternalName u5 pRELUDE f5 noSrcSpan ] + +-- Int +intIfaceTy = toIfaceType intTy + +wordIfaceTy = toIfaceType wordTy + +listIntTy = toIfaceType (mkListTy intTy) + +funTy = (intTy `mkVisFunTyMany` wordTy `mkVisFunTyMany` mkListTy intTy) + +funIfaceTy = toIfaceType funTy + +reallyBigFunTy = toIfaceType (funTy `mkVisFunTyMany` funTy `mkVisFunTyMany` funTy `mkVisFunTyMany` funTy) + +forallIfaceTy = toIfaceType (dataConType justDataCon) + + +types = [intIfaceTy, wordIfaceTy, listIntTy, funIfaceTy, reallyBigFunTy, forallIfaceTy] + ===================================== testsuite/tests/iface/IfaceSharingName.hs ===================================== @@ -0,0 +1,21 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE OverloadedStrings #-} + +module IfaceSharingName where + +import Lib +import GHC.Data.FastString +import GHC.Builtin.Uniques +import GHC.Builtin.Names +import GHC.Types.Name +import GHC.Types.SrcLoc + +[f1,f2,f3,f4,f5] = map mkVarOcc ["a", "b","c","d","e"] + +[u1,u2,u3,u4,u5] = map mkPreludeMiscIdUnique [10000..10004] + +names = [ mkExternalName u1 pRELUDE f1 noSrcSpan + , mkExternalName u2 pRELUDE f2 noSrcSpan + , mkExternalName u3 pRELUDE f3 noSrcSpan + , mkExternalName u4 pRELUDE f4 noSrcSpan + , mkExternalName u5 pRELUDE f5 noSrcSpan ] ===================================== testsuite/tests/iface/Lib.hs ===================================== @@ -0,0 +1,15 @@ +module Lib where + +import GHC.Utils.Binary +import GHC.Iface.Binary +import qualified Data.ByteString as B +import System.Environment +import Data.Maybe + +testSize :: Binary a => CompressionIFace -> a -> IO Int +testSize compLvl payload = do + args <- getArgs + bh <- openBinMem 1024 + putWithUserData QuietBinIFace compLvl bh payload + withBinBuffer bh (\b -> return (B.length b)) + ===================================== testsuite/tests/iface/Makefile ===================================== @@ -0,0 +1,4 @@ +TOP=../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + ===================================== testsuite/tests/iface/all.T ===================================== @@ -0,0 +1,24 @@ +test( 'if_faststring' + , [ stat_from_file('normal', 5, 'NORMALSIZE') + , stat_from_file('medium', 5, 'MEDIUMSIZE') + , stat_from_file('full', 5, 'FULLSIZE') + , extra_files(["Lib.hs"])] + , compile_and_run + , ['-package ghc']) + +test( 'if_name' + , [ stat_from_file('normal', 5, 'NORMALSIZE') + , stat_from_file('medium', 5, 'MEDIUMSIZE') + , stat_from_file('full', 5, 'FULLSIZE') + , extra_files(["Lib.hs", "IfaceSharingName.hs"])] + , compile_and_run + , ['-package ghc']) + +test( 'if_ifacetype' + , [ stat_from_file('normal', 5, 'NORMALSIZE') + , stat_from_file('medium', 5, 'MEDIUMSIZE') + , stat_from_file('full', 5, 'FULLSIZE') + , extra_files(["Lib.hs", "IfaceSharingIfaceType.hs"])] + , compile_and_run + , ['-package ghc']) + ===================================== testsuite/tests/iface/if_faststring.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE OverloadedStrings #-} + +import Lib +import GHC.Data.FastString +import GHC.Iface.Binary + +main :: IO () +main = do + sz <- testSize MaximalCompression (concat (replicate 1000 ["abc", "cde", "efg" :: FastString])) + writeFile "FULLSIZE" (show sz) + sz <- testSize SafeExtraCompression (concat (replicate 1000 ["abc", "cde", "efg" :: FastString])) + writeFile "MEDIUMSIZE" (show sz) + sz <- testSize NormalCompression (concat (replicate 1000 ["abc", "cde", "efg" :: FastString])) + writeFile "NORMALSIZE" (show sz) ===================================== testsuite/tests/iface/if_ifacetype.hs ===================================== @@ -0,0 +1,13 @@ +import Lib +import IfaceSharingIfaceType +import GHC.Iface.Binary + +main :: IO () +main = do + sz <- testSize MaximalCompression (concat (replicate 500 types)) + writeFile "FULLSIZE" (show sz) + sz <- testSize SafeExtraCompression (concat (replicate 500 types)) + writeFile "MEDIUMSIZE" (show sz) + sz <- testSize NormalCompression (concat (replicate 500 types)) + writeFile "NORMALSIZE" (show sz) + ===================================== testsuite/tests/iface/if_name.hs ===================================== @@ -0,0 +1,12 @@ +import Lib +import IfaceSharingName +import GHC.Iface.Binary + +main :: IO () +main = do + sz <- testSize MaximalCompression (concat (replicate 1000 names)) + writeFile "FULLSIZE" (show sz) + sz <- testSize SafeExtraCompression (concat (replicate 1000 names)) + writeFile "MEDIUMSIZE" (show sz) + sz <- testSize NormalCompression (concat (replicate 1000 names)) + writeFile "NORMALSIZE" (show sz) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1ac9d688e176ade5e309b273fdd298a8ded1d4be...33f6125fb1f3b2e264e85013fa07d25f1a9e9043 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1ac9d688e176ade5e309b273fdd298a8ded1d4be...33f6125fb1f3b2e264e85013fa07d25f1a9e9043 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 15:32:23 2024 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 07 May 2024 11:32:23 -0400 Subject: [Git][ghc/ghc][wip/T24334] 2 commits: Simplifier: Preserve OccInfo on DataAlt fields when case binder is dead (#24770) Message-ID: <663a4987195e6_3f17733b997ec1794e@gitlab.mail> Sebastian Graf pushed to branch wip/T24334 at Glasgow Haskell Compiler / GHC Commits: 626ba070 by Sebastian Graf at 2024-05-07T17:30:44+02:00 Simplifier: Preserve OccInfo on DataAlt fields when case binder is dead (#24770) See the adjusted `Note [DataAlt occ info]`. This change also has a positive repercussion on `Note [Combine case alts: awkward corner]`. Fixes #24770. We now try not to call `dataConRepStrictness` in `adjustFieldsIdInfo` when all fields are lazy anyway, leading to a 2% ghc/alloc decrease in T9675. Metric Decrease: T9675 - - - - - b0ebad0e by Sebastian Graf at 2024-05-07T17:31:56+02:00 Kill seqRule, discard dead seq# in Prep (#24334) Discarding seq#s in Core land via `seqRule` was problematic; see #24334. So instead we discard certain dead, discardable seq#s in Prep now. See the updated `Note [seq# magic]`. This fixes the symptoms of #24334. - - - - - 15 changed files: - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Types/Id/Make.hs - testsuite/tests/codeGen/should_compile/T24264.hs - + testsuite/tests/core-to-stg/T24334.hs - + testsuite/tests/core-to-stg/T24334.stdout - testsuite/tests/core-to-stg/all.T - testsuite/tests/simplCore/should_compile/T21851.stderr - + testsuite/tests/simplCore/should_compile/T24770.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/CSE.hs ===================================== @@ -9,12 +9,8 @@ module GHC.Core.Opt.CSE (cseProgram, cseOneExpr) where import GHC.Prelude import GHC.Core.Subst -import GHC.Types.Var ( Var ) import GHC.Types.Var.Env ( mkInScopeSet ) -import GHC.Types.Id ( Id, idType, idHasRules, zapStableUnfolding - , idInlineActivation, setInlineActivation - , zapIdOccInfo, zapIdUsageInfo, idInlinePragma - , isJoinId, idJoinPointHood, idUnfolding ) +import GHC.Types.Id import GHC.Core.Utils ( mkAltExpr , exprIsTickedString , stripTicksE, stripTicksT, mkTicks ) @@ -754,7 +750,7 @@ combineAlts alts , Alt _ bndrs1 rhs1 <- alt1 , let filtered_alts = filterOut (identical_alt rhs1) rest_alts , not (equalLength rest_alts filtered_alts) - = assertPpr (null bndrs1) (ppr alts) $ + = assertPpr (all isDeadBinder bndrs1) (ppr alts) $ Alt DEFAULT [] rhs1 : filtered_alts | otherwise @@ -762,14 +758,13 @@ combineAlts alts where find_bndr_free_alt :: [CoreAlt] -> (Maybe CoreAlt, [CoreAlt]) - -- The (Just alt) is a binder-free alt - -- See Note [Combine case alts: awkward corner] + -- The (Just alt) is an alt where all fields are dead find_bndr_free_alt [] = (Nothing, []) find_bndr_free_alt (alt@(Alt _ bndrs _) : alts) - | null bndrs = (Just alt, alts) - | otherwise = case find_bndr_free_alt alts of - (mb_bf, alts) -> (mb_bf, alt:alts) + | all isDeadBinder bndrs = (Just alt, alts) + | otherwise = case find_bndr_free_alt alts of + (mb_bf, alts) -> (mb_bf, alt:alts) identical_alt rhs1 (Alt _ _ rhs) = eqCoreExpr rhs1 rhs -- Even if this alt has binders, they will have been cloned @@ -823,9 +818,9 @@ big for cheapEqExpr to catch it. Note [Combine case alts: awkward corner] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We would really like to check isDeadBinder on the binders in the -alternative. But alas, the simplifer zaps occ-info on binders in case -alternatives; see Note [Case alternative occ info] in GHC.Core.Opt.Simplify. +We check isDeadBinder on field binders in order to collapse into a DEFAULT alt. +But alas, the simplifer often zaps occ-info on field binders in DataAlts when +the case binder is alive; see Note [DataAlt occ info] in GHC.Core.Opt.Simplify. * One alternative (perhaps a good one) would be to do OccAnal just before CSE. Then perhaps we could get rid of combineIdenticalAlts @@ -833,14 +828,12 @@ alternatives; see Note [Case alternative occ info] in GHC.Core.Opt.Simplify. * Another would be for CSE to return free vars as it goes. -* But the current solution is to find a nullary alternative (including - the DEFAULT alt, if any). This will not catch - case x of - A y -> blah - B z p -> blah - where no alternative is nullary or DEFAULT. But the current - solution is at least cheap. - +* But the current solution is to accept that we do not catch cases such as + case x of c + A _ -> blah[c] + B _ _ -> blah[c] + where the case binder c is alive and no alternative is DEFAULT. + But the current solution is at least cheap. ************************************************************************ * * ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -2067,21 +2067,18 @@ unsafeEqualityProofRule {- ********************************************************************* * * - Rules for seq# and spark# + Rules for spark# * * ********************************************************************* -} -seqRule :: RuleM CoreExpr -seqRule = do +-- spark# :: forall a s . a -> State# s -> (# State# s, a #) +sparkRule :: RuleM CoreExpr +sparkRule = do -- reduce on HNF [Type _ty_a, Type _ty_s, a, s] <- getArgs guard $ exprIsHNF a return $ mkCoreUnboxedTuple [s, a] - --- spark# :: forall a s . a -> State# s -> (# State# s, a #) -sparkRule :: RuleM CoreExpr -sparkRule = seqRule -- reduce on HNF, just the same - -- XXX perhaps we shouldn't do this, because a spark eliminated by - -- this rule won't be counted as a dud at runtime? + -- XXX perhaps we shouldn't do this, because a spark eliminated by + -- this rule won't be counted as a dud at runtime? {- ************************************************************************ @@ -2158,9 +2155,7 @@ builtinRules platform <- getPlatform return $ Var (primOpId IntAndOp) `App` arg `App` mkIntVal platform (d - 1) - ], - - mkBasicRule seqHashName 4 seqRule + ] ] ++ builtinBignumRules {-# NOINLINE builtinRules #-} ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -26,7 +26,7 @@ core expression with (hopefully) improved usage information. module GHC.Core.Opt.OccurAnal ( occurAnalysePgm, occurAnalyseExpr, - zapLambdaBndrs, scrutBinderSwap_maybe + zapLambdaBndrs, BinderSwapDecision(..), scrutOkForBinderSwap ) where import GHC.Prelude hiding ( head, init, last, tail ) @@ -3262,7 +3262,7 @@ inline x, cancel the casts, and away we go. Note [Care with binder-swap on dictionaries] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -This Note explains why we need isDictId in scrutBinderSwap_maybe. +This Note explains why we need isDictId in scrutOkForBinderSwap. Consider this tricky example (#21229, #21470): class Sing (b :: Bool) where sing :: Bool @@ -3306,7 +3306,7 @@ Conclusion: for a /dictionary variable/ do not perform the clever cast version of the binder-swap -Hence the subtle isDictId in scrutBinderSwap_maybe. +Hence the subtle isDictId in scrutOkForBinderSwap. Note [Zap case binders in proxy bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -3328,7 +3328,7 @@ addBndrSwap :: OutExpr -> Id -> OccEnv -> OccEnv -- See Note [The binder-swap substitution] addBndrSwap scrut case_bndr env@(OccEnv { occ_bs_env = swap_env, occ_bs_rng = rng_vars }) - | Just (scrut_var, mco) <- scrutBinderSwap_maybe scrut + | DoBinderSwap scrut_var mco <- scrutOkForBinderSwap scrut , scrut_var /= case_bndr -- Consider: case x of x { ... } -- Do not add [x :-> x] to occ_bs_env, else lookupBndrSwap will loop @@ -3342,25 +3342,30 @@ addBndrSwap scrut case_bndr case_bndr' = zapIdOccInfo case_bndr -- See Note [Zap case binders in proxy bindings] -scrutBinderSwap_maybe :: OutExpr -> Maybe (OutVar, MCoercion) --- If (scrutBinderSwap_maybe e = Just (v, mco), then +-- | See bBinderSwaOk. +data BinderSwapDecision + = NoBinderSwap + | DoBinderSwap OutVar MCoercion + +scrutOkForBinderSwap :: OutExpr -> BinderSwapDecision +-- If (scrutOkForBinderSwap e = DoBinderSwap v mco, then -- v = e |> mco -- See Note [Case of cast] -- See Note [Care with binder-swap on dictionaries] -- -- We use this same function in SpecConstr, and Simplify.Iteration, -- when something binder-swap-like is happening -scrutBinderSwap_maybe (Var v) = Just (v, MRefl) -scrutBinderSwap_maybe (Cast (Var v) co) - | not (isDictId v) = Just (v, MCo (mkSymCo co)) +scrutOkForBinderSwap (Var v) = DoBinderSwap v MRefl +scrutOkForBinderSwap (Cast (Var v) co) + | not (isDictId v) = DoBinderSwap v (MCo (mkSymCo co)) -- Cast: see Note [Case of cast] -- isDictId: see Note [Care with binder-swap on dictionaries] -- The isDictId rejects a Constraint/Constraint binder-swap, perhaps -- over-conservatively. But I have never seen one, so I'm leaving -- the code as simple as possible. Losing the binder-swap in a -- rare case probably has very low impact. -scrutBinderSwap_maybe (Tick _ e) = scrutBinderSwap_maybe e -- Drop ticks -scrutBinderSwap_maybe _ = Nothing +scrutOkForBinderSwap (Tick _ e) = scrutOkForBinderSwap e -- Drop ticks +scrutOkForBinderSwap _ = NoBinderSwap lookupBndrSwap :: OccEnv -> Id -> (CoreExpr, Id) -- See Note [The binder-swap substitution] ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -1719,7 +1719,7 @@ extendCaseBndrEnv :: LevelEnv -> LevelEnv extendCaseBndrEnv le@(LE { le_subst = subst, le_env = id_env }) case_bndr (Var scrut_var) - -- We could use OccurAnal. scrutBinderSwap_maybe here, and perhaps + -- We could use OccurAnal. scrutOkForBinderSwap here, and perhaps -- get a bit more floating. But we didn't in the past and it's -- an unforced change, so I'm leaving it. = le { le_subst = extendSubstWithVar subst case_bndr scrut_var ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -23,7 +23,7 @@ import GHC.Core.TyCo.Compare( eqType ) import GHC.Core.Opt.Simplify.Env import GHC.Core.Opt.Simplify.Inline import GHC.Core.Opt.Simplify.Utils -import GHC.Core.Opt.OccurAnal ( occurAnalyseExpr, zapLambdaBndrs, scrutBinderSwap_maybe ) +import GHC.Core.Opt.OccurAnal ( occurAnalyseExpr, zapLambdaBndrs, scrutOkForBinderSwap, BinderSwapDecision (..) ) import GHC.Core.Make ( FloatBind, mkImpossibleExpr, castBottomExpr ) import qualified GHC.Core.Make import GHC.Core.Coercion hiding ( substCo, substCoVar ) @@ -33,7 +33,7 @@ import GHC.Core.FamInstEnv ( FamInstEnv, topNormaliseType_maybe ) import GHC.Core.DataCon ( DataCon, dataConWorkId, dataConRepStrictness , dataConRepArgTys, isUnboxedTupleDataCon - , StrictnessMark (..) ) + , StrictnessMark (..), dataConWrapId_maybe ) import GHC.Core.Opt.Stats ( Tick(..) ) import GHC.Core.Ppr ( pprCoreExpr ) import GHC.Core.Unfold @@ -3234,16 +3234,36 @@ The point is that we bring into the envt a binding after the outer case, and that makes (a,b) alive. At least we do unless the case binder is guaranteed dead. -Note [Case alternative occ info] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -When we are simply reconstructing a case (the common case), we always -zap the occurrence info on the binders in the alternatives. Even -if the case binder is dead, the scrutinee is usually a variable, and *that* -can bring the case-alternative binders back to life. -See Note [Add unfolding for scrutinee] +Note [DataAlt occ info] +~~~~~~~~~~~~~~~~~~~~~~~ +Our general goal is to preserve dead-ness occ-info on the field binders of a +case alternative. Why? It's generally a good idea, but one specific reason is to +support (SEQ4) of Note [seq# magic]. + +But we have to be careful: even if the field binder is not mentioned in the case +alternative and thus annotated IAmDead by OccurAnal, it might "come back to +life" in one of two ways: + + 1. If the case binder is alive, its unfolding might bring back the field + binder, as in Note [knownCon occ info]: + case blah of y { I# _ -> $wf (case y of I# v -> v) } + ==> + case blah of y { I# v -> $wf v } + 2. Even if the case binder appears to be dead, there is the scenario in + Note [Add unfolding for scrutinee], in which the fields come back to live + through the unfolding of variable scrutinee, as follows: + join j = case x of Just v -> blah v; Nothing -> ... in + case x of Just _ -> jump j; Nothing -> ... + ==> { inline j, unfold x to Just v, simplify } + join j = case x of Just v -> blah v; Nothing -> ... in + case x of Just v -> blah v; Nothing -> ... + +Thus, when we are simply reconstructing a case (the common case), and the +case binder is not dead, or the scrutinee is a variable, we zap the +occurrence info on DataAlt field binders. See `adjustFieldOccInfo`. Note [Improving seq] -~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~ Consider type family F :: * -> * type instance F Int = Int @@ -3349,7 +3369,9 @@ simplAlts env0 scrut case_bndr alts cont' -- NB: pass case_bndr::InId, not case_bndr' :: OutId, to prepareAlts -- See Note [Shadowing in prepareAlts] in GHC.Core.Opt.Simplify.Utils - ; alts' <- mapM (simplAlt alt_env' (Just scrut') imposs_deflt_cons case_bndr' cont') in_alts + ; alts' <- forM in_alts $ + simplAlt alt_env' (Just scrut') imposs_deflt_cons + case_bndr' (scrutOkForBinderSwap scrut) cont' ; let alts_ty' = contResultType cont' -- See Note [Avoiding space leaks in OutType] @@ -3375,36 +3397,39 @@ improveSeq _ env scrut _ case_bndr1 _ ------------------------------------ simplAlt :: SimplEnv - -> Maybe OutExpr -- The scrutinee - -> [AltCon] -- These constructors can't be present when - -- matching the DEFAULT alternative - -> OutId -- The case binder + -> Maybe OutExpr -- The scrutinee + -> [AltCon] -- These constructors can't be present when + -- matching the DEFAULT alternative + -> OutId -- The case binder `bndr` + -> BinderSwapDecision -- DoBinderSwap v co <==> scrut = Just (v |> co), + -- add unfolding `v :-> bndr |> sym co` -> SimplCont -> InAlt -> SimplM OutAlt -simplAlt env scrut' imposs_deflt_cons case_bndr' cont' (Alt DEFAULT bndrs rhs) +simplAlt env _scrut' imposs_deflt_cons case_bndr' bndr_swap' cont' (Alt DEFAULT bndrs rhs) = assert (null bndrs) $ - do { let env' = addDefaultUnfoldings env scrut' case_bndr' imposs_deflt_cons + do { let env' = addDefaultUnfoldings env case_bndr' bndr_swap' imposs_deflt_cons ; rhs' <- simplExprC env' rhs cont' ; return (Alt DEFAULT [] rhs') } -simplAlt env scrut' _ case_bndr' cont' (Alt (LitAlt lit) bndrs rhs) +simplAlt env _scrut' _ case_bndr' bndr_swap' cont' (Alt (LitAlt lit) bndrs rhs) = assert (null bndrs) $ - do { let env' = addAltUnfoldings env scrut' case_bndr' (Lit lit) + do { let env' = addAltUnfoldings env case_bndr' bndr_swap' (Lit lit) ; rhs' <- simplExprC env' rhs cont' ; return (Alt (LitAlt lit) [] rhs') } -simplAlt env scrut' _ case_bndr' cont' (Alt (DataAlt con) vs rhs) +simplAlt env scrut' _ case_bndr' bndr_swap' cont' (Alt (DataAlt con) vs rhs) = do { -- See Note [Adding evaluatedness info to pattern-bound variables] - let vs_with_evals = addEvals scrut' con vs - ; (env', vs') <- simplBinders env vs_with_evals + -- and Note [DataAlt occ info] + ; let vs_with_info = adjustFieldsIdInfo scrut' case_bndr' bndr_swap' con vs + ; (env', vs') <- simplBinders env vs_with_info -- Bind the case-binder to (con args) ; let inst_tys' = tyConAppArgs (idType case_bndr') con_app :: OutExpr con_app = mkConApp2 con inst_tys' vs' - env'' = addAltUnfoldings env' scrut' case_bndr' con_app + env'' = addAltUnfoldings env' case_bndr' bndr_swap' con_app ; rhs' <- simplExprC env'' rhs cont' ; return (Alt (DataAlt con) vs' rhs') } @@ -3438,9 +3463,10 @@ do it here). The right thing is to do some kind of binder-swap; see #15226 for discussion. -} -addEvals :: Maybe OutExpr -> DataCon -> [Id] -> [Id] +adjustFieldsIdInfo :: Maybe OutExpr -> OutId -> BinderSwapDecision -> DataCon -> [Id] -> [Id] -- See Note [Adding evaluatedness info to pattern-bound variables] -addEvals scrut con vs +-- and Note [DataAlt occ info] +adjustFieldsIdInfo scrut case_bndr bndr_swap con vs -- Deal with seq# applications | Just scr <- scrut , isUnboxedTupleDataCon con @@ -3449,59 +3475,75 @@ addEvals scrut con vs -- a list of arguments only to throw it away immediately. , Just (Var f) <- stripNArgs 4 scr , f `hasKey` seqHashKey - , let x' = zapIdOccInfoAndSetEvald MarkedStrict x - = [s, x'] + , let x' = setCaseBndrEvald MarkedStrict x + = map (adjustFieldOccInfo case_bndr bndr_swap) [s, x'] -- Deal with banged datacon fields -addEvals _scrut con vs = go vs the_strs - where - the_strs = dataConRepStrictness con - - go [] [] = [] - go (v:vs') strs | isTyVar v = v : go vs' strs - go (v:vs') (str:strs) = zapIdOccInfoAndSetEvald str v : go vs' strs - go _ _ = pprPanic "Simplify.addEvals" - (ppr con $$ - ppr vs $$ - ppr_with_length (map strdisp the_strs) $$ - ppr_with_length (dataConRepArgTys con) $$ - ppr_with_length (dataConRepStrictness con)) - where - ppr_with_length list - = ppr list <+> parens (text "length =" <+> ppr (length list)) - strdisp :: StrictnessMark -> SDoc - strdisp MarkedStrict = text "MarkedStrict" - strdisp NotMarkedStrict = text "NotMarkedStrict" - -zapIdOccInfoAndSetEvald :: StrictnessMark -> Id -> Id -zapIdOccInfoAndSetEvald str v = - setCaseBndrEvald str $ -- Add eval'dness info - zapIdOccInfo v -- And kill occ info; - -- see Note [Case alternative occ info] - -addDefaultUnfoldings :: SimplEnv -> Maybe OutExpr -> OutId -> [AltCon] -> SimplEnv -addDefaultUnfoldings env mb_scrut case_bndr imposs_deflt_cons + -- This case is quite allocation sensitive to T9233 which has a large record + -- with strict fields. Hence we try not to update vs twice! +adjustFieldsIdInfo _scrut case_bndr bndr_swap con vs + | Nothing <- dataConWrapId_maybe con + -- A common fast path; no need to allocate the_strs when they are all lazy + -- anyway! It shaves off 2% in T9675 + = map (adjustFieldOccInfo case_bndr bndr_swap) vs + | otherwise + = go vs the_strs + where + the_strs = dataConRepStrictness con + + go [] [] = [] + go (v:vs') strs | isTyVar v = v : go vs' strs + go (v:vs') (str:strs) = adjustFieldOccInfo case_bndr bndr_swap (setCaseBndrEvald str v) : go vs' strs + go _ _ = pprPanic "Simplify.adjustFieldsIdInfo" + (ppr con $$ + ppr vs $$ + ppr_with_length (map strdisp the_strs) $$ + ppr_with_length (dataConRepArgTys con) $$ + ppr_with_length (dataConRepStrictness con)) + where + ppr_with_length list + = ppr list <+> parens (text "length =" <+> ppr (length list)) + strdisp :: StrictnessMark -> SDoc + strdisp MarkedStrict = text "MarkedStrict" + strdisp NotMarkedStrict = text "NotMarkedStrict" + +adjustFieldOccInfo :: OutId -> BinderSwapDecision -> CoreBndr -> CoreBndr +-- Kill occ info if we do binder swap and the case binder is alive; +-- see Note [DataAlt occ info] +adjustFieldOccInfo case_bndr bndr_swap field_bndr + | isTyVar field_bndr + = field_bndr + + | not (isDeadBinder case_bndr) -- (1) in the Note: If the case binder is alive, + = zapIdOccInfo field_bndr -- the field binders might come back alive + + | DoBinderSwap{} <- bndr_swap -- (2) in the Note: If binder swap might take place, + = zapIdOccInfo field_bndr -- the case binder might come back alive + + | otherwise + = field_bndr -- otherwise the field binders stay dead + +addDefaultUnfoldings :: SimplEnv -> OutId -> BinderSwapDecision -> [AltCon] -> SimplEnv +addDefaultUnfoldings env case_bndr bndr_swap imposs_deflt_cons = env2 where unf = mkOtherCon imposs_deflt_cons -- Record the constructors that the case-binder *can't* be. env1 = addBinderUnfolding env case_bndr unf - env2 | Just scrut <- mb_scrut - , Just (v,_mco) <- scrutBinderSwap_maybe scrut + env2 | DoBinderSwap v _mco <- bndr_swap = addBinderUnfolding env1 v unf | otherwise = env1 -addAltUnfoldings :: SimplEnv -> Maybe OutExpr -> OutId -> OutExpr -> SimplEnv -addAltUnfoldings env mb_scrut case_bndr con_app +addAltUnfoldings :: SimplEnv -> OutId -> BinderSwapDecision -> OutExpr -> SimplEnv +addAltUnfoldings env case_bndr bndr_swap con_app = env2 where con_app_unf = mk_simple_unf con_app env1 = addBinderUnfolding env case_bndr con_app_unf -- See Note [Add unfolding for scrutinee] - env2 | Just scrut <- mb_scrut - , Just (v,mco) <- scrutBinderSwap_maybe scrut + env2 | DoBinderSwap v mco <- bndr_swap = addBinderUnfolding env1 v $ if isReflMCo mco -- isReflMCo: avoid calling mk_simple_unf then con_app_unf -- twice in the common case @@ -3580,7 +3622,7 @@ So instead we add the unfolding x -> Just a, and x -> Nothing in the respective RHSs. Since this transformation is tantamount to a binder swap, we use -GHC.Core.Opt.OccurAnal.scrutBinderSwap_maybe to do the check. +GHC.Core.Opt.OccurAnal.scrutOkForBinderSwap to do the check. Exactly the same issue arises in GHC.Core.Opt.SpecConstr; see Note [Add scrutinee to ValueEnv too] in GHC.Core.Opt.SpecConstr @@ -3884,8 +3926,9 @@ mkDupableContWithDmds env _ ; let cont_scaling = contHoleScaling cont -- See Note [Scaling in case-of-case] ; (alt_env', case_bndr') <- simplBinder alt_env (scaleIdBy cont_scaling case_bndr) - ; alts' <- mapM (simplAlt alt_env' Nothing [] case_bndr' alt_cont) (scaleAltsBy cont_scaling alts) - -- Safe to say that there are no handled-cons for the DEFAULT case + ; alts' <- forM (scaleAltsBy cont_scaling alts) $ + simplAlt alt_env' Nothing [] case_bndr' NoBinderSwap alt_cont + -- Safe to say that there are no handled-cons for the DEFAULT case -- NB: simplBinder does not zap deadness occ-info, so -- a dead case_bndr' will still advertise its deadness -- This is really important because in ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -36,7 +36,7 @@ import GHC.Core.Opt.Simplify.Inline import GHC.Core.FVs ( exprsFreeVarsList, exprFreeVars ) import GHC.Core.Opt.Monad import GHC.Core.Opt.WorkWrap.Utils -import GHC.Core.Opt.OccurAnal( scrutBinderSwap_maybe ) +import GHC.Core.Opt.OccurAnal( BinderSwapDecision(..), scrutOkForBinderSwap ) import GHC.Core.DataCon import GHC.Core.Class( classTyVars ) import GHC.Core.Coercion hiding( substCo ) @@ -1104,7 +1104,7 @@ extendCaseBndrs env scrut case_bndr con alt_bndrs = (env2, alt_bndrs') where live_case_bndr = not (isDeadBinder case_bndr) - env1 | Just (v, mco) <- scrutBinderSwap_maybe scrut + env1 | DoBinderSwap v mco <- scrutOkForBinderSwap scrut , isReflMCo mco = extendValEnv env v cval | otherwise = env -- See Note [Add scrutinee to ValueEnv too] env2 | live_case_bndr = extendValEnv env1 case_bndr cval @@ -1198,7 +1198,7 @@ though the simplifier has systematically replaced uses of 'x' with 'y' and 'b' with 'c' in the code. The use of 'b' in the ValueEnv came from outside the case. See #4908 for the live example. -It's very like the binder-swap story, so we use scrutBinderSwap_maybe +It's very like the binder-swap story, so we use scrutOkForBinderSwap to identify suitable scrutinees -- but only if there is no cast (isReflMCo) because that's all that the ValueEnv allows. ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -890,6 +890,29 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con [covar] _]) floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } +cpeRhsE env (Case scrut bndr _ [Alt (DataAlt dc) [token_out, res] rhs]) + -- See item (SEQ4) of Note [seq# magic]. We want to match + -- case seq# @a @RealWorld s of (# s', _ #) -> rhs[s'] + -- and simplify to rhs[s]. Triggers in T15226. + | isUnboxedTupleDataCon dc + , (Var f,[_ty1, _ty2, arg, Var token_in]) <- collectArgs scrut + , f `hasKey` seqHashKey + , exprOkToDiscard arg + -- ok-to-discard, because we want to discard the evaluation of `arg`. + -- ok-to-discard includes ok-for-spec, but *also* CanFail primops such as + -- `quotInt# 1# 0#`, but not ThrowsException primops. + -- See Note [Classifying primop effects] + -- and Note [Transformations affected by primop effects] for why this is + -- the correct choice. + , Var token_in' <- lookupCorePrepEnv env token_in + , isDeadBinder res, isDeadBinder bndr + -- Check that bndr and res are dead + -- We can rely on `isDeadBinder res`, despite the fact that the Simplifier + -- often zaps the OccInfo on case-alternative binders (see Note [DataAlt occ info] + -- in GHC.Core.Opt.Simplify.Iteration) because the scrutinee is not a + -- variable, and in that case the zapping doesn't happen; see that Note. + = cpeRhsE (extendCorePrepEnv env token_out token_in') rhs + cpeRhsE env (Case scrut bndr ty alts) = do { (floats, scrut') <- cpeBody env scrut ; (env', bndr2) <- cpCloneBndr env bndr ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -2295,9 +2295,16 @@ Things to note also we can attach an evaldUnfolding to x' to discard any subsequent evals such as the `case x' of __DEFAULT`. +(SEQ4) + T15226 demonstrates that we want to discard ok-for-discard seq#s. That is, + simplify `case seq# s of (# s', _ #) -> rhs[s']` to `rhs[s]`. + You might wonder whether the Simplifier could do this. But see the excellent + example in #24334 (immortalised as test T24334) for why it should be done in + CorePrep. + Implementing seq#. The compiler has magic for `seq#` in -- GHC.Core.Opt.ConstantFold.seqRule: eliminate (seq# s) +- GHC.CoreToStg.Prep.cpeRhsE: Implement (SEQ4). - Simplify.addEvals records evaluated-ness for the result (cf. (SEQ3)); see Note [Adding evaluatedness info to pattern-bound variables] ===================================== testsuite/tests/codeGen/should_compile/T24264.hs ===================================== @@ -24,12 +24,8 @@ fun3 :: a -> IO a {-# OPAQUE fun3 #-} fun3 x = do pure () - -- "evaluate $! x" - case x of !x' -> IO (noinline seq# x') - -- noinline to work around the bogus seqRule - -- This ideally also should not push a continuation to the stack - -- before entering 'x'. It currently does, but let's wait for - -- !11515 to land before worrying about that. + evaluate $! x + -- This should not push a continuation to the stack before entering 'x' funPair :: a -> IO (a, a) {-# OPAQUE funPair #-} ===================================== testsuite/tests/core-to-stg/T24334.hs ===================================== @@ -0,0 +1,20 @@ +import Control.Exception +import Data.IORef + +strictPrint :: Show a => a -> IO () +{-# OPAQUE strictPrint #-} +strictPrint x = print $! x + +f :: Show a => a -> IORef a -> IO () +{-# OPAQUE f #-} +f x r = do + x' <- evaluate $! x + writeIORef r x' + strictPrint x' + +main :: IO () +main = do + r <- newIORef (42 :: Int) + f (error "foo") r `catch` \(e :: SomeException) -> return () + n <- readIORef r + print n ===================================== testsuite/tests/core-to-stg/T24334.stdout ===================================== @@ -0,0 +1 @@ +42 ===================================== testsuite/tests/core-to-stg/all.T ===================================== @@ -5,4 +5,5 @@ test('T23270', [grep_errmsg(r'patError')], compile, ['-O0 -dsuppress-uniques -dd test('T23914', normal, compile, ['-O']) test('T14895', normal, compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-uniques']) test('T24124', normal, compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-uniques']) +test('T24334', normal, compile_and_run, ['-O']) test('T24463', normal, compile, ['-O']) ===================================== testsuite/tests/simplCore/should_compile/T21851.stderr ===================================== @@ -10,8 +10,12 @@ g' :: Int -> Int [GblId, Arity=1, Str=, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 30 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [0] 30 0}] g' - = \ (x :: Int) -> case T21851a.$w$sf x of { (# ww, ww1 #) -> ww } + = \ (x :: Int) -> + case T21851a.$w$sf x of { (# ww, _ [Occ=Dead] #) -> ww } + + ===================================== testsuite/tests/simplCore/should_compile/T24770.hs ===================================== @@ -0,0 +1,3 @@ +module T24770 where + +foo = getLine >> getLine ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -516,3 +516,4 @@ test('T24370', normal, compile, ['-O']) test('T24551', normal, compile, ['-O -dcore-lint']) test('T24726', normal, compile, ['-dcore-lint -dsuppress-uniques']) test('T24768', normal, compile, ['-O']) +test('T24770', [ grep_errmsg(r'Dead') ], compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/214ab72dddb9a839448d61156f5f072717b778a5...b0ebad0ebc8c7cd8bf7730786add0a9f0a8a8227 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/214ab72dddb9a839448d61156f5f072717b778a5...b0ebad0ebc8c7cd8bf7730786add0a9f0a8a8227 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 16:11:33 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Tue, 07 May 2024 12:11:33 -0400 Subject: [Git][ghc/ghc][wip/romes/fixes-4] Document NcgImpl methods Message-ID: <663a52b522886_3f1773418d7d419201c@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/fixes-4 at Glasgow Haskell Compiler / GHC Commits: 3a89119a by Rodrigo Mesquita at 2024-05-07T17:11:24+01:00 Document NcgImpl methods Fixes #19914 - - - - - 4 changed files: - compiler/GHC/Cmm.hs - compiler/GHC/CmmToAsm/AArch64/RegInfo.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/X86/Instr.hs Changes: ===================================== compiler/GHC/Cmm.hs ===================================== @@ -304,7 +304,7 @@ instance Outputable CmmStatic where ppr (CmmString _) = text "CmmString" ppr (CmmFileEmbed fp _) = text "CmmFileEmbed" <+> text fp --- Static data before SRT generation +-- | Static data before or after SRT generation data GenCmmStatics (rawOnly :: Bool) where CmmStatics :: CLabel -- Label of statics ===================================== compiler/GHC/CmmToAsm/AArch64/RegInfo.hs ===================================== @@ -14,18 +14,16 @@ data JumpDest = DestBlockId BlockId instance Outputable JumpDest where ppr (DestBlockId bid) = text "jd:" <> ppr bid --- TODO: documen what this does. See Ticket 19914 +-- Implementations of the methods of 'NgcImpl' + getJumpDestBlockId :: JumpDest -> Maybe BlockId getJumpDestBlockId (DestBlockId bid) = Just bid --- TODO: document what this does. See Ticket 19914 canShortcut :: Instr -> Maybe JumpDest canShortcut _ = Nothing --- TODO: document what this does. See Ticket 19914 shortcutStatics :: (BlockId -> Maybe JumpDest) -> RawCmmStatics -> RawCmmStatics shortcutStatics _ other_static = other_static --- TODO: document what this does. See Ticket 19914 shortcutJump :: (BlockId -> Maybe JumpDest) -> Instr -> Instr shortcutJump _ other = other ===================================== compiler/GHC/CmmToAsm/Monad.hs ===================================== @@ -73,20 +73,33 @@ import GHC.Utils.Misc import GHC.CmmToAsm.CFG import GHC.CmmToAsm.CFG.Weight +-- | A Native Code Generator implementation is parametrised over +-- * The type of static data (typically related to 'CmmStatics') +-- * The type of instructions +-- * The type of jump destinations data NcgImpl statics instr jumpDest = NcgImpl { ncgConfig :: !NCGConfig, cmmTopCodeGen :: RawCmmDecl -> NatM [NatCmmDecl statics instr], generateJumpTableForInstr :: instr -> Maybe (NatCmmDecl statics instr), + -- | Given a jump destination, if it refers to a block, return the block id of the destination. getJumpDestBlockId :: jumpDest -> Maybe BlockId, -- | Does this jump always jump to a single destination and is shortcutable? -- - -- We use this to determine shortcutable instructions - See Note [What is shortcutting] + -- We use this to determine whether the given instruction is a shortcutable + -- jump to some destination - See Note [supporting shortcutting] -- Note that if we return a destination here we *most* support the relevant shortcutting in -- shortcutStatics for jump tables and shortcutJump for the instructions itself. canShortcut :: instr -> Maybe jumpDest, -- | Replace references to blockIds with other destinations - used to update jump tables. shortcutStatics :: (BlockId -> Maybe jumpDest) -> statics -> statics, -- | Change the jump destination(s) of an instruction. + -- + -- Rewrites the destination of a jump instruction to another + -- destination, if the given function returns a new jump destination for + -- the 'BlockId' of the original destination. + -- + -- For instance, for a mapping @block_a -> dest_b@ and a instruction @goto block_a@ we would + -- rewrite the instruction to @goto dest_b@ shortcutJump :: (BlockId -> Maybe jumpDest) -> instr -> instr, -- | 'Module' is only for printing internal labels. See Note [Internal proc -- labels] in CLabel. ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -1033,6 +1033,7 @@ instance Outputable JumpDest where ppr (DestBlockId bid) = text "jd:" <> ppr bid ppr (DestImm _imm) = text "jd:noShow" +-- Implementations of the methods of 'NgcImpl' getJumpDestBlockId :: JumpDest -> Maybe BlockId getJumpDestBlockId (DestBlockId bid) = Just bid @@ -1043,7 +1044,6 @@ canShortcut (JXX ALWAYS id) = Just (DestBlockId id) canShortcut (JMP (OpImm imm) _) = Just (DestImm imm) canShortcut _ = Nothing - -- This helper shortcuts a sequence of branches. -- The blockset helps avoid following cycles. shortcutJump :: (BlockId -> Maybe JumpDest) -> Instr -> Instr View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3a89119a2cb82f4751520da1caf16a9d5d4aa6bd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3a89119a2cb82f4751520da1caf16a9d5d4aa6bd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 16:18:19 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Tue, 07 May 2024 12:18:19 -0400 Subject: [Git][ghc/ghc][wip/reinstallable-th] 4 commits: Move GHC.Lexeme into ghc-internal Message-ID: <663a544b94caf_3f1773431b9ac194272@gitlab.mail> Teo Camarasu pushed to branch wip/reinstallable-th at Glasgow Haskell Compiler / GHC Commits: fe6bdab9 by Teo Camarasu at 2024-05-07T16:21:47+01:00 Move GHC.Lexeme into ghc-internal - - - - - 3734bab3 by Teo Camarasu at 2024-05-07T16:36:58+01:00 Move GHC.Internal.TH.Lib to ghc-internal - - - - - d3ff4716 by Teo Camarasu at 2024-05-07T17:17:18+01:00 Move GHC.Internal.TH.Lift to ghc-internal - - - - - bbb27ec8 by Teo Camarasu at 2024-05-07T17:17:43+01:00 Move GHC.Internal.TH.Quote to ghc-internal - - - - - 11 changed files: - compiler/GHC/Builtin/Names/TH.hs - libraries/base/src/Data/Array/Byte.hs - libraries/base/src/Data/Fixed.hs - libraries/ghc-boot-th/GHC/Internal/TH/Lift.hs - libraries/ghc-boot-th/GHC/Internal/TH/Ppr.hs - libraries/ghc-boot-th/ghc-boot-th.cabal.in - libraries/ghc-internal/ghc-internal.cabal - libraries/ghc-boot-th/GHC/Internal/TH/Lib.hs → libraries/ghc-internal/src/GHC/Internal/TH/Lib.hs - + libraries/ghc-internal/src/GHC/Internal/TH/Lift.hs - libraries/ghc-boot-th/GHC/Internal/TH/Quote.hs → libraries/ghc-internal/src/GHC/Internal/TH/Quote.hs - libraries/ghc-boot-th/GHC/Lexeme.hs → libraries/ghc-internal/src/GHC/Lexeme.hs Changes: ===================================== compiler/GHC/Builtin/Names/TH.hs ===================================== @@ -186,7 +186,7 @@ qqLib = mkTHModule (fsLit "GHC.Internal.TH.Quote") liftLib = mkTHModule (fsLit "GHC.Internal.TH.Lift") mkTHModule :: FastString -> Module -mkTHModule m = mkModule thUnit (mkModuleNameFS m) +mkTHModule m = mkModule ghcInternalUnit (mkModuleNameFS m) libFun, libTc, thFun, thTc, thCls, thCon, liftFun :: FastString -> Unique -> Name libFun = mk_known_key_name varName thLib ===================================== libraries/base/src/Data/Array/Byte.hs ===================================== @@ -13,6 +13,7 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE Trustworthy #-} {-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE TemplateHaskellQuotes #-} module Data.Array.Byte ( ByteArray(..), @@ -30,6 +31,9 @@ import GHC.Num.Integer (Integer(..)) import GHC.Internal.Show (intToDigit) import GHC.Internal.ST (ST(..), runST) import GHC.Internal.Word (Word8(..)) +import GHC.Internal.TH.Syntax +import GHC.Internal.TH.Lift +import GHC.Internal.ForeignPtr import Prelude -- | Lifted wrapper for 'ByteArray#'. @@ -179,6 +183,34 @@ instance Show ByteArray where where comma | i == 0 = id | otherwise = showString ", " +instance Lift ByteArray where + liftTyped x = unsafeCodeCoerce (lift x) + lift (ByteArray b) = return + (AppE (AppE (VarE addrToByteArrayName) (LitE (IntegerL (fromIntegral len)))) + (LitE (BytesPrimL (Bytes ptr 0 (fromIntegral len))))) + where + len# = sizeofByteArray# b + len = I# len# + pb :: ByteArray# + !(ByteArray pb) + | isTrue# (isByteArrayPinned# b) = ByteArray b + | otherwise = runST $ ST $ + \s -> case newPinnedByteArray# len# s of + (# s', mb #) -> case copyByteArray# b 0# mb 0# len# s' of + s'' -> case unsafeFreezeByteArray# mb s'' of + (# s''', ret #) -> (# s''', ByteArray ret #) + ptr :: ForeignPtr Word8 + ptr = ForeignPtr (byteArrayContents# pb) (PlainPtr (unsafeCoerce# pb)) + +addrToByteArrayName :: Name +addrToByteArrayName = 'addrToByteArray + +addrToByteArray :: Int -> Addr# -> ByteArray +addrToByteArray (I# len) addr = runST $ ST $ + \s -> case newByteArray# len s of + (# s', mb #) -> case copyAddrToByteArray# addr mb 0# len s' of + s'' -> case unsafeFreezeByteArray# mb s'' of + (# s''', ret #) -> (# s''', ByteArray ret #) -- | Compare prefixes of given length. compareByteArraysFromBeginning :: ByteArray -> ByteArray -> Int -> Ordering ===================================== libraries/base/src/Data/Fixed.hs ===================================== @@ -2,6 +2,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE TemplateHaskellQuotes #-} ----------------------------------------------------------------------------- -- | @@ -90,6 +91,8 @@ import GHC.Internal.TypeLits (KnownNat, natVal) import GHC.Internal.Read import GHC.Internal.Text.ParserCombinators.ReadPrec import GHC.Internal.Text.Read.Lex +import qualified GHC.Internal.TH.Syntax as TH +import qualified GHC.Internal.TH.Lift as TH import Data.Typeable import Prelude @@ -137,6 +140,11 @@ instance (Typeable k,Typeable a) => Data (Fixed (a :: k)) where dataTypeOf _ = tyFixed toConstr _ = conMkFixed +instance TH.Lift (Fixed a) where + liftTyped x = TH.unsafeCodeCoerce (TH.lift x) + lift (MkFixed x) = [| MkFixed x |] + + -- | Types which can be used as a resolution argument to the 'Fixed' type constructor must implement the 'HasResolution' typeclass. class HasResolution (a :: k) where -- | Provide the resolution for a fixed-point fractional number. ===================================== libraries/ghc-boot-th/GHC/Internal/TH/Lift.hs ===================================== @@ -1,602 +1,3 @@ -{-# OPTIONS_HADDOCK not-home #-} -- we want users to import Language.Haskell.TH.Syntax instead -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE DefaultSignatures #-} -{-# LANGUAGE KindSignatures #-} -{-# LANGUAGE MagicHash #-} -{-# LANGUAGE PolyKinds #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TemplateHaskellQuotes #-} -{-# LANGUAGE Trustworthy #-} -{-# LANGUAGE TypeOperators #-} -{-# LANGUAGE UnboxedSums #-} -{-# LANGUAGE UnboxedTuples #-} -{-# OPTIONS_GHC -fno-warn-inline-rule-shadowing #-} - -module GHC.Internal.TH.Lift where - -import GHC.Internal.TH.Syntax - -import Prelude -import Control.Monad (liftM) -import Data.Array.Byte (ByteArray(..)) -import Data.Char (ord) -import Data.Data hiding (Fixity(..)) -import Data.Int -import Data.List.NonEmpty ( NonEmpty(..) ) -import Data.Ratio -import Data.Void ( Void, absurd ) -import Data.Word -import GHC.CString ( unpackCString# ) -import GHC.Exts - ( ByteArray#, unsafeFreezeByteArray#, copyAddrToByteArray#, newByteArray# - , isByteArrayPinned#, isTrue#, sizeofByteArray#, unsafeCoerce#, byteArrayContents# - , copyByteArray#, newPinnedByteArray#) -import GHC.Types (TYPE, RuntimeRep(..), Levity(..)) -import GHC.ForeignPtr (ForeignPtr(..), ForeignPtrContents(..)) -import GHC.Lexeme ( startsVarSym, startsVarId ) -import GHC.Prim ( Int#, Word#, Char#, Double#, Float#, Addr# ) -import GHC.ST (ST(..), runST) -import GHC.Types ( Int(..), Word(..), Char(..), Double(..), Float(..)) -import Numeric.Natural -import qualified Data.Fixed as Fixed - --- See Note [Bootstrapping Template Haskell] - ------------------------------------------------------ --- --- The Lift class --- ------------------------------------------------------ - --- | A 'Lift' instance can have any of its values turned into a Template --- Haskell expression. This is needed when a value used within a Template --- Haskell quotation is bound outside the Oxford brackets (@[| ... |]@ or --- @[|| ... ||]@) but not at the top level. As an example: --- --- > add1 :: Int -> Code Q Int --- > add1 x = [|| x + 1 ||] --- --- Template Haskell has no way of knowing what value @x@ will take on at --- splice-time, so it requires the type of @x@ to be an instance of 'Lift'. --- --- A 'Lift' instance must satisfy @$(lift x) ≡ x@ and @$$(liftTyped x) ≡ x@ --- for all @x@, where @$(...)@ and @$$(...)@ are Template Haskell splices. --- It is additionally expected that @'lift' x ≡ 'unTypeCode' ('liftTyped' x)@. --- --- 'Lift' instances can be derived automatically by use of the @-XDeriveLift@ --- GHC language extension: --- --- > {-# LANGUAGE DeriveLift #-} --- > module Foo where --- > --- > import Language.Haskell.TH.Syntax --- > --- > data Bar a = Bar1 a (Bar a) | Bar2 String --- > deriving Lift --- --- Representation-polymorphic since /template-haskell-2.16.0.0/. -class Lift (t :: TYPE r) where - -- | Turn a value into a Template Haskell expression, suitable for use in - -- a splice. - lift :: Quote m => t -> m Exp - default lift :: (r ~ ('BoxedRep 'Lifted), Quote m) => t -> m Exp - lift = unTypeCode . liftTyped - - -- | Turn a value into a Template Haskell typed expression, suitable for use - -- in a typed splice. - -- - -- @since 2.16.0.0 - liftTyped :: Quote m => t -> Code m t - - --- If you add any instances here, consider updating test th/TH_Lift -instance Lift Integer where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL x)) - -instance Lift Int where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - --- | @since 2.16.0.0 -instance Lift Int# where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntPrimL (fromIntegral (I# x)))) - -instance Lift Int8 where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - -instance Lift Int16 where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - -instance Lift Int32 where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - -instance Lift Int64 where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - --- | @since 2.16.0.0 -instance Lift Word# where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (WordPrimL (fromIntegral (W# x)))) - -instance Lift Word where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - -instance Lift Word8 where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - -instance Lift Word16 where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - -instance Lift Word32 where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - -instance Lift Word64 where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - -instance Lift Natural where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (IntegerL (fromIntegral x))) - -instance Lift (Fixed.Fixed a) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (Fixed.MkFixed x) = do - ex <- lift x - return (ConE mkFixedName `AppE` ex) - where - mkFixedName = 'Fixed.MkFixed - -instance Integral a => Lift (Ratio a) where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (RationalL (toRational x))) - -instance Lift Float where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (RationalL (toRational x))) - --- | @since 2.16.0.0 -instance Lift Float# where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (FloatPrimL (toRational (F# x)))) - -instance Lift Double where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (RationalL (toRational x))) - --- | @since 2.16.0.0 -instance Lift Double# where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (DoublePrimL (toRational (D# x)))) - -instance Lift Char where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (CharL x)) - --- | @since 2.16.0.0 -instance Lift Char# where - liftTyped x = unsafeCodeCoerce (lift x) - lift x = return (LitE (CharPrimL (C# x))) - -instance Lift Bool where - liftTyped x = unsafeCodeCoerce (lift x) - - lift True = return (ConE trueName) - lift False = return (ConE falseName) - --- | Produces an 'Addr#' literal from the NUL-terminated C-string starting at --- the given memory address. --- --- @since 2.16.0.0 -instance Lift Addr# where - liftTyped x = unsafeCodeCoerce (lift x) - lift x - = return (LitE (StringPrimL (map (fromIntegral . ord) (unpackCString# x)))) - -- | --- @since 2.19.0.0 -instance Lift ByteArray where - liftTyped x = unsafeCodeCoerce (lift x) - lift (ByteArray b) = return - (AppE (AppE (VarE addrToByteArrayName) (LitE (IntegerL (fromIntegral len)))) - (LitE (BytesPrimL (Bytes ptr 0 (fromIntegral len))))) - where - len# = sizeofByteArray# b - len = I# len# - pb :: ByteArray# - !(ByteArray pb) - | isTrue# (isByteArrayPinned# b) = ByteArray b - | otherwise = runST $ ST $ - \s -> case newPinnedByteArray# len# s of - (# s', mb #) -> case copyByteArray# b 0# mb 0# len# s' of - s'' -> case unsafeFreezeByteArray# mb s'' of - (# s''', ret #) -> (# s''', ByteArray ret #) - ptr :: ForeignPtr Word8 - ptr = ForeignPtr (byteArrayContents# pb) (PlainPtr (unsafeCoerce# pb)) - -addrToByteArrayName :: Name -addrToByteArrayName = 'addrToByteArray - -addrToByteArray :: Int -> Addr# -> ByteArray -addrToByteArray (I# len) addr = runST $ ST $ - \s -> case newByteArray# len s of - (# s', mb #) -> case copyAddrToByteArray# addr mb 0# len s' of - s'' -> case unsafeFreezeByteArray# mb s'' of - (# s''', ret #) -> (# s''', ByteArray ret #) - -instance Lift a => Lift (Maybe a) where - liftTyped x = unsafeCodeCoerce (lift x) - - lift Nothing = return (ConE nothingName) - lift (Just x) = liftM (ConE justName `AppE`) (lift x) - -instance (Lift a, Lift b) => Lift (Either a b) where - liftTyped x = unsafeCodeCoerce (lift x) - - lift (Left x) = liftM (ConE leftName `AppE`) (lift x) - lift (Right y) = liftM (ConE rightName `AppE`) (lift y) - -instance Lift a => Lift [a] where - liftTyped x = unsafeCodeCoerce (lift x) - lift xs = do { xs' <- mapM lift xs; return (ListE xs') } - -liftString :: Quote m => String -> m Exp --- Used in GHC.Tc.Gen.Expr to short-circuit the lifting for strings -liftString s = return (LitE (StringL s)) - --- | @since 2.15.0.0 -instance Lift a => Lift (NonEmpty a) where - liftTyped x = unsafeCodeCoerce (lift x) - - lift (x :| xs) = do - x' <- lift x - xs' <- lift xs - return (InfixE (Just x') (ConE nonemptyName) (Just xs')) --- | @since 2.15.0.0 -instance Lift Void where - liftTyped = liftCode . absurd - lift = pure . absurd - -instance Lift () where - liftTyped x = unsafeCodeCoerce (lift x) - lift () = return (ConE (tupleDataName 0)) - -instance (Lift a, Lift b) => Lift (a, b) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (a, b) - = liftM TupE $ sequence $ map (fmap Just) [lift a, lift b] - -instance (Lift a, Lift b, Lift c) => Lift (a, b, c) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (a, b, c) - = liftM TupE $ sequence $ map (fmap Just) [lift a, lift b, lift c] - -instance (Lift a, Lift b, Lift c, Lift d) => Lift (a, b, c, d) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (a, b, c, d) - = liftM TupE $ sequence $ map (fmap Just) [lift a, lift b, lift c, lift d] - -instance (Lift a, Lift b, Lift c, Lift d, Lift e) - => Lift (a, b, c, d, e) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (a, b, c, d, e) - = liftM TupE $ sequence $ map (fmap Just) [ lift a, lift b - , lift c, lift d, lift e ] - -instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f) - => Lift (a, b, c, d, e, f) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (a, b, c, d, e, f) - = liftM TupE $ sequence $ map (fmap Just) [ lift a, lift b, lift c - , lift d, lift e, lift f ] - -instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f, Lift g) - => Lift (a, b, c, d, e, f, g) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (a, b, c, d, e, f, g) - = liftM TupE $ sequence $ map (fmap Just) [ lift a, lift b, lift c - , lift d, lift e, lift f, lift g ] - --- | @since 2.16.0.0 -instance Lift (# #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (# #) = return (ConE (unboxedTupleTypeName 0)) - --- | @since 2.16.0.0 -instance (Lift a) => Lift (# a #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (# a #) - = liftM UnboxedTupE $ sequence $ map (fmap Just) [lift a] - --- | @since 2.16.0.0 -instance (Lift a, Lift b) => Lift (# a, b #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (# a, b #) - = liftM UnboxedTupE $ sequence $ map (fmap Just) [lift a, lift b] - --- | @since 2.16.0.0 -instance (Lift a, Lift b, Lift c) - => Lift (# a, b, c #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (# a, b, c #) - = liftM UnboxedTupE $ sequence $ map (fmap Just) [lift a, lift b, lift c] - --- | @since 2.16.0.0 -instance (Lift a, Lift b, Lift c, Lift d) - => Lift (# a, b, c, d #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (# a, b, c, d #) - = liftM UnboxedTupE $ sequence $ map (fmap Just) [ lift a, lift b - , lift c, lift d ] - --- | @since 2.16.0.0 -instance (Lift a, Lift b, Lift c, Lift d, Lift e) - => Lift (# a, b, c, d, e #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (# a, b, c, d, e #) - = liftM UnboxedTupE $ sequence $ map (fmap Just) [ lift a, lift b - , lift c, lift d, lift e ] - --- | @since 2.16.0.0 -instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f) - => Lift (# a, b, c, d, e, f #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (# a, b, c, d, e, f #) - = liftM UnboxedTupE $ sequence $ map (fmap Just) [ lift a, lift b, lift c - , lift d, lift e, lift f ] - --- | @since 2.16.0.0 -instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f, Lift g) - => Lift (# a, b, c, d, e, f, g #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift (# a, b, c, d, e, f, g #) - = liftM UnboxedTupE $ sequence $ map (fmap Just) [ lift a, lift b, lift c - , lift d, lift e, lift f - , lift g ] - --- | @since 2.16.0.0 -instance (Lift a, Lift b) => Lift (# a | b #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift x - = case x of - (# y | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 2 - (# | y #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 2 - --- | @since 2.16.0.0 -instance (Lift a, Lift b, Lift c) - => Lift (# a | b | c #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift x - = case x of - (# y | | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 3 - (# | y | #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 3 - (# | | y #) -> UnboxedSumE <$> lift y <*> pure 3 <*> pure 3 - --- | @since 2.16.0.0 -instance (Lift a, Lift b, Lift c, Lift d) - => Lift (# a | b | c | d #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift x - = case x of - (# y | | | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 4 - (# | y | | #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 4 - (# | | y | #) -> UnboxedSumE <$> lift y <*> pure 3 <*> pure 4 - (# | | | y #) -> UnboxedSumE <$> lift y <*> pure 4 <*> pure 4 - --- | @since 2.16.0.0 -instance (Lift a, Lift b, Lift c, Lift d, Lift e) - => Lift (# a | b | c | d | e #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift x - = case x of - (# y | | | | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 5 - (# | y | | | #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 5 - (# | | y | | #) -> UnboxedSumE <$> lift y <*> pure 3 <*> pure 5 - (# | | | y | #) -> UnboxedSumE <$> lift y <*> pure 4 <*> pure 5 - (# | | | | y #) -> UnboxedSumE <$> lift y <*> pure 5 <*> pure 5 - --- | @since 2.16.0.0 -instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f) - => Lift (# a | b | c | d | e | f #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift x - = case x of - (# y | | | | | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 6 - (# | y | | | | #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 6 - (# | | y | | | #) -> UnboxedSumE <$> lift y <*> pure 3 <*> pure 6 - (# | | | y | | #) -> UnboxedSumE <$> lift y <*> pure 4 <*> pure 6 - (# | | | | y | #) -> UnboxedSumE <$> lift y <*> pure 5 <*> pure 6 - (# | | | | | y #) -> UnboxedSumE <$> lift y <*> pure 6 <*> pure 6 - --- | @since 2.16.0.0 -instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f, Lift g) - => Lift (# a | b | c | d | e | f | g #) where - liftTyped x = unsafeCodeCoerce (lift x) - lift x - = case x of - (# y | | | | | | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 7 - (# | y | | | | | #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 7 - (# | | y | | | | #) -> UnboxedSumE <$> lift y <*> pure 3 <*> pure 7 - (# | | | y | | | #) -> UnboxedSumE <$> lift y <*> pure 4 <*> pure 7 - (# | | | | y | | #) -> UnboxedSumE <$> lift y <*> pure 5 <*> pure 7 - (# | | | | | y | #) -> UnboxedSumE <$> lift y <*> pure 6 <*> pure 7 - (# | | | | | | y #) -> UnboxedSumE <$> lift y <*> pure 7 <*> pure 7 - --- TH has a special form for literal strings, --- which we should take advantage of. --- NB: the lhs of the rule has no args, so that --- the rule will apply to a 'lift' all on its own --- which happens to be the way the type checker --- creates it. -{-# RULES "TH:liftString" lift = \s -> return (LitE (StringL s)) #-} - - -trueName, falseName :: Name -trueName = 'True -falseName = 'False - -nothingName, justName :: Name -nothingName = 'Nothing -justName = 'Just - -leftName, rightName :: Name -leftName = 'Left -rightName = 'Right - -nonemptyName :: Name -nonemptyName = '(:|) - ------------------------------------------------------ --- --- Generic Lift implementations --- ------------------------------------------------------ - --- | 'dataToQa' is an internal utility function for constructing generic --- conversion functions from types with 'Data' instances to various --- quasi-quoting representations. See the source of 'dataToExpQ' and --- 'dataToPatQ' for two example usages: @mkCon@, @mkLit@ --- and @appQ@ are overloadable to account for different syntax for --- expressions and patterns; @antiQ@ allows you to override type-specific --- cases, a common usage is just @const Nothing@, which results in --- no overloading. -dataToQa :: forall m a k q. (Quote m, Data a) - => (Name -> k) - -> (Lit -> m q) - -> (k -> [m q] -> m q) - -> (forall b . Data b => b -> Maybe (m q)) - -> a - -> m q -dataToQa mkCon mkLit appCon antiQ t = - case antiQ t of - Nothing -> - case constrRep constr of - AlgConstr _ -> - appCon (mkCon funOrConName) conArgs - where - funOrConName :: Name - funOrConName = - case showConstr constr of - "(:)" -> Name (mkOccName ":") - (NameG DataName - (mkPkgName "ghc-prim") - (mkModName "GHC.Types")) - con@"[]" -> Name (mkOccName con) - (NameG DataName - (mkPkgName "ghc-prim") - (mkModName "GHC.Types")) - con@('(':_) -> Name (mkOccName con) - (NameG DataName - (mkPkgName "ghc-prim") - (mkModName "GHC.Tuple")) - - -- Tricky case: see Note [Data for non-algebraic types] - fun@(x:_) | startsVarSym x || startsVarId x - -> mkNameG_v tyconPkg tyconMod fun - con -> mkNameG_d tyconPkg tyconMod con - - where - tycon :: TyCon - tycon = (typeRepTyCon . typeOf) t - - tyconPkg, tyconMod :: String - tyconPkg = tyConPackage tycon - tyconMod = tyConModule tycon - - conArgs :: [m q] - conArgs = gmapQ (dataToQa mkCon mkLit appCon antiQ) t - IntConstr n -> - mkLit $ IntegerL n - FloatConstr n -> - mkLit $ RationalL n - CharConstr c -> - mkLit $ CharL c - where - constr :: Constr - constr = toConstr t - - Just y -> y - - -{- Note [Data for non-algebraic types] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Class Data was originally intended for algebraic data types. But -it is possible to use it for abstract types too. For example, in -package `text` we find - - instance Data Text where - ... - toConstr _ = packConstr - - packConstr :: Constr - packConstr = mkConstr textDataType "pack" [] Prefix - -Here `packConstr` isn't a real data constructor, it's an ordinary -function. Two complications - -* In such a case, we must take care to build the Name using - mkNameG_v (for values), not mkNameG_d (for data constructors). - See #10796. - -* The pseudo-constructor is named only by its string, here "pack". - But 'dataToQa' needs the TyCon of its defining module, and has - to assume it's defined in the same module as the TyCon itself. - But nothing enforces that; #12596 shows what goes wrong if - "pack" is defined in a different module than the data type "Text". - -} - --- | 'dataToExpQ' converts a value to a 'Exp' representation of the --- same value, in the SYB style. It is generalized to take a function --- override type-specific cases; see 'liftData' for a more commonly --- used variant. -dataToExpQ :: (Quote m, Data a) - => (forall b . Data b => b -> Maybe (m Exp)) - -> a - -> m Exp -dataToExpQ = dataToQa varOrConE litE (foldl appE) - where - -- Make sure that VarE is used if the Constr value relies on a - -- function underneath the surface (instead of a constructor). - -- See #10796. - varOrConE s = - case nameSpace s of - Just VarName -> return (VarE s) - Just (FldName {}) -> return (VarE s) - Just DataName -> return (ConE s) - _ -> error $ "Can't construct an expression from name " - ++ showName s - appE x y = do { a <- x; b <- y; return (AppE a b)} - litE c = return (LitE c) - --- | 'liftData' is a variant of 'lift' in the 'Lift' type class which --- works for any type with a 'Data' instance. -liftData :: (Quote m, Data a) => a -> m Exp -liftData = dataToExpQ (const Nothing) - --- | 'dataToPatQ' converts a value to a 'Pat' representation of the same --- value, in the SYB style. It takes a function to handle type-specific cases, --- alternatively, pass @const Nothing@ to get default behavior. -dataToPatQ :: (Quote m, Data a) - => (forall b . Data b => b -> Maybe (m Pat)) - -> a - -> m Pat -dataToPatQ = dataToQa id litP conP - where litP l = return (LitP l) - conP n ps = - case nameSpace n of - Just DataName -> do - ps' <- sequence ps - return (ConP n [] ps') - _ -> error $ "Can't construct a pattern from name " - ++ showName n +module GHC.Internal.TH.Lift where ===================================== libraries/ghc-boot-th/GHC/Internal/TH/Ppr.hs ===================================== @@ -1,4 +1,4 @@ -{-# LANGUAGE Safe #-} +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE LambdaCase #-} -- | contains a prettyprinter for the -- Template Haskell datatypes ===================================== libraries/ghc-boot-th/ghc-boot-th.cabal.in ===================================== @@ -41,8 +41,6 @@ Library default-extensions: NoImplicitPrelude exposed-modules: - GHC.Lexeme - GHC.Internal.TH.Lib GHC.Internal.TH.Lib.Map GHC.Internal.TH.Ppr GHC.Internal.TH.PprLib @@ -56,20 +54,23 @@ Library cpp-options: -DBOOTSTRAP_TH hs-source-dirs: @SourceRoot@ ../ghc-internal/src exposed-modules: + GHC.Lexeme GHC.LanguageExtensions.Type GHC.ForeignSrcLang.Type GHC.Internal.TH.Syntax + GHC.Internal.TH.Lib else hs-source-dirs: @SourceRoot@ -- We need to set the unit ID to template-haskell (without a -- version number) as it's magic. ghc-options: -this-unit-id ghc-boot-th - exposed-modules: - GHC.Internal.TH.Lift - GHC.Internal.TH.Quote build-depends: ghc-internal reexported-modules: + GHC.Internal.TH.Lib, GHC.LanguageExtensions.Type, GHC.ForeignSrcLang.Type, - GHC.Internal.TH.Syntax + GHC.Internal.TH.Syntax, + GHC.Lexeme, + GHC.Internal.TH.Lift, + GHC.Internal.TH.Quote ===================================== libraries/ghc-internal/ghc-internal.cabal ===================================== @@ -257,6 +257,9 @@ Library GHC.Internal.Stats GHC.Internal.Storable GHC.Internal.TH.Syntax + GHC.Internal.TH.Lib + GHC.Internal.TH.Lift + GHC.Internal.TH.Quote GHC.Internal.TopHandler GHC.Internal.TypeError GHC.Internal.TypeLits @@ -290,6 +293,7 @@ Library GHC.Internal.IOPort GHC.ForeignSrcLang.Type GHC.LanguageExtensions.Type + GHC.Lexeme reexported-modules: GHC.Num.Integer ===================================== libraries/ghc-boot-th/GHC/Internal/TH/Lib.hs → libraries/ghc-internal/src/GHC/Internal/TH/Lib.hs ===================================== @@ -1,4 +1,5 @@ {-# OPTIONS_HADDOCK not-home #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE StandaloneKindSignatures #-} {-# LANGUAGE Trustworthy #-} @@ -21,12 +22,26 @@ module GHC.Internal.TH.Lib where import GHC.Internal.TH.Syntax hiding (Role, InjectivityAnn) import qualified GHC.Internal.TH.Syntax as TH +#ifdef BOOTSTRAP_TH import Control.Applicative(liftA, Applicative(..)) import qualified Data.Kind as Kind (Type) import Data.Word( Word8 ) import Data.List.NonEmpty ( NonEmpty(..) ) import GHC.Exts (TYPE) import Prelude hiding (Applicative(..)) +#else +import GHC.Internal.Base hiding (Type, Module, inline) +import GHC.Internal.Data.Foldable +import GHC.Internal.Data.Functor +import GHC.Internal.Data.Maybe +import GHC.Internal.Data.Traversable (traverse, sequenceA) +import GHC.Internal.Integer +import GHC.Internal.List (zip) +import GHC.Internal.Real +import GHC.Internal.Show +import GHC.Internal.Word +import qualified GHC.Types as Kind (Type) +#endif ---------------------------------------------------------- -- * Type synonyms ===================================== libraries/ghc-internal/src/GHC/Internal/TH/Lift.hs ===================================== @@ -0,0 +1,558 @@ +{-# OPTIONS_HADDOCK not-home #-} -- we want users to import Language.Haskell.TH.Syntax instead +{-# LANGUAGE CPP #-} +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE DefaultSignatures #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TemplateHaskellQuotes #-} +{-# LANGUAGE Trustworthy #-} +{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE UnboxedSums #-} +{-# LANGUAGE UnboxedTuples #-} +{-# OPTIONS_GHC -fno-warn-inline-rule-shadowing #-} + +module GHC.Internal.TH.Lift where + +import GHC.Internal.TH.Syntax +import GHC.Lexeme ( startsVarSym, startsVarId ) + +import GHC.Internal.Data.Either +import GHC.Internal.Type.Reflection +import GHC.Internal.Data.Bool +import GHC.Internal.Base hiding (Type, Module, inline) +import GHC.Internal.Data.Foldable +import GHC.Internal.Data.Functor +import GHC.Internal.Integer +import GHC.Internal.Real +import GHC.Internal.Word +import GHC.Internal.Int +import GHC.Internal.Data.Data +import GHC.Internal.Natural + +-- See Note [Bootstrapping Template Haskell] + +----------------------------------------------------- +-- +-- The Lift class +-- +----------------------------------------------------- + +-- | A 'Lift' instance can have any of its values turned into a Template +-- Haskell expression. This is needed when a value used within a Template +-- Haskell quotation is bound outside the Oxford brackets (@[| ... |]@ or +-- @[|| ... ||]@) but not at the top level. As an example: +-- +-- > add1 :: Int -> Code Q Int +-- > add1 x = [|| x + 1 ||] +-- +-- Template Haskell has no way of knowing what value @x@ will take on at +-- splice-time, so it requires the type of @x@ to be an instance of 'Lift'. +-- +-- A 'Lift' instance must satisfy @$(lift x) ≡ x@ and @$$(liftTyped x) ≡ x@ +-- for all @x@, where @$(...)@ and @$$(...)@ are Template Haskell splices. +-- It is additionally expected that @'lift' x ≡ 'unTypeCode' ('liftTyped' x)@. +-- +-- 'Lift' instances can be derived automatically by use of the @-XDeriveLift@ +-- GHC language extension: +-- +-- > {-# LANGUAGE DeriveLift #-} +-- > module Foo where +-- > +-- > import Language.Haskell.TH.Syntax +-- > +-- > data Bar a = Bar1 a (Bar a) | Bar2 String +-- > deriving Lift +-- +-- Representation-polymorphic since /template-haskell-2.16.0.0/. +class Lift (t :: TYPE r) where + -- | Turn a value into a Template Haskell expression, suitable for use in + -- a splice. + lift :: Quote m => t -> m Exp + default lift :: (r ~ ('BoxedRep 'Lifted), Quote m) => t -> m Exp + lift = unTypeCode . liftTyped + + -- | Turn a value into a Template Haskell typed expression, suitable for use + -- in a typed splice. + -- + -- @since 2.16.0.0 + liftTyped :: Quote m => t -> Code m t + + +-- If you add any instances here, consider updating test th/TH_Lift +instance Lift Integer where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL x)) + +instance Lift Int where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +-- | @since 2.16.0.0 +instance Lift Int# where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntPrimL (fromIntegral (I# x)))) + +instance Lift Int8 where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +instance Lift Int16 where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +instance Lift Int32 where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +instance Lift Int64 where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +-- | @since 2.16.0.0 +instance Lift Word# where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (WordPrimL (fromIntegral (W# x)))) + +instance Lift Word where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +instance Lift Word8 where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +instance Lift Word16 where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +instance Lift Word32 where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +instance Lift Word64 where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +instance Lift Natural where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (IntegerL (fromIntegral x))) + +instance Integral a => Lift (Ratio a) where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (RationalL (toRational x))) + +instance Lift Float where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (RationalL (toRational x))) + +-- | @since 2.16.0.0 +instance Lift Float# where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (FloatPrimL (toRational (F# x)))) + +instance Lift Double where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (RationalL (toRational x))) + +-- | @since 2.16.0.0 +instance Lift Double# where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (DoublePrimL (toRational (D# x)))) + +instance Lift Char where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (CharL x)) + +-- | @since 2.16.0.0 +instance Lift Char# where + liftTyped x = unsafeCodeCoerce (lift x) + lift x = return (LitE (CharPrimL (C# x))) + +instance Lift Bool where + liftTyped x = unsafeCodeCoerce (lift x) + + lift True = return (ConE trueName) + lift False = return (ConE falseName) + +-- | Produces an 'Addr#' literal from the NUL-terminated C-string starting at +-- the given memory address. +-- +-- @since 2.16.0.0 +instance Lift Addr# where + liftTyped x = unsafeCodeCoerce (lift x) + lift x + = return (LitE (StringPrimL (map (fromIntegral . ord) (unpackCString# x)))) + +-- TODO: move this somewhere else +-- | +-- @since 2.19.0.0 + +instance Lift a => Lift (Maybe a) where + liftTyped x = unsafeCodeCoerce (lift x) + + lift Nothing = return (ConE nothingName) + lift (Just x) = liftM (ConE justName `AppE`) (lift x) + +instance (Lift a, Lift b) => Lift (Either a b) where + liftTyped x = unsafeCodeCoerce (lift x) + + lift (Left x) = liftM (ConE leftName `AppE`) (lift x) + lift (Right y) = liftM (ConE rightName `AppE`) (lift y) + +instance Lift a => Lift [a] where + liftTyped x = unsafeCodeCoerce (lift x) + lift xs = do { xs' <- mapM lift xs; return (ListE xs') } + +liftString :: Quote m => String -> m Exp +-- Used in GHC.Tc.Gen.Expr to short-circuit the lifting for strings +liftString s = return (LitE (StringL s)) + +-- | @since 2.15.0.0 +instance Lift a => Lift (NonEmpty a) where + liftTyped x = unsafeCodeCoerce (lift x) + + lift (x :| xs) = do + x' <- lift x + xs' <- lift xs + return (InfixE (Just x') (ConE nonemptyName) (Just xs')) + +-- | @since 2.15.0.0 +instance Lift Void where + liftTyped = liftCode . absurd + lift = pure . absurd + +instance Lift () where + liftTyped x = unsafeCodeCoerce (lift x) + lift () = return (ConE (tupleDataName 0)) + +instance (Lift a, Lift b) => Lift (a, b) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (a, b) + = liftM TupE $ sequence $ map (fmap Just) [lift a, lift b] + +instance (Lift a, Lift b, Lift c) => Lift (a, b, c) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (a, b, c) + = liftM TupE $ sequence $ map (fmap Just) [lift a, lift b, lift c] + +instance (Lift a, Lift b, Lift c, Lift d) => Lift (a, b, c, d) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (a, b, c, d) + = liftM TupE $ sequence $ map (fmap Just) [lift a, lift b, lift c, lift d] + +instance (Lift a, Lift b, Lift c, Lift d, Lift e) + => Lift (a, b, c, d, e) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (a, b, c, d, e) + = liftM TupE $ sequence $ map (fmap Just) [ lift a, lift b + , lift c, lift d, lift e ] + +instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f) + => Lift (a, b, c, d, e, f) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (a, b, c, d, e, f) + = liftM TupE $ sequence $ map (fmap Just) [ lift a, lift b, lift c + , lift d, lift e, lift f ] + +instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f, Lift g) + => Lift (a, b, c, d, e, f, g) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (a, b, c, d, e, f, g) + = liftM TupE $ sequence $ map (fmap Just) [ lift a, lift b, lift c + , lift d, lift e, lift f, lift g ] + +-- | @since 2.16.0.0 +instance Lift (# #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (# #) = return (ConE (unboxedTupleTypeName 0)) + +-- | @since 2.16.0.0 +instance (Lift a) => Lift (# a #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (# a #) + = liftM UnboxedTupE $ sequence $ map (fmap Just) [lift a] + +-- | @since 2.16.0.0 +instance (Lift a, Lift b) => Lift (# a, b #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (# a, b #) + = liftM UnboxedTupE $ sequence $ map (fmap Just) [lift a, lift b] + +-- | @since 2.16.0.0 +instance (Lift a, Lift b, Lift c) + => Lift (# a, b, c #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (# a, b, c #) + = liftM UnboxedTupE $ sequence $ map (fmap Just) [lift a, lift b, lift c] + +-- | @since 2.16.0.0 +instance (Lift a, Lift b, Lift c, Lift d) + => Lift (# a, b, c, d #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (# a, b, c, d #) + = liftM UnboxedTupE $ sequence $ map (fmap Just) [ lift a, lift b + , lift c, lift d ] + +-- | @since 2.16.0.0 +instance (Lift a, Lift b, Lift c, Lift d, Lift e) + => Lift (# a, b, c, d, e #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (# a, b, c, d, e #) + = liftM UnboxedTupE $ sequence $ map (fmap Just) [ lift a, lift b + , lift c, lift d, lift e ] + +-- | @since 2.16.0.0 +instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f) + => Lift (# a, b, c, d, e, f #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (# a, b, c, d, e, f #) + = liftM UnboxedTupE $ sequence $ map (fmap Just) [ lift a, lift b, lift c + , lift d, lift e, lift f ] + +-- | @since 2.16.0.0 +instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f, Lift g) + => Lift (# a, b, c, d, e, f, g #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (# a, b, c, d, e, f, g #) + = liftM UnboxedTupE $ sequence $ map (fmap Just) [ lift a, lift b, lift c + , lift d, lift e, lift f + , lift g ] + +-- | @since 2.16.0.0 +instance (Lift a, Lift b) => Lift (# a | b #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift x + = case x of + (# y | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 2 + (# | y #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 2 + +-- | @since 2.16.0.0 +instance (Lift a, Lift b, Lift c) + => Lift (# a | b | c #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift x + = case x of + (# y | | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 3 + (# | y | #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 3 + (# | | y #) -> UnboxedSumE <$> lift y <*> pure 3 <*> pure 3 + +-- | @since 2.16.0.0 +instance (Lift a, Lift b, Lift c, Lift d) + => Lift (# a | b | c | d #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift x + = case x of + (# y | | | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 4 + (# | y | | #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 4 + (# | | y | #) -> UnboxedSumE <$> lift y <*> pure 3 <*> pure 4 + (# | | | y #) -> UnboxedSumE <$> lift y <*> pure 4 <*> pure 4 + +-- | @since 2.16.0.0 +instance (Lift a, Lift b, Lift c, Lift d, Lift e) + => Lift (# a | b | c | d | e #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift x + = case x of + (# y | | | | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 5 + (# | y | | | #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 5 + (# | | y | | #) -> UnboxedSumE <$> lift y <*> pure 3 <*> pure 5 + (# | | | y | #) -> UnboxedSumE <$> lift y <*> pure 4 <*> pure 5 + (# | | | | y #) -> UnboxedSumE <$> lift y <*> pure 5 <*> pure 5 + +-- | @since 2.16.0.0 +instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f) + => Lift (# a | b | c | d | e | f #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift x + = case x of + (# y | | | | | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 6 + (# | y | | | | #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 6 + (# | | y | | | #) -> UnboxedSumE <$> lift y <*> pure 3 <*> pure 6 + (# | | | y | | #) -> UnboxedSumE <$> lift y <*> pure 4 <*> pure 6 + (# | | | | y | #) -> UnboxedSumE <$> lift y <*> pure 5 <*> pure 6 + (# | | | | | y #) -> UnboxedSumE <$> lift y <*> pure 6 <*> pure 6 + +-- | @since 2.16.0.0 +instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f, Lift g) + => Lift (# a | b | c | d | e | f | g #) where + liftTyped x = unsafeCodeCoerce (lift x) + lift x + = case x of + (# y | | | | | | #) -> UnboxedSumE <$> lift y <*> pure 1 <*> pure 7 + (# | y | | | | | #) -> UnboxedSumE <$> lift y <*> pure 2 <*> pure 7 + (# | | y | | | | #) -> UnboxedSumE <$> lift y <*> pure 3 <*> pure 7 + (# | | | y | | | #) -> UnboxedSumE <$> lift y <*> pure 4 <*> pure 7 + (# | | | | y | | #) -> UnboxedSumE <$> lift y <*> pure 5 <*> pure 7 + (# | | | | | y | #) -> UnboxedSumE <$> lift y <*> pure 6 <*> pure 7 + (# | | | | | | y #) -> UnboxedSumE <$> lift y <*> pure 7 <*> pure 7 + +-- TH has a special form for literal strings, +-- which we should take advantage of. +-- NB: the lhs of the rule has no args, so that +-- the rule will apply to a 'lift' all on its own +-- which happens to be the way the type checker +-- creates it. +{-# RULES "TH:liftString" lift = \s -> return (LitE (StringL s)) #-} + + +trueName, falseName :: Name +trueName = 'True +falseName = 'False + +nothingName, justName :: Name +nothingName = 'Nothing +justName = 'Just + +leftName, rightName :: Name +leftName = 'Left +rightName = 'Right + +nonemptyName :: Name +nonemptyName = '(:|) + +----------------------------------------------------- +-- +-- Generic Lift implementations +-- +----------------------------------------------------- + +-- | 'dataToQa' is an internal utility function for constructing generic +-- conversion functions from types with 'Data' instances to various +-- quasi-quoting representations. See the source of 'dataToExpQ' and +-- 'dataToPatQ' for two example usages: @mkCon@, @mkLit@ +-- and @appQ@ are overloadable to account for different syntax for +-- expressions and patterns; @antiQ@ allows you to override type-specific +-- cases, a common usage is just @const Nothing@, which results in +-- no overloading. +dataToQa :: forall m a k q. (Quote m, Data a) + => (Name -> k) + -> (Lit -> m q) + -> (k -> [m q] -> m q) + -> (forall b . Data b => b -> Maybe (m q)) + -> a + -> m q +dataToQa mkCon mkLit appCon antiQ t = + case antiQ t of + Nothing -> + case constrRep constr of + AlgConstr _ -> + appCon (mkCon funOrConName) conArgs + where + funOrConName :: Name + funOrConName = + case showConstr constr of + "(:)" -> Name (mkOccName ":") + (NameG DataName + (mkPkgName "ghc-prim") + (mkModName "GHC.Types")) + con@"[]" -> Name (mkOccName con) + (NameG DataName + (mkPkgName "ghc-prim") + (mkModName "GHC.Types")) + con@('(':_) -> Name (mkOccName con) + (NameG DataName + (mkPkgName "ghc-prim") + (mkModName "GHC.Tuple")) + + -- Tricky case: see Note [Data for non-algebraic types] + fun@(x:_) | startsVarSym x || startsVarId x + -> mkNameG_v tyconPkg tyconMod fun + con -> mkNameG_d tyconPkg tyconMod con + + where + tycon :: TyCon + tycon = (typeRepTyCon . typeOf) t + + tyconPkg, tyconMod :: String + tyconPkg = tyConPackage tycon + tyconMod = tyConModule tycon + + conArgs :: [m q] + conArgs = gmapQ (dataToQa mkCon mkLit appCon antiQ) t + IntConstr n -> + mkLit $ IntegerL n + FloatConstr n -> + mkLit $ RationalL n + CharConstr c -> + mkLit $ CharL c + where + constr :: Constr + constr = toConstr t + + Just y -> y + + +{- Note [Data for non-algebraic types] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Class Data was originally intended for algebraic data types. But +it is possible to use it for abstract types too. For example, in +package `text` we find + + instance Data Text where + ... + toConstr _ = packConstr + + packConstr :: Constr + packConstr = mkConstr textDataType "pack" [] Prefix + +Here `packConstr` isn't a real data constructor, it's an ordinary +function. Two complications + +* In such a case, we must take care to build the Name using + mkNameG_v (for values), not mkNameG_d (for data constructors). + See #10796. + +* The pseudo-constructor is named only by its string, here "pack". + But 'dataToQa' needs the TyCon of its defining module, and has + to assume it's defined in the same module as the TyCon itself. + But nothing enforces that; #12596 shows what goes wrong if + "pack" is defined in a different module than the data type "Text". + -} + +-- | 'dataToExpQ' converts a value to a 'Exp' representation of the +-- same value, in the SYB style. It is generalized to take a function +-- override type-specific cases; see 'liftData' for a more commonly +-- used variant. +dataToExpQ :: (Quote m, Data a) + => (forall b . Data b => b -> Maybe (m Exp)) + -> a + -> m Exp +dataToExpQ = dataToQa varOrConE litE (foldl appE) + where + -- Make sure that VarE is used if the Constr value relies on a + -- function underneath the surface (instead of a constructor). + -- See #10796. + varOrConE s = + case nameSpace s of + Just VarName -> return (VarE s) + Just (FldName {}) -> return (VarE s) + Just DataName -> return (ConE s) + _ -> error $ "Can't construct an expression from name " + ++ showName s + appE x y = do { a <- x; b <- y; return (AppE a b)} + litE c = return (LitE c) + +-- | 'liftData' is a variant of 'lift' in the 'Lift' type class which +-- works for any type with a 'Data' instance. +liftData :: (Quote m, Data a) => a -> m Exp +liftData = dataToExpQ (const Nothing) + +-- | 'dataToPatQ' converts a value to a 'Pat' representation of the same +-- value, in the SYB style. It takes a function to handle type-specific cases, +-- alternatively, pass @const Nothing@ to get default behavior. +dataToPatQ :: (Quote m, Data a) + => (forall b . Data b => b -> Maybe (m Pat)) + -> a + -> m Pat +dataToPatQ = dataToQa id litP conP + where litP l = return (LitP l) + conP n ps = + case nameSpace n of + Just DataName -> do + ps' <- sequence ps + return (ConP n [] ps') + _ -> error $ "Can't construct a pattern from name " + ++ showName n ===================================== libraries/ghc-boot-th/GHC/Internal/TH/Quote.hs → libraries/ghc-internal/src/GHC/Internal/TH/Quote.hs ===================================== @@ -1,6 +1,6 @@ -{-# LANGUAGE RankNTypes, ScopedTypeVariables, Safe #-} +{-# LANGUAGE CPP, RankNTypes, ScopedTypeVariables, Trustworthy #-} {- | -Module : Language.Haskell.TH.Quote +Module : GHC.Internal.TH.Quote Description : Quasi-quoting support for Template Haskell Template Haskell supports quasiquoting, which permits users to construct @@ -22,7 +22,9 @@ module GHC.Internal.TH.Quote( import GHC.Internal.TH.Syntax import GHC.Internal.TH.Lift -import Prelude +import GHC.Internal.Base hiding (Type) +import GHC.Internal.System.IO + -- | The 'QuasiQuoter' type, a value @q@ of this type can be used -- in the syntax @[q| ... string to parse ...|]@. In fact, for ===================================== libraries/ghc-boot-th/GHC/Lexeme.hs → libraries/ghc-internal/src/GHC/Lexeme.hs ===================================== @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- -- | -- Module : GHC.Lexeme @@ -14,8 +15,14 @@ module GHC.Lexeme ( startsVarSymASCII, isVarSymChar, okSymChar ) where +#ifdef BOOTSTRAP_TH import Prelude -- See note [Why do we import Prelude here?] import Data.Char +#else +import GHC.Internal.Base +import GHC.Internal.Unicode +import GHC.Internal.List (elem) +#endif -- | Is this character acceptable in a symbol (after the first char)? -- See alexGetByte in GHC.Parser.Lexer View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3589e3de39b39307861d38cd207703c8f24d3f34...bbb27ec859c36dcb889dd9ed62cca1cb1deb4b00 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3589e3de39b39307861d38cd207703c8f24d3f34...bbb27ec859c36dcb889dd9ed62cca1cb1deb4b00 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 18:34:04 2024 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 07 May 2024 14:34:04 -0400 Subject: [Git][ghc/ghc][wip/T24334] 2 commits: Simplifier: Preserve OccInfo on DataAlt fields when case binder is dead (#24770) Message-ID: <663a741c729f_393e9460596428972@gitlab.mail> Sebastian Graf pushed to branch wip/T24334 at Glasgow Haskell Compiler / GHC Commits: 318c7be8 by Sebastian Graf at 2024-05-07T20:31:42+02:00 Simplifier: Preserve OccInfo on DataAlt fields when case binder is dead (#24770) See the adjusted `Note [DataAlt occ info]`. This change also has a positive repercussion on `Note [Combine case alts: awkward corner]`. Fixes #24770. We now try not to call `dataConRepStrictness` in `adjustFieldsIdInfo` when all fields are lazy anyway, leading to a 2% ghc/alloc decrease in T9675. Metric Decrease: T9675 - - - - - f2125e6b by Sebastian Graf at 2024-05-07T20:31:42+02:00 Kill seqRule, discard dead seq# in Prep (#24334) Discarding seq#s in Core land via `seqRule` was problematic; see #24334. So instead we discard certain dead, discardable seq#s in Prep now. See the updated `Note [seq# magic]`. This fixes the symptoms of #24334. - - - - - 15 changed files: - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Types/Id/Make.hs - testsuite/tests/codeGen/should_compile/T24264.hs - + testsuite/tests/core-to-stg/T24334.hs - + testsuite/tests/core-to-stg/T24334.stdout - testsuite/tests/core-to-stg/all.T - testsuite/tests/simplCore/should_compile/T21851.stderr - + testsuite/tests/simplCore/should_compile/T24770.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/CSE.hs ===================================== @@ -9,12 +9,8 @@ module GHC.Core.Opt.CSE (cseProgram, cseOneExpr) where import GHC.Prelude import GHC.Core.Subst -import GHC.Types.Var ( Var ) import GHC.Types.Var.Env ( mkInScopeSet ) -import GHC.Types.Id ( Id, idType, idHasRules, zapStableUnfolding - , idInlineActivation, setInlineActivation - , zapIdOccInfo, zapIdUsageInfo, idInlinePragma - , isJoinId, idJoinPointHood, idUnfolding ) +import GHC.Types.Id import GHC.Core.Utils ( mkAltExpr , exprIsTickedString , stripTicksE, stripTicksT, mkTicks ) @@ -754,7 +750,7 @@ combineAlts alts , Alt _ bndrs1 rhs1 <- alt1 , let filtered_alts = filterOut (identical_alt rhs1) rest_alts , not (equalLength rest_alts filtered_alts) - = assertPpr (null bndrs1) (ppr alts) $ + = assertPpr (all isDeadBinder bndrs1) (ppr alts) $ Alt DEFAULT [] rhs1 : filtered_alts | otherwise @@ -762,14 +758,13 @@ combineAlts alts where find_bndr_free_alt :: [CoreAlt] -> (Maybe CoreAlt, [CoreAlt]) - -- The (Just alt) is a binder-free alt - -- See Note [Combine case alts: awkward corner] + -- The (Just alt) is an alt where all fields are dead find_bndr_free_alt [] = (Nothing, []) find_bndr_free_alt (alt@(Alt _ bndrs _) : alts) - | null bndrs = (Just alt, alts) - | otherwise = case find_bndr_free_alt alts of - (mb_bf, alts) -> (mb_bf, alt:alts) + | all isDeadBinder bndrs = (Just alt, alts) + | otherwise = case find_bndr_free_alt alts of + (mb_bf, alts) -> (mb_bf, alt:alts) identical_alt rhs1 (Alt _ _ rhs) = eqCoreExpr rhs1 rhs -- Even if this alt has binders, they will have been cloned @@ -823,9 +818,9 @@ big for cheapEqExpr to catch it. Note [Combine case alts: awkward corner] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We would really like to check isDeadBinder on the binders in the -alternative. But alas, the simplifer zaps occ-info on binders in case -alternatives; see Note [Case alternative occ info] in GHC.Core.Opt.Simplify. +We check isDeadBinder on field binders in order to collapse into a DEFAULT alt. +But alas, the simplifer often zaps occ-info on field binders in DataAlts when +the case binder is alive; see Note [DataAlt occ info] in GHC.Core.Opt.Simplify. * One alternative (perhaps a good one) would be to do OccAnal just before CSE. Then perhaps we could get rid of combineIdenticalAlts @@ -833,14 +828,12 @@ alternatives; see Note [Case alternative occ info] in GHC.Core.Opt.Simplify. * Another would be for CSE to return free vars as it goes. -* But the current solution is to find a nullary alternative (including - the DEFAULT alt, if any). This will not catch - case x of - A y -> blah - B z p -> blah - where no alternative is nullary or DEFAULT. But the current - solution is at least cheap. - +* But the current solution is to accept that we do not catch cases such as + case x of c + A _ -> blah[c] + B _ _ -> blah[c] + where the case binder c is alive and no alternative is DEFAULT. + But the current solution is at least cheap. ************************************************************************ * * ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -2067,21 +2067,18 @@ unsafeEqualityProofRule {- ********************************************************************* * * - Rules for seq# and spark# + Rules for spark# * * ********************************************************************* -} -seqRule :: RuleM CoreExpr -seqRule = do +-- spark# :: forall a s . a -> State# s -> (# State# s, a #) +sparkRule :: RuleM CoreExpr +sparkRule = do -- reduce on HNF [Type _ty_a, Type _ty_s, a, s] <- getArgs guard $ exprIsHNF a return $ mkCoreUnboxedTuple [s, a] - --- spark# :: forall a s . a -> State# s -> (# State# s, a #) -sparkRule :: RuleM CoreExpr -sparkRule = seqRule -- reduce on HNF, just the same - -- XXX perhaps we shouldn't do this, because a spark eliminated by - -- this rule won't be counted as a dud at runtime? + -- XXX perhaps we shouldn't do this, because a spark eliminated by + -- this rule won't be counted as a dud at runtime? {- ************************************************************************ @@ -2158,9 +2155,7 @@ builtinRules platform <- getPlatform return $ Var (primOpId IntAndOp) `App` arg `App` mkIntVal platform (d - 1) - ], - - mkBasicRule seqHashName 4 seqRule + ] ] ++ builtinBignumRules {-# NOINLINE builtinRules #-} ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -26,7 +26,7 @@ core expression with (hopefully) improved usage information. module GHC.Core.Opt.OccurAnal ( occurAnalysePgm, occurAnalyseExpr, - zapLambdaBndrs, scrutBinderSwap_maybe + zapLambdaBndrs, BinderSwapDecision(..), scrutOkForBinderSwap ) where import GHC.Prelude hiding ( head, init, last, tail ) @@ -3262,7 +3262,7 @@ inline x, cancel the casts, and away we go. Note [Care with binder-swap on dictionaries] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -This Note explains why we need isDictId in scrutBinderSwap_maybe. +This Note explains why we need isDictId in scrutOkForBinderSwap. Consider this tricky example (#21229, #21470): class Sing (b :: Bool) where sing :: Bool @@ -3306,7 +3306,7 @@ Conclusion: for a /dictionary variable/ do not perform the clever cast version of the binder-swap -Hence the subtle isDictId in scrutBinderSwap_maybe. +Hence the subtle isDictId in scrutOkForBinderSwap. Note [Zap case binders in proxy bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -3328,7 +3328,7 @@ addBndrSwap :: OutExpr -> Id -> OccEnv -> OccEnv -- See Note [The binder-swap substitution] addBndrSwap scrut case_bndr env@(OccEnv { occ_bs_env = swap_env, occ_bs_rng = rng_vars }) - | Just (scrut_var, mco) <- scrutBinderSwap_maybe scrut + | DoBinderSwap scrut_var mco <- scrutOkForBinderSwap scrut , scrut_var /= case_bndr -- Consider: case x of x { ... } -- Do not add [x :-> x] to occ_bs_env, else lookupBndrSwap will loop @@ -3342,25 +3342,30 @@ addBndrSwap scrut case_bndr case_bndr' = zapIdOccInfo case_bndr -- See Note [Zap case binders in proxy bindings] -scrutBinderSwap_maybe :: OutExpr -> Maybe (OutVar, MCoercion) --- If (scrutBinderSwap_maybe e = Just (v, mco), then +-- | See bBinderSwaOk. +data BinderSwapDecision + = NoBinderSwap + | DoBinderSwap OutVar MCoercion + +scrutOkForBinderSwap :: OutExpr -> BinderSwapDecision +-- If (scrutOkForBinderSwap e = DoBinderSwap v mco, then -- v = e |> mco -- See Note [Case of cast] -- See Note [Care with binder-swap on dictionaries] -- -- We use this same function in SpecConstr, and Simplify.Iteration, -- when something binder-swap-like is happening -scrutBinderSwap_maybe (Var v) = Just (v, MRefl) -scrutBinderSwap_maybe (Cast (Var v) co) - | not (isDictId v) = Just (v, MCo (mkSymCo co)) +scrutOkForBinderSwap (Var v) = DoBinderSwap v MRefl +scrutOkForBinderSwap (Cast (Var v) co) + | not (isDictId v) = DoBinderSwap v (MCo (mkSymCo co)) -- Cast: see Note [Case of cast] -- isDictId: see Note [Care with binder-swap on dictionaries] -- The isDictId rejects a Constraint/Constraint binder-swap, perhaps -- over-conservatively. But I have never seen one, so I'm leaving -- the code as simple as possible. Losing the binder-swap in a -- rare case probably has very low impact. -scrutBinderSwap_maybe (Tick _ e) = scrutBinderSwap_maybe e -- Drop ticks -scrutBinderSwap_maybe _ = Nothing +scrutOkForBinderSwap (Tick _ e) = scrutOkForBinderSwap e -- Drop ticks +scrutOkForBinderSwap _ = NoBinderSwap lookupBndrSwap :: OccEnv -> Id -> (CoreExpr, Id) -- See Note [The binder-swap substitution] ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -1719,7 +1719,7 @@ extendCaseBndrEnv :: LevelEnv -> LevelEnv extendCaseBndrEnv le@(LE { le_subst = subst, le_env = id_env }) case_bndr (Var scrut_var) - -- We could use OccurAnal. scrutBinderSwap_maybe here, and perhaps + -- We could use OccurAnal. scrutOkForBinderSwap here, and perhaps -- get a bit more floating. But we didn't in the past and it's -- an unforced change, so I'm leaving it. = le { le_subst = extendSubstWithVar subst case_bndr scrut_var ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -23,7 +23,7 @@ import GHC.Core.TyCo.Compare( eqType ) import GHC.Core.Opt.Simplify.Env import GHC.Core.Opt.Simplify.Inline import GHC.Core.Opt.Simplify.Utils -import GHC.Core.Opt.OccurAnal ( occurAnalyseExpr, zapLambdaBndrs, scrutBinderSwap_maybe ) +import GHC.Core.Opt.OccurAnal ( occurAnalyseExpr, zapLambdaBndrs, scrutOkForBinderSwap, BinderSwapDecision (..) ) import GHC.Core.Make ( FloatBind, mkImpossibleExpr, castBottomExpr ) import qualified GHC.Core.Make import GHC.Core.Coercion hiding ( substCo, substCoVar ) @@ -33,7 +33,7 @@ import GHC.Core.FamInstEnv ( FamInstEnv, topNormaliseType_maybe ) import GHC.Core.DataCon ( DataCon, dataConWorkId, dataConRepStrictness , dataConRepArgTys, isUnboxedTupleDataCon - , StrictnessMark (..) ) + , StrictnessMark (..), dataConWrapId_maybe ) import GHC.Core.Opt.Stats ( Tick(..) ) import GHC.Core.Ppr ( pprCoreExpr ) import GHC.Core.Unfold @@ -3234,16 +3234,36 @@ The point is that we bring into the envt a binding after the outer case, and that makes (a,b) alive. At least we do unless the case binder is guaranteed dead. -Note [Case alternative occ info] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -When we are simply reconstructing a case (the common case), we always -zap the occurrence info on the binders in the alternatives. Even -if the case binder is dead, the scrutinee is usually a variable, and *that* -can bring the case-alternative binders back to life. -See Note [Add unfolding for scrutinee] +Note [DataAlt occ info] +~~~~~~~~~~~~~~~~~~~~~~~ +Our general goal is to preserve dead-ness occ-info on the field binders of a +case alternative. Why? It's generally a good idea, but one specific reason is to +support (SEQ4) of Note [seq# magic]. + +But we have to be careful: even if the field binder is not mentioned in the case +alternative and thus annotated IAmDead by OccurAnal, it might "come back to +life" in one of two ways: + + 1. If the case binder is alive, its unfolding might bring back the field + binder, as in Note [knownCon occ info]: + case blah of y { I# _ -> $wf (case y of I# v -> v) } + ==> + case blah of y { I# v -> $wf v } + 2. Even if the case binder appears to be dead, there is the scenario in + Note [Add unfolding for scrutinee], in which the fields come back to live + through the unfolding of variable scrutinee, as follows: + join j = case x of Just v -> blah v; Nothing -> ... in + case x of Just _ -> jump j; Nothing -> ... + ==> { inline j, unfold x to Just v, simplify } + join j = case x of Just v -> blah v; Nothing -> ... in + case x of Just v -> blah v; Nothing -> ... + +Thus, when we are simply reconstructing a case (the common case), and the +case binder is not dead, or the scrutinee is a variable, we zap the +occurrence info on DataAlt field binders. See `adjustFieldOccInfo`. Note [Improving seq] -~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~ Consider type family F :: * -> * type instance F Int = Int @@ -3349,7 +3369,9 @@ simplAlts env0 scrut case_bndr alts cont' -- NB: pass case_bndr::InId, not case_bndr' :: OutId, to prepareAlts -- See Note [Shadowing in prepareAlts] in GHC.Core.Opt.Simplify.Utils - ; alts' <- mapM (simplAlt alt_env' (Just scrut') imposs_deflt_cons case_bndr' cont') in_alts + ; alts' <- forM in_alts $ + simplAlt alt_env' (Just scrut') imposs_deflt_cons + case_bndr' (scrutOkForBinderSwap scrut) cont' ; let alts_ty' = contResultType cont' -- See Note [Avoiding space leaks in OutType] @@ -3375,36 +3397,42 @@ improveSeq _ env scrut _ case_bndr1 _ ------------------------------------ simplAlt :: SimplEnv - -> Maybe OutExpr -- The scrutinee - -> [AltCon] -- These constructors can't be present when - -- matching the DEFAULT alternative - -> OutId -- The case binder + -> Maybe OutExpr -- The scrutinee + -> [AltCon] -- These constructors can't be present when + -- matching the DEFAULT alternative + -> OutId -- The case binder `bndr` + -> BinderSwapDecision -- DoBinderSwap v co <==> scrut = Just (v |> co), + -- add unfolding `v :-> bndr |> sym co` -> SimplCont -> InAlt -> SimplM OutAlt -simplAlt env scrut' imposs_deflt_cons case_bndr' cont' (Alt DEFAULT bndrs rhs) +simplAlt env _scrut' imposs_deflt_cons case_bndr' bndr_swap' cont' (Alt DEFAULT bndrs rhs) = assert (null bndrs) $ - do { let env' = addDefaultUnfoldings env scrut' case_bndr' imposs_deflt_cons + do { let env' = addDefaultUnfoldings env case_bndr' bndr_swap' imposs_deflt_cons ; rhs' <- simplExprC env' rhs cont' ; return (Alt DEFAULT [] rhs') } -simplAlt env scrut' _ case_bndr' cont' (Alt (LitAlt lit) bndrs rhs) +simplAlt env _scrut' _ case_bndr' bndr_swap' cont' (Alt (LitAlt lit) bndrs rhs) = assert (null bndrs) $ - do { let env' = addAltUnfoldings env scrut' case_bndr' (Lit lit) + do { let env' = addAltUnfoldings env case_bndr' bndr_swap' (Lit lit) ; rhs' <- simplExprC env' rhs cont' ; return (Alt (LitAlt lit) [] rhs') } -simplAlt env scrut' _ case_bndr' cont' (Alt (DataAlt con) vs rhs) +simplAlt env scrut' _ case_bndr' bndr_swap' cont' (Alt (DataAlt con) vs rhs) = do { -- See Note [Adding evaluatedness info to pattern-bound variables] - let vs_with_evals = addEvals scrut' con vs - ; (env', vs') <- simplBinders env vs_with_evals + -- and Note [DataAlt occ info] + ; let vs_with_info = adjustFieldsIdInfo scrut' case_bndr' bndr_swap' con vs + -- Adjust evaluated-ness and occ-info flags before `simplBinders` + -- because the latter extends the in-scope set, which propagates this + -- adjusted info to use sites. + ; (env', vs') <- simplBinders env vs_with_info -- Bind the case-binder to (con args) ; let inst_tys' = tyConAppArgs (idType case_bndr') con_app :: OutExpr con_app = mkConApp2 con inst_tys' vs' - env'' = addAltUnfoldings env' scrut' case_bndr' con_app + env'' = addAltUnfoldings env' case_bndr' bndr_swap' con_app ; rhs' <- simplExprC env'' rhs cont' ; return (Alt (DataAlt con) vs' rhs') } @@ -3438,9 +3466,10 @@ do it here). The right thing is to do some kind of binder-swap; see #15226 for discussion. -} -addEvals :: Maybe OutExpr -> DataCon -> [Id] -> [Id] +adjustFieldsIdInfo :: Maybe OutExpr -> OutId -> BinderSwapDecision -> DataCon -> [Id] -> [Id] -- See Note [Adding evaluatedness info to pattern-bound variables] -addEvals scrut con vs +-- and Note [DataAlt occ info] +adjustFieldsIdInfo scrut case_bndr bndr_swap con vs -- Deal with seq# applications | Just scr <- scrut , isUnboxedTupleDataCon con @@ -3449,59 +3478,75 @@ addEvals scrut con vs -- a list of arguments only to throw it away immediately. , Just (Var f) <- stripNArgs 4 scr , f `hasKey` seqHashKey - , let x' = zapIdOccInfoAndSetEvald MarkedStrict x - = [s, x'] + , let x' = setCaseBndrEvald MarkedStrict x + = map (adjustFieldOccInfo case_bndr bndr_swap) [s, x'] -- Deal with banged datacon fields -addEvals _scrut con vs = go vs the_strs - where - the_strs = dataConRepStrictness con - - go [] [] = [] - go (v:vs') strs | isTyVar v = v : go vs' strs - go (v:vs') (str:strs) = zapIdOccInfoAndSetEvald str v : go vs' strs - go _ _ = pprPanic "Simplify.addEvals" - (ppr con $$ - ppr vs $$ - ppr_with_length (map strdisp the_strs) $$ - ppr_with_length (dataConRepArgTys con) $$ - ppr_with_length (dataConRepStrictness con)) - where - ppr_with_length list - = ppr list <+> parens (text "length =" <+> ppr (length list)) - strdisp :: StrictnessMark -> SDoc - strdisp MarkedStrict = text "MarkedStrict" - strdisp NotMarkedStrict = text "NotMarkedStrict" - -zapIdOccInfoAndSetEvald :: StrictnessMark -> Id -> Id -zapIdOccInfoAndSetEvald str v = - setCaseBndrEvald str $ -- Add eval'dness info - zapIdOccInfo v -- And kill occ info; - -- see Note [Case alternative occ info] - -addDefaultUnfoldings :: SimplEnv -> Maybe OutExpr -> OutId -> [AltCon] -> SimplEnv -addDefaultUnfoldings env mb_scrut case_bndr imposs_deflt_cons + -- This case is quite allocation sensitive to T9233 which has a large record + -- with strict fields. Hence we try not to update vs twice! +adjustFieldsIdInfo _scrut case_bndr bndr_swap con vs + | Nothing <- dataConWrapId_maybe con + -- A common fast path; no need to allocate the_strs when they are all lazy + -- anyway! It shaves off 2% in T9675 + = map (adjustFieldOccInfo case_bndr bndr_swap) vs + | otherwise + = go vs the_strs + where + the_strs = dataConRepStrictness con + + go [] [] = [] + go (v:vs') strs | isTyVar v = v : go vs' strs + go (v:vs') (str:strs) = adjustFieldOccInfo case_bndr bndr_swap (setCaseBndrEvald str v) : go vs' strs + go _ _ = pprPanic "Simplify.adjustFieldsIdInfo" + (ppr con $$ + ppr vs $$ + ppr_with_length (map strdisp the_strs) $$ + ppr_with_length (dataConRepArgTys con) $$ + ppr_with_length (dataConRepStrictness con)) + where + ppr_with_length list + = ppr list <+> parens (text "length =" <+> ppr (length list)) + strdisp :: StrictnessMark -> SDoc + strdisp MarkedStrict = text "MarkedStrict" + strdisp NotMarkedStrict = text "NotMarkedStrict" + +adjustFieldOccInfo :: OutId -> BinderSwapDecision -> CoreBndr -> CoreBndr +-- Kill occ info if we do binder swap and the case binder is alive; +-- see Note [DataAlt occ info] +adjustFieldOccInfo case_bndr bndr_swap field_bndr + | isTyVar field_bndr + = field_bndr + + | not (isDeadBinder case_bndr) -- (1) in the Note: If the case binder is alive, + = zapIdOccInfo field_bndr -- the field binders might come back alive + + | DoBinderSwap{} <- bndr_swap -- (2) in the Note: If binder swap might take place, + = zapIdOccInfo field_bndr -- the case binder might come back alive + + | otherwise + = field_bndr -- otherwise the field binders stay dead + +addDefaultUnfoldings :: SimplEnv -> OutId -> BinderSwapDecision -> [AltCon] -> SimplEnv +addDefaultUnfoldings env case_bndr bndr_swap imposs_deflt_cons = env2 where unf = mkOtherCon imposs_deflt_cons -- Record the constructors that the case-binder *can't* be. env1 = addBinderUnfolding env case_bndr unf - env2 | Just scrut <- mb_scrut - , Just (v,_mco) <- scrutBinderSwap_maybe scrut + env2 | DoBinderSwap v _mco <- bndr_swap = addBinderUnfolding env1 v unf | otherwise = env1 -addAltUnfoldings :: SimplEnv -> Maybe OutExpr -> OutId -> OutExpr -> SimplEnv -addAltUnfoldings env mb_scrut case_bndr con_app +addAltUnfoldings :: SimplEnv -> OutId -> BinderSwapDecision -> OutExpr -> SimplEnv +addAltUnfoldings env case_bndr bndr_swap con_app = env2 where con_app_unf = mk_simple_unf con_app env1 = addBinderUnfolding env case_bndr con_app_unf -- See Note [Add unfolding for scrutinee] - env2 | Just scrut <- mb_scrut - , Just (v,mco) <- scrutBinderSwap_maybe scrut + env2 | DoBinderSwap v mco <- bndr_swap = addBinderUnfolding env1 v $ if isReflMCo mco -- isReflMCo: avoid calling mk_simple_unf then con_app_unf -- twice in the common case @@ -3580,7 +3625,7 @@ So instead we add the unfolding x -> Just a, and x -> Nothing in the respective RHSs. Since this transformation is tantamount to a binder swap, we use -GHC.Core.Opt.OccurAnal.scrutBinderSwap_maybe to do the check. +GHC.Core.Opt.OccurAnal.scrutOkForBinderSwap to do the check. Exactly the same issue arises in GHC.Core.Opt.SpecConstr; see Note [Add scrutinee to ValueEnv too] in GHC.Core.Opt.SpecConstr @@ -3884,8 +3929,9 @@ mkDupableContWithDmds env _ ; let cont_scaling = contHoleScaling cont -- See Note [Scaling in case-of-case] ; (alt_env', case_bndr') <- simplBinder alt_env (scaleIdBy cont_scaling case_bndr) - ; alts' <- mapM (simplAlt alt_env' Nothing [] case_bndr' alt_cont) (scaleAltsBy cont_scaling alts) - -- Safe to say that there are no handled-cons for the DEFAULT case + ; alts' <- forM (scaleAltsBy cont_scaling alts) $ + simplAlt alt_env' Nothing [] case_bndr' NoBinderSwap alt_cont + -- Safe to say that there are no handled-cons for the DEFAULT case -- NB: simplBinder does not zap deadness occ-info, so -- a dead case_bndr' will still advertise its deadness -- This is really important because in ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -36,7 +36,7 @@ import GHC.Core.Opt.Simplify.Inline import GHC.Core.FVs ( exprsFreeVarsList, exprFreeVars ) import GHC.Core.Opt.Monad import GHC.Core.Opt.WorkWrap.Utils -import GHC.Core.Opt.OccurAnal( scrutBinderSwap_maybe ) +import GHC.Core.Opt.OccurAnal( BinderSwapDecision(..), scrutOkForBinderSwap ) import GHC.Core.DataCon import GHC.Core.Class( classTyVars ) import GHC.Core.Coercion hiding( substCo ) @@ -1104,7 +1104,7 @@ extendCaseBndrs env scrut case_bndr con alt_bndrs = (env2, alt_bndrs') where live_case_bndr = not (isDeadBinder case_bndr) - env1 | Just (v, mco) <- scrutBinderSwap_maybe scrut + env1 | DoBinderSwap v mco <- scrutOkForBinderSwap scrut , isReflMCo mco = extendValEnv env v cval | otherwise = env -- See Note [Add scrutinee to ValueEnv too] env2 | live_case_bndr = extendValEnv env1 case_bndr cval @@ -1198,7 +1198,7 @@ though the simplifier has systematically replaced uses of 'x' with 'y' and 'b' with 'c' in the code. The use of 'b' in the ValueEnv came from outside the case. See #4908 for the live example. -It's very like the binder-swap story, so we use scrutBinderSwap_maybe +It's very like the binder-swap story, so we use scrutOkForBinderSwap to identify suitable scrutinees -- but only if there is no cast (isReflMCo) because that's all that the ValueEnv allows. ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -890,6 +890,29 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con [covar] _]) floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } +cpeRhsE env (Case scrut bndr _ [Alt (DataAlt dc) [token_out, res] rhs]) + -- See item (SEQ4) of Note [seq# magic]. We want to match + -- case seq# @a @RealWorld s of (# s', _ #) -> rhs[s'] + -- and simplify to rhs[s]. Triggers in T15226. + | isUnboxedTupleDataCon dc + , (Var f,[_ty1, _ty2, arg, Var token_in]) <- collectArgs scrut + , f `hasKey` seqHashKey + , exprOkToDiscard arg + -- ok-to-discard, because we want to discard the evaluation of `arg`. + -- ok-to-discard includes ok-for-spec, but *also* CanFail primops such as + -- `quotInt# 1# 0#`, but not ThrowsException primops. + -- See Note [Classifying primop effects] + -- and Note [Transformations affected by primop effects] for why this is + -- the correct choice. + , Var token_in' <- lookupCorePrepEnv env token_in + , isDeadBinder res, isDeadBinder bndr + -- Check that bndr and res are dead + -- We can rely on `isDeadBinder res`, despite the fact that the Simplifier + -- often zaps the OccInfo on case-alternative binders (see Note [DataAlt occ info] + -- in GHC.Core.Opt.Simplify.Iteration) because the scrutinee is not a + -- variable, and in that case the zapping doesn't happen; see that Note. + = cpeRhsE (extendCorePrepEnv env token_out token_in') rhs + cpeRhsE env (Case scrut bndr ty alts) = do { (floats, scrut') <- cpeBody env scrut ; (env', bndr2) <- cpCloneBndr env bndr ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -2295,9 +2295,16 @@ Things to note also we can attach an evaldUnfolding to x' to discard any subsequent evals such as the `case x' of __DEFAULT`. +(SEQ4) + T15226 demonstrates that we want to discard ok-for-discard seq#s. That is, + simplify `case seq# s of (# s', _ #) -> rhs[s']` to `rhs[s]`. + You might wonder whether the Simplifier could do this. But see the excellent + example in #24334 (immortalised as test T24334) for why it should be done in + CorePrep. + Implementing seq#. The compiler has magic for `seq#` in -- GHC.Core.Opt.ConstantFold.seqRule: eliminate (seq# s) +- GHC.CoreToStg.Prep.cpeRhsE: Implement (SEQ4). - Simplify.addEvals records evaluated-ness for the result (cf. (SEQ3)); see Note [Adding evaluatedness info to pattern-bound variables] ===================================== testsuite/tests/codeGen/should_compile/T24264.hs ===================================== @@ -24,12 +24,8 @@ fun3 :: a -> IO a {-# OPAQUE fun3 #-} fun3 x = do pure () - -- "evaluate $! x" - case x of !x' -> IO (noinline seq# x') - -- noinline to work around the bogus seqRule - -- This ideally also should not push a continuation to the stack - -- before entering 'x'. It currently does, but let's wait for - -- !11515 to land before worrying about that. + evaluate $! x + -- This should not push a continuation to the stack before entering 'x' funPair :: a -> IO (a, a) {-# OPAQUE funPair #-} ===================================== testsuite/tests/core-to-stg/T24334.hs ===================================== @@ -0,0 +1,20 @@ +import Control.Exception +import Data.IORef + +strictPrint :: Show a => a -> IO () +{-# OPAQUE strictPrint #-} +strictPrint x = print $! x + +f :: Show a => a -> IORef a -> IO () +{-# OPAQUE f #-} +f x r = do + x' <- evaluate $! x + writeIORef r x' + strictPrint x' + +main :: IO () +main = do + r <- newIORef (42 :: Int) + f (error "foo") r `catch` \(e :: SomeException) -> return () + n <- readIORef r + print n ===================================== testsuite/tests/core-to-stg/T24334.stdout ===================================== @@ -0,0 +1 @@ +42 ===================================== testsuite/tests/core-to-stg/all.T ===================================== @@ -5,4 +5,5 @@ test('T23270', [grep_errmsg(r'patError')], compile, ['-O0 -dsuppress-uniques -dd test('T23914', normal, compile, ['-O']) test('T14895', normal, compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-uniques']) test('T24124', normal, compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-uniques']) +test('T24334', normal, compile_and_run, ['-O']) test('T24463', normal, compile, ['-O']) ===================================== testsuite/tests/simplCore/should_compile/T21851.stderr ===================================== @@ -10,8 +10,12 @@ g' :: Int -> Int [GblId, Arity=1, Str=, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 30 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [0] 30 0}] g' - = \ (x :: Int) -> case T21851a.$w$sf x of { (# ww, ww1 #) -> ww } + = \ (x :: Int) -> + case T21851a.$w$sf x of { (# ww, _ [Occ=Dead] #) -> ww } + + ===================================== testsuite/tests/simplCore/should_compile/T24770.hs ===================================== @@ -0,0 +1,3 @@ +module T24770 where + +foo = getLine >> getLine ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -516,3 +516,4 @@ test('T24370', normal, compile, ['-O']) test('T24551', normal, compile, ['-O -dcore-lint']) test('T24726', normal, compile, ['-dcore-lint -dsuppress-uniques']) test('T24768', normal, compile, ['-O']) +test('T24770', [ grep_errmsg(r'Dead') ], compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b0ebad0ebc8c7cd8bf7730786add0a9f0a8a8227...f2125e6b19165e737af6d37efefc557adab7a48c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b0ebad0ebc8c7cd8bf7730786add0a9f0a8a8227...f2125e6b19165e737af6d37efefc557adab7a48c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 18:40:34 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 07 May 2024 14:40:34 -0400 Subject: [Git][ghc/ghc][master] Rename Solo# data constructor to MkSolo# (#24673) Message-ID: <663a75a2198d0_393e948320ac35033@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 3b51995c by Andrei Borzenkov at 2024-05-07T14:39:40-04:00 Rename Solo# data constructor to MkSolo# (#24673) - data Solo# a = (# a #) + data Solo# a = MkSolo# a And `(# foo #)` syntax now becomes just a syntactic sugar for `MkSolo# a`. - - - - - 11 changed files: - compiler/GHC/Builtin/Types.hs - libraries/ghc-boot/GHC/Utils/Encoding.hs - libraries/ghc-experimental/src/Data/Tuple/Experimental.hs - libraries/ghc-prim/GHC/Types.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Syntax.hs - testsuite/tests/core-to-stg/T24124.stderr - testsuite/tests/ghci/scripts/ListTuplePunsPpr.script - testsuite/tests/ghci/scripts/ListTuplePunsPpr.stdout - testsuite/tests/interface-stability/ghc-experimental-exports.stdout - testsuite/tests/simplStg/should_compile/T15226b.stderr - testsuite/tests/th/TH_tuple1.stdout Changes: ===================================== compiler/GHC/Builtin/Types.hs ===================================== @@ -1015,7 +1015,7 @@ mkUnboxedTupleStr ns 0 | isDataConNameSpace ns = "(##)" | otherwise = "Unit#" mkUnboxedTupleStr ns 1 - | isDataConNameSpace ns = "(# #)" -- See Note [One-tuples] + | isDataConNameSpace ns = "MkSolo#" -- See Note [One-tuples] | otherwise = "Solo#" mkUnboxedTupleStr ns ar | isDataConNameSpace ns = "(#" ++ commas ar ++ "#)" ===================================== libraries/ghc-boot/GHC/Utils/Encoding.hs ===================================== @@ -79,7 +79,7 @@ The basic encoding scheme is this. :+ ZCzp () Z0T 0-tuple (,,,,) Z5T 5-tuple - (# #) Z1H unboxed 1-tuple (note the space) + (##) Z0H unboxed 0-tuple (#,,,,#) Z5H unboxed 5-tuple -} @@ -212,7 +212,6 @@ decode_tuple d rest go n (c : rest) | isDigit c = go (10*n + digitToInt c) rest go 0 ('T':rest) = "()" ++ zDecodeString rest go n ('T':rest) = '(' : replicate (n-1) ',' ++ ")" ++ zDecodeString rest - go 1 ('H':rest) = "(# #)" ++ zDecodeString rest go n ('H':rest) = '(' : '#' : replicate (n-1) ',' ++ "#)" ++ zDecodeString rest go n other = error ("decode_tuple: " ++ show n ++ ' ':other) @@ -223,15 +222,13 @@ for 3-tuples or unboxed 3-tuples respectively. No other encoding starts Z * "(##)" is the tycon for an unboxed 0-tuple -* "(# #)" is the tycon for an unboxed 1-tuple -* "()" is the tycon for a boxed 0-tuple. +* "()" is the tycon for a boxed 0-tuple -} maybe_tuple :: UserString -> Maybe EncodedString maybe_tuple "(##)" = Just("Z0H") -maybe_tuple "(# #)" = Just("Z1H") maybe_tuple ('(' : '#' : cs) = case count_commas (0::Int) cs of (n, '#' : ')' : _) -> Just ('Z' : shows (n+1) "H") _ -> Nothing ===================================== libraries/ghc-experimental/src/Data/Tuple/Experimental.hs ===================================== @@ -21,7 +21,7 @@ module Data.Tuple.Experimental ( -- * Unboxed tuples Unit#, - Solo#, + Solo#(..), Tuple0#, Tuple1#, Tuple2#, ===================================== libraries/ghc-prim/GHC/Types.hs ===================================== @@ -65,7 +65,7 @@ module GHC.Types ( -- * Unboxed tuples Unit#, - Solo#, + Solo#(..), Tuple0#, Tuple1#, Tuple2#, @@ -889,7 +889,7 @@ type Unit# :: TYPE (TupleRep '[]) data Unit# = (# #) type Solo# :: TYPE rep -> TYPE (TupleRep '[rep]) -data Solo# a = (# a #) +data Solo# a = MkSolo# a type Tuple0# = Unit# type Tuple1# = Solo# ===================================== libraries/template-haskell/Language/Haskell/TH/Lib/Syntax.hs ===================================== @@ -1933,9 +1933,7 @@ mk_tup_name n space boxed | space == DataName = "MkSolo" | otherwise = "Solo" - unboxed_solo - | space == DataName = "(# #)" - | otherwise = "Solo#" + unboxed_solo = solo ++ "#" -- Unboxed sum data and type constructors -- | Unboxed sum data constructor ===================================== testsuite/tests/core-to-stg/T24124.stderr ===================================== @@ -24,7 +24,7 @@ T15226b.testFun1 case y of conrep { __DEFAULT -> case T15226b.MkStrictPair [sat conrep] of sat { - __DEFAULT -> (# #) [sat]; + __DEFAULT -> MkSolo# [sat]; }; }; }; ===================================== testsuite/tests/ghci/scripts/ListTuplePunsPpr.script ===================================== @@ -1,6 +1,7 @@ -:set -XUnboxedTuples -XNoListTuplePuns -XDataKinds +:set -XUnboxedTuples -XMagicHash -XNoListTuplePuns -XDataKinds import GHC.Tuple (Solo (MkSolo)) +import Data.Tuple.Experimental (Solo# (MkSolo#)) :i () :i (##) @@ -26,3 +27,5 @@ f i (j, k) = i + j + k :: Int :t f :t (\ (_, _) -> ()) :t (\ (MkSolo _) -> ()) +:i Solo# +:t MkSolo# ===================================== testsuite/tests/ghci/scripts/ListTuplePunsPpr.stdout ===================================== @@ -75,13 +75,17 @@ data Tuple2# a b = (#,#) a b (Int, Int) :: Tuple2 (*) (*) type T :: Tuple2 (*) (*) type T = (Int, Int) :: Tuple2 (*) (*) - -- Defined at :18:1 + -- Defined at :19:1 type S :: Solo (*) type S = MkSolo Int :: Solo (*) - -- Defined at :19:1 + -- Defined at :20:1 type L :: List (*) type L = [Int] :: List (*) - -- Defined at :20:1 + -- Defined at :21:1 f :: Int -> Tuple2 Int Int -> Int (\ (_, _) -> ()) :: Tuple2 a b -> Unit (\ (MkSolo _) -> ()) :: Solo a -> Unit +type Solo# :: * -> TYPE (GHC.Types.TupleRep [GHC.Types.LiftedRep]) +data Solo# a = MkSolo# a + -- Defined in ‘GHC.Types’ +MkSolo# :: a -> Solo# a ===================================== testsuite/tests/interface-stability/ghc-experimental-exports.stdout ===================================== @@ -2633,7 +2633,7 @@ module Data.Tuple.Experimental where type Solo :: * -> * data Solo a = MkSolo a type Solo# :: forall (k :: GHC.Types.RuntimeRep). TYPE k -> TYPE (GHC.Types.TupleRep '[k]) - data Solo# a = ... + data Solo# a = MkSolo# a type Tuple0 :: * type Tuple0 = () type Tuple0# :: GHC.Types.ZeroBitType ===================================== testsuite/tests/simplStg/should_compile/T15226b.stderr ===================================== @@ -20,7 +20,7 @@ T15226b.bar1 sat [Occ=Once1] :: T15226b.Str (GHC.Internal.Maybe.Maybe a) [LclId] = T15226b.Str! [sat]; - } in (# #) [sat]; + } in MkSolo# [sat]; }; T15226b.bar ===================================== testsuite/tests/th/TH_tuple1.stdout ===================================== @@ -6,5 +6,5 @@ GHC.Tuple.MkSolo 1 :: GHC.Tuple.Solo GHC.Num.Integer.Integer SigE (AppE (AppE (ConE GHC.Types.(#,#)) (LitE (IntegerL 1))) (LitE (IntegerL 2))) (AppT (AppT (ConT GHC.Types.Tuple2#) (ConT GHC.Num.Integer.Integer)) (ConT GHC.Num.Integer.Integer)) GHC.Types.(#,#) 1 2 :: GHC.Types.Tuple2# GHC.Num.Integer.Integer GHC.Num.Integer.Integer -SigE (AppE (ConE GHC.Types.(# #)) (LitE (IntegerL 1))) (AppT (ConT GHC.Types.Solo#) (ConT GHC.Num.Integer.Integer)) -GHC.Types.(# #) 1 :: GHC.Types.Solo# GHC.Num.Integer.Integer +SigE (AppE (ConE GHC.Types.MkSolo#) (LitE (IntegerL 1))) (AppT (ConT GHC.Types.Solo#) (ConT GHC.Num.Integer.Integer)) +GHC.Types.MkSolo# 1 :: GHC.Types.Solo# GHC.Num.Integer.Integer View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3b51995c158fe19d48839b92cf1ff78ce7825ce4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3b51995c158fe19d48839b92cf1ff78ce7825ce4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 18:41:24 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 07 May 2024 14:41:24 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Add the cmm_cpp_is_gcc predicate to the testsuite Message-ID: <663a75d4cde8f_393e94a00aa0397b1@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 4d59abf2 by Arsen Arsenović at 2024-05-07T14:40:24-04:00 Add the cmm_cpp_is_gcc predicate to the testsuite A future C-- test called T24474-cmm-override-g0 relies on the GCC-specific behaviour of -g3 implying -dD, which, in turn, leads to it emitting #defines past the preprocessing stage. Clang, at least, does not do this, so the test would fail if ran on Clang. As the behaviour here being tested is ``-optCmmP-g3'' undoing effects of the workaround we apply as a fix for bug #24474, and the workaround was for GCC-specific behaviour, the test needs to be marked as fragile on other compilers. - - - - - 25b0b404 by Arsen Arsenović at 2024-05-07T14:40:24-04:00 Split out the C-- preprocessor, and make it pass -g0 Previously, C-- was processed with the C preprocessor program. This means that it inherited flags passed via -optc. A flag that is somewhat often passed through -optc is -g. At certain -g levels (>=2), GCC starts emitting defines *after* preprocessing, for the purposes of debug info generation. This is not useful for the C-- compiler, and, in fact, causes lexer errors. We can suppress this effect (safely, if supported) via -g0. As a workaround, in older versions of GCC (<=10), GCC only emitted defines if a certain set of -g*3 flags was passed. Newer versions check the debug level. For the former, we filter out those -g*3 flags and, for the latter, we specify -g0 on top of that. As a compatible and effective solution, this change adds a C-- preprocessor distinct from the C compiler and preprocessor, but that keeps its flags. The command line produced for C-- preprocessing now looks like: $pgmCmmP $optCs_without_g3 $g0_if_supported $optCmmP Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/24474 - - - - - 30 changed files: - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Recomp/Flags.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools/Cpp.hs - compiler/GHC/SysTools/Tasks.hs - configure.ac - distrib/configure.ac.in - docs/users_guide/phases.rst - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cfg/default.host.target.in - hadrian/cfg/default.target.in - hadrian/src/Rules/Generate.hs - + m4/fp_cmm_cpp_cmd_with_args.m4 - m4/fp_settings.m4 - m4/fp_setup_windows_toolchain.m4 - m4/ghc_toolchain.m4 - m4/prep_target_file.m4 - testsuite/config/ghc - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - + testsuite/tests/cmm/should_compile/T24474-cmm-gets-c-opts.cmm - + testsuite/tests/cmm/should_compile/T24474-cmm-opt-order.cmm - + testsuite/tests/cmm/should_compile/T24474.cmm - testsuite/tests/cmm/should_compile/all.T - + testsuite/tests/cmm/should_fail/T24474-cmm-override-g0.cmm - + testsuite/tests/cmm/should_fail/T24474-cmm-override-g0.stderr - + testsuite/tests/cmm/should_fail/all.T The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3b51995c158fe19d48839b92cf1ff78ce7825ce4...25b0b40467d0a12601497117c0ad14e1fcab0b74 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3b51995c158fe19d48839b92cf1ff78ce7825ce4...25b0b40467d0a12601497117c0ad14e1fcab0b74 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 18:44:24 2024 From: gitlab at gitlab.haskell.org (Serge S. Gulin (@gulin.serge)) Date: Tue, 07 May 2024 14:44:24 -0400 Subject: [Git][ghc/ghc][wip/T24504] 5 commits: Rename Solo# data constructor to MkSolo# (#24673) Message-ID: <663a768841a0f_393e94b20c8c402ba@gitlab.mail> Serge S. Gulin pushed to branch wip/T24504 at Glasgow Haskell Compiler / GHC Commits: 3b51995c by Andrei Borzenkov at 2024-05-07T14:39:40-04:00 Rename Solo# data constructor to MkSolo# (#24673) - data Solo# a = (# a #) + data Solo# a = MkSolo# a And `(# foo #)` syntax now becomes just a syntactic sugar for `MkSolo# a`. - - - - - 4d59abf2 by Arsen Arsenović at 2024-05-07T14:40:24-04:00 Add the cmm_cpp_is_gcc predicate to the testsuite A future C-- test called T24474-cmm-override-g0 relies on the GCC-specific behaviour of -g3 implying -dD, which, in turn, leads to it emitting #defines past the preprocessing stage. Clang, at least, does not do this, so the test would fail if ran on Clang. As the behaviour here being tested is ``-optCmmP-g3'' undoing effects of the workaround we apply as a fix for bug #24474, and the workaround was for GCC-specific behaviour, the test needs to be marked as fragile on other compilers. - - - - - 25b0b404 by Arsen Arsenović at 2024-05-07T14:40:24-04:00 Split out the C-- preprocessor, and make it pass -g0 Previously, C-- was processed with the C preprocessor program. This means that it inherited flags passed via -optc. A flag that is somewhat often passed through -optc is -g. At certain -g levels (>=2), GCC starts emitting defines *after* preprocessing, for the purposes of debug info generation. This is not useful for the C-- compiler, and, in fact, causes lexer errors. We can suppress this effect (safely, if supported) via -g0. As a workaround, in older versions of GCC (<=10), GCC only emitted defines if a certain set of -g*3 flags was passed. Newer versions check the debug level. For the former, we filter out those -g*3 flags and, for the latter, we specify -g0 on top of that. As a compatible and effective solution, this change adds a C-- preprocessor distinct from the C compiler and preprocessor, but that keeps its flags. The command line produced for C-- preprocessing now looks like: $pgmCmmP $optCs_without_g3 $g0_if_supported $optCmmP Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/24474 - - - - - 8b5a4acd by Ben Gamari at 2024-05-07T21:43:57+03:00 IPE: Eliminate dependency on Read Instead of encoding the closure type as decimal string we now simply represent it as an integer, eliminating the need for `Read` in `GHC.Internal.InfoProv.Types.peekInfoProv`. Closes #24504. ------------------------- Metric Decrease: T24602_perf_size size_hello_artifact ------------------------- - - - - - 4e5ab5eb by Serge S. Gulin at 2024-05-07T21:43:57+03:00 IPE: WIP: Replace closure_desc string representation in logs output on Word32 - - - - - 30 changed files: - compiler/GHC/Builtin/Types.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Recomp/Flags.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/StgToCmm/InfoTableProv.hs - compiler/GHC/SysTools/Cpp.hs - compiler/GHC/SysTools/Tasks.hs - configure.ac - distrib/configure.ac.in - docs/users_guide/phases.rst - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cfg/default.host.target.in - hadrian/cfg/default.target.in - hadrian/src/Rules/Generate.hs - libraries/ghc-boot/GHC/Utils/Encoding.hs - libraries/ghc-experimental/src/Data/Tuple/Experimental.hs - libraries/ghc-internal/src/GHC/Internal/InfoProv/Types.hsc - libraries/ghc-prim/GHC/Types.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Syntax.hs - + m4/fp_cmm_cpp_cmd_with_args.m4 - m4/fp_settings.m4 - m4/fp_setup_windows_toolchain.m4 - m4/ghc_toolchain.m4 - m4/prep_target_file.m4 - rts/IPE.c - rts/Trace.c - rts/eventlog/EventLog.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a9badfdd0784db9f36611ecfeac841f8c44a004b...4e5ab5eba326524891adc788def8816d446b1ad0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a9badfdd0784db9f36611ecfeac841f8c44a004b...4e5ab5eba326524891adc788def8816d446b1ad0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 19:41:53 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 07 May 2024 15:41:53 -0400 Subject: [Git][ghc/ghc][wip/T24466] 370 commits: Define GHC2024 language edition (#24320) Message-ID: <663a84011a74a_393e94122af6449354@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24466 at Glasgow Haskell Compiler / GHC Commits: 09941666 by Adam Gundry at 2024-02-21T13:53:12+00:00 Define GHC2024 language edition (#24320) See https://github.com/ghc-proposals/ghc-proposals/pull/613. Also fixes #24343 and improves the documentation of language editions. Co-authored-by: Joachim Breitner <mail at joachim-breitner.de> - - - - - 5121a4ed by Ben Gamari at 2024-02-23T06:40:55-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. Bumps haddock submodule. - - - - - 0eb2265d by Hécate Moonlight at 2024-02-24T16:02:16-05:00 Improve the synopsis and description of base - - - - - 2e36f5d2 by Jade at 2024-02-24T16:02:51-05:00 Error Messages: Properly align cyclic module error Fixes: #24476 - - - - - bbfb051c by Ben Gamari at 2024-02-24T19:10:23-05:00 Allow docstrings after exports Here we extend the parser and AST to preserve docstrings following export items. We then extend Haddock to parse `@since` annotations in such docstrings, allowing changes in export structure to be properly documented. - - - - - d8d6ad8c by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Move modules into GHC.Internal.* namespace Bumps haddock submodule due to testsuite output changes. - - - - - a82af7cd by Ben Gamari at 2024-02-24T19:10:23-05:00 ghc-internal: Rewrite `@since ` to `@since base-` These will be incrementally moved to the export sites in `base` where possible. - - - - - ca3836e1 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Migrate Haddock `not-home` pragmas from `ghc-internal` This ensures that we do not use `base` stub modules as declarations' homes when not appropriate. - - - - - c8cf3e26 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Partially freeze exports of GHC.Base Sadly there are still a few module reexports. However, at least we have decoupled from the exports of `GHC.Internal.Base`. - - - - - 272573c6 by Ben Gamari at 2024-02-24T19:10:23-05:00 Move Haddock named chunks - - - - - 2d8a881d by Ben Gamari at 2024-02-24T19:10:23-05:00 Drop GHC.Internal.Data.Int - - - - - 55c4c385 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler: Fix mention to `GHC....` modules in wasm desugaring Really, these references should be via known-key names anyways. I have fixed the proximate issue here but have opened #24472 to track the additional needed refactoring. - - - - - 64150911 by Ben Gamari at 2024-02-24T19:10:23-05:00 Accept performance shifts from ghc-internal restructure As expected, Haddock now does more work. Less expected is that some other testcases actually get faster, presumably due to less interface file loading. As well, the size_hello_artifact test regressed a bit when debug information is enabled due to debug information for the new stub symbols. Metric Decrease: T12227 T13056 Metric Increase: haddock.Cabal haddock.base MultiLayerModulesTH_OneShot size_hello_artifact - - - - - 317a915b by Ben Gamari at 2024-02-24T19:10:23-05:00 Expose GHC.Wasm.Prim from ghc-experimental Previously this was only exposed from `ghc-internal` which violates our agreement that users shall not rely on things exposed from that package. Fixes #24479. - - - - - 3bbd2bf2 by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Small optimisation of evCallStack Don't lookupIds unless we actually need them. - - - - - 3e5c9e3c by Ben Gamari at 2024-02-24T19:10:23-05:00 compiler/tc: Use toException instead of SomeException - - - - - 125714a6 by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Factor out errorBelch This was useful when debugging - - - - - 3d6aae7c by Ben Gamari at 2024-02-24T19:10:23-05:00 base: Clean up imports of GHC.Stack.CloneStack - - - - - 6900306e by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move PrimMVar to GHC.Internal.MVar - - - - - 28f8a148 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Move prettyCallStack to GHC.Internal.Stack - - - - - 4892de47 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Explicit dependency to workaround #24436 Currently `ghc -M` fails to account for `.hs-boot` files correctly, leading to issues with cross-package one-shot builds failing. This currently manifests in `GHC.Exception` due to the boot file for `GHC.Internal.Stack`. Work around this by adding an explicit `import`, ensuring that `GHC.Internal.Stack` is built before `GHC.Exception`. See #24436. - - - - - 294c93a5 by Ben Gamari at 2024-02-24T19:10:24-05:00 base: Use displayException in top-level exception handler Happily this also allows us to eliminate a special case for Deadlock exceptions. Implements [CLC #198](https://github.com/haskell/core-libraries-committee/issues/198). - - - - - cf756a25 by Ben Gamari at 2024-02-24T22:11:53-05:00 rts: Fix symbol references in Wasm RTS - - - - - 4e4d47a0 by Jade at 2024-02-26T15:17:20-05:00 GHCi: Improve response to unloading, loading and reloading modules Fixes #13869 - - - - - f3de8a3c by Zubin Duggal at 2024-02-26T15:17:57-05:00 rel-eng/fetch-gitlab.py: Fix name of aarch64 alpine 3_18 release job - - - - - c71bfdff by Cheng Shao at 2024-02-26T15:18:35-05:00 hadrian/hie-bios: pass -j to hadrian This commit passes -j to hadrian in the hadrian/hie-bios scripts. When the user starts HLS in a fresh clone that has just been configured, it takes quite a while for hie-bios to pick up the ghc flags and start actual indexing, due to the fact that the hadrian build step defaulted to -j1, so -j speeds things up and improve HLS user experience in GHC. Also add -j flag to .ghcid to speed up ghcid, and sets the Windows build root to .hie-bios which also works and unifies with other platforms, the previous build root _hie-bios was missing from .gitignore anyway. - - - - - 50bfdb46 by Cheng Shao at 2024-02-26T15:18:35-05:00 ci: enable parallelism in hadrian/ghci scripts This commit enables parallelism when the hadrian/ghci scripts are called in CI. The time bottleneck is in the hadrian build step, but previously the build step wasn't parallelized. - - - - - 61a78231 by Felix Yan at 2024-02-26T15:19:14-05:00 m4: Correctly detect GCC version When calling as `cc`, GCC does not outputs lowercased "gcc" at least in 13.2.1 version here. ``` $ cc --version cc (GCC) 13.2.1 20230801 ... ``` This fails the check and outputs the confusing message: `configure: $CC is not gcc; assuming it's a reasonably new C compiler` This patch makes it check for upper-cased "GCC" too so that it works correctly: ``` checking version of gcc... 13.2.1 ``` - - - - - 001aa539 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Fix formatting in whereFrom docstring Previously it used markdown syntax rather than Haddock syntax for code quotes - - - - - e8034d15 by Teo Camarasu at 2024-02-27T13:26:46-05:00 Move ClosureType type to ghc-internal - Use ClosureType for InfoProv.ipDesc. - Use ClosureType for CloneStack.closureType. - Now ghc-heap re-exports this type from ghc-internal. See the accompanying CLC proposal: https://github.com/haskell/core-libraries-committee/issues/210 Resolves #22600 - - - - - 3da0a551 by Matthew Craven at 2024-02-27T13:27:22-05:00 StgToJS: Simplify ExprInline constructor of ExprResult Its payload was used only for a small optimization in genAlts, avoiding a few assignments for programs of this form: case NormalDataCon arg1 arg2 of x { NormalDataCon x1 x2 -> ... ; } But when compiling with optimizations, this sort of code is generally eliminated by case-of-known-constructor in Core-to-Core. So it doesn't seem worth tracking and cleaning up again in StgToJS. - - - - - 61bc92cc by Cheng Shao at 2024-02-27T16:58:42-05:00 rts: add missing ccs_mutex guard to internal_dlopen See added comment for details. Closes #24423. - - - - - dd29d3b2 by doyougnu at 2024-02-27T16:59:23-05:00 cg: Remove GHC.Cmm.DataFlow.Collections In pursuit of #15560 and #17957 and generally removing redundancy. - - - - - d3a050d2 by Cheng Shao at 2024-02-27T17:00:00-05:00 utils: remove unused lndir from tree Ever since the removal of the make build system, the in tree lndir hasn't been actually built, so this patch removes it. - - - - - 74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00 rts: avoid checking bdescr of value outside of Haskell heap In nonmovingTidyWeaks we want to check if the key of a weak pointer lives in the non-moving heap. We do this by checking the flags of the block the key lives in. But we need to be careful with values that live outside the Haskell heap, since they will lack a block descriptor and looking for one may lead to a segfault. In this case we should just accept that it isn't on the non-moving heap. Resolves #24492 - - - - - b4cae4ec by Simon Peyton Jones at 2024-02-29T02:10:08-05:00 In mkDataConRep, ensure the in-scope set is right A small change that fixes #24489 - - - - - 3836a110 by Cheng Shao at 2024-02-29T21:25:45-05:00 testsuite: fix T23540 fragility on 32-bit platforms T23540 is fragile on 32-bit platforms. The root cause is usage of `getEvidenceTreesAtPoint`, which internally relies on `Name`'s `Ord` instance, which is indeterministic. The solution is adding a deterministic `Ord` instance for `EvidenceInfo` and sorting the evidence trees before pretty printing. Fixes #24449. - - - - - 960c8d47 by Teo Camarasu at 2024-02-29T21:26:20-05:00 Reduce AtomicModifyIORef increment count This test leads to a lot of contention when N>2 and becomes very slow. Let's reduce the amount of work we do to compensate. Resolves #24490 - - - - - 2e46c8ad by Matthew Pickering at 2024-03-01T05:48:06-05:00 hadrian: Improve parallelism in binary-dist-dir rule I noticed that the "docs" target was needed after the libraries and executables were built. We can improve the parallelism by needing everything at once so that documentation can be built immediately after a library is built for example. - - - - - cb6c11fe by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Bump windows and freebsd boot compilers to 9.6.4 We have previously bumped the docker images to use 9.6.4, but neglected to bump the windows images until now. - - - - - 30f06996 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: darwin: Update to 9.6.2 for boot compiler 9.6.4 is currently broken due to #24050 Also update to use LLVM-15 rather than LLVM-11, which is out of date. - - - - - d9d69e12 by Matthew Pickering at 2024-03-01T05:48:07-05:00 Bump minimum bootstrap version to 9.6 - - - - - 67ace1c5 by Matthew Pickering at 2024-03-01T05:48:07-05:00 ci: Enable more documentation building Here we enable documentation building on 1. Darwin: The sphinx toolchain was already installed so we enable html and manpages. 2. Rocky8: Full documentation (toolchain already installed) 3. Alpine: Full documetnation (toolchain already installed) 4. Windows: HTML and manpages (toolchain already installed) Fixes #24465 - - - - - 39583c39 by Matthew Pickering at 2024-03-01T05:48:42-05:00 ci: Bump ci-images to allow updated aarch64-alpine image with llvm15 and clang15 - - - - - d91d00fc by Torsten Schmits at 2024-03-01T15:01:50-05:00 Introduce ListTuplePuns extension This implements Proposal 0475, introducing the `ListTuplePuns` extension which is enabled by default. Disabling this extension makes it invalid to refer to list, tuple and sum type constructors by using built-in syntax like `[Int]`, `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`. Instead, this syntax exclusively denotes data constructors for use with `DataKinds`. The conventional way of referring to these data constructors by prefixing them with a single quote (`'(Int, Int)`) is now a parser error. Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo` data constructor has been renamed to `MkSolo` (in a previous commit). Unboxed tuples and sums now have real source declarations in `GHC.Types`. Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo` and `Solo#`. Constraint tuples now have the unambiguous type constructors `CTuple<n>` as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before. A new parser construct has been added for the unboxed sum data constructor declarations. The type families `Tuple`, `Sum#` etc. that were intended to provide nicer syntax have been omitted from this change set due to inference problems, to be implemented at a later time. See the MR discussion for more info. Updates the submodule utils/haddock. Updates the cabal submodule due to new language extension. Metric Increase: haddock.base Metric Decrease: MultiLayerModulesTH_OneShot size_hello_artifact Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst Merge request: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8820 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/21294 - - - - - bbdb6286 by Sylvain Henry at 2024-03-01T15:01:50-05:00 JS linker: filter unboxed tuples - - - - - dec6d8d3 by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Improve error messages coming from non-linear patterns This enriched the `CtOrigin` for non-linear patterns to include data of the pattern that created the constraint (which can be quite useful if it occurs nested in a pattern) as well as an explanation why the pattern is non-restricted in (at least in some cases). - - - - - 6612388e by Arnaud Spiwack at 2024-03-01T15:02:30-05:00 Adjust documentation of linear lets according to committee decision - - - - - 1c064ef1 by Cheng Shao at 2024-03-02T17:11:19-05:00 compiler: start deprecating cmmToRawCmmHook cmmToRawCmmHook was added 4 years ago in d561c8f6244f8280a2483e8753c38e39d34c1f01. Its only user is the Asterius project, which has been archived and deprecated in favor of the ghc wasm backend. This patch starts deprecating cmmToRawCmmHook by placing a DEPRECATED pragma, and actual removal shall happen in a future GHC major release if no issue to oppose the deprecation has been raised in the meantime. - - - - - 9b74845f by Andrew Lelechenko at 2024-03-02T17:11:55-05:00 Data.List.NonEmpty.unzip: use WARNING with category instead of DEPRECATED CLC proposal: https://github.com/haskell/core-libraries-committee/issues/258 - - - - - 61bb5ff6 by Finley McIlwaine at 2024-03-04T09:01:40-08:00 add -fprof-late-overloaded and -fprof-late-overloaded-calls * Refactor late cost centre insertion for extensibility * Add two more late cost centre insertion methods that add SCCs to overloaded top level bindings and call sites with dictionary arguments. * Some tests for the basic functionality of the new insertion methods Resolves: #24500 - - - - - 82ccb801 by Andreas Klebinger at 2024-03-04T19:59:14-05:00 x86-ncg: Fix fma codegen when arguments are globals Fix a bug in the x86 ncg where results would be wrong when the desired output register and one of the input registers were the same global. Also adds a tiny optimization to make use of the memory addressing support when convenient. Fixes #24496 - - - - - 18ad1077 by Matthew Pickering at 2024-03-05T14:22:31-05:00 rel_eng: Update hackage docs upload scripts This adds the upload of ghc-internal and ghc-experimental to our scripts which upload packages to hackage. - - - - - bf47c9ba by Matthew Pickering at 2024-03-05T14:22:31-05:00 docs: Remove stray module comment from GHC.Profiling.Eras - - - - - 37d9b340 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix ghc-internal cabal file The file mentioned some artifacts relating to the base library. I have renamed these to the new ghc-internal variants. - - - - - 23f2a478 by Matthew Pickering at 2024-03-05T14:22:31-05:00 Fix haddock source links and hyperlinked source There were a few issues with the hackage links: 1. We were using the package id rather than the package name for the package links. This is fixed by now allowing the template to mention %pkg% or %pkgid% and substituing both appropiatly. 2. The `--haddock-base-url` flag is renamed to `--haddock-for-hackage` as the new base link works on a local or remote hackage server. 3. The "src" path including too much stuff, so cross-package source links were broken as the template was getting double expanded. Fixes #24086 - - - - - 2fa336a9 by Ben Gamari at 2024-03-05T14:23:07-05:00 filepath: Bump submodule to 1.5.2.0 - - - - - 31217944 by Ben Gamari at 2024-03-05T14:23:07-05:00 os-string: Bump submodule to 2.0.2 - - - - - 4074a3f2 by Matthew Pickering at 2024-03-05T21:44:35-05:00 base: Reflect new era profiling RTS flags in GHC.RTS.Flags * -he profiling mode * -he profiling selector * --automatic-era-increment CLC proposal #254 - https://github.com/haskell/core-libraries-committee/issues/254 - - - - - a8c0e31b by Sylvain Henry at 2024-03-05T21:45:14-05:00 JS: faster implementation for some numeric primitives (#23597) Use faster implementations for the following primitives in the JS backend by not using JavaScript's BigInt: - plusInt64 - minusInt64 - minusWord64 - timesWord64 - timesInt64 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 21e3f325 by Cheng Shao at 2024-03-05T21:45:52-05:00 rts: add -xr option to control two step allocator reserved space size This patch adds a -xr RTS option to control the size of virtual memory address space reserved by the two step allocator on a 64-bit platform, see added documentation for explanation. Closes #24498. - - - - - dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 8a8ac65a by Matthew Craven at 2024-03-23T00:20:52-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 0c48f2b9 by Apoorv Ingle at 2024-03-23T00:21:28-04:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - b72705e9 by Simon Peyton Jones at 2024-03-23T00:22:04-04:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 8f7cfc7e by Tristan Cacqueray at 2024-03-23T00:22:44-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - 5bd8ed53 by Andreas Klebinger at 2024-03-23T16:18:33-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8d67f247 by Ben Gamari at 2024-03-23T16:19:09-04:00 docs: Drop old release notes, add for 9.12.1 - - - - - 7db8c992 by Cheng Shao at 2024-03-25T13:45:46-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. - - - - - 237194ce by Sylvain Henry at 2024-03-25T13:46:27-04:00 Lexer: fix imports for Alex 3.5.1 (#24583) - - - - - 810660b7 by Cheng Shao at 2024-03-25T22:19:16-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - d2ba41e8 by Alan Zimmerman at 2024-03-25T22:19:51-04:00 EPA: do not duplicate comments in signature RHS - - - - - 32a8103f by Rodrigo Mesquita at 2024-03-26T21:16:12-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. - - - - - bf65a7c3 by Rodrigo Mesquita at 2024-03-26T21:16:48-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 - - - - - cfeb70d3 by Rodrigo Mesquita at 2024-03-26T21:17:24-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 13223f6d by Serge S. Gulin at 2024-03-27T07:28:51-04:00 JS: `h$rts_isProfiled` is removed from `profiling` and left its version at `rts/js/config.js` - - - - - 0acfe391 by Alan Zimmerman at 2024-03-27T07:29:27-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. - - - - - cd0fb82f by Alan Zimmerman at 2024-03-27T19:33:08+00:00 EPA: Fix FamDecl range The span was incorrect if opt_datafam_kind_sig was empty - - - - - f8f384a8 by Ben Gamari at 2024-03-29T01:23:03-04:00 Fix type of _get_osfhandle foreign import Fixes #24601. - - - - - 00d3ecf0 by Alan Zimmerman at 2024-03-29T12:19:10+00:00 EPA: Extend StringLiteral range to include trailing commas This goes slightly against the exact printing philosophy where trailing decorations should be in an annotation, but the practicalities of adding it to the WarningTxt environment, and the problems caused by deviating do not make a more principles approach worthwhile. - - - - - efab3649 by brandon s allbery kf8nh at 2024-03-31T20:04:01-04:00 clarify Note [Preproccesing invocations] - - - - - c8a4c050 by Ben Gamari at 2024-04-02T12:50:35-04:00 rts: Fix TSAN_ENABLED CPP guard This should be `#if defined(TSAN_ENABLED)`, not `#if TSAN_ENABLED`, lest we suffer warnings. - - - - - e91dad93 by Cheng Shao at 2024-04-02T12:50:35-04:00 rts: fix errors when compiling with TSAN This commit fixes rts compilation errors when compiling with TSAN: - xxx_FENCE macros are redefined and trigger CPP warnings. - Use SIZEOF_W. WORD_SIZE_IN_BITS is provided by MachDeps.h which Cmm.h doesn't include by default. - - - - - a9ab9455 by Cheng Shao at 2024-04-02T12:50:35-04:00 rts: fix clang-specific errors when compiling with TSAN This commit fixes clang-specific rts compilation errors when compiling with TSAN: - clang doesn't have -Wtsan flag - Fix prototype of ghc_tsan_* helper functions - __tsan_atomic_* functions aren't clang built-ins and sanitizer/tsan_interface_atomic.h needs to be included - On macOS, TSAN runtime library is libclang_rt.tsan_osx_dynamic.dylib, not libtsan. -fsanitize-thread as a link-time flag will take care of linking the TSAN runtime library anyway so remove tsan as an rts extra library - - - - - 865bd717 by Cheng Shao at 2024-04-02T12:50:35-04:00 compiler: fix github link to __tsan_memory_order in a comment - - - - - 07cb627c by Cheng Shao at 2024-04-02T12:50:35-04:00 ci: improve TSAN CI jobs - Run TSAN jobs with +thread_sanitizer_cmm which enables Cmm instrumentation as well. - Run TSAN jobs in deb12 which ships gcc-12, a reasonably recent gcc that @bgamari confirms he's using in #GHC:matrix.org. Ideally we should be using latest clang release for latest improvements in sanitizers, though that's left as future work. - Mark TSAN jobs as manual+allow_failure in validate pipelines. The purpose is to demonstrate that we have indeed at least fixed building of TSAN mode in CI without blocking the patch to land, and once merged other people can begin playing with TSAN using their own dev setups and feature branches. - - - - - a1c18c7b by Andrei Borzenkov at 2024-04-02T12:51:11-04:00 Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy (#24299, #23639) This patch implements refactoring which is a prerequisite to updating kind checking of type patterns. This is a huge simplification of the main worker that checks kind of HsType. It also fixes the issues caused by previous code duplication, e.g. that we didn't add module finalizers from splices in inference mode. - - - - - 817e8936 by Rodrigo Mesquita at 2024-04-02T20:13:05-04:00 th: Hide the Language.Haskell.TH.Lib.Internal module from haddock Fixes #24562 - - - - - b36ee57b by Sylvain Henry at 2024-04-02T20:13:46-04:00 JS: reenable h$appendToHsString optimization (#24495) The optimization introducing h$appendToHsString wasn't kicking in anymore (while it did in 9.8.1) because of the changes introduced in #23270 (7e0c8b3bab30). This patch reenables the optimization by matching on case-expression, as done in Cmm for unpackCString# standard thunks. The test is also T24495 added in the next commits (two commits for ease of backporting to 9.8). - - - - - 527616e9 by Sylvain Henry at 2024-04-02T20:13:46-04:00 JS: fix h$appendToHsString implementation (#24495) h$appendToHsString needs to wrap its argument in an updatable thunk to behave like unpackAppendCString#. Otherwise if a SingleEntry thunk is passed, it is stored as-is in a CONS cell, making the resulting list impossible to deepseq (forcing the thunk doesn't update the contents of the CONS cell)! The added test checks that the optimization kicks in and that h$appendToHsString works as intended. Fix #24495 - - - - - faa30b41 by Simon Peyton Jones at 2024-04-02T20:14:22-04:00 Deal with duplicate tyvars in type declarations GHC was outright crashing before this fix: #24604 - - - - - e0b0c717 by Simon Peyton Jones at 2024-04-02T20:14:58-04:00 Try using MCoercion in exprIsConApp_maybe This is just a simple refactor that makes exprIsConApp_maybe a little bit more direct, simple, and efficient. Metrics: compile_time/bytes allocated geo. mean -0.1% minimum -2.0% maximum -0.0% Not a big gain, but worthwhile given that the code is, if anything, easier to grok. - - - - - 15f4d867 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Initial ./configure support for selecting I/O managers In this patch we just define new CPP vars, but don't yet use them or replace the existing approach. That will follow. The intention here is that every I/O manager can be enabled/disabled at GHC build time (subject to some constraints). More than one I/O manager can be enabled to be built. At least one I/O manager supporting the non-threaded RTS must be enabled as well as at least one supporting the non-threaded RTS. The I/O managers enabled here will become the choices available at runtime at RTS startup (in later patches). The choice can be made with RTS flags. There are separate sets of choices for the threaded and non-threaded RTS ways, because most I/O managers are specific to these ways. Furthermore we must establish a default I/O manager for the threaded and non-threaded RTS. Most I/O managers are platform-specific so there are checks to ensure each one can be enabled on the platform. Such checks are also where (in future) any system dependencies (e.g. libraries) can be checked. The output is a set of CPP flags (in the mk/config.h file), with one flag per named I/O manager: * IOMGR_BUILD_<name> : which ones should be built (some) * IOMGR_DEFAULT_NON_THREADED_<name> : which one is default (exactly one) * IOMGR_DEFAULT_THREADED_<name> : which one is default (exactly one) and a set of derived flags in IOManager.h * IOMGR_ENABLED_<name> : enabled for the current RTS way Note that IOMGR_BUILD_<name> just says that an I/O manager will be built for _some_ RTS way (i.e. threaded or non-threaded). The derived flags IOMGR_ENABLED_<name> in IOManager.h say if each I/O manager is enabled in the "current" RTS way. These are the ones that can be used for conditional compilation of the I/O manager code. Co-authored-by: Pi Delport <pi at well-typed.com> - - - - - 85b0f87a by Duncan Coutts at 2024-04-03T01:27:17-04:00 Change the handling of the RTS flag --io-manager= Now instead of it being just used on Windows to select between the WinIO vs the MIO or Win32-legacy I/O managers, it is now used on all platforms for selecting the I/O manager to use. Right now it remains the case that there is only an actual choice on Windows, but that will change later. Document the --io-manager flag in the user guide. This change is also reflected in the RTS flags types in the base library. Deprecate the export of IoSubSystem from GHC.RTS.Flags with a message to import it from GHC.IO.Subsystem. The way the 'IoSubSystem' is detected also changes. Instead of looking at the RTS flag, there is now a C bool global var in the RTS which gets set on startup when the I/O manager is selected. This bool var says whether the selected I/O manager classifies as "native" on Windows, which in practice means the WinIO I/O manager has been selected. Similarly, the is_io_mng_native_p RTS helper function is re-implemented in terms of the selected I/O manager, rather than based on the RTS flags. We do however remove the ./configure --native-io-manager flag because we're bringing the WinIO/MIO/Win32-legacy choice under the new general scheme for selecting I/O managers, and that new scheme involves no ./configure time user choices, just runtime RTS flag choices. - - - - - 1a8f020f by Duncan Coutts at 2024-04-03T01:27:17-04:00 Convert {init,stop,exit}IOManager to switch style Rather than ad-hoc cpp conitionals on THREADED_RTS and mingw32_HOST_OS, we use a style where we switch on the I/O manager impl, with cases for each I/O manager impl. - - - - - a5bad3d2 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Split up the CapIOManager content by I/O manager Using the new IOMGR_ENABLED_<name> CPP defines. - - - - - 1d36e609 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Convert initIOManagerAfterFork and wakeupIOManager to switch style - - - - - c2f26f36 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move most of waitRead#/Write# from cmm to C Moves it into the IOManager.c where we can follow the new pattern of switching on the selected I/O manager. - - - - - 457705a8 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move most of the delay# impl from cmm to C Moves it into the IOManager.c where we can follow the new pattern of switching on the selected I/O manager. Uses a new IOManager API: syncDelay, following the naming convention of sync* for thread-synchronous I/O & timer/delay operations. As part of porting from cmm to C, we maintain the rule that the why_blocked gets accessed using load acquire and store release atomic memory operations. There was one exception to this rule: in the delay# primop cmm code on posix (not win32), the why_blocked was being updated using a store relaxed, not a store release. I've no idea why. In this convesion I'm playing it safe here and using store release consistently. - - - - - e93058e0 by Duncan Coutts at 2024-04-03T01:27:18-04:00 insertIntoSleepingQueue is no longer public No longer defined in IOManager.h, just a private function in IOManager.c. Since it is no longer called from cmm code, just from syncDelay. It ought to get moved further into the select() I/O manager impl, rather than living in IOManager.c. On the other hand appendToIOBlockedQueue is still called from cmm code in the win32-legacy I/O manager primops async{Read,Write}#, and it is also used by the select() I/O manager. Update the CPP and comments to reflect this. - - - - - 60ce9910 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move anyPendingTimeoutsOrIO impl from .h to .c The implementation is eventually going to need to use more private things, which will drag in unwanted includes into IOManager.h, so it's better to move the impl out of the header file and into the .c file, at the slight cost of it no longer being inline. At the same time, change to the "switch (iomgr_type)" style. - - - - - f70b8108 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Take a simpler approach to gcc warnings in IOManager.c We have lots of functions with conditional implementations for different I/O managers. Some functions, for some I/O managers, naturally have implementations that do nothing or barf. When only one such I/O manager is enabled then the whole function implementation will have an implementation that does nothing or barfs. This then results in warnings from gcc that parameters are unused, or that the function should be marked with attribute noreturn (since barf does not return). The USED_IF_THREADS trick for fine-grained warning supression is fine for just two cases, but an equivalent here would need USED_IF_THE_ONLY_ENABLED_IOMGR_IS_X_OR_Y which would have combinitorial blowup. So we take a coarse grained approach and simply disable these two warnings for the whole file. So we use a GCC pragma, with its handy push/pop support: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsuggest-attribute=noreturn" #pragma GCC diagnostic ignored "-Wunused-parameter" ... #pragma GCC diagnostic pop - - - - - b48805b9 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add a new trace class for the iomanager It makes sense now for it to be separate from the scheduler class of tracers. Enabled with +RTS -Do. Document the -Do debug flag in the user guide. - - - - - f0c1f862 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Have the throwTo impl go via (new) IOManager APIs rather than directly operating on the IO manager's data structures. Specifically, when thowing an async exception to a thread that is blocked waiting for I/O or waiting for a timer, then we want to cancel that I/O waiting or cancel the timer. Currently this is done directly in removeFromQueues() in RaiseAsync.c. We want it to go via proper APIs both for modularity but also to let us support multiple I/O managers. So add sync{IO,Delay}Cancel, which is the cancellation for the corresponding sync{IO,Delay}. The implementations of these use the usual "switch (iomgr_type)" style. - - - - - 4f9e9c4e by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move awaitEvent into a proper IOManager API and have the scheduler use it. Previously the scheduler calls awaitEvent directly, and awaitEvent is implemented directly in the RTS I/O managers (select, win32). This relies on the old scheme where there's a single active I/O manager for each platform and RTS way. We want to move that to go via an API in IOManager.{h,c} which can then call out to the active I/O manager. Also take the opportunity to split awaitEvent into two. The existing awaitEvent has a bool wait parameter, to say if the call should be blocking or non-blocking. We split this into two separate functions: pollCompletedTimeoutsOrIO and awaitCompletedTimeoutsOrIO. We split them for a few reasons: they have different post-conditions (specifically the await version is supposed to guarantee that there are threads runnable when it completes). Secondly, it is also anticipated that in future I/O managers the implementations of the two cases will be simpler if they are separated. - - - - - 5ad4b30f by Duncan Coutts at 2024-04-03T01:27:18-04:00 Rename awaitEvent in select and win32 I/O managers These are now just called from IOManager.c and are the per-I/O manager backend impls (whereas previously awaitEvent was the entry point). Follow the new naming convention in the IOManager.{h,c} of awaitCompletedTimeoutsOrIO, with the I/O manager's name as a suffix: so awaitCompletedTimeoutsOrIO{Select,Win32}. - - - - - d30c6bc6 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Tidy up a couple things in Select.{h,c} Use the standard #include {Begin,End}Private.h style rather than RTS_PRIVATE on individual decls. And conditionally build the code for the select I/O manager based on the new CPP IOMGR_ENABLED_SELECT rather than on THREADED_RTS. - - - - - 4161f516 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add an IOManager API for scavenging TSO blocked_info When the GC scavenges a TSO it needs to scavenge the tso->blocked_info but the blocked_info is a big union and what lives there depends on the two->why_blocked, which for I/O-related reasons is something that in principle is the responsibility of the I/O manager and not the GC. So the right thing to do is for the GC to ask the I/O manager to sscavenge the blocked_info if it encounters any I/O-related why_blocked reasons. So we add scavengeTSOIOManager in IOManager.{h,c} with the usual style. Now as it happens, right now, there is no special scavenging to do, so the implementation of scavengeTSOIOManager is a fancy no-op. That's because the select I/O manager uses only the fd and target members, which are not GC pointers, and the win32-legacy I/O manager _ought_ to be using GC-managed heap objects for the StgAsyncIOResult but it is actually usingthe C heap, so again no GC pointers. If the win32-legacy were doing this more sensibly, then scavengeTSOIOManager would be the right place to do the GC magic. Future I/O managers will need GC heap objects in the tso->blocked_info and will make use of this functionality. - - - - - 94a87d21 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add I/O manager API notifyIOManagerCapabilitiesChanged Used in setNumCapabilities. It only does anything for MIO on Posix. Previously it always invoked Haskell code, but that code only did anything on non-Windows (and non-JS), and only threaded. That currently effectively means the MIO I/O manager on Posix. So now it only invokes it for the MIO Posix case. - - - - - 3be6d591 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Select an I/O manager early in RTS startup We need to select the I/O manager to use during startup before the per-cap I/O manager initialisation. - - - - - aaa294d0 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Make struct CapIOManager be fully opaque Provide an opaque (forward) definition in Capability.h (since the cap contains a *CapIOManager) and then only provide a full definition in a new file IOManagerInternals.h. This new file is only supposed to be included by the IOManager implementation, not by its users. So that means IOManager.c and individual I/O manager implementations. The posix/Signals.c still needs direct access, but that should be eliminated. Anything that needs direct access either needs to be clearly part of an I/O manager (e.g. the sleect() one) or go via a proper API. - - - - - 877a2a80 by Duncan Coutts at 2024-04-03T01:27:18-04:00 The select() I/O manager does have some global initialisation It's just to make sure an exception CAF is a GC root. - - - - - 9c51473b by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add tracing for the main I/O manager actions Using the new tracer class. Note: The unconditional definition of showIOManager should be compatible with the debugTrace change in 7c7d1f6. Co-authored-by: Pi Delport <pi at well-typed.com> - - - - - c7d3e3a3 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Include the default I/O manager in the +RTS --info output Document the extra +RTS --info output in the user guide - - - - - 8023bad4 by Duncan Coutts at 2024-04-03T01:27:18-04:00 waitRead# / waitWrite# do not work for win32-legacy I/O manager Previously it was unclear that they did not work because the code path was shared with other I/O managers (in particular select()). Following the code carefully shows that what actually happens is that the calling thread would block forever: the thread will be put into the blocked queue, but no other action is scheduled that will ever result in it getting unblocked. It's better to just fail loudly in case anyone accidentally calls it, also it's less confusing code. - - - - - 83a74d20 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Conditionally ignore some GCC warnings Some GCC versions don't know about some warnings, and they complain that we're ignoring unknown warnings. So we try to ignore the warning based on the GCC version. - - - - - 1adc6fa4 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Accept changes to base-exports All the changes are in fact not changes at all. Previously, the IoSubSystem data type was defined in GHC.RTS.Flags and exported from both GHC.RTS.Flags and GHC.IO.SubSystem. Now, the data type is defined in GHC.IO.SubSystem and still exported from both modules. Therefore, the same exports and same instances are still available from both modules. But the base-exports records only the defining module, and so it looks like a change when it is fully compatible. Related: we do add a deprecation to the export of the type via GHC.RTS.Flags, telling people to use the export from GHC.IO.SubSystem. Also the sort order for some unrelated Show instances changed. No idea why. The same changes apply in the other versions, with a few more changes due to sort order weirdness. - - - - - 8d950968 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Accept metric decrease in T12227 I can't think of any good reason that anything in this MR should have changed the number of allocations, up or down. (Yes this is an empty commit.) Metric Decrease: T12227 - - - - - e869605e by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Several improvements to the handling of coercions * Make `mkSymCo` and `mkInstCo` smarter Fixes #23642 * Fix return role of `SelCo` in the coercion optimiser. Fixes #23617 * Make the coercion optimiser `opt_trans_rule` work better for newtypes Fixes #23619 - - - - - 1efd0714 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 FloatOut: improve floating for join point See the new Note [Floating join point bindings]. * Completely get rid of the complicated join_ceiling nonsense, which I have never understood. * Do not float join points at all, except perhaps to top level. * Some refactoring around wantToFloat, to treat Rec and NonRec more uniformly - - - - - 9c00154d by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Improve eta-expansion through call stacks See Note [Eta expanding through CallStacks] in GHC.Core.Opt.Arity This is a one-line change, that fixes an inconsistency - || isCallStackPredTy ty + || isCallStackPredTy ty || isCallStackTy ty - - - - - 95a9a172 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Spelling, layout, pretty-printing only - - - - - bdf1660f by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Improve exprIsConApp_maybe a little Eliminate a redundant case at birth. This sometimes reduces Simplifier iterations. See Note [Case elim in exprIsConApp_maybe]. - - - - - 609cd32c by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Inline GHC.HsToCore.Pmc.Solver.Types.trvVarInfo When exploring compile-time regressions after meddling with the Simplifier, I discovered that GHC.HsToCore.Pmc.Solver.Types.trvVarInfo was very delicately balanced. It's a small, heavily used, overloaded function and it's important that it inlines. By a fluke it was before, but at various times in my journey it stopped doing so. So I just added an INLINE pragma to it; no sense in depending on a delicately-balanced fluke. - - - - - ae24c9bc by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Slight improvement in WorkWrap Ensure that WorkWrap preserves lambda binders, in case of join points. Sadly I have forgotten why I made this change (it was while I was doing a lot of meddling in the Simplifier, but * it does no harm, * it is slightly more efficient, and * presumably it made something better! Anyway I have kept it in a separate commit. - - - - - e9297181 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Use named record fields for the CastIt { ... } data constructor This is a pure refactor - - - - - b4581e23 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Remove a long-commented-out line Pure refactoring - - - - - e026bdf2 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The main changes are below. There are also many new or rewritten Notes. Avoiding simplifying repeatedly ~~~~~~~~~~~~~~~ See Note [Avoiding simplifying repeatedly] * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env. Currently used only for the next point: avoiding repeatedly simplifying coercions. * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] * Improve the case-merge transformation: - Move the main code to `GHC.Core.Utils.mergeCaseAlts`, to join `filterAlts` and friends. See Note [Merge Nested Cases] in GHC.Core.Utils. - Add a new case for `tagToEnum#`; see wrinkle (MC3). - Add a new case to look through join points: see wrinkle (MC4) postInlineUnconditionally ~~~~~~~~~~~~~~~~~~~~~~~~~ * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. * Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. * Improve occurrence analyis for bottoming function calls, to help postInlineUnconditionally. See Note [Bottoming function calls] in GHC.Core.Opt.OccurAnal Inlining generally ~~~~~~~~~~~~~~~~~~ * In GHC.Core.Opt.Simplify.Utils.interestingCallContext, use RhsCtxt NonRecursive (not BoringCtxt) for a plain-seq case. See Note [Seq is boring] Also, wrinkle (SB1), inline in that `seq` context only for INLINE functions (UnfWhen guidance). * In GHC.Core.Opt.Simplify.Utils.interestingArg, - return ValueArg for OtherCon [c1,c2, ...], but - return NonTrivArg for OtherCon [] This makes a function a little less likely to inline if all we know is that the argument is evaluated, but nothing else. * isConLikeUnfolding is no longer true for OtherCon {}. This propagates to exprIsConLike. Con-like-ness has /positive/ information. Join points ~~~~~~~~~~~ * Be very careful about inlining join points. See these two long Notes Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline * When making join points, don't do so if the join point is so small it will immediately be inlined; check uncondInlineJoin. * In GHC.Core.Opt.Simplify.Inline.tryUnfolding, improve the inlining heuristics for join points. In general we /do not/ want to inline join points /even if they are small/. See Note [Duplicating join points] GHC.Core.Opt.Simplify.Iteration. But sometimes we do: see Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline; and the new `isBetterUnfoldingThan` function. * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * In GHC.Core.Unfold.sizeExpr, make jumps small, so that we don't penalise having a non-inlined join point. Performance changes ~~~~~~~~~~~~~~~~~~~ * Binary sizes fall by around 2.6%, according to nofib. * Compile times improve slightly. Here are the figures over 1%. I investiate the biggest differnce in T18304. It's a very small module, just a few hundred nodes. The large percentage difffence is due to a single function that didn't quite inline before, and does now, making code size a bit bigger. I decided gains outweighed the losses. Metrics: compile_time/bytes allocated (changes over +/- 1%) ------------------------------------------------ CoOpt_Singletons(normal) -9.2% GOOD LargeRecord(normal) -23.5% GOOD MultiComponentModulesRecomp(normal) +1.2% MultiLayerModulesTH_OneShot(normal) +4.1% BAD PmSeriesS(normal) -3.8% PmSeriesV(normal) -1.5% T11195(normal) -1.3% T12227(normal) -20.4% GOOD T12545(normal) -3.2% T12707(normal) -2.1% GOOD T13253(normal) -1.2% T13253-spj(normal) +8.1% BAD T13386(normal) -3.1% GOOD T14766(normal) -2.6% GOOD T15164(normal) -1.4% T15304(normal) +1.2% T15630(normal) -8.2% T15630a(normal) NEW T15703(normal) -14.7% GOOD T16577(normal) -2.3% GOOD T17516(normal) -39.7% GOOD T18140(normal) +1.2% T18223(normal) -17.1% GOOD T18282(normal) -5.0% GOOD T18304(normal) +10.8% BAD T18923(normal) -2.9% GOOD T1969(normal) +1.0% T19695(normal) -1.5% T20049(normal) -12.7% GOOD T21839c(normal) -4.1% GOOD T3064(normal) -1.5% T3294(normal) +1.2% BAD T4801(normal) +1.2% T5030(normal) -15.2% GOOD T5321Fun(normal) -2.2% GOOD T6048(optasm) -16.8% GOOD T783(normal) -1.2% T8095(normal) -6.0% GOOD T9630(normal) -4.7% GOOD T9961(normal) +1.9% BAD WWRec(normal) -1.4% info_table_map_perf(normal) -1.3% parsing001(normal) +1.5% geo. mean -2.0% minimum -39.7% maximum +10.8% * Runtimes generally improve. In the testsuite perf/should_run gives: Metrics: runtime/bytes allocated ------------------------------------------ Conversions(normal) -0.3% T13536a(optasm) -41.7% GOOD T4830(normal) -0.1% haddock.Cabal(normal) -0.1% haddock.base(normal) -0.1% haddock.compiler(normal) -0.1% geo. mean -0.8% minimum -41.7% maximum +0.0% * For runtime, nofib is a better test. The news is mostly good. Here are the number more than +/- 0.1%: # bytes allocated ==========================++========== imaginary/digits-of-e1 || -14.40% imaginary/digits-of-e2 || -4.41% imaginary/paraffins || -0.17% imaginary/rfib || -0.15% imaginary/wheel-sieve2 || -0.10% real/compress || -0.47% real/fluid || -0.10% real/fulsom || +0.14% real/gamteb || -1.47% real/gg || -0.20% real/infer || +0.24% real/pic || -0.23% real/prolog || -0.36% real/scs || -0.46% real/smallpt || +4.03% shootout/k-nucleotide || -20.23% shootout/n-body || -0.42% shootout/spectral-norm || -0.13% spectral/boyer2 || -3.80% spectral/constraints || -0.27% spectral/hartel/ida || -0.82% spectral/mate || -20.34% spectral/para || +0.46% spectral/rewrite || +1.30% spectral/sphere || -0.14% ==========================++========== geom mean || -0.59% real/smallpt has a huge nest of local definitions, and I could not pin down a reason for a regression. But there are three big wins! Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12707 T13386 T13536a T14766 T15703 T16577 T17516 T18223 T18282 T18923 T21839c T20049 T5321Fun T5030 T6048 T8095 T9630 T783 Metric Increase: MultiLayerModulesTH_OneShot T13253-spj T18304 T18698a T9961 T3294 - - - - - 27db3c5e by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Testsuite message changes from simplifier improvements - - - - - 271a7812 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Account for bottoming functions in OccurAnal This fixes #24582, a small but long-standing bug - - - - - 0fde229f by Ben Gamari at 2024-04-04T07:04:58-04:00 testsuite: Introduce template-haskell-exports test - - - - - 0c4a9686 by Luite Stegeman at 2024-04-04T07:05:39-04:00 Update correct counter in bumpTickyAllocd - - - - - 5f085d3a by Fendor at 2024-04-04T14:47:33-04:00 Replace `SizedSeq` with `FlatBag` for flattened structure LinkedLists are notoriously memory ineffiecient when all we do is traversing a structure. As 'UnlinkedBCO' has been identified as a data structure that impacts the overall memory usage of GHCi sessions, we avoid linked lists and prefer flattened structure for storing. We introduce a new memory efficient representation of sequential elements that has special support for the cases: * Empty * Singleton * Tuple Elements This improves sharing in the 'Empty' case and avoids the overhead of 'Array' until its constant overhead is justified. - - - - - 82cfe10c by Fendor at 2024-04-04T14:47:33-04:00 Compact FlatBag array representation `Array` contains three additional `Word`'s we do not need in `FlatBag`. Move `FlatBag` to `SmallArray`. Expand the API of SmallArray by `sizeofSmallArray` and add common traversal functions, such as `mapSmallArray` and `foldMapSmallArray`. Additionally, allow users to force the elements of a `SmallArray` via `rnfSmallArray`. - - - - - 36a75b80 by Andrei Borzenkov at 2024-04-04T14:48:10-04:00 Change how invisible patterns represented in haskell syntax and TH AST (#24557) Before this patch: data ArgPat p = InvisPat (LHsType p) | VisPat (LPat p) With this patch: data Pat p = ... | InvisPat (LHsType p) ... And the same transformation in the TH land. The rest of the changes is just updating code to handle new AST and writing tests to check if it is possible to create invalid states using TH. Metric Increase: MultiLayerModulesTH_OneShot - - - - - 28009fbc by Matthew Pickering at 2024-04-04T14:48:46-04:00 Fix off by one error in seekBinNoExpand and seekBin - - - - - 9b9e031b by Ben Gamari at 2024-04-04T21:30:08-04:00 compiler: Allow more types in GHCForeignImportPrim For many, many years `GHCForeignImportPrim` has suffered from the rather restrictive limitation of not allowing any non-trivial types in arguments or results. This limitation was justified by the code generator allegely barfing in the presence of such types. However, this restriction appears to originate well before the NCG rewrite and the new NCG does not appear to have any trouble with such types (see the added `T24598` test). Lift this restriction. Fixes #24598. - - - - - 1324b862 by Alan Zimmerman at 2024-04-04T21:30:44-04:00 EPA: Use EpaLocation not SrcSpan in ForeignDecls This allows us to update them for makeDeltaAst in ghc-exactprint - - - - - 19883a23 by Alan Zimmerman at 2024-04-05T16:58:17-04:00 EPA: Use EpaLocation for RecFieldsDotDot So we can update it to a delta position in makeDeltaAst if needed. - - - - - e8724327 by Matthew Pickering at 2024-04-05T16:58:53-04:00 Remove accidentally committed test.hs - - - - - 88cb3e10 by Fendor at 2024-04-08T09:03:34-04:00 Avoid UArray when indexing is not required `UnlinkedBCO`'s can occur many times in the heap. Each `UnlinkedBCO` references two `UArray`'s but never indexes them. They are only needed to encode the elements into a `ByteArray#`. The three words for the lower bound, upper bound and number of elements are essentially unused, thus we replace `UArray` with a wrapper around `ByteArray#`. This saves us up to three words for each `UnlinkedBCO`. Further, to avoid re-allocating these words for `ResolvedBCO`, we repeat the procedure for `ResolvedBCO` and add custom `Binary` and `Show` instances. For example, agda's repl session has around 360_000 UnlinkedBCO's, so avoiding these three words is already saving us around 8MB residency. - - - - - f2cc1107 by Fendor at 2024-04-08T09:04:11-04:00 Never UNPACK `FastMutInt` for counting z-encoded `FastString`s In `FastStringTable`, we count the number of z-encoded FastStrings that exist in a GHC session. We used to UNPACK the counters to not waste memory, but live retainer analysis showed that we allocate a lot of `FastMutInt`s, retained by `mkFastZString`. We lazily compute the `FastZString`, only incrementing the counter when the `FastZString` is forced. The function `mkFastStringWith` calls `mkZFastString` and boxes the `FastMutInt`, leading to the following core: mkFastStringWith = \ mk_fs _ -> = case stringTable of { FastStringTable _ n_zencs segments# _ -> ... case ((mk_fs (I# ...) (FastMutInt n_zencs)) `cast` <Co:2> :: ...) ... Marking this field as `NOUNPACK` avoids this reboxing, eliminating the allocation of a fresh `FastMutInt` on every `FastString` allocation. - - - - - c6def949 by Matthew Pickering at 2024-04-08T16:06:51-04:00 Force in_multi to avoid retaining entire hsc_env - - - - - fbb91a63 by Fendor at 2024-04-08T16:06:51-04:00 Eliminate name thunk in declaration fingerprinting Thunk analysis showed that we have about 100_000 thunks (in agda and `-fwrite-simplified-core`) pointing to the name of the name decl. Forcing this thunk fixes this issue. The thunk created here is retained by the thunk created by forkM, it is better to eagerly force this because the result (a `Name`) is already retained indirectly via the `IfaceDecl`. - - - - - 3b7b0c1c by Alan Zimmerman at 2024-04-08T16:07:27-04:00 EPA: Use EpaLocation in WarningTxt This allows us to use an EpDelta if needed when using makeDeltaAst. - - - - - 12b997df by Alan Zimmerman at 2024-04-08T16:07:27-04:00 EPA: Move DeltaPos and EpaLocation' into GHC.Types.SrcLoc This allows us to use a NoCommentsLocation for the possibly trailing comma location in a StringLiteral. This in turn allows us to correctly roundtrip via makeDeltaAst. - - - - - 868c8a78 by Fendor at 2024-04-09T08:51:50-04:00 Prefer packed representation for CompiledByteCode As there are many 'CompiledByteCode' objects alive during a GHCi session, representing its element in a more packed manner improves space behaviour at a minimal cost. When running GHCi on the agda codebase, we find around 380 live 'CompiledByteCode' objects. Packing their respective 'UnlinkedByteCode' can save quite some pointers. - - - - - be3bddde by Alan Zimmerman at 2024-04-09T08:52:26-04:00 EPA: Capture all comments in a ClassDecl Hopefully the final fix needed for #24533 - - - - - 3d0806fc by Jade at 2024-04-10T05:39:53-04:00 Validate -main-is flag using parseIdentifier Fixes #24368 - - - - - dd530bb7 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: free error message before returning Fixes a memory leak in rts/linker/PEi386.c - - - - - e008a19a by Alexis King at 2024-04-10T05:40:29-04:00 linker: Avoid linear search when looking up Haskell symbols via dlsym See the primary Note [Looking up symbols in the relevant objects] for a more in-depth explanation. When dynamically loading a Haskell symbol (typical when running a splice or GHCi expression), before this commit we would search for the symbol in all dynamic libraries that were loaded. However, this could be very inefficient when too many packages are loaded (which can happen if there are many package dependencies) because the time to lookup the would be linear in the number of packages loaded. This commit drastically improves symbol loading performance by introducing a mapping from units to the handles of corresponding loaded dlls. These handles are returned by dlopen when we load a dll, and can then be used to look up in a specific dynamic library. Looking up a given Name is now much more precise because we can get lookup its unit in the mapping and lookup the symbol solely in the handles of the dynamic libraries loaded for that unit. In one measurement, the wait time before the expression was executed went from +-38 seconds down to +-2s. This commit also includes Note [Symbols may not be found in pkgs_loaded], explaining the fallback to the old behaviour in case no dll can be found in the unit mapping for a given Name. Fixes #23415 Co-authored-by: Rodrigo Mesquita (@alt-romes) - - - - - dcfaa190 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: Make addDLL a wrapper around loadNativeObj Rewrite the implementation of `addDLL` as a wrapper around the more principled `loadNativeObj` rts linker function. The latter should be preferred while the former is preserved for backwards compatibility. `loadNativeObj` was previously only available on ELF platforms, so this commit further refactors the rts linker to transform loadNativeObj_ELF into loadNativeObj_POSIX, which is available in ELF and MachO platforms. The refactor made it possible to remove the `dl_mutex` mutex in favour of always using `linker_mutex` (rather than a combination of both). Lastly, we implement `loadNativeObj` for Windows too. - - - - - 12931698 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 Use symbol cache in internal interpreter too This commit makes the symbol cache that was used by the external interpreter available for the internal interpreter too. This follows from the analysis in #23415 that suggests the internal interpreter could benefit from this cache too, and that there is no good reason not to have the cache for it too. It also makes it a bit more uniform to have the symbol cache range over both the internal and external interpreter. This commit also refactors the cache into a function which is used by both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the caching logic to `lookupSymbolInDLL` too. - - - - - dccd3ea1 by Ben Gamari at 2024-04-10T05:40:29-04:00 testsuite: Add test for lookupSymbolInNativeObj - - - - - 1b1a92bd by Alan Zimmerman at 2024-04-10T05:41:05-04:00 EPA: Remove unnecessary XRec in CompleteMatchSig The XRec for [LIdP pass] is not needed for exact printing, remove it. - - - - - 6e18ce2b by Ben Gamari at 2024-04-12T08:16:09-04:00 users-guide: Clarify language extension documentation Over the years the users guide's language extension documentation has gone through quite a few refactorings. In the process some of the descriptions have been rendered non-sensical. For instance, the description of `NoImplicitPrelude` actually describes the semantics of `ImplicitPrelude`. To fix this we: * ensure that all extensions are named in their "positive" sense (e.g. `ImplicitPrelude` rather than `NoImplicitPrelude`). * rework the documentation to avoid flag-oriented wording like "enable" and "disable" * ensure that the polarity of the documentation is consistent with reality. Fixes #23895. - - - - - a933aff3 by Zubin Duggal at 2024-04-12T08:16:45-04:00 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - 23c3e624 by Andreas Klebinger at 2024-04-12T08:17:21-04:00 RTS: Emit warning when -M < -H Fixes #24487 - - - - - d23afb8c by Ben Gamari at 2024-04-12T08:17:56-04:00 testsuite: Add broken test for CApiFFI with -fprefer-bytecode See #24634. - - - - - a4bb3a51 by Ben Gamari at 2024-04-12T08:18:32-04:00 base: Deprecate GHC.Pack As proposed in #21461. Closes #21540. - - - - - 55eb8c98 by Ben Gamari at 2024-04-12T08:19:08-04:00 ghc-internal: Fix mentions of ghc-internal in deprecation warnings Closes #24609. - - - - - b0fbd181 by Ben Gamari at 2024-04-12T08:19:44-04:00 rts: Implement set_initial_registers for AArch64 Fixes #23680. - - - - - 14c9ec62 by Ben Gamari at 2024-04-12T08:20:20-04:00 ghcup-metadata: Use Debian 9 binaries on Ubuntu 16, 17 Closes #24646. - - - - - 35a1621e by Ben Gamari at 2024-04-12T08:20:55-04:00 Bump unix submodule to 2.8.5.1 Closes #24640. - - - - - a1c24df0 by Finley McIlwaine at 2024-04-12T08:21:31-04:00 Correct default -funfolding-use-threshold in docs - - - - - 0255d03c by Oleg Grenrus at 2024-04-12T08:22:07-04:00 FastString is a __Modified__ UTF-8 - - - - - c3489547 by Matthew Pickering at 2024-04-12T13:13:44-04:00 rts: Improve tracing message when nursery is resized It is sometimes more useful to know how much bigger or smaller the nursery got when it is resized. In particular I am trying to investigate situations where we end up with fragmentation due to the nursery (#24577) - - - - - 5e4f4ba8 by Simon Peyton Jones at 2024-04-12T13:14:20-04:00 Don't generate wrappers for `type data` constructors with StrictData Previously, the logic for checking if a data constructor needs a wrapper or not would take into account whether the constructor's fields have explicit strictness (e.g., `data T = MkT !Int`), but the logic would _not_ take into account whether `StrictData` was enabled. This meant that something like `type data T = MkT Int` would incorrectly generate a wrapper for `MkT` if `StrictData` was enabled, leading to the horrible errors seen in #24620. To fix this, we disable generating wrappers for `type data` constructors altogether. Fixes #24620. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - dbdf1995 by Alex Mason at 2024-04-15T15:28:26+10:00 Implements MO_S_Mul2 and MO_U_Mul2 using the UMULH, UMULL and SMULH instructions for AArch64 Also adds a test for MO_S_Mul2 - - - - - 42bd0407 by Teo Camarasu at 2024-04-16T20:06:39-04:00 Make template-haskell a stage1 package Promoting template-haskell from a stage0 to a stage1 package means that we can much more easily refactor template-haskell. We implement this by duplicating the in-tree `template-haskell`. A new `template-haskell-next` library is autogenerated to mirror `template-haskell` `stage1:ghc` to depend on the new interface of the library including the `Binary` instances without adding an explicit dependency on `template-haskell`. This is controlled by the `bootstrap-th` cabal flag When building `template-haskell` modules as part of this vendoring we do not have access to quote syntax, so we cannot use variable quote notation (`'Just`). So we either replace these with hand-written `Name`s or hide the code behind CPP. We can remove the `th_hack` from hadrian, which was required when building stage0 packages using the in-tree `template-haskell` library. For more details see Note [Bootstrapping Template Haskell]. Resolves #23536 Co-Authored-By: Sebastian Graf <sgraf1337 at gmail.com> Co-Authored-By: Matthew Craven <5086-clyring at users.noreply.gitlab.haskell.org> - - - - - 3d973e47 by Ben Gamari at 2024-04-16T20:07:15-04:00 Bump parsec submodule to 3.1.17.0 - - - - - 9d38bfa0 by Simon Peyton Jones at 2024-04-16T20:07:51-04:00 Clone CoVars in CorePrep This MR addresses #24463. It's all explained in the new Note [Cloning CoVars and TyVars] - - - - - 0fe2b410 by Andreas Klebinger at 2024-04-16T20:08:27-04:00 NCG: Fix a bug where we errounously removed a required jump instruction. Add a new method to the Instruction class to check if we can eliminate a jump in favour of fallthrough control flow. Fixes #24507 - - - - - 9f99126a by Teo Camarasu at 2024-04-16T20:09:04-04:00 Fix documentation preview from doc-tarball job - Include all the .html files and assets in the job artefacts - Include all the .pdf files in the job artefacts - Mark the artefact as an "exposed" artefact meaning it turns up in the UI. Resolves #24651 - - - - - 3a0642ea by Ben Gamari at 2024-04-16T20:09:39-04:00 rts: Ignore EINTR while polling in timerfd itimer implementation While the RTS does attempt to mask signals, it may be that a foreign library unmasks them. This previously caused benign warnings which we now ignore. See #24610. - - - - - 9a53cd3f by Alan Zimmerman at 2024-04-16T20:10:15-04:00 EPA: Add additional comments field to AnnsModule This is used in exact printing to store comments coming after the `where` keyword but before any comments allocated to imports or decls. It is used in ghc-exactprint, see https://github.com/alanz/ghc-exactprint/commit/44bbed311fd8f0d053053fef195bf47c17d34fa7 - - - - - e5c43259 by Bryan Richter at 2024-04-16T20:10:51-04:00 Remove unrunnable FreeBSD CI jobs FreeBSD runner supply is inelastic. Currently there is only one, and it's unavailable because of a hardware issue. - - - - - 914eb49a by Ben Gamari at 2024-04-16T20:11:27-04:00 rel-eng: Fix mktemp usage in recompress-all We need a temporary directory, not a file. - - - - - f30e4984 by Teo Camarasu at 2024-04-16T20:12:03-04:00 Fix ghc API link in docs/index.html This was missing part of the unit ID meaning it would 404. Resolves #24674 - - - - - d7a3d6b5 by Ben Gamari at 2024-04-16T20:12:39-04:00 template-haskell: Declare TH.Lib.Internal as not-home Rather than `hide`. Closes #24659. - - - - - 5eaa46e7 by Matthew Pickering at 2024-04-19T02:14:55-04:00 testsuite: Rename isCross() predicate to needsTargetWrapper() isCross() was a misnamed because it assumed that all cross targets would provide a target wrapper, but the two most common cross targets (javascript, wasm) don't need a target wrapper. Therefore we rename this predicate to `needsTargetWrapper()` so situations in the testsuite where we can check whether running executables requires a target wrapper or not. - - - - - 55a9d699 by Simon Peyton Jones at 2024-04-19T02:15:32-04:00 Do not float HNFs out of lambdas This MR adjusts SetLevels so that it is less eager to float a HNF (lambda or constructor application) out of a lambda, unless it gets to top level. Data suggests that this change is a small net win: * nofib bytes-allocated falls by -0.09% (but a couple go up) * perf/should_compile bytes-allocated falls by -0.5% * perf/should_run bytes-allocated falls by -0.1% See !12410 for more detail. When fiddling elsewhere, I also found that this patch had a huge positive effect on the (very delicate) test perf/should_run/T21839r But that improvement doesn't show up in this MR by itself. Metric Decrease: MultiLayerModulesRecomp T15703 parsing001 - - - - - f0701585 by Alan Zimmerman at 2024-04-19T02:16:08-04:00 EPA: Fix comments in mkListSyntaxTy0 Also extend the test to confirm. Addresses #24669, 1 of 4 - - - - - b01c01d4 by Serge S. Gulin at 2024-04-19T02:16:51-04:00 JS: set image `x86_64-linux-deb11-emsdk-closure` for build - - - - - c90c6039 by Alan Zimmerman at 2024-04-19T02:17:27-04:00 EPA: Provide correct span for PatBind And remove unused parameter in checkPatBind Contributes to #24669 - - - - - 26036f96 by Alan Zimmerman at 2024-04-19T13:11:08-04:00 EPA: Fix span for PatBuilderAppType Include the location of the prefix @ in the span for InVisPat. Also removes unnecessary annotations from HsTP. Contributes to #24669 - - - - - dba03aab by Matthew Craven at 2024-04-19T13:11:44-04:00 testsuite: Give the pre_cmd for mhu-perf more time - - - - - d31fbf6c by Krzysztof Gogolewski at 2024-04-19T21:04:09-04:00 Fix quantification order for a `op` b and a %m -> b Fixes #23764 Implements https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0640-tyop-quantification-order.rst Updates haddock submodule. - - - - - 385cd1c4 by Sebastian Graf at 2024-04-19T21:04:45-04:00 Make `seq#` a magic Id and inline it in CorePrep (#24124) We can save much code and explanation in Tag Inference and StgToCmm by making `seq#` a known-key Magic Id in `GHC.Internal.IO` and inline this definition in CorePrep. See the updated `Note [seq# magic]`. I also implemented a new `Note [Flatten case-bind]` to get better code for otherwise nested case scrutinees. I renamed the contructors of `ArgInfo` to use an `AI` prefix in order to resolve the clash between `type CpeApp = CoreExpr` and the data constructor of `ArgInfo`, as well as fixed typos in `Note [CorePrep invariants]`. Fixes #24252 and #24124. - - - - - 275e41a9 by Jade at 2024-04-20T11:10:40-04:00 Put the newline after errors instead of before them This mainly has consequences for GHCi but also slightly alters how the output of GHC on the commandline looks. Fixes: #22499 - - - - - dd339c7a by Teo Camarasu at 2024-04-20T11:11:16-04:00 Remove unecessary stage0 packages Historically quite a few packages had to be stage0 as they depended on `template-haskell` and that was stage0. In #23536 we made it so that was no longer the case. This allows us to remove a bunch of packages from this list. A few still remain. A new version of `Win32` is required by `semaphore-compat`. Including `Win32` in the stage0 set requires also including `filepath` because otherwise Hadrian's dependency logic gets confused. Once our boot compiler has a newer version of `Win32` all of these will be able to be dropped. Resolves #24652 - - - - - 2f8e3a25 by Alan Zimmerman at 2024-04-20T11:11:52-04:00 EPA: Avoid duplicated comments in splice decls Contributes to #24669 - - - - - c70b9ddb by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fix typos and namings (fixes #24602) You may noted that I've also changed term of ``` , global "h$vt_double" ||= toJExpr IntV ``` See "IntV" and ``` WaitReadOp -> \[] [fd] -> pure $ PRPrimCall $ returnS (app "h$waidRead" [fd]) ``` See "h$waidRead" - - - - - 3db54f9b by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: trivial checks for variable presence (fixes #24602) - - - - - 777f108f by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fs module imported twice (by emscripten and by ghc-internal). ghc-internal import wrapped in a closure to prevent conflict with emscripten (fixes #24602) Better solution is to use some JavaScript module system like AMD, CommonJS or even UMD. It will be investigated at other issues. At first glance we should try UMD (See https://github.com/umdjs/umd) - - - - - a45a5712 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: thread.js requires h$fds and h$fdReady to be declared for static code analysis, minimal code copied from GHCJS (fixes #24602) I've just copied some old pieces of GHCJS from publicly available sources (See https://github.com/Taneb/shims/blob/a6dd0202dcdb86ad63201495b8b5d9763483eb35/src/io.js#L607). Also I didn't put details to h$fds. I took minimal and left only its object initialization: `var h$fds = {};` - - - - - ad90bf12 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: heap and stack overflows reporting defined as js hard failure (fixes #24602) These errors were treated as a hard failure for browser application. The fix is trivial: just throw error. - - - - - 5962fa52 by Serge S. Gulin at 2024-04-21T16:33:44+03:00 JS: Stubs for code without actual implementation detected by Google Closure Compiler (fixes #24602) These errors were fixed just by introducing stubbed functions with throw for further implementation. - - - - - a0694298 by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add externs to linker (fixes #24602) After enabling jsdoc and built-in google closure compiler types I was needed to deal with the following: 1. Define NodeJS-environment types. I've just copied minimal set of externs from semi-official repo (see https://github.com/externs/nodejs/blob/6c6882c73efcdceecf42e7ba11f1e3e5c9c041f0/v8/nodejs.js#L8). 2. Define Emscripten-environment types: `HEAP8`. Emscripten already provides some externs in our code but it supposed to be run in some module system. And its definitions do not work well in plain bundle. 3. We have some functions which purpose is to add to functions some contextual information via function properties. These functions should be marked as `modifies` to let google closure compiler remove calls if these functions are not used actually by call graph. Such functions are: `h$o`, `h$sti`, `h$init_closure`, `h$setObjInfo`. 4. STG primitives such as registries and stuff from `GHC.StgToJS`. `dXX` properties were already present at externs generator function but they are started from `7`, not from `1`. This message is related: `// fixme does closure compiler bite us here?` - - - - - e58bb29f by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: added both tests: for size and for correctness (fixes #24602) By some reason MacOS builds add to stderr messages like: Ignoring unexpected archive entry: __.SYMDEF ... However I left stderr to `/dev/null` for compatibility with linux CI builds. - - - - - 909f3a9c by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Disable js linker warning for empty symbol table to make js tests running consistent across environments - - - - - 83eb10da by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add special preprocessor for js files due of needing to keep jsdoc comments (fixes #24602) Our js files have defined google closure compiler types at jsdoc entries but these jsdoc entries are removed by cpp preprocessor. I considered that reusing them in javascript-backend would be a nice thing. Right now haskell processor uses `-traditional` option to deal with comments and `//` operators. But now there are following compiler options: `-C` and `-CC`. You can read about them at GCC (see https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#index-CC) and CLang (see https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-CC). It seems that `-CC` works better for javascript jsdoc than `-traditional`. At least it leaves `/* ... */` comments w/o changes. - - - - - e1cf8dc2 by brandon s allbery kf8nh at 2024-04-22T03:48:26-04:00 fix link in CODEOWNERS It seems that our local Gitlab no longer has documentation for the `CODEOWNERS` file, but the master documentation still does. Use that instead. - - - - - 593f4e04 by Fendor at 2024-04-23T10:19:14-04:00 Add performance regression test for '-fwrite-simplified-core' - - - - - 1ba39b05 by Fendor at 2024-04-23T10:19:14-04:00 Typecheck corebindings lazily during bytecode generation This delays typechecking the corebindings until the bytecode generation happens. We also avoid allocating a thunk that is retained by `unsafeInterleaveIO`. In general, we shouldn't retain values of the hydrated `Type`, as not evaluating the bytecode object keeps it alive. It is better if we retain the unhydrated `IfaceType`. See Note [Hydrating Modules] - - - - - e916fc92 by Alan Zimmerman at 2024-04-23T10:19:50-04:00 EPA: Keep comments in a CaseAlt match The comments now live in the surrounding location, not inside the Match. Make sure we keep them. Closes #24707 - - - - - d2b17f32 by Cheng Shao at 2024-04-23T15:01:22-04:00 driver: force merge objects when building dynamic objects This patch forces the driver to always merge objects when building dynamic objects even when ar -L is supported. It is an oversight of !8887: original rationale of that patch is favoring the relatively cheap ar -L operation over object merging when ar -L is supported, which makes sense but only if we are building static objects! Omitting check for whether we are building dynamic objects will result in broken .so files with undefined reference errors at executable link time when building GHC with llvm-ar. Fixes #22210. - - - - - 209d09f5 by Julian Ospald at 2024-04-23T15:02:03-04:00 Allow non-absolute values for bootstrap GHC variable Fixes #24682 - - - - - 3fff0977 by Matthew Pickering at 2024-04-23T15:02:38-04:00 Don't depend on registerPackage function in Cabal More recent versions of Cabal modify the behaviour of libAbiHash which breaks our usage of registerPackage. It is simpler to inline the part of registerPackage that we need and avoid any additional dependency and complication using the higher-level function introduces. - - - - - c62dc317 by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: remove obsolete ln script This commit removes an obsolete ln script in ghc-bignum/gmp. See 060251c24ad160264ae8553efecbb8bed2f06360 for its original intention, but it's been obsolete for a long time, especially since the removal of the make build system. Hence the house cleaning. - - - - - 6399d52b by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: update gmp to 6.3.0 This patch bumps the gmp-tarballs submodule and updates gmp to 6.3.0. The tarball format is now xz, and gmpsrc.patch has been patched into the tarball so hadrian no longer needs to deal with patching logic when building in-tree GMP. - - - - - 65b4b92f by Cheng Shao at 2024-04-25T01:32:02-04:00 hadrian: remove obsolete Patch logic This commit removes obsolete Patch logic from hadrian, given we no longer need to patch the gmp tarball when building in-tree GMP. - - - - - 71f28958 by Cheng Shao at 2024-04-25T01:32:02-04:00 autoconf: remove obsolete patch detection This commit removes obsolete deletection logic of the patch command from autoconf scripts, given we no longer need to patch anything in the GHC build process. - - - - - daeda834 by Sylvain Henry at 2024-04-25T01:32:43-04:00 JS: correctly handle RUBBISH literals (#24664) - - - - - 8a06ddf6 by Matthew Pickering at 2024-04-25T11:16:16-04:00 Linearise ghc-internal and base build This is achieved by requesting the final package database for ghc-internal, which mandates it is fully built as a dependency of configuring the `base` package. This is at the expense of cross-package parrallelism between ghc-internal and the base package. Fixes #24436 - - - - - 94da9365 by Andrei Borzenkov at 2024-04-25T11:16:54-04:00 Fix tuple puns renaming (24702) Move tuple renaming short cutter from `isBuiltInOcc_maybe` to `isPunOcc_maybe`, so we consider incoming module. I also fixed some hidden bugs that raised after the change was done. - - - - - fa03b1fb by Fendor at 2024-04-26T18:03:13-04:00 Refactor the Binary serialisation interface The goal is simplifiy adding deduplication tables to `ModIface` interface serialisation. We identify two main points of interest that make this difficult: 1. UserData hardcodes what `Binary` instances can have deduplication tables. Moreover, it heavily uses partial functions. 2. GHC.Iface.Binary hardcodes the deduplication tables for 'Name' and 'FastString', making it difficult to add more deduplication. Instead of having a single `UserData` record with fields for all the types that can have deduplication tables, we allow to provide custom serialisers for any `Typeable`. These are wrapped in existentials and stored in a `Map` indexed by their respective `TypeRep`. The `Binary` instance of the type to deduplicate still needs to explicitly look up the decoder via `findUserDataReader` and `findUserDataWriter`, which is no worse than the status-quo. `Map` was chosen as microbenchmarks indicate it is the fastest for a small number of keys (< 10). To generalise the deduplication table serialisation mechanism, we introduce the types `ReaderTable` and `WriterTable` which provide a simple interface that is sufficient to implement a general purpose deduplication mechanism for `writeBinIface` and `readBinIface`. This allows us to provide a list of deduplication tables for serialisation that can be extended more easily, for example for `IfaceTyCon`, see the issue https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for more motivation. In addition to this refactoring, we split `UserData` into `ReaderUserData` and `WriterUserData`, to avoid partial functions and reduce overall memory usage, as we need fewer mutable variables. Bump haddock submodule to accomodate for `UserData` split. ------------------------- Metric Increase: MultiLayerModulesTH_Make MultiLayerModulesRecomp T21839c ------------------------- - - - - - bac57298 by Fendor at 2024-04-26T18:03:13-04:00 Split `BinHandle` into `ReadBinHandle` and `WriteBinHandle` A `BinHandle` contains too much information for reading data. For example, it needs to keep a `FastMutInt` and a `IORef BinData`, when the non-mutable variants would suffice. Additionally, this change has the benefit that anyone can immediately tell whether the `BinHandle` is used for reading or writing. Bump haddock submodule BinHandle split. - - - - - 4d6394dd by Simon Peyton Jones at 2024-04-26T18:03:49-04:00 Fix missing escaping-kind check in tcPatSynSig Note [Escaping kind in type signatures] explains how we deal with escaping kinds in type signatures, e.g. f :: forall r (a :: TYPE r). a where the kind of the body is (TYPE r), but `r` is not in scope outside the forall-type. I had missed this subtlety in tcPatSynSig, leading to #24686. This MR fixes it; and a similar bug in tc_top_lhs_type. (The latter is tested by T24686a.) - - - - - 981c2c2c by Alan Zimmerman at 2024-04-26T18:04:25-04:00 EPA: check-exact: check that the roundtrip reproduces the source Closes #24670 - - - - - a8616747 by Andrew Lelechenko at 2024-04-26T18:05:01-04:00 Document that setEnv is not thread-safe - - - - - 1e41de83 by Bryan Richter at 2024-04-26T18:05:37-04:00 CI: Work around frequent Signal 9 errors - - - - - a6d5f9da by Naïm Favier at 2024-04-27T17:52:40-04:00 ghc-internal: add MonadFix instance for (,) Closes https://gitlab.haskell.org/ghc/ghc/-/issues/24288, implements CLC proposal https://github.com/haskell/core-libraries-committee/issues/238. Adds a MonadFix instance for tuples, permitting value recursion in the "native" writer monad and bringing consistency with the existing instance for transformers's WriterT (and, to a lesser extent, for Solo). - - - - - 64feadcd by Rodrigo Mesquita at 2024-04-27T17:53:16-04:00 bindist: Fix xattr cleaning The original fix (725343aa) was incorrect because it used the shell bracket syntax which is the quoting syntax in autoconf, making the test for existence be incorrect and therefore `xattr` was never run. Fixes #24554 - - - - - e2094df3 by damhiya at 2024-04-28T23:52:00+09:00 Make read accepts binary integer formats CLC proposal : https://github.com/haskell/core-libraries-committee/issues/177 - - - - - 1c2fd963 by Alan Zimmerman at 2024-04-29T23:17:00-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 - - - - - 4189d17e by Sylvain Henry at 2024-04-29T23:17:42-04:00 LLVM: better unreachable default destination in Switch (#24717) See added note. Co-authored-by: Siddharth Bhat <siddu.druid at gmail.com> - - - - - a3725c88 by Cheng Shao at 2024-04-29T23:18:20-04:00 ci: enable wasm jobs for MRs with wasm label This patch enables wasm jobs for MRs with wasm label. Previously the wasm label didn't actually have any effect on the CI pipeline, and full-ci needed to be applied to run wasm jobs which was a waste of runners when working on the wasm backend, hence the fix here. - - - - - 702f7964 by Matthew Pickering at 2024-04-29T23:18:56-04:00 Make interface files and object files depend on inplace .conf file A potential fix for #24737 - - - - - 728af21e by Cheng Shao at 2024-04-30T05:30:23-04:00 utils: remove obsolete vagrant scripts Vagrantfile has long been removed in !5288. This commit further removes the obsolete vagrant scripts in the tree. - - - - - 36f2c342 by Cheng Shao at 2024-04-30T05:31:00-04:00 Update autoconf scripts Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 - - - - - ecbf22a6 by Ben Gamari at 2024-04-30T05:31:36-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 7eab4e01 by Alan Zimmerman at 2024-05-04T16:14:55+01:00 EPA: Widen stmtslist to include last semicolon Closes #24754 - - - - - 06f7db40 by Teo Camarasu at 2024-05-05T00:19:38-04:00 doc: Fix type error in hs_try_putmvar example - - - - - af000532 by Moritz Schuler at 2024-05-05T06:30:58-04:00 Fix parsing of module names in CLI arguments closes issue #24732 - - - - - da74e9c9 by Ben Gamari at 2024-05-05T06:31:34-04:00 ghc-platform: Add Setup.hs The Hadrian bootstrapping script relies upon `Setup.hs` to drive its build. Addresses #24761. - - - - - 35d34fde by Alan Zimmerman at 2024-05-05T12:52:40-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 - - - - - 03c5dfbf by Simon Peyton Jones at 2024-05-05T12:53:15-04:00 Fix a float-out error Ticket #24768 showed that the Simplifier was accidentally destroying a join point. It turned out to be that we were sending a bottoming join point to the top, accidentally abstracting over /other/ join points. Easily fixed. - - - - - adba68e7 by John Ericson at 2024-05-05T19:35:56-04:00 Substitute bindist files with Hadrian not configure The `ghc-toolchain` overhaul will eventually replace all this stuff with something much more cleaned up, but I think it is still worth making this sort of cleanup in the meantime so other untanglings and dead code cleaning can procede. I was able to delete a fair amount of dead code doing this too. `LLVMTarget_CPP` is renamed to / merged with `LLVMTarget` because it wasn't actually turned into a valid CPP identifier. (Original to 1345c7cc42c45e63ab1726a8fd24a7e4d4222467, actually.) Progress on #23966 Co-Authored-By: Sylvain Henry <hsyl20 at gmail.com> - - - - - 18f4ff84 by Alan Zimmerman at 2024-05-05T19:36:32-04:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 - - - - - a19201d4 by Matthew Craven at 2024-05-06T19:54:29-04:00 Add test cases for #24664 ...since none are present in the original MR !12463 fixing this issue. - - - - - 46328a49 by Alan Zimmerman at 2024-05-06T19:55:05-04:00 EPA: preserve comments in data decls Closes #24771 - - - - - 3b51995c by Andrei Borzenkov at 2024-05-07T14:39:40-04:00 Rename Solo# data constructor to MkSolo# (#24673) - data Solo# a = (# a #) + data Solo# a = MkSolo# a And `(# foo #)` syntax now becomes just a syntactic sugar for `MkSolo# a`. - - - - - 4d59abf2 by Arsen Arsenović at 2024-05-07T14:40:24-04:00 Add the cmm_cpp_is_gcc predicate to the testsuite A future C-- test called T24474-cmm-override-g0 relies on the GCC-specific behaviour of -g3 implying -dD, which, in turn, leads to it emitting #defines past the preprocessing stage. Clang, at least, does not do this, so the test would fail if ran on Clang. As the behaviour here being tested is ``-optCmmP-g3'' undoing effects of the workaround we apply as a fix for bug #24474, and the workaround was for GCC-specific behaviour, the test needs to be marked as fragile on other compilers. - - - - - 25b0b404 by Arsen Arsenović at 2024-05-07T14:40:24-04:00 Split out the C-- preprocessor, and make it pass -g0 Previously, C-- was processed with the C preprocessor program. This means that it inherited flags passed via -optc. A flag that is somewhat often passed through -optc is -g. At certain -g levels (>=2), GCC starts emitting defines *after* preprocessing, for the purposes of debug info generation. This is not useful for the C-- compiler, and, in fact, causes lexer errors. We can suppress this effect (safely, if supported) via -g0. As a workaround, in older versions of GCC (<=10), GCC only emitted defines if a certain set of -g*3 flags was passed. Newer versions check the debug level. For the former, we filter out those -g*3 flags and, for the latter, we specify -g0 on top of that. As a compatible and effective solution, this change adds a C-- preprocessor distinct from the C compiler and preprocessor, but that keeps its flags. The command line produced for C-- preprocessing now looks like: $pgmCmmP $optCs_without_g3 $g0_if_supported $optCmmP Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/24474 - - - - - d2899451 by Simon Peyton Jones at 2024-05-07T20:40:35+01:00 Try improving FloatIn ..to address #24466 - - - - - 47df3eb1 by Simon Peyton Jones at 2024-05-07T20:40:35+01:00 Restore preinlineUnconditinoally See ghc log for 1 March and wheel-sieve1 - - - - - 2da3212a by Simon Peyton Jones at 2024-05-07T20:40:35+01:00 Wibbles to pipeline Accidentlly added an unnecessary pass - - - - - 0e82ee96 by Simon Peyton Jones at 2024-05-07T20:40:35+01:00 Don't push non-thunks into all branches - - - - - 21 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - CODEOWNERS - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/PrimOps.hs-boot The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fe53f1321c6d200c49dae5bc2d20bf2cc1c73841...0e82ee9631a320f892125ebba84ae31afb47a5cf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fe53f1321c6d200c49dae5bc2d20bf2cc1c73841...0e82ee9631a320f892125ebba84ae31afb47a5cf You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 20:34:22 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Tue, 07 May 2024 16:34:22 -0400 Subject: [Git][ghc/ghc][wip/document-system-io] 51 commits: Make read accepts binary integer formats Message-ID: <663a904e313e9_393e941839b945469f@gitlab.mail> Jade pushed to branch wip/document-system-io at Glasgow Haskell Compiler / GHC Commits: e2094df3 by damhiya at 2024-04-28T23:52:00+09:00 Make read accepts binary integer formats CLC proposal : https://github.com/haskell/core-libraries-committee/issues/177 - - - - - 1c2fd963 by Alan Zimmerman at 2024-04-29T23:17:00-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 - - - - - 4189d17e by Sylvain Henry at 2024-04-29T23:17:42-04:00 LLVM: better unreachable default destination in Switch (#24717) See added note. Co-authored-by: Siddharth Bhat <siddu.druid at gmail.com> - - - - - a3725c88 by Cheng Shao at 2024-04-29T23:18:20-04:00 ci: enable wasm jobs for MRs with wasm label This patch enables wasm jobs for MRs with wasm label. Previously the wasm label didn't actually have any effect on the CI pipeline, and full-ci needed to be applied to run wasm jobs which was a waste of runners when working on the wasm backend, hence the fix here. - - - - - 702f7964 by Matthew Pickering at 2024-04-29T23:18:56-04:00 Make interface files and object files depend on inplace .conf file A potential fix for #24737 - - - - - 728af21e by Cheng Shao at 2024-04-30T05:30:23-04:00 utils: remove obsolete vagrant scripts Vagrantfile has long been removed in !5288. This commit further removes the obsolete vagrant scripts in the tree. - - - - - 36f2c342 by Cheng Shao at 2024-04-30T05:31:00-04:00 Update autoconf scripts Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 - - - - - ecbf22a6 by Ben Gamari at 2024-04-30T05:31:36-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 7eab4e01 by Alan Zimmerman at 2024-05-04T16:14:55+01:00 EPA: Widen stmtslist to include last semicolon Closes #24754 - - - - - 06f7db40 by Teo Camarasu at 2024-05-05T00:19:38-04:00 doc: Fix type error in hs_try_putmvar example - - - - - af000532 by Moritz Schuler at 2024-05-05T06:30:58-04:00 Fix parsing of module names in CLI arguments closes issue #24732 - - - - - da74e9c9 by Ben Gamari at 2024-05-05T06:31:34-04:00 ghc-platform: Add Setup.hs The Hadrian bootstrapping script relies upon `Setup.hs` to drive its build. Addresses #24761. - - - - - 35d34fde by Alan Zimmerman at 2024-05-05T12:52:40-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 - - - - - 03c5dfbf by Simon Peyton Jones at 2024-05-05T12:53:15-04:00 Fix a float-out error Ticket #24768 showed that the Simplifier was accidentally destroying a join point. It turned out to be that we were sending a bottoming join point to the top, accidentally abstracting over /other/ join points. Easily fixed. - - - - - adba68e7 by John Ericson at 2024-05-05T19:35:56-04:00 Substitute bindist files with Hadrian not configure The `ghc-toolchain` overhaul will eventually replace all this stuff with something much more cleaned up, but I think it is still worth making this sort of cleanup in the meantime so other untanglings and dead code cleaning can procede. I was able to delete a fair amount of dead code doing this too. `LLVMTarget_CPP` is renamed to / merged with `LLVMTarget` because it wasn't actually turned into a valid CPP identifier. (Original to 1345c7cc42c45e63ab1726a8fd24a7e4d4222467, actually.) Progress on #23966 Co-Authored-By: Sylvain Henry <hsyl20 at gmail.com> - - - - - 18f4ff84 by Alan Zimmerman at 2024-05-05T19:36:32-04:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 - - - - - a19201d4 by Matthew Craven at 2024-05-06T19:54:29-04:00 Add test cases for #24664 ...since none are present in the original MR !12463 fixing this issue. - - - - - 46328a49 by Alan Zimmerman at 2024-05-06T19:55:05-04:00 EPA: preserve comments in data decls Closes #24771 - - - - - c9d7f679 by Jade at 2024-05-07T22:07:35+02:00 Documentation: Improve documentation for symbols exported from System.IO - - - - - fed80fc2 by Jade at 2024-05-07T22:07:35+02:00 WIP - - - - - f5a98501 by Jade at 2024-05-07T22:07:35+02:00 bring pragmas closer to definition - - - - - d70a81f7 by Jade at 2024-05-07T22:38:32+02:00 add fixIO examples - - - - - 30 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - compiler/GHC.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/88faaea43152ba2a324d5f9e8a2798b9f736a78d...d70a81f720314c22c95fae46dc4180edaba8c7d5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/88faaea43152ba2a324d5f9e8a2798b9f736a78d...d70a81f720314c22c95fae46dc4180edaba8c7d5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 20:52:00 2024 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Tue, 07 May 2024 16:52:00 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/wasm-gmp-slim Message-ID: <663a947013982_393e941b27b8057716@gitlab.mail> Cheng Shao pushed new branch wip/wasm-gmp-slim at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/wasm-gmp-slim You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 21:23:42 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 07 May 2024 17:23:42 -0400 Subject: [Git][ghc/ghc][wip/T24676] 44 commits: testsuite: Handle exceptions in framework_fail when testdir is not initialised Message-ID: <663a9bde21aa_393e941f8db985959@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24676 at Glasgow Haskell Compiler / GHC Commits: c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 7eab4e01 by Alan Zimmerman at 2024-05-04T16:14:55+01:00 EPA: Widen stmtslist to include last semicolon Closes #24754 - - - - - 06f7db40 by Teo Camarasu at 2024-05-05T00:19:38-04:00 doc: Fix type error in hs_try_putmvar example - - - - - af000532 by Moritz Schuler at 2024-05-05T06:30:58-04:00 Fix parsing of module names in CLI arguments closes issue #24732 - - - - - da74e9c9 by Ben Gamari at 2024-05-05T06:31:34-04:00 ghc-platform: Add Setup.hs The Hadrian bootstrapping script relies upon `Setup.hs` to drive its build. Addresses #24761. - - - - - 35d34fde by Alan Zimmerman at 2024-05-05T12:52:40-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 - - - - - 03c5dfbf by Simon Peyton Jones at 2024-05-05T12:53:15-04:00 Fix a float-out error Ticket #24768 showed that the Simplifier was accidentally destroying a join point. It turned out to be that we were sending a bottoming join point to the top, accidentally abstracting over /other/ join points. Easily fixed. - - - - - adba68e7 by John Ericson at 2024-05-05T19:35:56-04:00 Substitute bindist files with Hadrian not configure The `ghc-toolchain` overhaul will eventually replace all this stuff with something much more cleaned up, but I think it is still worth making this sort of cleanup in the meantime so other untanglings and dead code cleaning can procede. I was able to delete a fair amount of dead code doing this too. `LLVMTarget_CPP` is renamed to / merged with `LLVMTarget` because it wasn't actually turned into a valid CPP identifier. (Original to 1345c7cc42c45e63ab1726a8fd24a7e4d4222467, actually.) Progress on #23966 Co-Authored-By: Sylvain Henry <hsyl20 at gmail.com> - - - - - 18f4ff84 by Alan Zimmerman at 2024-05-05T19:36:32-04:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 - - - - - a19201d4 by Matthew Craven at 2024-05-06T19:54:29-04:00 Add test cases for #24664 ...since none are present in the original MR !12463 fixing this issue. - - - - - 46328a49 by Alan Zimmerman at 2024-05-06T19:55:05-04:00 EPA: preserve comments in data decls Closes #24771 - - - - - 3b51995c by Andrei Borzenkov at 2024-05-07T14:39:40-04:00 Rename Solo# data constructor to MkSolo# (#24673) - data Solo# a = (# a #) + data Solo# a = MkSolo# a And `(# foo #)` syntax now becomes just a syntactic sugar for `MkSolo# a`. - - - - - 4d59abf2 by Arsen Arsenović at 2024-05-07T14:40:24-04:00 Add the cmm_cpp_is_gcc predicate to the testsuite A future C-- test called T24474-cmm-override-g0 relies on the GCC-specific behaviour of -g3 implying -dD, which, in turn, leads to it emitting #defines past the preprocessing stage. Clang, at least, does not do this, so the test would fail if ran on Clang. As the behaviour here being tested is ``-optCmmP-g3'' undoing effects of the workaround we apply as a fix for bug #24474, and the workaround was for GCC-specific behaviour, the test needs to be marked as fragile on other compilers. - - - - - 25b0b404 by Arsen Arsenović at 2024-05-07T14:40:24-04:00 Split out the C-- preprocessor, and make it pass -g0 Previously, C-- was processed with the C preprocessor program. This means that it inherited flags passed via -optc. A flag that is somewhat often passed through -optc is -g. At certain -g levels (>=2), GCC starts emitting defines *after* preprocessing, for the purposes of debug info generation. This is not useful for the C-- compiler, and, in fact, causes lexer errors. We can suppress this effect (safely, if supported) via -g0. As a workaround, in older versions of GCC (<=10), GCC only emitted defines if a certain set of -g*3 flags was passed. Newer versions check the debug level. For the former, we filter out those -g*3 flags and, for the latter, we specify -g0 on top of that. As a compatible and effective solution, this change adds a C-- preprocessor distinct from the C compiler and preprocessor, but that keeps its flags. The command line produced for C-- preprocessing now looks like: $pgmCmmP $optCs_without_g3 $g0_if_supported $optCmmP Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/24474 - - - - - 5298847a by Simon Peyton Jones at 2024-05-07T22:21:44+01:00 Fix a QuickLook bug This MR fixes the bug exposed by #24676. The problem was that quickLookArg was trying to avoid calling tcInstFun unnecessarily; but it was in fact necessary. But that in turn forced me into a significant refactoring, putting more fields into EValArgQL. I added a lot of new material to Note [Quick Look at value arguments] It is a bit more subtle than I would like, but the overall plan is rather clearer now than it was. - - - - - 701b35ea by Simon Peyton Jones at 2024-05-07T22:22:16+01:00 Fix tpyo in comment - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Recomp/Flags.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/729a5f48c5386f246a07bbe612aae1a4bb85ec0d...701b35ea8fb2d41702dfdb0a68b0fcfdac735e73 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/729a5f48c5386f246a07bbe612aae1a4bb85ec0d...701b35ea8fb2d41702dfdb0a68b0fcfdac735e73 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 21:41:06 2024 From: gitlab at gitlab.haskell.org (Serge S. Gulin (@gulin.serge)) Date: Tue, 07 May 2024 17:41:06 -0400 Subject: [Git][ghc/ghc][wip/T24504] IPE: WIP: Replace closure_desc string representation in logs output on Word32 Message-ID: <663a9ff2ab6a8_393e9422300446038c@gitlab.mail> Serge S. Gulin pushed to branch wip/T24504 at Glasgow Haskell Compiler / GHC Commits: 0fcbb9c6 by Serge S. Gulin at 2024-05-08T00:40:38+03:00 IPE: WIP: Replace closure_desc string representation in logs output on Word32 - - - - - 7 changed files: - rts/IPE.c - rts/Trace.c - rts/eventlog/EventLog.c - rts/include/rts/IPE.h - testsuite/tests/rts/ipe/ipeEventLog_fromMap.stderr - testsuite/tests/rts/ipe/ipeMap.c - testsuite/tests/rts/ipe/ipe_lib.c Changes: ===================================== rts/IPE.c ===================================== @@ -176,6 +176,10 @@ void registerInfoProvList(IpeBufferListNode *node) { } } +void formatClosureDescIpe(const InfoProvEnt *ipe_buf, const char *str_buf) { + sprintf((char*) str_buf, "closure_desc_%03u", ipe_buf->prov.closure_desc); +} + bool lookupIPE(const StgInfoTable *info, InfoProvEnt *out) { updateIpeMap(); IpeMapEntry *map_ent = (IpeMapEntry *) lookupHashTable(ipeMap, (StgWord)info); ===================================== rts/Trace.c ===================================== @@ -688,9 +688,12 @@ void traceIPE(const InfoProvEnt *ipe) if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) { ACQUIRE_LOCK(&trace_utx); + const char closure_desc_buf[256] = {}; + formatClosureDescIpe(ipe, closure_desc_buf); + tracePreface(); - debugBelch("IPE: table_name %s, closure_desc %d, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", - ipe->prov.table_name, ipe->prov.closure_desc, ipe->prov.ty_desc, + debugBelch("IPE: table_name %s, closure_desc %s, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", + ipe->prov.table_name, closure_desc_buf, ipe->prov.ty_desc, ipe->prov.label, ipe->prov.unit_id, ipe->prov.module, ipe->prov.src_file, ipe->prov.src_span); ===================================== rts/eventlog/EventLog.c ===================================== @@ -1441,11 +1441,14 @@ void postTickyCounterSamples(StgEntCounter *counters) #endif /* TICKY_TICKY */ void postIPE(const InfoProvEnt *ipe) { + const char closure_desc_buf[256] = {}; + formatClosureDescIpe(ipe, closure_desc_buf); + // See Note [Maximum event length]. const StgWord MAX_IPE_STRING_LEN = 65535; ACQUIRE_LOCK(&eventBufMutex); StgWord table_name_len = MIN(strlen(ipe->prov.table_name), MAX_IPE_STRING_LEN); - StgWord closure_desc_len = MIN(strlen(ipe->prov.closure_desc), MAX_IPE_STRING_LEN); + StgWord closure_desc_len = MIN(strlen(closure_desc_buf), MAX_IPE_STRING_LEN); StgWord ty_desc_len = MIN(strlen(ipe->prov.ty_desc), MAX_IPE_STRING_LEN); StgWord label_len = MIN(strlen(ipe->prov.label), MAX_IPE_STRING_LEN); StgWord module_len = MIN(strlen(ipe->prov.module), MAX_IPE_STRING_LEN); @@ -1462,7 +1465,7 @@ void postIPE(const InfoProvEnt *ipe) postPayloadSize(&eventBuf, len); postWord64(&eventBuf, (StgWord) INFO_PTR_TO_STRUCT(ipe->info)); postStringLen(&eventBuf, ipe->prov.table_name, table_name_len); - postStringLen(&eventBuf, ipe->prov.closure_desc, closure_desc_len); + postStringLen(&eventBuf, closure_desc_buf, closure_desc_len); postStringLen(&eventBuf, ipe->prov.ty_desc, ty_desc_len); postStringLen(&eventBuf, ipe->prov.label, label_len); postStringLen(&eventBuf, ipe->prov.module, module_len); ===================================== rts/include/rts/IPE.h ===================================== @@ -89,5 +89,9 @@ typedef struct IpeBufferListNode_ { void registerInfoProvList(IpeBufferListNode *node); +// We leave it in old format to keep compatibility with existing https://github.com/haskell/ghc-events +// See: https://github.com/haskell/ghc-events/commit/cce6a35677f5f99b44c21d86febd295b909ef1ce +void formatClosureDescIpe(const InfoProvEnt *ipe_buf, const char *str_buf); + // Returns true on success, initializes `out`. bool lookupIPE(const StgInfoTable *info, InfoProvEnt *out); ===================================== testsuite/tests/rts/ipe/ipeEventLog_fromMap.stderr ===================================== @@ -1,20 +1,20 @@ -7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 -7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 -7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 -7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 -7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 -7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 -7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 -7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 -7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 -7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 -7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 -7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 -7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 -7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 -7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 -7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 -7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 ===================================== testsuite/tests/rts/ipe/ipeMap.c ===================================== @@ -68,10 +68,13 @@ HaskellObj shouldFindOneIfItHasBeenRegistered(Capability *cap) { registerInfoProvList(node); - InfoProvEnt result = lookupIPE_("shouldFindOneIfItHasBeenRegistered", get_itbl(fortyTwo)); + const InfoProvEnt result = lookupIPE_("shouldFindOneIfItHasBeenRegistered", get_itbl(fortyTwo)); + + const char closure_desc_buf[256] = {}; + formatClosureDescIpe(&result, closure_desc_buf); assertStringsEqual(result.prov.table_name, "table_name_042"); - assertStringsEqual(result.prov.closure_desc, "closure_desc_042"); + assertStringsEqual(closure_desc_buf, "closure_desc_042"); assertStringsEqual(result.prov.ty_desc, "ty_desc_042"); assertStringsEqual(result.prov.label, "label_042"); assertStringsEqual(result.prov.unit_id, "unit-id"); ===================================== testsuite/tests/rts/ipe/ipe_lib.c ===================================== @@ -33,10 +33,7 @@ IpeBufferEntry makeAnyProvEntry(Capability *cap, StringTable *st, int i) { snprintf(tableName, tableNameLength, "table_name_%03i", i); provEnt.table_name = add_string(st, tableName); - unsigned int closureDescLength = strlen("closure_desc_") + 3 /* digits */ + 1 /* null character */; - char *closureDesc = malloc(sizeof(char) * closureDescLength); - snprintf(closureDesc, closureDescLength, "closure_desc_%03i", i); - provEnt.closure_desc = add_string(st, closureDesc); + provEnt.closure_desc = i; unsigned int tyDescLength = strlen("ty_desc_") + 3 /* digits */ + 1 /* null character */; char *tyDesc = malloc(sizeof(char) * tyDescLength); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0fcbb9c6647034f74a785e424baab8b47afc0850 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0fcbb9c6647034f74a785e424baab8b47afc0850 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue May 7 23:09:39 2024 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Tue, 07 May 2024 19:09:39 -0400 Subject: [Git][ghc/ghc][wip/romes/12569] 8 commits: Substitute bindist files with Hadrian not configure Message-ID: <663ab4b34138c_393e942ce9c10685fa@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/12569 at Glasgow Haskell Compiler / GHC Commits: adba68e7 by John Ericson at 2024-05-05T19:35:56-04:00 Substitute bindist files with Hadrian not configure The `ghc-toolchain` overhaul will eventually replace all this stuff with something much more cleaned up, but I think it is still worth making this sort of cleanup in the meantime so other untanglings and dead code cleaning can procede. I was able to delete a fair amount of dead code doing this too. `LLVMTarget_CPP` is renamed to / merged with `LLVMTarget` because it wasn't actually turned into a valid CPP identifier. (Original to 1345c7cc42c45e63ab1726a8fd24a7e4d4222467, actually.) Progress on #23966 Co-Authored-By: Sylvain Henry <hsyl20 at gmail.com> - - - - - 18f4ff84 by Alan Zimmerman at 2024-05-05T19:36:32-04:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 - - - - - a19201d4 by Matthew Craven at 2024-05-06T19:54:29-04:00 Add test cases for #24664 ...since none are present in the original MR !12463 fixing this issue. - - - - - 46328a49 by Alan Zimmerman at 2024-05-06T19:55:05-04:00 EPA: preserve comments in data decls Closes #24771 - - - - - 3b51995c by Andrei Borzenkov at 2024-05-07T14:39:40-04:00 Rename Solo# data constructor to MkSolo# (#24673) - data Solo# a = (# a #) + data Solo# a = MkSolo# a And `(# foo #)` syntax now becomes just a syntactic sugar for `MkSolo# a`. - - - - - 4d59abf2 by Arsen Arsenović at 2024-05-07T14:40:24-04:00 Add the cmm_cpp_is_gcc predicate to the testsuite A future C-- test called T24474-cmm-override-g0 relies on the GCC-specific behaviour of -g3 implying -dD, which, in turn, leads to it emitting #defines past the preprocessing stage. Clang, at least, does not do this, so the test would fail if ran on Clang. As the behaviour here being tested is ``-optCmmP-g3'' undoing effects of the workaround we apply as a fix for bug #24474, and the workaround was for GCC-specific behaviour, the test needs to be marked as fragile on other compilers. - - - - - 25b0b404 by Arsen Arsenović at 2024-05-07T14:40:24-04:00 Split out the C-- preprocessor, and make it pass -g0 Previously, C-- was processed with the C preprocessor program. This means that it inherited flags passed via -optc. A flag that is somewhat often passed through -optc is -g. At certain -g levels (>=2), GCC starts emitting defines *after* preprocessing, for the purposes of debug info generation. This is not useful for the C-- compiler, and, in fact, causes lexer errors. We can suppress this effect (safely, if supported) via -g0. As a workaround, in older versions of GCC (<=10), GCC only emitted defines if a certain set of -g*3 flags was passed. Newer versions check the debug level. For the former, we filter out those -g*3 flags and, for the latter, we specify -g0 on top of that. As a compatible and effective solution, this change adds a C-- preprocessor distinct from the C compiler and preprocessor, but that keeps its flags. The command line produced for C-- preprocessing now looks like: $pgmCmmP $optCs_without_g3 $g0_if_supported $optCmmP Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/24474 - - - - - 6e655c8b by Rodrigo Mesquita at 2024-05-08T00:09:27+01:00 Rename pre-processor invocation args Small clean up. Uses proper names for the various groups of arguments that make up the pre-processor invocation. - - - - - 30 changed files: - compiler/GHC/Builtin/Types.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Recomp/Flags.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools/Cpp.hs - compiler/GHC/SysTools/Tasks.hs - configure.ac - distrib/configure.ac.in - docs/users_guide/phases.rst - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cfg/default.host.target.in - hadrian/cfg/default.target.in - hadrian/cfg/system.config.in - hadrian/src/Oracles/Setting.hs - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Rules/Generate.hs - libraries/ghc-boot/GHC/Utils/Encoding.hs - libraries/ghc-experimental/src/Data/Tuple/Experimental.hs - libraries/ghc-prim/GHC/Types.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Syntax.hs - + m4/fp_cmm_cpp_cmd_with_args.m4 - m4/fp_settings.m4 - m4/fp_setup_windows_toolchain.m4 - m4/ghc_toolchain.m4 - m4/prep_target_file.m4 The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5edc63d5a05aebbe96b1771924b2baacc6394cda...6e655c8bbbd30e32421b1d51cc95c0b4b15b5708 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5edc63d5a05aebbe96b1771924b2baacc6394cda...6e655c8bbbd30e32421b1d51cc95c0b4b15b5708 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 01:14:09 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 07 May 2024 21:14:09 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Rename Solo# data constructor to MkSolo# (#24673) Message-ID: <663ad1e1dbc91_3c00693415e883669@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 3b51995c by Andrei Borzenkov at 2024-05-07T14:39:40-04:00 Rename Solo# data constructor to MkSolo# (#24673) - data Solo# a = (# a #) + data Solo# a = MkSolo# a And `(# foo #)` syntax now becomes just a syntactic sugar for `MkSolo# a`. - - - - - 4d59abf2 by Arsen Arsenović at 2024-05-07T14:40:24-04:00 Add the cmm_cpp_is_gcc predicate to the testsuite A future C-- test called T24474-cmm-override-g0 relies on the GCC-specific behaviour of -g3 implying -dD, which, in turn, leads to it emitting #defines past the preprocessing stage. Clang, at least, does not do this, so the test would fail if ran on Clang. As the behaviour here being tested is ``-optCmmP-g3'' undoing effects of the workaround we apply as a fix for bug #24474, and the workaround was for GCC-specific behaviour, the test needs to be marked as fragile on other compilers. - - - - - 25b0b404 by Arsen Arsenović at 2024-05-07T14:40:24-04:00 Split out the C-- preprocessor, and make it pass -g0 Previously, C-- was processed with the C preprocessor program. This means that it inherited flags passed via -optc. A flag that is somewhat often passed through -optc is -g. At certain -g levels (>=2), GCC starts emitting defines *after* preprocessing, for the purposes of debug info generation. This is not useful for the C-- compiler, and, in fact, causes lexer errors. We can suppress this effect (safely, if supported) via -g0. As a workaround, in older versions of GCC (<=10), GCC only emitted defines if a certain set of -g*3 flags was passed. Newer versions check the debug level. For the former, we filter out those -g*3 flags and, for the latter, we specify -g0 on top of that. As a compatible and effective solution, this change adds a C-- preprocessor distinct from the C compiler and preprocessor, but that keeps its flags. The command line produced for C-- preprocessing now looks like: $pgmCmmP $optCs_without_g3 $g0_if_supported $optCmmP Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/24474 - - - - - e1e7b1a4 by Andreas Klebinger at 2024-05-07T21:13:56-04:00 -fprof-late: Only insert cost centres on functions/non-workfree cafs. They are usually useless and doing so for data values comes with a large compile time/code size overhead. Fixes #24103 - - - - - b8db6ac2 by Sebastian Graf at 2024-05-07T21:13:57-04:00 Simplifier: Preserve OccInfo on DataAlt fields when case binder is dead (#24770) See the adjusted `Note [DataAlt occ info]`. This change also has a positive repercussion on `Note [Combine case alts: awkward corner]`. Fixes #24770. We now try not to call `dataConRepStrictness` in `adjustFieldsIdInfo` when all fields are lazy anyway, leading to a 2% ghc/alloc decrease in T9675. Metric Decrease: T9675 - - - - - 413985ad by Sebastian Graf at 2024-05-07T21:13:57-04:00 Kill seqRule, discard dead seq# in Prep (#24334) Discarding seq#s in Core land via `seqRule` was problematic; see #24334. So instead we discard certain dead, discardable seq#s in Prep now. See the updated `Note [seq# magic]`. This fixes the symptoms of #24334. - - - - - 30 changed files: - compiler/GHC/Builtin/Types.hs - compiler/GHC/Core/LateCC.hs - compiler/GHC/Core/LateCC/TopLevelBinds.hs - compiler/GHC/Core/LateCC/Types.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Recomp/Flags.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools/Cpp.hs - compiler/GHC/SysTools/Tasks.hs - compiler/GHC/Types/Id/Make.hs - compiler/GHC/Types/RepType.hs - configure.ac - distrib/configure.ac.in - docs/users_guide/9.12.1-notes.rst - docs/users_guide/phases.rst - docs/users_guide/profiling.rst - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cfg/default.host.target.in The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5626195031591b987fa0bfd73c0570a0c2ae2e69...413985ad937ec77a40c7a59ae12eb9ff6f6c98df -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5626195031591b987fa0bfd73c0570a0c2ae2e69...413985ad937ec77a40c7a59ae12eb9ff6f6c98df You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 05:02:18 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 08 May 2024 01:02:18 -0400 Subject: [Git][ghc/ghc][wip/ghc-9.10] 13 commits: ghcup-metadata: Drop output_name field Message-ID: <663b075a9dd84_3c00691bbb1c8988c5@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: 29ed876b by Ben Gamari at 2024-04-27T13:12:45-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - 1fb2344c by Alan Zimmerman at 2024-05-08T00:51:18-04:00 EPA: check-exact: check that the roundtrip reproduces the source Closes #24670 (cherry picked from commit 981c2c2c5017cb7ae47babff4d2163324d7cbde6) - - - - - 6f94f24a by Alan Zimmerman at 2024-05-08T00:52:01-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 (cherry picked from commit 1c2fd963d6fd78d1c752a21348c7db85f5d64df2) - - - - - da909f2c by Alan Zimmerman at 2024-05-08T00:52:25-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 (cherry picked from commit 40026ac30fcdbe84a551f445f5e20691c0527ded) - - - - - 39faadee by Alan Zimmerman at 2024-05-08T00:53:39-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 (cherry picked from commit 167a56a003106ed84742e3970cc2189ffb98b0c7) - - - - - 3658bbf2 by Alan Zimmerman at 2024-05-08T00:55:20-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 (cherry picked from commit 35d34fde62cd9e0002ac42f10bf705552f5c654e) - - - - - 73dc0545 by Alan Zimmerman at 2024-05-08T00:55:44-04:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 (cherry picked from commit 18f4ff84b323236f6dfd07f3bbc2842308a01e91) - - - - - fad75913 by Alan Zimmerman at 2024-05-08T00:56:05-04:00 EPA: preserve comments in data decls Closes #24771 (cherry picked from commit 46328a49d988143111ab530d7907b9426b58311a) - - - - - 30de1399 by Simon Peyton Jones at 2024-05-08T00:56:17-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! (cherry picked from commit be1e60eec0ec37da41643af17d78c698ab2a7083) - - - - - 9149b5ce by Andrew Lelechenko at 2024-05-08T00:56:35-04:00 Document that setEnv is not thread-safe (cherry picked from commit a86167471a7a471fb75ae9ba6c641bd1e74bc16d) - - - - - 63748a90 by Matthew Pickering at 2024-05-08T00:56:48-04:00 Don't depend on registerPackage function in Cabal More recent versions of Cabal modify the behaviour of libAbiHash which breaks our usage of registerPackage. It is simpler to inline the part of registerPackage that we need and avoid any additional dependency and complication using the higher-level function introduces. (cherry picked from commit 3fff09779d5830549ae455a15907b7bb9fe7859a) - - - - - 569105e8 by Hécate Moonlight at 2024-05-08T01:01:11-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 (cherry picked from commit 9213478931b18402998c18f5c4e6f0ee09054b18) - - - - - 4b3314f5 by Teo Camarasu at 2024-05-08T01:01:19-04:00 doc: Fix type error in hs_try_putmvar example (cherry picked from commit 06f7db4001e4eee0f3076d949876f8f4af0eb6fb) - - - - - 24 changed files: - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - compiler/GHC/Core/Rules.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - docs/users_guide/exts/ffi.rst - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc - libraries/ghc-internal/src/GHC/Internal/System/Environment.hs - libraries/ghc-internal/src/GHC/Internal/System/Environment/Blank.hsc - testsuite/tests/parser/should_compile/T20846.stderr - testsuite/tests/printer/Makefile - + testsuite/tests/printer/MatchPatComments.hs - testsuite/tests/printer/PprExportWarn.hs - + testsuite/tests/printer/PrefixConComment.hs - + testsuite/tests/printer/Test24748.hs - + testsuite/tests/printer/Test24753.hs - + testsuite/tests/printer/Test24755.hs - + testsuite/tests/printer/Test24771.hs - testsuite/tests/printer/all.T - + testsuite/tests/simplCore/should_compile/T24726.hs - + testsuite/tests/simplCore/should_compile/T24726.stderr - testsuite/tests/simplCore/should_compile/all.T - utils/check-exact/Main.hs Changes: ===================================== .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py ===================================== @@ -65,7 +65,6 @@ eprint(f"Supported platforms: {job_mapping.keys()}") class Artifact(NamedTuple): job_name: str download_name: str - output_name: str subdir: str # Platform spec provides a specification which is agnostic to Job @@ -75,11 +74,9 @@ class PlatformSpec(NamedTuple): subdir: str source_artifact = Artifact('source-tarball' - , 'ghc-{version}-src.tar.xz' , 'ghc-{version}-src.tar.xz' , 'ghc-{version}' ) test_artifact = Artifact('source-tarball' - , 'ghc-{version}-testsuite.tar.xz' , 'ghc-{version}-testsuite.tar.xz' , 'ghc-{version}/testsuite' ) @@ -164,11 +161,6 @@ def mk_one_metadata(release_mode, version, job_map, artifact): , "dlSubdir": artifact.subdir.format(version=version) , "dlHash" : h } - # Only add dlOutput if it is inconsistent with the filename inferred from the URL - output = artifact.output_name.format(version=version) - if Path(urlparse(final_url).path).name != output: - res["dlOutput"] = output - eprint(res) return res ===================================== compiler/GHC/Core/Rules.hs ===================================== @@ -47,7 +47,7 @@ import GHC.Driver.Ppr( showSDoc ) import GHC.Core -- All of it import GHC.Core.Subst import GHC.Core.SimpleOpt ( exprIsLambda_maybe ) -import GHC.Core.FVs ( exprFreeVars, exprsFreeVars, bindFreeVars +import GHC.Core.FVs ( exprFreeVars, bindFreeVars , rulesFreeVarsDSet, exprsOrphNames ) import GHC.Core.Utils ( exprType, mkTick, mkTicks , stripTicksTopT, stripTicksTopE @@ -1887,41 +1887,59 @@ ruleCheckProgram ropts phase rule_pat rules binds vcat [ p $$ line | p <- bagToList results ] ] where + line = text (replicate 20 '-') env = RuleCheckEnv { rc_is_active = isActive phase , rc_id_unf = idUnfolding -- Not quite right -- Should use activeUnfolding , rc_pattern = rule_pat , rc_rules = rules , rc_ropts = ropts - } - results = unionManyBags (map (ruleCheckBind env) binds) - line = text (replicate 20 '-') + , rc_in_scope = emptyInScopeSet } + + results = go env binds + + go _ [] = emptyBag + go env (bind:binds) = let (env', ds) = ruleCheckBind env bind + in ds `unionBags` go env' binds + +data RuleCheckEnv = RuleCheckEnv + { rc_is_active :: Activation -> Bool + , rc_id_unf :: IdUnfoldingFun + , rc_pattern :: String + , rc_rules :: Id -> [CoreRule] + , rc_ropts :: RuleOpts + , rc_in_scope :: InScopeSet } + +extendInScopeRC :: RuleCheckEnv -> Var -> RuleCheckEnv +extendInScopeRC env@(RuleCheckEnv { rc_in_scope = in_scope }) v + = env { rc_in_scope = in_scope `extendInScopeSet` v } -data RuleCheckEnv = RuleCheckEnv { - rc_is_active :: Activation -> Bool, - rc_id_unf :: IdUnfoldingFun, - rc_pattern :: String, - rc_rules :: Id -> [CoreRule], - rc_ropts :: RuleOpts -} +extendInScopeListRC :: RuleCheckEnv -> [Var] -> RuleCheckEnv +extendInScopeListRC env@(RuleCheckEnv { rc_in_scope = in_scope }) vs + = env { rc_in_scope = in_scope `extendInScopeSetList` vs } -ruleCheckBind :: RuleCheckEnv -> CoreBind -> Bag SDoc +ruleCheckBind :: RuleCheckEnv -> CoreBind -> (RuleCheckEnv, Bag SDoc) -- The Bag returned has one SDoc for each call site found -ruleCheckBind env (NonRec _ r) = ruleCheck env r -ruleCheckBind env (Rec prs) = unionManyBags [ruleCheck env r | (_,r) <- prs] +ruleCheckBind env (NonRec b r) = (env `extendInScopeRC` b, ruleCheck env r) +ruleCheckBind env (Rec prs) = (env', unionManyBags (map (ruleCheck env') rhss)) + where + (bs, rhss) = unzip prs + env' = env `extendInScopeListRC` bs ruleCheck :: RuleCheckEnv -> CoreExpr -> Bag SDoc -ruleCheck _ (Var _) = emptyBag -ruleCheck _ (Lit _) = emptyBag -ruleCheck _ (Type _) = emptyBag -ruleCheck _ (Coercion _) = emptyBag -ruleCheck env (App f a) = ruleCheckApp env (App f a) [] -ruleCheck env (Tick _ e) = ruleCheck env e -ruleCheck env (Cast e _) = ruleCheck env e -ruleCheck env (Let bd e) = ruleCheckBind env bd `unionBags` ruleCheck env e -ruleCheck env (Lam _ e) = ruleCheck env e -ruleCheck env (Case e _ _ as) = ruleCheck env e `unionBags` - unionManyBags [ruleCheck env r | Alt _ _ r <- as] +ruleCheck _ (Var _) = emptyBag +ruleCheck _ (Lit _) = emptyBag +ruleCheck _ (Type _) = emptyBag +ruleCheck _ (Coercion _) = emptyBag +ruleCheck env (App f a) = ruleCheckApp env (App f a) [] +ruleCheck env (Tick _ e) = ruleCheck env e +ruleCheck env (Cast e _) = ruleCheck env e +ruleCheck env (Let bd e) = let (env', ds) = ruleCheckBind env bd + in ds `unionBags` ruleCheck env' e +ruleCheck env (Lam b e) = ruleCheck (env `extendInScopeRC` b) e +ruleCheck env (Case e b _ as) = ruleCheck env e `unionBags` + unionManyBags [ruleCheck (env `extendInScopeListRC` (b:bs)) r + | Alt _ bs r <- as] ruleCheckApp :: RuleCheckEnv -> Expr CoreBndr -> [Arg CoreBndr] -> Bag SDoc ruleCheckApp env (App f a) as = ruleCheck env a `unionBags` ruleCheckApp env f (a:as) @@ -1945,8 +1963,9 @@ ruleAppCheck_help env fn args rules vcat [text "Expression:" <+> ppr (mkApps (Var fn) args), vcat (map check_rule rules)] where - n_args = length args - i_args = args `zip` [1::Int ..] + in_scope = rc_in_scope env + n_args = length args + i_args = args `zip` [1::Int ..] rough_args = map roughTopName args check_rule rule = rule_herald rule <> colon <+> rule_info (rc_ropts env) rule @@ -1976,10 +1995,8 @@ ruleAppCheck_help env fn args rules mismatches = [i | (rule_arg, (arg,i)) <- rule_args `zip` i_args, not (isJust (match_fn rule_arg arg))] - lhs_fvs = exprsFreeVars rule_args -- Includes template tyvars match_fn rule_arg arg = match renv emptyRuleSubst rule_arg arg MRefl where - in_scope = mkInScopeSet (lhs_fvs `unionVarSet` exprFreeVars arg) renv = RV { rv_lcl = mkRnEnv2 in_scope , rv_tmpls = mkVarSet rule_bndrs , rv_fltR = mkEmptySubst in_scope ===================================== compiler/GHC/Parser.y ===================================== @@ -2486,9 +2486,8 @@ forall :: { Located ([AddEpAnn], Maybe [LHsTyVarBndr Specificity GhcPs]) } | {- empty -} { noLoc ([], Nothing) } constr_stuff :: { Located (LocatedN RdrName, HsConDeclH98Details GhcPs) } - : infixtype {% fmap (reLoc. (fmap (\b -> (dataConBuilderCon b, - dataConBuilderDetails b)))) - (runPV $1) } + : infixtype {% do { b <- runPV $1 + ; return (sL1 b (dataConBuilderCon b, dataConBuilderDetails b)) }} | '(#' usum_constr '#)' {% let (t, tag, arity) = $2 in pure (sLL $1 $3 $ mkUnboxedSumCon t tag arity)} usum_constr :: { (LHsType GhcPs, Int, Int) } -- constructor for the data decls SumN# @@ -2900,10 +2899,10 @@ aexp :: { ECP } [mj AnnLam $1] } | '\\' 'lcase' altslist(pats1) { ECP $ $3 >>= \ $3 -> - mkHsLamPV (comb2 $1 $>) LamCase $3 [mj AnnLam $1,mj AnnCase $2] } + mkHsLamPV (comb3 $1 $2 $>) LamCase $3 [mj AnnLam $1,mj AnnCase $2] } | '\\' 'lcases' altslist(argpats) { ECP $ $3 >>= \ $3 -> - mkHsLamPV (comb2 $1 $>) LamCases $3 [mj AnnLam $1,mj AnnCases $2] } + mkHsLamPV (comb3 $1 $2 $>) LamCases $3 [mj AnnLam $1,mj AnnCases $2] } | 'if' exp optSemi 'then' exp optSemi 'else' exp {% runPV (unECP $2) >>= \ ($2 :: LHsExpr GhcPs) -> return $ ECP $ ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -1244,7 +1244,7 @@ transferAnnsOnlyA (EpAnn a an cs) (EpAnn a' an' cs') -- | Transfer comments from the annotations in the -- first 'SrcSpanAnnA' argument to those in the second. -transferCommentsOnlyA :: SrcSpanAnnA -> SrcSpanAnnA -> (SrcSpanAnnA, SrcSpanAnnA) +transferCommentsOnlyA :: EpAnn a -> EpAnn b -> (EpAnn a, EpAnn b) transferCommentsOnlyA (EpAnn a an cs) (EpAnn a' an' cs') = (EpAnn a an emptyComments, EpAnn a' an' (cs <> cs')) ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -205,11 +205,11 @@ mkClassDecl :: SrcSpan -> P (LTyClDecl GhcPs) mkClassDecl loc' (L _ (mcxt, tycl_hdr)) fds where_cls layout annsIn - = do { let loc = noAnnSrcSpan loc' - ; (binds, sigs, ats, at_defs, _, docs) <- cvBindsAndSigs where_cls - ; (cls, tparams, fixity, ann) <- checkTyClHdr True tycl_hdr + = do { (binds, sigs, ats, at_defs, _, docs) <- cvBindsAndSigs where_cls + ; (cls, tparams, fixity, ann, cs) <- checkTyClHdr True tycl_hdr ; tyvars <- checkTyVars (text "class") whereDots cls tparams ; let anns' = annsIn Semi.<> ann + ; let loc = EpAnn (spanAsAnchor loc') noAnn cs ; return (L loc (ClassDecl { tcdCExt = (anns', layout, NoAnnSortKey) , tcdCtxt = mcxt , tcdLName = cls, tcdTyVars = tyvars @@ -232,12 +232,13 @@ mkTyData :: SrcSpan -> P (LTyClDecl GhcPs) mkTyData loc' is_type_data new_or_data cType (L _ (mcxt, tycl_hdr)) ksig data_cons (L _ maybe_deriv) annsIn - = do { let loc = noAnnSrcSpan loc' - ; (tc, tparams, fixity, ann) <- checkTyClHdr False tycl_hdr + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False tycl_hdr ; tyvars <- checkTyVars (ppr new_or_data) equalsDots tc tparams ; let anns' = annsIn Semi.<> ann - ; data_cons <- checkNewOrData (locA loc) (unLoc tc) is_type_data new_or_data data_cons + ; data_cons <- checkNewOrData loc' (unLoc tc) is_type_data new_or_data data_cons ; defn <- mkDataDefn cType mcxt ksig data_cons maybe_deriv + ; !cs' <- getCommentsFor loc' + ; let loc = EpAnn (spanAsAnchor loc') noAnn (cs' Semi.<> cs) ; return (L loc (DataDecl { tcdDExt = anns', tcdLName = tc, tcdTyVars = tyvars, tcdFixity = fixity, @@ -264,14 +265,14 @@ mkTySynonym :: SrcSpan -> [AddEpAnn] -> P (LTyClDecl GhcPs) mkTySynonym loc lhs rhs annsIn - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs ; tyvars <- checkTyVars (text "type") equalsDots tc tparams ; let anns' = annsIn Semi.<> ann - ; return (L (noAnnSrcSpan loc) (SynDecl - { tcdSExt = anns' - , tcdLName = tc, tcdTyVars = tyvars - , tcdFixity = fixity - , tcdRhs = rhs })) } + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (SynDecl { tcdSExt = anns' + , tcdLName = tc, tcdTyVars = tyvars + , tcdFixity = fixity + , tcdRhs = rhs })) } mkStandaloneKindSig :: SrcSpan @@ -304,8 +305,9 @@ mkTyFamInstEqn :: SrcSpan -> [AddEpAnn] -> P (LTyFamInstEqn GhcPs) mkTyFamInstEqn loc bndrs lhs rhs anns - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs - ; return (L (noAnnSrcSpan loc) $ FamEqn + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' $ FamEqn { feqn_ext = anns `mappend` ann , feqn_tycon = tc , feqn_bndrs = bndrs @@ -325,10 +327,11 @@ mkDataFamInst :: SrcSpan -> P (LInstDecl GhcPs) mkDataFamInst loc new_or_data cType (mcxt, bndrs, tycl_hdr) ksig data_cons (L _ maybe_deriv) anns - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False tycl_hdr + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False tycl_hdr ; data_cons <- checkNewOrData loc (unLoc tc) False new_or_data data_cons ; defn <- mkDataDefn cType mcxt ksig data_cons maybe_deriv - ; return (L (noAnnSrcSpan loc) (DataFamInstD noExtField (DataFamInstDecl + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (DataFamInstD noExtField (DataFamInstDecl (FamEqn { feqn_ext = ann Semi.<> anns , feqn_tycon = tc , feqn_bndrs = bndrs @@ -369,10 +372,10 @@ mkFamDecl :: SrcSpan -> [AddEpAnn] -> P (LTyClDecl GhcPs) mkFamDecl loc info topLevel lhs ksig injAnn annsIn - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs ; tyvars <- checkTyVars (ppr info) equals_or_where tc tparams - ; return (L (noAnnSrcSpan loc) (FamDecl noExtField - (FamilyDecl + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (FamDecl noExtField (FamilyDecl { fdExt = annsIn Semi.<> ann , fdTopLevel = topLevel , fdInfo = info, fdLName = tc @@ -1041,45 +1044,46 @@ checkTyClHdr :: Bool -- True <=> class header -> P (LocatedN RdrName, -- the head symbol (type or class name) [LHsTypeArg GhcPs], -- parameters of head symbol LexicalFixity, -- the declaration is in infix format - [AddEpAnn]) -- API Annotation for HsParTy + [AddEpAnn], -- API Annotation for HsParTy -- when stripping parens + EpAnnComments) -- Accumulated comments from re-arranging -- Well-formedness check and decomposition of type and class heads. -- Decomposes T ty1 .. tyn into (T, [ty1, ..., tyn]) -- Int :*: Bool into (:*:, [Int, Bool]) -- returning the pieces checkTyClHdr is_cls ty - = goL ty [] [] [] Prefix + = goL emptyComments ty [] [] [] Prefix where - goL (L l ty) acc ops cps fix = go l ty acc ops cps fix + goL cs (L l ty) acc ops cps fix = go cs l ty acc ops cps fix -- workaround to define '*' despite StarIsType - go ll (HsParTy an (L l (HsStarTy _ isUni))) acc ops' cps' fix + go cs ll (HsParTy an (L l (HsStarTy _ isUni))) acc ops' cps' fix = do { addPsMessage (locA l) PsWarnStarBinder ; let name = mkOccNameFS tcClsName (starSym isUni) ; let a' = newAnns ll l an ; return (L a' (Unqual name), acc, fix - , (reverse ops') ++ cps') } + , (reverse ops') ++ cps', cs) } - go _ (HsTyVar _ _ ltc@(L _ tc)) acc ops cps fix - | isRdrTc tc = return (ltc, acc, fix, (reverse ops) ++ cps) - go _ (HsOpTy _ _ t1 ltc@(L _ tc) t2) acc ops cps _fix - | isRdrTc tc = return (ltc, lhs:rhs:acc, Infix, (reverse ops) ++ cps) + go cs l (HsTyVar _ _ ltc@(L _ tc)) acc ops cps fix + | isRdrTc tc = return (ltc, acc, fix, (reverse ops) ++ cps, cs Semi.<> comments l) + go cs l (HsOpTy _ _ t1 ltc@(L _ tc) t2) acc ops cps _fix + | isRdrTc tc = return (ltc, lhs:rhs:acc, Infix, (reverse ops) ++ cps, cs Semi.<> comments l) where lhs = HsValArg noExtField t1 rhs = HsValArg noExtField t2 - go l (HsParTy _ ty) acc ops cps fix = goL ty acc (o:ops) (c:cps) fix + go cs l (HsParTy _ ty) acc ops cps fix = goL (cs Semi.<> comments l) ty acc (o:ops) (c:cps) fix where (o,c) = mkParensEpAnn (realSrcSpan (locA l)) - go _ (HsAppTy _ t1 t2) acc ops cps fix = goL t1 (HsValArg noExtField t2:acc) ops cps fix - go _ (HsAppKindTy at ty ki) acc ops cps fix = goL ty (HsTypeArg at ki:acc) ops cps fix - go l (HsTupleTy _ HsBoxedOrConstraintTuple ts) [] ops cps fix + go cs l (HsAppTy _ t1 t2) acc ops cps fix = goL (cs Semi.<> comments l) t1 (HsValArg noExtField t2:acc) ops cps fix + go cs l (HsAppKindTy at ty ki) acc ops cps fix = goL (cs Semi.<> comments l) ty (HsTypeArg at ki:acc) ops cps fix + go cs l (HsTupleTy _ HsBoxedOrConstraintTuple ts) [] ops cps fix = return (L (l2l l) (nameRdrName tup_name) - , map (HsValArg noExtField) ts, fix, (reverse ops)++cps) + , map (HsValArg noExtField) ts, fix, (reverse ops)++cps, cs Semi.<> comments l) where arity = length ts tup_name | is_cls = cTupleTyConName arity | otherwise = getName (tupleTyCon Boxed arity) -- See Note [Unit tuples] in GHC.Hs.Type (TODO: is this still relevant?) - go l _ _ _ _ _ + go _ l _ _ _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope (locA l) $ (PsErrMalformedTyOrClDecl ty) @@ -1211,33 +1215,34 @@ checkPattern_details :: ParseContext -> PV (LocatedA (PatBuilder GhcPs)) -> P (L checkPattern_details extraDetails pp = runPV_details extraDetails (pp >>= checkLPat) checkLArgPat :: LocatedA (ArgPatBuilder GhcPs) -> PV (LPat GhcPs) -checkLArgPat (L l (ArgPatBuilderVisPat p)) - = checkPat l (L l p) [] [] +checkLArgPat (L l (ArgPatBuilderVisPat p)) = checkLPat (L l p) checkLArgPat (L l (ArgPatBuilderArgPat p)) = return (L l p) checkLPat :: LocatedA (PatBuilder GhcPs) -> PV (LPat GhcPs) -checkLPat e@(L l _) = checkPat l e [] [] - -checkPat :: SrcSpanAnnA -> LocatedA (PatBuilder GhcPs) -> [HsConPatTyArg GhcPs] -> [LPat GhcPs] - -> PV (LPat GhcPs) -checkPat loc (L l e@(PatBuilderVar (L ln c))) tyargs args - | isRdrDataCon c = return . L loc $ ConPat +checkLPat (L l@(EpAnn anc an _) p) = do + (L l' p', cs) <- checkPat (EpAnn anc an emptyComments) emptyComments (L l p) [] [] + return (L (addCommentsToEpAnn l' cs) p') + +checkPat :: SrcSpanAnnA -> EpAnnComments -> LocatedA (PatBuilder GhcPs) -> [HsConPatTyArg GhcPs] -> [LPat GhcPs] + -> PV (LPat GhcPs, EpAnnComments) +checkPat loc cs (L l e@(PatBuilderVar (L ln c))) tyargs args + | isRdrDataCon c = return (L loc $ ConPat { pat_con_ext = noAnn -- AZ: where should this come from? , pat_con = L ln c , pat_args = PrefixCon tyargs args - } + }, comments l Semi.<> cs) | (not (null args) && patIsRec c) = do ctx <- askParseContext patFail (locA l) . PsErrInPat e $ PEIP_RecPattern args YesPatIsRecursive ctx -checkPat loc (L _ (PatBuilderAppType f at t)) tyargs args = - checkPat loc f (HsConPatTyArg at t : tyargs) args -checkPat loc (L _ (PatBuilderApp f e)) [] args = do +checkPat loc cs (L la (PatBuilderAppType f at t)) tyargs args = + checkPat loc (cs Semi.<> comments la) f (HsConPatTyArg at t : tyargs) args +checkPat loc cs (L la (PatBuilderApp f e)) [] args = do p <- checkLPat e - checkPat loc f [] (p : args) -checkPat loc (L l e) [] [] = do + checkPat loc (cs Semi.<> comments la) f [] (p : args) +checkPat loc cs (L l e) [] [] = do p <- checkAPat loc e - return (L l p) -checkPat loc e _ _ = do + return (L l p, cs) +checkPat loc _ e _ _ = do details <- fromParseContext <$> askParseContext patFail (locA loc) (PsErrInPat (unLoc e) details) @@ -1346,13 +1351,13 @@ checkFunBind :: SrcStrictness -> [LocatedA (ArgPatBuilder GhcPs)] -> Located (GRHSs GhcPs (LHsExpr GhcPs)) -> P (HsBind GhcPs) -checkFunBind strictness locF ann fun is_infix pats (L _ grhss) +checkFunBind strictness locF ann (L lf fun) is_infix pats (L _ grhss) = do ps <- runPV_details extraDetails (mapM checkLArgPat pats) let match_span = noAnnSrcSpan $ locF - return (makeFunBind fun (L (noAnnSrcSpan $ locA match_span) + return (makeFunBind (L (l2l lf) fun) (L (noAnnSrcSpan $ locA match_span) [L match_span (Match { m_ext = ann , m_ctxt = FunRhs - { mc_fun = fun + { mc_fun = L lf fun , mc_fixity = is_infix , mc_strictness = strictness } , m_pats = ps @@ -1361,7 +1366,7 @@ checkFunBind strictness locF ann fun is_infix pats (L _ grhss) -- That isn't quite right, but it'll do for now. where extraDetails - | Infix <- is_infix = ParseContext (Just $ unLoc fun) NoIncompleteDoBlock + | Infix <- is_infix = ParseContext (Just fun) NoIncompleteDoBlock | otherwise = noParseContext makeFunBind :: LocatedN RdrName -> LocatedL [LMatch GhcPs (LHsExpr GhcPs)] @@ -1433,20 +1438,27 @@ isFunLhs e = go e [] [] [] where mk = fmap ArgPatBuilderVisPat - go (L _ (PatBuilderVar (L loc f))) es ops cps - | not (isRdrDataCon f) = return (Just (L loc f, Prefix, es, (reverse ops) ++ cps)) - go (L _ (PatBuilderApp f e)) es ops cps = go f (mk e:es) ops cps - go (L l (PatBuilderPar _ e _)) es@(_:_) ops cps = go e es (o:ops) (c:cps) + go (L l (PatBuilderVar (L loc f))) es ops cps + | not (isRdrDataCon f) = do + let (_l, loc') = transferCommentsOnlyA l loc + return (Just (L loc' f, Prefix, es, (reverse ops) ++ cps)) + go (L l (PatBuilderApp (L lf f) e)) es ops cps = do + let (_l, lf') = transferCommentsOnlyA l lf + go (L lf' f) (mk e:es) ops cps + go (L l (PatBuilderPar _ (L le e) _)) es@(_:_) ops cps = go (L le' e) es (o:ops) (c:cps) -- NB: es@(_:_) means that there must be an arg after the parens for the -- LHS to be a function LHS. This corresponds to the Haskell Report's definition -- of funlhs. where + (_l, le') = transferCommentsOnlyA l le (o,c) = mkParensEpAnn (realSrcSpan $ locA l) - go (L loc (PatBuilderOpApp l (L loc' op) r anns)) es ops cps + go (L loc (PatBuilderOpApp (L ll l) (L loc' op) r anns)) es ops cps | not (isRdrDataCon op) -- We have found the function! - = return (Just (L loc' op, Infix, (mk l:mk r:es), (anns ++ reverse ops ++ cps))) + = do { let (_l, ll') = transferCommentsOnlyA loc ll + ; return (Just (L loc' op, Infix, (mk (L ll' l):mk r:es), (anns ++ reverse ops ++ cps))) } | otherwise -- Infix data con; keep going - = do { mb_l <- go l es ops cps + = do { let (_l, ll') = transferCommentsOnlyA loc ll + ; mb_l <- go (L ll' l) es ops cps ; return (reassociate =<< mb_l) } where reassociate (op', Infix, j : L k_loc (ArgPatBuilderVisPat k) : es', anns') @@ -1455,12 +1467,13 @@ isFunLhs e = go e [] [] [] op_app = mk $ L loc (PatBuilderOpApp (L k_loc k) (L loc' op) r (reverse ops ++ cps)) reassociate _other = Nothing - go (L _ (PatBuilderAppType pat tok ty_pat@(HsTP _ (L (EpAnn anc ann cs) _)))) es ops cps - = go pat (L (EpAnn anc' ann cs) (ArgPatBuilderArgPat invis_pat) : es) ops cps + go (L l (PatBuilderAppType (L lp pat) tok ty_pat@(HsTP _ (L (EpAnn anc ann cs) _)))) es ops cps + = go (L lp' pat) (L (EpAnn anc' ann cs) (ArgPatBuilderArgPat invis_pat) : es) ops cps where invis_pat = InvisPat tok ty_pat anc' = case tok of NoEpTok -> anc EpTok l -> widenAnchor anc [AddEpAnn AnnAnyclass l] + (_l, lp') = transferCommentsOnlyA l lp go _ _ _ _ = return Nothing data ArgPatBuilder p @@ -2048,28 +2061,32 @@ instance DisambTD (HsType GhcPs) where mkHsAppTyHeadPV = return mkHsAppTyPV t1 t2 = return (mkHsAppTy t1 t2) mkHsAppKindTyPV t at ki = return (mkHsAppKindTy at t ki) - mkHsOpTyPV prom t1 op t2 = return (mkLHsOpTy prom t1 op t2) + mkHsOpTyPV prom t1 op t2 = do + let (L l ty) = mkLHsOpTy prom t1 op t2 + !cs <- getCommentsFor (locA l) + return (L (addCommentsToEpAnn l cs) ty) mkUnpackednessPV = addUnpackednessP -dataConBuilderCon :: DataConBuilder -> LocatedN RdrName -dataConBuilderCon (PrefixDataConBuilder _ dc) = dc -dataConBuilderCon (InfixDataConBuilder _ dc _) = dc +dataConBuilderCon :: LocatedA DataConBuilder -> LocatedN RdrName +dataConBuilderCon (L _ (PrefixDataConBuilder _ dc)) = dc +dataConBuilderCon (L _ (InfixDataConBuilder _ dc _)) = dc -dataConBuilderDetails :: DataConBuilder -> HsConDeclH98Details GhcPs +dataConBuilderDetails :: LocatedA DataConBuilder -> HsConDeclH98Details GhcPs -- Detect when the record syntax is used: -- data T = MkT { ... } -dataConBuilderDetails (PrefixDataConBuilder flds _) +dataConBuilderDetails (L _ (PrefixDataConBuilder flds _)) | [L (EpAnn anc _ cs) (HsRecTy an fields)] <- toList flds = RecCon (L (EpAnn anc an cs) fields) -- Normal prefix constructor, e.g. data T = MkT A B C -dataConBuilderDetails (PrefixDataConBuilder flds _) +dataConBuilderDetails (L _ (PrefixDataConBuilder flds _)) = PrefixCon noTypeArgs (map hsLinear (toList flds)) -- Infix constructor, e.g. data T = Int :! Bool -dataConBuilderDetails (InfixDataConBuilder lhs _ rhs) - = InfixCon (hsLinear lhs) (hsLinear rhs) +dataConBuilderDetails (L (EpAnn _ _ csl) (InfixDataConBuilder (L (EpAnn anc ann csll) lhs) _ rhs)) + = InfixCon (hsLinear (L (EpAnn anc ann (csl Semi.<> csll)) lhs)) (hsLinear rhs) + instance DisambTD DataConBuilder where mkHsAppTyHeadPV = tyToDataConBuilder @@ -2090,8 +2107,9 @@ instance DisambTD DataConBuilder where mkHsOpTyPV prom lhs tc rhs = do check_no_ops (unLoc rhs) -- check the RHS because parsing type operators is right-associative data_con <- eitherToP $ tyConToDataCon tc + !cs <- getCommentsFor (locA l) checkNotPromotedDataCon prom data_con - return $ L l (InfixDataConBuilder lhs data_con rhs) + return $ L (addCommentsToEpAnn l cs) (InfixDataConBuilder lhs data_con rhs) where l = combineLocsA lhs rhs check_no_ops (HsBangTy _ _ t) = check_no_ops (unLoc t) @@ -3212,8 +3230,8 @@ mkSumOrTuplePat l Boxed a at Sum{} _ = mkLHsOpTy :: PromotionFlag -> LHsType GhcPs -> LocatedN RdrName -> LHsType GhcPs -> LHsType GhcPs mkLHsOpTy prom x op y = - let loc = getLoc x `combineSrcSpansA` (noAnnSrcSpan $ getLocA op) `combineSrcSpansA` getLoc y - in L loc (mkHsOpTy prom x op y) + let loc = locA x `combineSrcSpans` locA op `combineSrcSpans` locA y + in L (noAnnSrcSpan loc) (mkHsOpTy prom x op y) mkMultTy :: EpToken "%" -> LHsType GhcPs -> EpUniToken "->" "→" -> HsArrow GhcPs mkMultTy pct t@(L _ (HsTyLit _ (HsNumTy (SourceText (unpackFS -> "1")) 1))) arr ===================================== docs/users_guide/exts/ffi.rst ===================================== @@ -998,7 +998,7 @@ the data. We can do it like this: sp <- newStablePtrPrimMVar mvar fp <- mallocForeignPtr withForeignPtr fp $ \presult -> do - cap <- threadCapability =<< myThreadId + (cap, _) <- threadCapability =<< myThreadId scheduleCallback sp cap presult takeMVar mvar `onException` forkIO (do takeMVar mvar; touchForeignPtr fp) ===================================== hadrian/src/Hadrian/Haskell/Cabal/Parse.hs ===================================== @@ -31,6 +31,7 @@ import qualified Distribution.PackageDescription.Parsec as C import qualified Distribution.Simple.Compiler as C import qualified Distribution.Simple.Program.Db as C import qualified Distribution.Simple as C +import qualified Distribution.Simple.GHC as GHC import qualified Distribution.Simple.Program.Builtin as C import qualified Distribution.Simple.Utils as C import qualified Distribution.Simple.Program.Types as C @@ -363,12 +364,11 @@ registerPackage rs context = do need [setupConfig] -- This triggers 'configurePackage' pd <- packageDescription <$> readContextData context db_path <- packageDbPath (PackageDbLoc (stage context) (iplace context)) - dist_dir <- Context.buildPath context pid <- pkgUnitId (stage context) (package context) -- Note: the @cPath@ is ignored. The path that's used is the 'buildDir' path -- from the local build info @lbi at . lbi <- liftIO $ C.getPersistBuildConfig cPath - liftIO $ register db_path pid dist_dir pd lbi + liftIO $ register db_path pid pd lbi -- Then after the register, which just writes the .conf file, do the recache step. buildWithResources rs $ target context (GhcPkg Recache (stage context)) [] [] @@ -377,25 +377,23 @@ registerPackage rs context = do -- into a different package database to the one it was configured against. register :: FilePath -> String -- ^ Package Identifier - -> FilePath -> C.PackageDescription -> LocalBuildInfo -> IO () -register pkg_db pid build_dir pd lbi +register pkg_db pid pd lbi = withLibLBI pd lbi $ \lib clbi -> do - absPackageDBs <- C.absolutePackageDBPaths packageDbs - installedPkgInfo <- C.generateRegistrationInfo - C.silent pd lib lbi clbi False reloc build_dir - (C.registrationPackageDB absPackageDBs) - + when reloc $ error "register does not support reloc" + installedPkgInfo <- generateRegistrationInfo pd lbi lib clbi writeRegistrationFile installedPkgInfo where regFile = pkg_db pid <.> "conf" reloc = relocatable lbi - -- Using a specific package db here is why we have to copy the function from Cabal. - packageDbs = [C.SpecificPackageDB pkg_db] + + generateRegistrationInfo pkg lbi lib clbi = do + abi_hash <- C.mkAbiHash <$> GHC.libAbiHash C.silent pkg lbi lib clbi + return (C.absoluteInstalledPackageInfo pkg abi_hash lib lbi clbi) writeRegistrationFile installedPkgInfo = do writeUTF8File regFile (CP.showInstalledPackageInfo installedPkgInfo) ===================================== libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc ===================================== @@ -399,14 +399,14 @@ data ParFlags = ParFlags -- | Parameters pertaining to Haskell program coverage (HPC) -- --- @since base-4.22.0.0 +-- @since base-4.20.0.0 data HpcFlags = HpcFlags { writeTixFile :: Bool -- ^ Controls whether the @.tix@ file should be -- written after the execution of the program. } - deriving (Show -- ^ @since base-4.22.0.0 - , Generic -- ^ @since base-4.22.0.0 + deriving (Show -- ^ @since base-4.20.0.0 + , Generic -- ^ @since base-4.20.0.0 ) -- | Parameters of the runtime system -- ===================================== libraries/ghc-internal/src/GHC/Internal/System/Environment.hs ===================================== @@ -225,6 +225,13 @@ ioe_missingEnvVar name = ioException (IOError Nothing NoSuchThing "getEnv" -- Throws `Control.Exception.IOException` if @name@ is the empty string or -- contains an equals sign. -- +-- Beware that this function must not be executed concurrently +-- with 'getEnv', 'lookupEnv', 'getEnvironment' and such. One thread +-- reading environment variables at the same time with another one modifying them +-- can result in a segfault, see +-- [Setenv is not Thread Safe](https://www.evanjones.ca/setenv-is-not-thread-safe.html) +-- for discussion. +-- -- @since base-4.7.0.0 setEnv :: String -> String -> IO () setEnv key_ value_ @@ -269,6 +276,13 @@ foreign import ccall unsafe "putenv" c_putenv :: CString -> IO CInt -- Throws `Control.Exception.IOException` if @name@ is the empty string or -- contains an equals sign. -- +-- Beware that this function must not be executed concurrently +-- with 'getEnv', 'lookupEnv', 'getEnvironment' and such. One thread +-- reading environment variables at the same time with another one modifying them +-- can result in a segfault, see +-- [Setenv is not Thread Safe](https://www.evanjones.ca/setenv-is-not-thread-safe.html) +-- for discussion. +-- -- @since base-4.7.0.0 unsetEnv :: String -> IO () #if defined(mingw32_HOST_OS) ===================================== libraries/ghc-internal/src/GHC/Internal/System/Environment/Blank.hsc ===================================== @@ -109,6 +109,13 @@ getEnvDefault name fallback = fromMaybe fallback <$> getEnv name -- | Like 'GHC.Internal.System.Environment.setEnv', but allows blank environment values -- and mimics the function signature of 'System.Posix.Env.setEnv' from the -- @unix@ package. +-- +-- Beware that this function must not be executed concurrently +-- with 'getEnv', 'lookupEnv', 'getEnvironment' and such. One thread +-- reading environment variables at the same time with another one modifying them +-- can result in a segfault, see +-- [Setenv is not Thread Safe](https://www.evanjones.ca/setenv-is-not-thread-safe.html) +-- for discussion. setEnv :: String {- ^ variable name -} -> String {- ^ variable value -} -> @@ -151,6 +158,13 @@ foreign import ccall unsafe "setenv" -- | Like 'GHC.Internal.System.Environment.unsetEnv', but allows for the removal of -- blank environment variables. May throw an exception if the underlying -- platform doesn't support unsetting of environment variables. +-- +-- Beware that this function must not be executed concurrently +-- with 'getEnv', 'lookupEnv', 'getEnvironment' and such. One thread +-- reading environment variables at the same time with another one modifying them +-- can result in a segfault, see +-- [Setenv is not Thread Safe](https://www.evanjones.ca/setenv-is-not-thread-safe.html) +-- for discussion. unsetEnv :: String -> IO () #if defined(mingw32_HOST_OS) unsetEnv key = withCWString key $ \k -> do ===================================== testsuite/tests/parser/should_compile/T20846.stderr ===================================== @@ -71,11 +71,7 @@ (L (EpAnn (EpaSpan { T20846.hs:4:1-6 }) - (NameAnn - (NameParens) - (EpaSpan { T20846.hs:4:1 }) - (EpaSpan { T20846.hs:4:2-5 }) - (EpaSpan { T20846.hs:4:6 }) + (NameAnnTrailing []) (EpaComments [])) ===================================== testsuite/tests/printer/Makefile ===================================== @@ -826,3 +826,33 @@ Test24533: PprLetIn: $(CHECK_PPR) $(LIBDIR) PprLetIn.hs $(CHECK_EXACT) $(LIBDIR) PprLetIn.hs + +.PHONY: CaseAltComments +CaseAltComments: + $(CHECK_PPR) $(LIBDIR) CaseAltComments.hs + $(CHECK_EXACT) $(LIBDIR) CaseAltComments.hs + +.PHONY: MatchPatComments +MatchPatComments: + $(CHECK_PPR) $(LIBDIR) MatchPatComments.hs + $(CHECK_EXACT) $(LIBDIR) MatchPatComments.hs + +.PHONY: Test24748 +Test24748: + $(CHECK_PPR) $(LIBDIR) Test24748.hs + $(CHECK_EXACT) $(LIBDIR) Test24748.hs + +.PHONY: Test24755 +Test24755: + $(CHECK_PPR) $(LIBDIR) Test24755.hs + $(CHECK_EXACT) $(LIBDIR) Test24755.hs + +.PHONY: Test24753 +Test24753: + $(CHECK_PPR) $(LIBDIR) Test24753.hs + $(CHECK_EXACT) $(LIBDIR) Test24753.hs + +.PHONY: Test24771 +Test24771: + $(CHECK_PPR) $(LIBDIR) Test24771.hs + $(CHECK_EXACT) $(LIBDIR) Test24771.hs ===================================== testsuite/tests/printer/MatchPatComments.hs ===================================== @@ -0,0 +1,16 @@ +module MatchPatComments where + +expandProcess + outCHAs -- c0 + locationDescr = + blah + +next + ( steps -- c1 + , ys -- c2 + ) x -- c3 + = (steps, x, ys) + +makeProjection + Function{funMutual = VV, -- c4 + funAbstr = ConcreteDef} = undefined ===================================== testsuite/tests/printer/PprExportWarn.hs ===================================== @@ -6,12 +6,12 @@ module PprExportWarning ( reallyreallyreallyreallyreallyreallyreallyreallylongname, {-# DEPRECATED "Just because" #-} Bar(Bar1, Bar2), {-# WARNING "Just because" #-} name, - {-# DEPRECATED ["Reason", - "Another reason"] #-} + {-# DEPRECATED ["Reason", + "Another reason"] #-} Baz, {-# DEPRECATED [ ] #-} module GHC, {-# WARNING "Dummy Pattern" #-} pattern Dummy, - Foo'(..), + Foo'(..), reallyreallyreallyreallyreallyreallyreallyreallylongname', Bar'(Bar1, Bar2), name', Baz', module Data.List, pattern Dummy' ) where ===================================== testsuite/tests/printer/PrefixConComment.hs ===================================== @@ -0,0 +1,4 @@ +module PrefixConComment where + +fun (Con {- c1 -} a {- c2 -} b {- c3 -}) + = undefined ===================================== testsuite/tests/printer/Test24748.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE LambdaCase #-} +module Test24748 where + +instance SDecide Nat where + SZero %~ (SSucc _) = Disproved (\case) + +foo = (\case) +bar = (\cases) ===================================== testsuite/tests/printer/Test24753.hs ===================================== @@ -0,0 +1,8 @@ +module Test24753 where + +type ErrorChoiceApi + = "path0" :> Get '[JSON] Int -- c0 + :<|> "path4" :> (ReqBody '[PlainText] Int :> Post '[PlainText] Int -- c4 + :<|> ReqBody '[PlainText] Int :> Post '[JSON] Int) -- c5 + :<|> "path5" :> (ReqBody '[JSON] Int :> Post '[PlainText] Int -- c6 + :<|> ReqBody '[PlainText] Int :> Post '[PlainText] Int) -- c7 ===================================== testsuite/tests/printer/Test24755.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeOperators #-} +module Test24755 where + +class + a -- c1 + :+ -- c2 + b -- c3 ===================================== testsuite/tests/printer/Test24771.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeOperators #-} +module Test24771 where + +data Foo + = Int -- c1 + :* -- c2 + String -- c3 ===================================== testsuite/tests/printer/all.T ===================================== @@ -198,3 +198,9 @@ test('ListTuplePuns', extra_files(['ListTuplePuns.hs']), ghci_script, ['ListTupl test('AnnotationNoListTuplePuns', [ignore_stderr, req_ppr_deps], makefile_test, ['AnnotationNoListTuplePuns']) test('Test24533', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24533']) test('PprLetIn', [ignore_stderr, req_ppr_deps], makefile_test, ['PprLetIn']) +test('CaseAltComments', [ignore_stderr, req_ppr_deps], makefile_test, ['CaseAltComments']) +test('MatchPatComments', [ignore_stderr, req_ppr_deps], makefile_test, ['MatchPatComments']) +test('Test24748', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24748']) +test('Test24755', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24755']) +test('Test24753', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24753']) +test('Test24771', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24771']) ===================================== testsuite/tests/simplCore/should_compile/T24726.hs ===================================== @@ -0,0 +1,26 @@ +{-# OPTIONS_GHC -drule-check concatMap #-} + -- This rule-check thing crashed #24726 + +module T24726 where + +data Stream a = forall s. Stream (s -> ()) s + +concatMapS :: (a -> Stream b) -> Stream a -> Stream b +concatMapS f (Stream next0 s0) = Stream undefined undefined +{-# INLINE [1] concatMapS #-} + +concatMapS' :: (s -> ()) -> (a -> s) -> Stream a -> Stream b +concatMapS' = undefined + +{-# RULES "concatMap" forall step f. concatMapS (\x -> Stream step (f x)) = concatMapS' step f #-} + +replicateStep :: a -> b +replicateStep _ = undefined +{-# INLINE replicateStep #-} + +replicateS :: Int -> a -> Stream a +replicateS n x0 = Stream replicateStep undefined +{-# INLINE replicateS #-} + +foo1 :: Stream Int -> Stream Int +foo1 = concatMapS (replicateS 2) ===================================== testsuite/tests/simplCore/should_compile/T24726.stderr ===================================== @@ -0,0 +1,36 @@ + +==================== Rule check ==================== +Rule check results: +-------------------- +Expression: concatMapS @(*) @Int @Int foo1 +Rule "concatMap": all arguments match (considered individually), but rule as a whole does not +-------------------- + + + +==================== Rule check ==================== +Rule check results: +-------------------- +Expression: concatMapS @(*) @Int @Int foo1 +Rule "concatMap": all arguments match (considered individually), but rule as a whole does not +-------------------- + + + +==================== Rule check ==================== +Rule check results: +-------------------- +Expression: concatMapS @(*) @Int @Int foo1 +Rule "concatMap": all arguments match (considered individually), but rule as a whole does not +-------------------- + + + +==================== Rule check ==================== +Rule check results: +-------------------- +Expression: concatMapS @(*) @Int @Int foo1 +Rule "concatMap": all arguments match (considered individually), but rule as a whole does not +-------------------- + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -515,3 +515,4 @@ test('T24229a', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typea test('T24229b', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques -dppr-cols=99999']) test('T24370', normal, compile, ['-O']) test('T24551', normal, compile, ['-O -dcore-lint']) +test('T24726', normal, compile, ['-dcore-lint -dsuppress-uniques']) ===================================== utils/check-exact/Main.hs ===================================== @@ -128,7 +128,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/ghc/_build/stage1/ -- "../../testsuite/tests/printer/Ppr034.hs" Nothing -- "../../testsuite/tests/printer/Ppr035.hs" Nothing -- "../../testsuite/tests/printer/Ppr036.hs" Nothing - "../../testsuite/tests/printer/Ppr037.hs" Nothing + "../../testsuite/tests/printer/MatchPatComments.hs" Nothing -- "../../testsuite/tests/printer/Ppr038.hs" Nothing -- "../../testsuite/tests/printer/Ppr039.hs" Nothing -- "../../testsuite/tests/printer/Ppr040.hs" Nothing @@ -319,8 +319,10 @@ testOneFile _ libdir fileName mchanger = do expectedSource <- readFile newFileExpected changedSource <- readFile newFileChanged return (expectedSource == changedSource, expectedSource, changedSource) - Nothing -> return (True, "", "") - + Nothing -> do + expectedSource <- readFile fileName + changedSource <- readFile newFile + return (expectedSource == changedSource, expectedSource, changedSource) (p',_) <- parseOneFile libdir newFile let newAstStr :: String View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ea3839f64bf5dfc8373734f18d766766b024c026...4b3314f59fa0f66ceface97e5e97668e5e59feaa -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ea3839f64bf5dfc8373734f18d766766b024c026...4b3314f59fa0f66ceface97e5e97668e5e59feaa You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 05:24:25 2024 From: gitlab at gitlab.haskell.org (Serge S. Gulin (@gulin.serge)) Date: Wed, 08 May 2024 01:24:25 -0400 Subject: [Git][ghc/ghc][wip/T24504] IPE: WIP: Replace closure_desc string representation in logs output on Word32 Message-ID: <663b0c89bdc03_37d0532b72308653@gitlab.mail> Serge S. Gulin pushed to branch wip/T24504 at Glasgow Haskell Compiler / GHC Commits: 97998bb6 by Serge S. Gulin at 2024-05-08T08:24:06+03:00 IPE: WIP: Replace closure_desc string representation in logs output on Word32 - - - - - 6 changed files: - rts/IPE.c - rts/Trace.c - rts/eventlog/EventLog.c - rts/include/rts/IPE.h - testsuite/tests/rts/ipe/ipeMap.c - testsuite/tests/rts/ipe/ipe_lib.c Changes: ===================================== rts/IPE.c ===================================== @@ -176,6 +176,10 @@ void registerInfoProvList(IpeBufferListNode *node) { } } +void formatClosureDescIpe(const InfoProvEnt *ipe_buf, const char *str_buf) { + sprintf((char*) str_buf, "closure_desc_%03u", ipe_buf->prov.closure_desc); +} + bool lookupIPE(const StgInfoTable *info, InfoProvEnt *out) { updateIpeMap(); IpeMapEntry *map_ent = (IpeMapEntry *) lookupHashTable(ipeMap, (StgWord)info); ===================================== rts/Trace.c ===================================== @@ -688,9 +688,12 @@ void traceIPE(const InfoProvEnt *ipe) if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) { ACQUIRE_LOCK(&trace_utx); + const char closure_desc_buf[256] = {}; + formatClosureDescIpe(ipe, closure_desc_buf); + tracePreface(); - debugBelch("IPE: table_name %s, closure_desc %d, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", - ipe->prov.table_name, ipe->prov.closure_desc, ipe->prov.ty_desc, + debugBelch("IPE: table_name %s, closure_desc %s, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", + ipe->prov.table_name, closure_desc_buf, ipe->prov.ty_desc, ipe->prov.label, ipe->prov.unit_id, ipe->prov.module, ipe->prov.src_file, ipe->prov.src_span); ===================================== rts/eventlog/EventLog.c ===================================== @@ -1441,11 +1441,14 @@ void postTickyCounterSamples(StgEntCounter *counters) #endif /* TICKY_TICKY */ void postIPE(const InfoProvEnt *ipe) { + const char closure_desc_buf[256] = {}; + formatClosureDescIpe(ipe, closure_desc_buf); + // See Note [Maximum event length]. const StgWord MAX_IPE_STRING_LEN = 65535; ACQUIRE_LOCK(&eventBufMutex); StgWord table_name_len = MIN(strlen(ipe->prov.table_name), MAX_IPE_STRING_LEN); - StgWord closure_desc_len = MIN(strlen(ipe->prov.closure_desc), MAX_IPE_STRING_LEN); + StgWord closure_desc_len = MIN(strlen(closure_desc_buf), MAX_IPE_STRING_LEN); StgWord ty_desc_len = MIN(strlen(ipe->prov.ty_desc), MAX_IPE_STRING_LEN); StgWord label_len = MIN(strlen(ipe->prov.label), MAX_IPE_STRING_LEN); StgWord module_len = MIN(strlen(ipe->prov.module), MAX_IPE_STRING_LEN); @@ -1462,7 +1465,7 @@ void postIPE(const InfoProvEnt *ipe) postPayloadSize(&eventBuf, len); postWord64(&eventBuf, (StgWord) INFO_PTR_TO_STRUCT(ipe->info)); postStringLen(&eventBuf, ipe->prov.table_name, table_name_len); - postStringLen(&eventBuf, ipe->prov.closure_desc, closure_desc_len); + postStringLen(&eventBuf, closure_desc_buf, closure_desc_len); postStringLen(&eventBuf, ipe->prov.ty_desc, ty_desc_len); postStringLen(&eventBuf, ipe->prov.label, label_len); postStringLen(&eventBuf, ipe->prov.module, module_len); ===================================== rts/include/rts/IPE.h ===================================== @@ -89,5 +89,9 @@ typedef struct IpeBufferListNode_ { void registerInfoProvList(IpeBufferListNode *node); +// We leave it in old format to keep compatibility with existing https://github.com/haskell/ghc-events +// See: https://github.com/haskell/ghc-events/commit/cce6a35677f5f99b44c21d86febd295b909ef1ce +void formatClosureDescIpe(const InfoProvEnt *ipe_buf, const char *str_buf); + // Returns true on success, initializes `out`. bool lookupIPE(const StgInfoTable *info, InfoProvEnt *out); ===================================== testsuite/tests/rts/ipe/ipeMap.c ===================================== @@ -68,10 +68,13 @@ HaskellObj shouldFindOneIfItHasBeenRegistered(Capability *cap) { registerInfoProvList(node); - InfoProvEnt result = lookupIPE_("shouldFindOneIfItHasBeenRegistered", get_itbl(fortyTwo)); + const InfoProvEnt result = lookupIPE_("shouldFindOneIfItHasBeenRegistered", get_itbl(fortyTwo)); + + const char closure_desc_buf[256] = {}; + formatClosureDescIpe(&result, closure_desc_buf); assertStringsEqual(result.prov.table_name, "table_name_042"); - assertStringsEqual(result.prov.closure_desc, "closure_desc_042"); + assertStringsEqual(closure_desc_buf, "closure_desc_042"); assertStringsEqual(result.prov.ty_desc, "ty_desc_042"); assertStringsEqual(result.prov.label, "label_042"); assertStringsEqual(result.prov.unit_id, "unit-id"); ===================================== testsuite/tests/rts/ipe/ipe_lib.c ===================================== @@ -33,10 +33,7 @@ IpeBufferEntry makeAnyProvEntry(Capability *cap, StringTable *st, int i) { snprintf(tableName, tableNameLength, "table_name_%03i", i); provEnt.table_name = add_string(st, tableName); - unsigned int closureDescLength = strlen("closure_desc_") + 3 /* digits */ + 1 /* null character */; - char *closureDesc = malloc(sizeof(char) * closureDescLength); - snprintf(closureDesc, closureDescLength, "closure_desc_%03i", i); - provEnt.closure_desc = add_string(st, closureDesc); + provEnt.closure_desc = i; unsigned int tyDescLength = strlen("ty_desc_") + 3 /* digits */ + 1 /* null character */; char *tyDesc = malloc(sizeof(char) * tyDescLength); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97998bb63996088251207247f10e5e3b15a7c62f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97998bb63996088251207247f10e5e3b15a7c62f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 06:10:02 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 08 May 2024 02:10:02 -0400 Subject: [Git][ghc/ghc][wip/ghc-9.10] 15 commits: Add missing entries in the base-4.20 release notes Message-ID: <663b173ae764d_37d0537f968013147@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: 2c6375b9 by Hécate Moonlight at 2024-05-01T01:44:10+02:00 Add missing entries in the base-4.20 release notes - - - - - b8c66bf3 by Rodrigo Mesquita at 2024-05-08T02:08:37-04:00 bindist: Fix xattr cleaning The original fix (725343aa) was incorrect because it used the shell bracket syntax which is the quoting syntax in autoconf, making the test for existence be incorrect and therefore `xattr` was never run. Fixes #24554 (cherry picked from commit e03760db6713068ad8ba953d2252ec12b3278c9b) - - - - - 250c5df7 by Ben Gamari at 2024-05-08T02:08:37-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - 7b327164 by Alan Zimmerman at 2024-05-08T02:08:37-04:00 EPA: check-exact: check that the roundtrip reproduces the source Closes #24670 (cherry picked from commit 981c2c2c5017cb7ae47babff4d2163324d7cbde6) - - - - - a8c27c7c by Alan Zimmerman at 2024-05-08T02:09:14-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 (cherry picked from commit 1c2fd963d6fd78d1c752a21348c7db85f5d64df2) - - - - - e8603c75 by Alan Zimmerman at 2024-05-08T02:09:27-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 (cherry picked from commit 40026ac30fcdbe84a551f445f5e20691c0527ded) - - - - - 015a0430 by Alan Zimmerman at 2024-05-08T02:09:27-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 (cherry picked from commit 167a56a003106ed84742e3970cc2189ffb98b0c7) - - - - - c5a65a7f by Alan Zimmerman at 2024-05-08T02:09:27-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 (cherry picked from commit 35d34fde62cd9e0002ac42f10bf705552f5c654e) - - - - - 43a7dc68 by Alan Zimmerman at 2024-05-08T02:09:27-04:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 (cherry picked from commit 18f4ff84b323236f6dfd07f3bbc2842308a01e91) - - - - - 01eeecec by Alan Zimmerman at 2024-05-08T02:09:27-04:00 EPA: preserve comments in data decls Closes #24771 (cherry picked from commit 46328a49d988143111ab530d7907b9426b58311a) - - - - - 2c7a0cf7 by Simon Peyton Jones at 2024-05-08T02:09:27-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! (cherry picked from commit be1e60eec0ec37da41643af17d78c698ab2a7083) - - - - - 4896c50b by Andrew Lelechenko at 2024-05-08T02:09:27-04:00 Document that setEnv is not thread-safe (cherry picked from commit a86167471a7a471fb75ae9ba6c641bd1e74bc16d) - - - - - 843f95b1 by Matthew Pickering at 2024-05-08T02:09:27-04:00 Don't depend on registerPackage function in Cabal More recent versions of Cabal modify the behaviour of libAbiHash which breaks our usage of registerPackage. It is simpler to inline the part of registerPackage that we need and avoid any additional dependency and complication using the higher-level function introduces. (cherry picked from commit 3fff09779d5830549ae455a15907b7bb9fe7859a) - - - - - 720ff1f9 by Hécate Moonlight at 2024-05-08T02:09:27-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 (cherry picked from commit 9213478931b18402998c18f5c4e6f0ee09054b18) - - - - - 7f9b05a8 by Teo Camarasu at 2024-05-08T02:09:27-04:00 doc: Fix type error in hs_try_putmvar example (cherry picked from commit 06f7db4001e4eee0f3076d949876f8f4af0eb6fb) - - - - - 26 changed files: - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - compiler/GHC/Core/Rules.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - distrib/configure.ac.in - docs/users_guide/9.10.1-notes.rst - docs/users_guide/exts/ffi.rst - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc - libraries/ghc-internal/src/GHC/Internal/System/Environment.hs - libraries/ghc-internal/src/GHC/Internal/System/Environment/Blank.hsc - testsuite/tests/parser/should_compile/T20846.stderr - testsuite/tests/printer/Makefile - + testsuite/tests/printer/MatchPatComments.hs - testsuite/tests/printer/PprExportWarn.hs - + testsuite/tests/printer/PrefixConComment.hs - + testsuite/tests/printer/Test24748.hs - + testsuite/tests/printer/Test24753.hs - + testsuite/tests/printer/Test24755.hs - + testsuite/tests/printer/Test24771.hs - testsuite/tests/printer/all.T - + testsuite/tests/simplCore/should_compile/T24726.hs - + testsuite/tests/simplCore/should_compile/T24726.stderr - testsuite/tests/simplCore/should_compile/all.T - utils/check-exact/Main.hs Changes: ===================================== .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py ===================================== @@ -65,7 +65,6 @@ eprint(f"Supported platforms: {job_mapping.keys()}") class Artifact(NamedTuple): job_name: str download_name: str - output_name: str subdir: str # Platform spec provides a specification which is agnostic to Job @@ -75,11 +74,9 @@ class PlatformSpec(NamedTuple): subdir: str source_artifact = Artifact('source-tarball' - , 'ghc-{version}-src.tar.xz' , 'ghc-{version}-src.tar.xz' , 'ghc-{version}' ) test_artifact = Artifact('source-tarball' - , 'ghc-{version}-testsuite.tar.xz' , 'ghc-{version}-testsuite.tar.xz' , 'ghc-{version}/testsuite' ) @@ -164,11 +161,6 @@ def mk_one_metadata(release_mode, version, job_map, artifact): , "dlSubdir": artifact.subdir.format(version=version) , "dlHash" : h } - # Only add dlOutput if it is inconsistent with the filename inferred from the URL - output = artifact.output_name.format(version=version) - if Path(urlparse(final_url).path).name != output: - res["dlOutput"] = output - eprint(res) return res ===================================== compiler/GHC/Core/Rules.hs ===================================== @@ -47,7 +47,7 @@ import GHC.Driver.Ppr( showSDoc ) import GHC.Core -- All of it import GHC.Core.Subst import GHC.Core.SimpleOpt ( exprIsLambda_maybe ) -import GHC.Core.FVs ( exprFreeVars, exprsFreeVars, bindFreeVars +import GHC.Core.FVs ( exprFreeVars, bindFreeVars , rulesFreeVarsDSet, exprsOrphNames ) import GHC.Core.Utils ( exprType, mkTick, mkTicks , stripTicksTopT, stripTicksTopE @@ -1887,41 +1887,59 @@ ruleCheckProgram ropts phase rule_pat rules binds vcat [ p $$ line | p <- bagToList results ] ] where + line = text (replicate 20 '-') env = RuleCheckEnv { rc_is_active = isActive phase , rc_id_unf = idUnfolding -- Not quite right -- Should use activeUnfolding , rc_pattern = rule_pat , rc_rules = rules , rc_ropts = ropts - } - results = unionManyBags (map (ruleCheckBind env) binds) - line = text (replicate 20 '-') + , rc_in_scope = emptyInScopeSet } + + results = go env binds + + go _ [] = emptyBag + go env (bind:binds) = let (env', ds) = ruleCheckBind env bind + in ds `unionBags` go env' binds + +data RuleCheckEnv = RuleCheckEnv + { rc_is_active :: Activation -> Bool + , rc_id_unf :: IdUnfoldingFun + , rc_pattern :: String + , rc_rules :: Id -> [CoreRule] + , rc_ropts :: RuleOpts + , rc_in_scope :: InScopeSet } + +extendInScopeRC :: RuleCheckEnv -> Var -> RuleCheckEnv +extendInScopeRC env@(RuleCheckEnv { rc_in_scope = in_scope }) v + = env { rc_in_scope = in_scope `extendInScopeSet` v } -data RuleCheckEnv = RuleCheckEnv { - rc_is_active :: Activation -> Bool, - rc_id_unf :: IdUnfoldingFun, - rc_pattern :: String, - rc_rules :: Id -> [CoreRule], - rc_ropts :: RuleOpts -} +extendInScopeListRC :: RuleCheckEnv -> [Var] -> RuleCheckEnv +extendInScopeListRC env@(RuleCheckEnv { rc_in_scope = in_scope }) vs + = env { rc_in_scope = in_scope `extendInScopeSetList` vs } -ruleCheckBind :: RuleCheckEnv -> CoreBind -> Bag SDoc +ruleCheckBind :: RuleCheckEnv -> CoreBind -> (RuleCheckEnv, Bag SDoc) -- The Bag returned has one SDoc for each call site found -ruleCheckBind env (NonRec _ r) = ruleCheck env r -ruleCheckBind env (Rec prs) = unionManyBags [ruleCheck env r | (_,r) <- prs] +ruleCheckBind env (NonRec b r) = (env `extendInScopeRC` b, ruleCheck env r) +ruleCheckBind env (Rec prs) = (env', unionManyBags (map (ruleCheck env') rhss)) + where + (bs, rhss) = unzip prs + env' = env `extendInScopeListRC` bs ruleCheck :: RuleCheckEnv -> CoreExpr -> Bag SDoc -ruleCheck _ (Var _) = emptyBag -ruleCheck _ (Lit _) = emptyBag -ruleCheck _ (Type _) = emptyBag -ruleCheck _ (Coercion _) = emptyBag -ruleCheck env (App f a) = ruleCheckApp env (App f a) [] -ruleCheck env (Tick _ e) = ruleCheck env e -ruleCheck env (Cast e _) = ruleCheck env e -ruleCheck env (Let bd e) = ruleCheckBind env bd `unionBags` ruleCheck env e -ruleCheck env (Lam _ e) = ruleCheck env e -ruleCheck env (Case e _ _ as) = ruleCheck env e `unionBags` - unionManyBags [ruleCheck env r | Alt _ _ r <- as] +ruleCheck _ (Var _) = emptyBag +ruleCheck _ (Lit _) = emptyBag +ruleCheck _ (Type _) = emptyBag +ruleCheck _ (Coercion _) = emptyBag +ruleCheck env (App f a) = ruleCheckApp env (App f a) [] +ruleCheck env (Tick _ e) = ruleCheck env e +ruleCheck env (Cast e _) = ruleCheck env e +ruleCheck env (Let bd e) = let (env', ds) = ruleCheckBind env bd + in ds `unionBags` ruleCheck env' e +ruleCheck env (Lam b e) = ruleCheck (env `extendInScopeRC` b) e +ruleCheck env (Case e b _ as) = ruleCheck env e `unionBags` + unionManyBags [ruleCheck (env `extendInScopeListRC` (b:bs)) r + | Alt _ bs r <- as] ruleCheckApp :: RuleCheckEnv -> Expr CoreBndr -> [Arg CoreBndr] -> Bag SDoc ruleCheckApp env (App f a) as = ruleCheck env a `unionBags` ruleCheckApp env f (a:as) @@ -1945,8 +1963,9 @@ ruleAppCheck_help env fn args rules vcat [text "Expression:" <+> ppr (mkApps (Var fn) args), vcat (map check_rule rules)] where - n_args = length args - i_args = args `zip` [1::Int ..] + in_scope = rc_in_scope env + n_args = length args + i_args = args `zip` [1::Int ..] rough_args = map roughTopName args check_rule rule = rule_herald rule <> colon <+> rule_info (rc_ropts env) rule @@ -1976,10 +1995,8 @@ ruleAppCheck_help env fn args rules mismatches = [i | (rule_arg, (arg,i)) <- rule_args `zip` i_args, not (isJust (match_fn rule_arg arg))] - lhs_fvs = exprsFreeVars rule_args -- Includes template tyvars match_fn rule_arg arg = match renv emptyRuleSubst rule_arg arg MRefl where - in_scope = mkInScopeSet (lhs_fvs `unionVarSet` exprFreeVars arg) renv = RV { rv_lcl = mkRnEnv2 in_scope , rv_tmpls = mkVarSet rule_bndrs , rv_fltR = mkEmptySubst in_scope ===================================== compiler/GHC/Parser.y ===================================== @@ -2486,9 +2486,8 @@ forall :: { Located ([AddEpAnn], Maybe [LHsTyVarBndr Specificity GhcPs]) } | {- empty -} { noLoc ([], Nothing) } constr_stuff :: { Located (LocatedN RdrName, HsConDeclH98Details GhcPs) } - : infixtype {% fmap (reLoc. (fmap (\b -> (dataConBuilderCon b, - dataConBuilderDetails b)))) - (runPV $1) } + : infixtype {% do { b <- runPV $1 + ; return (sL1 b (dataConBuilderCon b, dataConBuilderDetails b)) }} | '(#' usum_constr '#)' {% let (t, tag, arity) = $2 in pure (sLL $1 $3 $ mkUnboxedSumCon t tag arity)} usum_constr :: { (LHsType GhcPs, Int, Int) } -- constructor for the data decls SumN# @@ -2900,10 +2899,10 @@ aexp :: { ECP } [mj AnnLam $1] } | '\\' 'lcase' altslist(pats1) { ECP $ $3 >>= \ $3 -> - mkHsLamPV (comb2 $1 $>) LamCase $3 [mj AnnLam $1,mj AnnCase $2] } + mkHsLamPV (comb3 $1 $2 $>) LamCase $3 [mj AnnLam $1,mj AnnCase $2] } | '\\' 'lcases' altslist(argpats) { ECP $ $3 >>= \ $3 -> - mkHsLamPV (comb2 $1 $>) LamCases $3 [mj AnnLam $1,mj AnnCases $2] } + mkHsLamPV (comb3 $1 $2 $>) LamCases $3 [mj AnnLam $1,mj AnnCases $2] } | 'if' exp optSemi 'then' exp optSemi 'else' exp {% runPV (unECP $2) >>= \ ($2 :: LHsExpr GhcPs) -> return $ ECP $ ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -1244,7 +1244,7 @@ transferAnnsOnlyA (EpAnn a an cs) (EpAnn a' an' cs') -- | Transfer comments from the annotations in the -- first 'SrcSpanAnnA' argument to those in the second. -transferCommentsOnlyA :: SrcSpanAnnA -> SrcSpanAnnA -> (SrcSpanAnnA, SrcSpanAnnA) +transferCommentsOnlyA :: EpAnn a -> EpAnn b -> (EpAnn a, EpAnn b) transferCommentsOnlyA (EpAnn a an cs) (EpAnn a' an' cs') = (EpAnn a an emptyComments, EpAnn a' an' (cs <> cs')) ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -205,11 +205,11 @@ mkClassDecl :: SrcSpan -> P (LTyClDecl GhcPs) mkClassDecl loc' (L _ (mcxt, tycl_hdr)) fds where_cls layout annsIn - = do { let loc = noAnnSrcSpan loc' - ; (binds, sigs, ats, at_defs, _, docs) <- cvBindsAndSigs where_cls - ; (cls, tparams, fixity, ann) <- checkTyClHdr True tycl_hdr + = do { (binds, sigs, ats, at_defs, _, docs) <- cvBindsAndSigs where_cls + ; (cls, tparams, fixity, ann, cs) <- checkTyClHdr True tycl_hdr ; tyvars <- checkTyVars (text "class") whereDots cls tparams ; let anns' = annsIn Semi.<> ann + ; let loc = EpAnn (spanAsAnchor loc') noAnn cs ; return (L loc (ClassDecl { tcdCExt = (anns', layout, NoAnnSortKey) , tcdCtxt = mcxt , tcdLName = cls, tcdTyVars = tyvars @@ -232,12 +232,13 @@ mkTyData :: SrcSpan -> P (LTyClDecl GhcPs) mkTyData loc' is_type_data new_or_data cType (L _ (mcxt, tycl_hdr)) ksig data_cons (L _ maybe_deriv) annsIn - = do { let loc = noAnnSrcSpan loc' - ; (tc, tparams, fixity, ann) <- checkTyClHdr False tycl_hdr + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False tycl_hdr ; tyvars <- checkTyVars (ppr new_or_data) equalsDots tc tparams ; let anns' = annsIn Semi.<> ann - ; data_cons <- checkNewOrData (locA loc) (unLoc tc) is_type_data new_or_data data_cons + ; data_cons <- checkNewOrData loc' (unLoc tc) is_type_data new_or_data data_cons ; defn <- mkDataDefn cType mcxt ksig data_cons maybe_deriv + ; !cs' <- getCommentsFor loc' + ; let loc = EpAnn (spanAsAnchor loc') noAnn (cs' Semi.<> cs) ; return (L loc (DataDecl { tcdDExt = anns', tcdLName = tc, tcdTyVars = tyvars, tcdFixity = fixity, @@ -264,14 +265,14 @@ mkTySynonym :: SrcSpan -> [AddEpAnn] -> P (LTyClDecl GhcPs) mkTySynonym loc lhs rhs annsIn - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs ; tyvars <- checkTyVars (text "type") equalsDots tc tparams ; let anns' = annsIn Semi.<> ann - ; return (L (noAnnSrcSpan loc) (SynDecl - { tcdSExt = anns' - , tcdLName = tc, tcdTyVars = tyvars - , tcdFixity = fixity - , tcdRhs = rhs })) } + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (SynDecl { tcdSExt = anns' + , tcdLName = tc, tcdTyVars = tyvars + , tcdFixity = fixity + , tcdRhs = rhs })) } mkStandaloneKindSig :: SrcSpan @@ -304,8 +305,9 @@ mkTyFamInstEqn :: SrcSpan -> [AddEpAnn] -> P (LTyFamInstEqn GhcPs) mkTyFamInstEqn loc bndrs lhs rhs anns - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs - ; return (L (noAnnSrcSpan loc) $ FamEqn + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' $ FamEqn { feqn_ext = anns `mappend` ann , feqn_tycon = tc , feqn_bndrs = bndrs @@ -325,10 +327,11 @@ mkDataFamInst :: SrcSpan -> P (LInstDecl GhcPs) mkDataFamInst loc new_or_data cType (mcxt, bndrs, tycl_hdr) ksig data_cons (L _ maybe_deriv) anns - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False tycl_hdr + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False tycl_hdr ; data_cons <- checkNewOrData loc (unLoc tc) False new_or_data data_cons ; defn <- mkDataDefn cType mcxt ksig data_cons maybe_deriv - ; return (L (noAnnSrcSpan loc) (DataFamInstD noExtField (DataFamInstDecl + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (DataFamInstD noExtField (DataFamInstDecl (FamEqn { feqn_ext = ann Semi.<> anns , feqn_tycon = tc , feqn_bndrs = bndrs @@ -369,10 +372,10 @@ mkFamDecl :: SrcSpan -> [AddEpAnn] -> P (LTyClDecl GhcPs) mkFamDecl loc info topLevel lhs ksig injAnn annsIn - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs ; tyvars <- checkTyVars (ppr info) equals_or_where tc tparams - ; return (L (noAnnSrcSpan loc) (FamDecl noExtField - (FamilyDecl + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (FamDecl noExtField (FamilyDecl { fdExt = annsIn Semi.<> ann , fdTopLevel = topLevel , fdInfo = info, fdLName = tc @@ -1041,45 +1044,46 @@ checkTyClHdr :: Bool -- True <=> class header -> P (LocatedN RdrName, -- the head symbol (type or class name) [LHsTypeArg GhcPs], -- parameters of head symbol LexicalFixity, -- the declaration is in infix format - [AddEpAnn]) -- API Annotation for HsParTy + [AddEpAnn], -- API Annotation for HsParTy -- when stripping parens + EpAnnComments) -- Accumulated comments from re-arranging -- Well-formedness check and decomposition of type and class heads. -- Decomposes T ty1 .. tyn into (T, [ty1, ..., tyn]) -- Int :*: Bool into (:*:, [Int, Bool]) -- returning the pieces checkTyClHdr is_cls ty - = goL ty [] [] [] Prefix + = goL emptyComments ty [] [] [] Prefix where - goL (L l ty) acc ops cps fix = go l ty acc ops cps fix + goL cs (L l ty) acc ops cps fix = go cs l ty acc ops cps fix -- workaround to define '*' despite StarIsType - go ll (HsParTy an (L l (HsStarTy _ isUni))) acc ops' cps' fix + go cs ll (HsParTy an (L l (HsStarTy _ isUni))) acc ops' cps' fix = do { addPsMessage (locA l) PsWarnStarBinder ; let name = mkOccNameFS tcClsName (starSym isUni) ; let a' = newAnns ll l an ; return (L a' (Unqual name), acc, fix - , (reverse ops') ++ cps') } + , (reverse ops') ++ cps', cs) } - go _ (HsTyVar _ _ ltc@(L _ tc)) acc ops cps fix - | isRdrTc tc = return (ltc, acc, fix, (reverse ops) ++ cps) - go _ (HsOpTy _ _ t1 ltc@(L _ tc) t2) acc ops cps _fix - | isRdrTc tc = return (ltc, lhs:rhs:acc, Infix, (reverse ops) ++ cps) + go cs l (HsTyVar _ _ ltc@(L _ tc)) acc ops cps fix + | isRdrTc tc = return (ltc, acc, fix, (reverse ops) ++ cps, cs Semi.<> comments l) + go cs l (HsOpTy _ _ t1 ltc@(L _ tc) t2) acc ops cps _fix + | isRdrTc tc = return (ltc, lhs:rhs:acc, Infix, (reverse ops) ++ cps, cs Semi.<> comments l) where lhs = HsValArg noExtField t1 rhs = HsValArg noExtField t2 - go l (HsParTy _ ty) acc ops cps fix = goL ty acc (o:ops) (c:cps) fix + go cs l (HsParTy _ ty) acc ops cps fix = goL (cs Semi.<> comments l) ty acc (o:ops) (c:cps) fix where (o,c) = mkParensEpAnn (realSrcSpan (locA l)) - go _ (HsAppTy _ t1 t2) acc ops cps fix = goL t1 (HsValArg noExtField t2:acc) ops cps fix - go _ (HsAppKindTy at ty ki) acc ops cps fix = goL ty (HsTypeArg at ki:acc) ops cps fix - go l (HsTupleTy _ HsBoxedOrConstraintTuple ts) [] ops cps fix + go cs l (HsAppTy _ t1 t2) acc ops cps fix = goL (cs Semi.<> comments l) t1 (HsValArg noExtField t2:acc) ops cps fix + go cs l (HsAppKindTy at ty ki) acc ops cps fix = goL (cs Semi.<> comments l) ty (HsTypeArg at ki:acc) ops cps fix + go cs l (HsTupleTy _ HsBoxedOrConstraintTuple ts) [] ops cps fix = return (L (l2l l) (nameRdrName tup_name) - , map (HsValArg noExtField) ts, fix, (reverse ops)++cps) + , map (HsValArg noExtField) ts, fix, (reverse ops)++cps, cs Semi.<> comments l) where arity = length ts tup_name | is_cls = cTupleTyConName arity | otherwise = getName (tupleTyCon Boxed arity) -- See Note [Unit tuples] in GHC.Hs.Type (TODO: is this still relevant?) - go l _ _ _ _ _ + go _ l _ _ _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope (locA l) $ (PsErrMalformedTyOrClDecl ty) @@ -1211,33 +1215,34 @@ checkPattern_details :: ParseContext -> PV (LocatedA (PatBuilder GhcPs)) -> P (L checkPattern_details extraDetails pp = runPV_details extraDetails (pp >>= checkLPat) checkLArgPat :: LocatedA (ArgPatBuilder GhcPs) -> PV (LPat GhcPs) -checkLArgPat (L l (ArgPatBuilderVisPat p)) - = checkPat l (L l p) [] [] +checkLArgPat (L l (ArgPatBuilderVisPat p)) = checkLPat (L l p) checkLArgPat (L l (ArgPatBuilderArgPat p)) = return (L l p) checkLPat :: LocatedA (PatBuilder GhcPs) -> PV (LPat GhcPs) -checkLPat e@(L l _) = checkPat l e [] [] - -checkPat :: SrcSpanAnnA -> LocatedA (PatBuilder GhcPs) -> [HsConPatTyArg GhcPs] -> [LPat GhcPs] - -> PV (LPat GhcPs) -checkPat loc (L l e@(PatBuilderVar (L ln c))) tyargs args - | isRdrDataCon c = return . L loc $ ConPat +checkLPat (L l@(EpAnn anc an _) p) = do + (L l' p', cs) <- checkPat (EpAnn anc an emptyComments) emptyComments (L l p) [] [] + return (L (addCommentsToEpAnn l' cs) p') + +checkPat :: SrcSpanAnnA -> EpAnnComments -> LocatedA (PatBuilder GhcPs) -> [HsConPatTyArg GhcPs] -> [LPat GhcPs] + -> PV (LPat GhcPs, EpAnnComments) +checkPat loc cs (L l e@(PatBuilderVar (L ln c))) tyargs args + | isRdrDataCon c = return (L loc $ ConPat { pat_con_ext = noAnn -- AZ: where should this come from? , pat_con = L ln c , pat_args = PrefixCon tyargs args - } + }, comments l Semi.<> cs) | (not (null args) && patIsRec c) = do ctx <- askParseContext patFail (locA l) . PsErrInPat e $ PEIP_RecPattern args YesPatIsRecursive ctx -checkPat loc (L _ (PatBuilderAppType f at t)) tyargs args = - checkPat loc f (HsConPatTyArg at t : tyargs) args -checkPat loc (L _ (PatBuilderApp f e)) [] args = do +checkPat loc cs (L la (PatBuilderAppType f at t)) tyargs args = + checkPat loc (cs Semi.<> comments la) f (HsConPatTyArg at t : tyargs) args +checkPat loc cs (L la (PatBuilderApp f e)) [] args = do p <- checkLPat e - checkPat loc f [] (p : args) -checkPat loc (L l e) [] [] = do + checkPat loc (cs Semi.<> comments la) f [] (p : args) +checkPat loc cs (L l e) [] [] = do p <- checkAPat loc e - return (L l p) -checkPat loc e _ _ = do + return (L l p, cs) +checkPat loc _ e _ _ = do details <- fromParseContext <$> askParseContext patFail (locA loc) (PsErrInPat (unLoc e) details) @@ -1346,13 +1351,13 @@ checkFunBind :: SrcStrictness -> [LocatedA (ArgPatBuilder GhcPs)] -> Located (GRHSs GhcPs (LHsExpr GhcPs)) -> P (HsBind GhcPs) -checkFunBind strictness locF ann fun is_infix pats (L _ grhss) +checkFunBind strictness locF ann (L lf fun) is_infix pats (L _ grhss) = do ps <- runPV_details extraDetails (mapM checkLArgPat pats) let match_span = noAnnSrcSpan $ locF - return (makeFunBind fun (L (noAnnSrcSpan $ locA match_span) + return (makeFunBind (L (l2l lf) fun) (L (noAnnSrcSpan $ locA match_span) [L match_span (Match { m_ext = ann , m_ctxt = FunRhs - { mc_fun = fun + { mc_fun = L lf fun , mc_fixity = is_infix , mc_strictness = strictness } , m_pats = ps @@ -1361,7 +1366,7 @@ checkFunBind strictness locF ann fun is_infix pats (L _ grhss) -- That isn't quite right, but it'll do for now. where extraDetails - | Infix <- is_infix = ParseContext (Just $ unLoc fun) NoIncompleteDoBlock + | Infix <- is_infix = ParseContext (Just fun) NoIncompleteDoBlock | otherwise = noParseContext makeFunBind :: LocatedN RdrName -> LocatedL [LMatch GhcPs (LHsExpr GhcPs)] @@ -1433,20 +1438,27 @@ isFunLhs e = go e [] [] [] where mk = fmap ArgPatBuilderVisPat - go (L _ (PatBuilderVar (L loc f))) es ops cps - | not (isRdrDataCon f) = return (Just (L loc f, Prefix, es, (reverse ops) ++ cps)) - go (L _ (PatBuilderApp f e)) es ops cps = go f (mk e:es) ops cps - go (L l (PatBuilderPar _ e _)) es@(_:_) ops cps = go e es (o:ops) (c:cps) + go (L l (PatBuilderVar (L loc f))) es ops cps + | not (isRdrDataCon f) = do + let (_l, loc') = transferCommentsOnlyA l loc + return (Just (L loc' f, Prefix, es, (reverse ops) ++ cps)) + go (L l (PatBuilderApp (L lf f) e)) es ops cps = do + let (_l, lf') = transferCommentsOnlyA l lf + go (L lf' f) (mk e:es) ops cps + go (L l (PatBuilderPar _ (L le e) _)) es@(_:_) ops cps = go (L le' e) es (o:ops) (c:cps) -- NB: es@(_:_) means that there must be an arg after the parens for the -- LHS to be a function LHS. This corresponds to the Haskell Report's definition -- of funlhs. where + (_l, le') = transferCommentsOnlyA l le (o,c) = mkParensEpAnn (realSrcSpan $ locA l) - go (L loc (PatBuilderOpApp l (L loc' op) r anns)) es ops cps + go (L loc (PatBuilderOpApp (L ll l) (L loc' op) r anns)) es ops cps | not (isRdrDataCon op) -- We have found the function! - = return (Just (L loc' op, Infix, (mk l:mk r:es), (anns ++ reverse ops ++ cps))) + = do { let (_l, ll') = transferCommentsOnlyA loc ll + ; return (Just (L loc' op, Infix, (mk (L ll' l):mk r:es), (anns ++ reverse ops ++ cps))) } | otherwise -- Infix data con; keep going - = do { mb_l <- go l es ops cps + = do { let (_l, ll') = transferCommentsOnlyA loc ll + ; mb_l <- go (L ll' l) es ops cps ; return (reassociate =<< mb_l) } where reassociate (op', Infix, j : L k_loc (ArgPatBuilderVisPat k) : es', anns') @@ -1455,12 +1467,13 @@ isFunLhs e = go e [] [] [] op_app = mk $ L loc (PatBuilderOpApp (L k_loc k) (L loc' op) r (reverse ops ++ cps)) reassociate _other = Nothing - go (L _ (PatBuilderAppType pat tok ty_pat@(HsTP _ (L (EpAnn anc ann cs) _)))) es ops cps - = go pat (L (EpAnn anc' ann cs) (ArgPatBuilderArgPat invis_pat) : es) ops cps + go (L l (PatBuilderAppType (L lp pat) tok ty_pat@(HsTP _ (L (EpAnn anc ann cs) _)))) es ops cps + = go (L lp' pat) (L (EpAnn anc' ann cs) (ArgPatBuilderArgPat invis_pat) : es) ops cps where invis_pat = InvisPat tok ty_pat anc' = case tok of NoEpTok -> anc EpTok l -> widenAnchor anc [AddEpAnn AnnAnyclass l] + (_l, lp') = transferCommentsOnlyA l lp go _ _ _ _ = return Nothing data ArgPatBuilder p @@ -2048,28 +2061,32 @@ instance DisambTD (HsType GhcPs) where mkHsAppTyHeadPV = return mkHsAppTyPV t1 t2 = return (mkHsAppTy t1 t2) mkHsAppKindTyPV t at ki = return (mkHsAppKindTy at t ki) - mkHsOpTyPV prom t1 op t2 = return (mkLHsOpTy prom t1 op t2) + mkHsOpTyPV prom t1 op t2 = do + let (L l ty) = mkLHsOpTy prom t1 op t2 + !cs <- getCommentsFor (locA l) + return (L (addCommentsToEpAnn l cs) ty) mkUnpackednessPV = addUnpackednessP -dataConBuilderCon :: DataConBuilder -> LocatedN RdrName -dataConBuilderCon (PrefixDataConBuilder _ dc) = dc -dataConBuilderCon (InfixDataConBuilder _ dc _) = dc +dataConBuilderCon :: LocatedA DataConBuilder -> LocatedN RdrName +dataConBuilderCon (L _ (PrefixDataConBuilder _ dc)) = dc +dataConBuilderCon (L _ (InfixDataConBuilder _ dc _)) = dc -dataConBuilderDetails :: DataConBuilder -> HsConDeclH98Details GhcPs +dataConBuilderDetails :: LocatedA DataConBuilder -> HsConDeclH98Details GhcPs -- Detect when the record syntax is used: -- data T = MkT { ... } -dataConBuilderDetails (PrefixDataConBuilder flds _) +dataConBuilderDetails (L _ (PrefixDataConBuilder flds _)) | [L (EpAnn anc _ cs) (HsRecTy an fields)] <- toList flds = RecCon (L (EpAnn anc an cs) fields) -- Normal prefix constructor, e.g. data T = MkT A B C -dataConBuilderDetails (PrefixDataConBuilder flds _) +dataConBuilderDetails (L _ (PrefixDataConBuilder flds _)) = PrefixCon noTypeArgs (map hsLinear (toList flds)) -- Infix constructor, e.g. data T = Int :! Bool -dataConBuilderDetails (InfixDataConBuilder lhs _ rhs) - = InfixCon (hsLinear lhs) (hsLinear rhs) +dataConBuilderDetails (L (EpAnn _ _ csl) (InfixDataConBuilder (L (EpAnn anc ann csll) lhs) _ rhs)) + = InfixCon (hsLinear (L (EpAnn anc ann (csl Semi.<> csll)) lhs)) (hsLinear rhs) + instance DisambTD DataConBuilder where mkHsAppTyHeadPV = tyToDataConBuilder @@ -2090,8 +2107,9 @@ instance DisambTD DataConBuilder where mkHsOpTyPV prom lhs tc rhs = do check_no_ops (unLoc rhs) -- check the RHS because parsing type operators is right-associative data_con <- eitherToP $ tyConToDataCon tc + !cs <- getCommentsFor (locA l) checkNotPromotedDataCon prom data_con - return $ L l (InfixDataConBuilder lhs data_con rhs) + return $ L (addCommentsToEpAnn l cs) (InfixDataConBuilder lhs data_con rhs) where l = combineLocsA lhs rhs check_no_ops (HsBangTy _ _ t) = check_no_ops (unLoc t) @@ -3212,8 +3230,8 @@ mkSumOrTuplePat l Boxed a at Sum{} _ = mkLHsOpTy :: PromotionFlag -> LHsType GhcPs -> LocatedN RdrName -> LHsType GhcPs -> LHsType GhcPs mkLHsOpTy prom x op y = - let loc = getLoc x `combineSrcSpansA` (noAnnSrcSpan $ getLocA op) `combineSrcSpansA` getLoc y - in L loc (mkHsOpTy prom x op y) + let loc = locA x `combineSrcSpans` locA op `combineSrcSpans` locA y + in L (noAnnSrcSpan loc) (mkHsOpTy prom x op y) mkMultTy :: EpToken "%" -> LHsType GhcPs -> EpUniToken "->" "→" -> HsArrow GhcPs mkMultTy pct t@(L _ (HsTyLit _ (HsNumTy (SourceText (unpackFS -> "1")) 1))) arr ===================================== distrib/configure.ac.in ===================================== @@ -114,16 +114,16 @@ if test "$HostOS" = "darwin"; then # The following is the work around suggested by @carter in #17418 during # install time. This should help us with code signing issues by removing # extended attributes from all files. - XATTR=${XATTR:-/usr/bin/xattr} + XATTR="${XATTR:-/usr/bin/xattr}" - if [ -e "${XATTR}" ]; then + if test -e "${XATTR}"; then # Instead of cleaning the attributes of the ghc-toolchain binary only, # we clean them from all files in the bin/ and lib/ directories, as it additionally future # proofs running executables from the bindist besides ghc-toolchain at configure time, and # we can avoid figuring out the path to the ghc-toolchain dynlib specifically. - /usr/bin/xattr -rc bin/ - /usr/bin/xattr -rc lib/ + "$XATTR" -rc bin/ + "$XATTR" -rc lib/ fi fi ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -293,6 +293,13 @@ Runtime system can be individually enabled and disabled via :base-ref:`GHC.Exception.Backtrace.setEnabledBacktraceMechanisms`. +- Deprecation of ``GHC.Pack`` has reached Phase 2. A warning is now thrown when importing the module. + See `ghc/ghc#21461 `_. + +- `CLC proposal #258 `_: + ``Data.List.NonEmpty.unzip`` raises a specific warning about its future monomorphisation. + Do consider switching to ``Data.Functor.unzip`` if you need to keep it polymorphic. + ``ghc-prim`` library ~~~~~~~~~~~~~~~~~~~~ ===================================== docs/users_guide/exts/ffi.rst ===================================== @@ -998,7 +998,7 @@ the data. We can do it like this: sp <- newStablePtrPrimMVar mvar fp <- mallocForeignPtr withForeignPtr fp $ \presult -> do - cap <- threadCapability =<< myThreadId + (cap, _) <- threadCapability =<< myThreadId scheduleCallback sp cap presult takeMVar mvar `onException` forkIO (do takeMVar mvar; touchForeignPtr fp) ===================================== hadrian/src/Hadrian/Haskell/Cabal/Parse.hs ===================================== @@ -31,6 +31,7 @@ import qualified Distribution.PackageDescription.Parsec as C import qualified Distribution.Simple.Compiler as C import qualified Distribution.Simple.Program.Db as C import qualified Distribution.Simple as C +import qualified Distribution.Simple.GHC as GHC import qualified Distribution.Simple.Program.Builtin as C import qualified Distribution.Simple.Utils as C import qualified Distribution.Simple.Program.Types as C @@ -363,12 +364,11 @@ registerPackage rs context = do need [setupConfig] -- This triggers 'configurePackage' pd <- packageDescription <$> readContextData context db_path <- packageDbPath (PackageDbLoc (stage context) (iplace context)) - dist_dir <- Context.buildPath context pid <- pkgUnitId (stage context) (package context) -- Note: the @cPath@ is ignored. The path that's used is the 'buildDir' path -- from the local build info @lbi at . lbi <- liftIO $ C.getPersistBuildConfig cPath - liftIO $ register db_path pid dist_dir pd lbi + liftIO $ register db_path pid pd lbi -- Then after the register, which just writes the .conf file, do the recache step. buildWithResources rs $ target context (GhcPkg Recache (stage context)) [] [] @@ -377,25 +377,23 @@ registerPackage rs context = do -- into a different package database to the one it was configured against. register :: FilePath -> String -- ^ Package Identifier - -> FilePath -> C.PackageDescription -> LocalBuildInfo -> IO () -register pkg_db pid build_dir pd lbi +register pkg_db pid pd lbi = withLibLBI pd lbi $ \lib clbi -> do - absPackageDBs <- C.absolutePackageDBPaths packageDbs - installedPkgInfo <- C.generateRegistrationInfo - C.silent pd lib lbi clbi False reloc build_dir - (C.registrationPackageDB absPackageDBs) - + when reloc $ error "register does not support reloc" + installedPkgInfo <- generateRegistrationInfo pd lbi lib clbi writeRegistrationFile installedPkgInfo where regFile = pkg_db pid <.> "conf" reloc = relocatable lbi - -- Using a specific package db here is why we have to copy the function from Cabal. - packageDbs = [C.SpecificPackageDB pkg_db] + + generateRegistrationInfo pkg lbi lib clbi = do + abi_hash <- C.mkAbiHash <$> GHC.libAbiHash C.silent pkg lbi lib clbi + return (C.absoluteInstalledPackageInfo pkg abi_hash lib lbi clbi) writeRegistrationFile installedPkgInfo = do writeUTF8File regFile (CP.showInstalledPackageInfo installedPkgInfo) ===================================== libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc ===================================== @@ -399,14 +399,14 @@ data ParFlags = ParFlags -- | Parameters pertaining to Haskell program coverage (HPC) -- --- @since base-4.22.0.0 +-- @since base-4.20.0.0 data HpcFlags = HpcFlags { writeTixFile :: Bool -- ^ Controls whether the @.tix@ file should be -- written after the execution of the program. } - deriving (Show -- ^ @since base-4.22.0.0 - , Generic -- ^ @since base-4.22.0.0 + deriving (Show -- ^ @since base-4.20.0.0 + , Generic -- ^ @since base-4.20.0.0 ) -- | Parameters of the runtime system -- ===================================== libraries/ghc-internal/src/GHC/Internal/System/Environment.hs ===================================== @@ -225,6 +225,13 @@ ioe_missingEnvVar name = ioException (IOError Nothing NoSuchThing "getEnv" -- Throws `Control.Exception.IOException` if @name@ is the empty string or -- contains an equals sign. -- +-- Beware that this function must not be executed concurrently +-- with 'getEnv', 'lookupEnv', 'getEnvironment' and such. One thread +-- reading environment variables at the same time with another one modifying them +-- can result in a segfault, see +-- [Setenv is not Thread Safe](https://www.evanjones.ca/setenv-is-not-thread-safe.html) +-- for discussion. +-- -- @since base-4.7.0.0 setEnv :: String -> String -> IO () setEnv key_ value_ @@ -269,6 +276,13 @@ foreign import ccall unsafe "putenv" c_putenv :: CString -> IO CInt -- Throws `Control.Exception.IOException` if @name@ is the empty string or -- contains an equals sign. -- +-- Beware that this function must not be executed concurrently +-- with 'getEnv', 'lookupEnv', 'getEnvironment' and such. One thread +-- reading environment variables at the same time with another one modifying them +-- can result in a segfault, see +-- [Setenv is not Thread Safe](https://www.evanjones.ca/setenv-is-not-thread-safe.html) +-- for discussion. +-- -- @since base-4.7.0.0 unsetEnv :: String -> IO () #if defined(mingw32_HOST_OS) ===================================== libraries/ghc-internal/src/GHC/Internal/System/Environment/Blank.hsc ===================================== @@ -109,6 +109,13 @@ getEnvDefault name fallback = fromMaybe fallback <$> getEnv name -- | Like 'GHC.Internal.System.Environment.setEnv', but allows blank environment values -- and mimics the function signature of 'System.Posix.Env.setEnv' from the -- @unix@ package. +-- +-- Beware that this function must not be executed concurrently +-- with 'getEnv', 'lookupEnv', 'getEnvironment' and such. One thread +-- reading environment variables at the same time with another one modifying them +-- can result in a segfault, see +-- [Setenv is not Thread Safe](https://www.evanjones.ca/setenv-is-not-thread-safe.html) +-- for discussion. setEnv :: String {- ^ variable name -} -> String {- ^ variable value -} -> @@ -151,6 +158,13 @@ foreign import ccall unsafe "setenv" -- | Like 'GHC.Internal.System.Environment.unsetEnv', but allows for the removal of -- blank environment variables. May throw an exception if the underlying -- platform doesn't support unsetting of environment variables. +-- +-- Beware that this function must not be executed concurrently +-- with 'getEnv', 'lookupEnv', 'getEnvironment' and such. One thread +-- reading environment variables at the same time with another one modifying them +-- can result in a segfault, see +-- [Setenv is not Thread Safe](https://www.evanjones.ca/setenv-is-not-thread-safe.html) +-- for discussion. unsetEnv :: String -> IO () #if defined(mingw32_HOST_OS) unsetEnv key = withCWString key $ \k -> do ===================================== testsuite/tests/parser/should_compile/T20846.stderr ===================================== @@ -71,11 +71,7 @@ (L (EpAnn (EpaSpan { T20846.hs:4:1-6 }) - (NameAnn - (NameParens) - (EpaSpan { T20846.hs:4:1 }) - (EpaSpan { T20846.hs:4:2-5 }) - (EpaSpan { T20846.hs:4:6 }) + (NameAnnTrailing []) (EpaComments [])) ===================================== testsuite/tests/printer/Makefile ===================================== @@ -826,3 +826,33 @@ Test24533: PprLetIn: $(CHECK_PPR) $(LIBDIR) PprLetIn.hs $(CHECK_EXACT) $(LIBDIR) PprLetIn.hs + +.PHONY: CaseAltComments +CaseAltComments: + $(CHECK_PPR) $(LIBDIR) CaseAltComments.hs + $(CHECK_EXACT) $(LIBDIR) CaseAltComments.hs + +.PHONY: MatchPatComments +MatchPatComments: + $(CHECK_PPR) $(LIBDIR) MatchPatComments.hs + $(CHECK_EXACT) $(LIBDIR) MatchPatComments.hs + +.PHONY: Test24748 +Test24748: + $(CHECK_PPR) $(LIBDIR) Test24748.hs + $(CHECK_EXACT) $(LIBDIR) Test24748.hs + +.PHONY: Test24755 +Test24755: + $(CHECK_PPR) $(LIBDIR) Test24755.hs + $(CHECK_EXACT) $(LIBDIR) Test24755.hs + +.PHONY: Test24753 +Test24753: + $(CHECK_PPR) $(LIBDIR) Test24753.hs + $(CHECK_EXACT) $(LIBDIR) Test24753.hs + +.PHONY: Test24771 +Test24771: + $(CHECK_PPR) $(LIBDIR) Test24771.hs + $(CHECK_EXACT) $(LIBDIR) Test24771.hs ===================================== testsuite/tests/printer/MatchPatComments.hs ===================================== @@ -0,0 +1,16 @@ +module MatchPatComments where + +expandProcess + outCHAs -- c0 + locationDescr = + blah + +next + ( steps -- c1 + , ys -- c2 + ) x -- c3 + = (steps, x, ys) + +makeProjection + Function{funMutual = VV, -- c4 + funAbstr = ConcreteDef} = undefined ===================================== testsuite/tests/printer/PprExportWarn.hs ===================================== @@ -6,12 +6,12 @@ module PprExportWarning ( reallyreallyreallyreallyreallyreallyreallyreallylongname, {-# DEPRECATED "Just because" #-} Bar(Bar1, Bar2), {-# WARNING "Just because" #-} name, - {-# DEPRECATED ["Reason", - "Another reason"] #-} + {-# DEPRECATED ["Reason", + "Another reason"] #-} Baz, {-# DEPRECATED [ ] #-} module GHC, {-# WARNING "Dummy Pattern" #-} pattern Dummy, - Foo'(..), + Foo'(..), reallyreallyreallyreallyreallyreallyreallyreallylongname', Bar'(Bar1, Bar2), name', Baz', module Data.List, pattern Dummy' ) where ===================================== testsuite/tests/printer/PrefixConComment.hs ===================================== @@ -0,0 +1,4 @@ +module PrefixConComment where + +fun (Con {- c1 -} a {- c2 -} b {- c3 -}) + = undefined ===================================== testsuite/tests/printer/Test24748.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE LambdaCase #-} +module Test24748 where + +instance SDecide Nat where + SZero %~ (SSucc _) = Disproved (\case) + +foo = (\case) +bar = (\cases) ===================================== testsuite/tests/printer/Test24753.hs ===================================== @@ -0,0 +1,8 @@ +module Test24753 where + +type ErrorChoiceApi + = "path0" :> Get '[JSON] Int -- c0 + :<|> "path4" :> (ReqBody '[PlainText] Int :> Post '[PlainText] Int -- c4 + :<|> ReqBody '[PlainText] Int :> Post '[JSON] Int) -- c5 + :<|> "path5" :> (ReqBody '[JSON] Int :> Post '[PlainText] Int -- c6 + :<|> ReqBody '[PlainText] Int :> Post '[PlainText] Int) -- c7 ===================================== testsuite/tests/printer/Test24755.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeOperators #-} +module Test24755 where + +class + a -- c1 + :+ -- c2 + b -- c3 ===================================== testsuite/tests/printer/Test24771.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeOperators #-} +module Test24771 where + +data Foo + = Int -- c1 + :* -- c2 + String -- c3 ===================================== testsuite/tests/printer/all.T ===================================== @@ -198,3 +198,8 @@ test('ListTuplePuns', extra_files(['ListTuplePuns.hs']), ghci_script, ['ListTupl test('AnnotationNoListTuplePuns', [ignore_stderr, req_ppr_deps], makefile_test, ['AnnotationNoListTuplePuns']) test('Test24533', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24533']) test('PprLetIn', [ignore_stderr, req_ppr_deps], makefile_test, ['PprLetIn']) +test('MatchPatComments', [ignore_stderr, req_ppr_deps], makefile_test, ['MatchPatComments']) +test('Test24748', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24748']) +test('Test24755', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24755']) +test('Test24753', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24753']) +test('Test24771', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24771']) ===================================== testsuite/tests/simplCore/should_compile/T24726.hs ===================================== @@ -0,0 +1,26 @@ +{-# OPTIONS_GHC -drule-check concatMap #-} + -- This rule-check thing crashed #24726 + +module T24726 where + +data Stream a = forall s. Stream (s -> ()) s + +concatMapS :: (a -> Stream b) -> Stream a -> Stream b +concatMapS f (Stream next0 s0) = Stream undefined undefined +{-# INLINE [1] concatMapS #-} + +concatMapS' :: (s -> ()) -> (a -> s) -> Stream a -> Stream b +concatMapS' = undefined + +{-# RULES "concatMap" forall step f. concatMapS (\x -> Stream step (f x)) = concatMapS' step f #-} + +replicateStep :: a -> b +replicateStep _ = undefined +{-# INLINE replicateStep #-} + +replicateS :: Int -> a -> Stream a +replicateS n x0 = Stream replicateStep undefined +{-# INLINE replicateS #-} + +foo1 :: Stream Int -> Stream Int +foo1 = concatMapS (replicateS 2) ===================================== testsuite/tests/simplCore/should_compile/T24726.stderr ===================================== @@ -0,0 +1,36 @@ + +==================== Rule check ==================== +Rule check results: +-------------------- +Expression: concatMapS @(*) @Int @Int foo1 +Rule "concatMap": all arguments match (considered individually), but rule as a whole does not +-------------------- + + + +==================== Rule check ==================== +Rule check results: +-------------------- +Expression: concatMapS @(*) @Int @Int foo1 +Rule "concatMap": all arguments match (considered individually), but rule as a whole does not +-------------------- + + + +==================== Rule check ==================== +Rule check results: +-------------------- +Expression: concatMapS @(*) @Int @Int foo1 +Rule "concatMap": all arguments match (considered individually), but rule as a whole does not +-------------------- + + + +==================== Rule check ==================== +Rule check results: +-------------------- +Expression: concatMapS @(*) @Int @Int foo1 +Rule "concatMap": all arguments match (considered individually), but rule as a whole does not +-------------------- + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -515,3 +515,4 @@ test('T24229a', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typea test('T24229b', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques -dppr-cols=99999']) test('T24370', normal, compile, ['-O']) test('T24551', normal, compile, ['-O -dcore-lint']) +test('T24726', normal, compile, ['-dcore-lint -dsuppress-uniques']) ===================================== utils/check-exact/Main.hs ===================================== @@ -128,7 +128,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/ghc/_build/stage1/ -- "../../testsuite/tests/printer/Ppr034.hs" Nothing -- "../../testsuite/tests/printer/Ppr035.hs" Nothing -- "../../testsuite/tests/printer/Ppr036.hs" Nothing - "../../testsuite/tests/printer/Ppr037.hs" Nothing + "../../testsuite/tests/printer/MatchPatComments.hs" Nothing -- "../../testsuite/tests/printer/Ppr038.hs" Nothing -- "../../testsuite/tests/printer/Ppr039.hs" Nothing -- "../../testsuite/tests/printer/Ppr040.hs" Nothing @@ -319,8 +319,10 @@ testOneFile _ libdir fileName mchanger = do expectedSource <- readFile newFileExpected changedSource <- readFile newFileChanged return (expectedSource == changedSource, expectedSource, changedSource) - Nothing -> return (True, "", "") - + Nothing -> do + expectedSource <- readFile fileName + changedSource <- readFile newFile + return (expectedSource == changedSource, expectedSource, changedSource) (p',_) <- parseOneFile libdir newFile let newAstStr :: String View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4b3314f59fa0f66ceface97e5e97668e5e59feaa...7f9b05a899d8d5030d884f4028b628a5d3453ec9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4b3314f59fa0f66ceface97e5e97668e5e59feaa...7f9b05a899d8d5030d884f4028b628a5d3453ec9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 07:14:45 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Wed, 08 May 2024 03:14:45 -0400 Subject: [Git][ghc/ghc][wip/fendor/ifacetype-deduplication] 2 commits: Add run-time configurability of .hi file compression Message-ID: <663b266579f33_37d053f569c8135d4@gitlab.mail> Hannes Siebenhandl pushed to branch wip/fendor/ifacetype-deduplication at Glasgow Haskell Compiler / GHC Commits: c1c6fed5 by Matthew Pickering at 2024-05-08T09:12:52+02:00 Add run-time configurability of .hi file compression Introduce the flag `-fwrite-if-compression=<n>` which allows to configure the compression level of writing .hi files. The motivation is that some deduplication operations are too expensive for the average use case. Hence, we introduce multiple compression levels with variable impact on performance, but still reduce the memory residency and `.hi` file size on disk considerably. We introduce three compression levels: * `1`: `Normal` mode. This is the least amount of compression. It deduplicates only `Name` and `FastString`s, and is naturally the fastest compression mode. * `2`: `Safe` mode. It has a noticeable impact on .hi file size and is marginally slower than `Normal` mode. In general, it should be safe to always use `Safe` mode. * `3`: `Full` deduplication mode. Deduplicate as much as we can, resulting in minimal .hi files, but at the cost of additional compilation time. Reading .hi files doesn't need to know the initial compression level, and can always deserialise a `ModIface`, as we write out a byte that indicates the next value has been deduplicated. This allows users to experiment with different compression levels for packages, without recompilation of dependencies. Note, the deduplication also has an additional side effect of reduced memory consumption to implicit sharing of deduplicated elements. See https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for example where that matters. ------------------------- Metric Decrease: MultiLayerModulesDefsGhciWithCore T16875 T21839c T24471 hard_hole_fits libdir ------------------------- - - - - - 22579324 by Matthew Pickering at 2024-05-08T09:14:20+02:00 Introduce regression tests for `.hi` file sizes Add regression tests to track how `-fwrite-if-compression` levels affect the size of `.hi` files. - - - - - 16 changed files: - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Type.hs - docs/users_guide/using-optimisation.rst - + testsuite/tests/iface/IfaceSharingIfaceType.hs - + testsuite/tests/iface/IfaceSharingName.hs - + testsuite/tests/iface/Lib.hs - + testsuite/tests/iface/Makefile - + testsuite/tests/iface/all.T - + testsuite/tests/iface/if_faststring.hs - + testsuite/tests/iface/if_ifacetype.hs - + testsuite/tests/iface/if_name.hs Changes: ===================================== compiler/GHC/Driver/DynFlags.hs ===================================== @@ -207,6 +207,7 @@ data DynFlags = DynFlags { dmdUnboxWidth :: !Int, -- ^ Whether DmdAnal should optimistically put an -- Unboxed demand on returned products with at most -- this number of fields + ifCompression :: Int, specConstrThreshold :: Maybe Int, -- ^ Threshold for SpecConstr specConstrCount :: Maybe Int, -- ^ Max number of specialisations for any one function specConstrRecursive :: Int, -- ^ Max number of specialisations for recursive types @@ -546,6 +547,7 @@ defaultDynFlags mySettings = maxPmCheckModels = 30, simplTickFactor = 100, dmdUnboxWidth = 3, -- Default: Assume an unboxed demand on function bodies returning a triple + ifCompression = 2, -- Default: Apply safe compressions specConstrThreshold = Just 2000, specConstrCount = Just 3, specConstrRecursive = 3, ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -163,7 +163,7 @@ import GHC.JS.Syntax import GHC.IfaceToCore ( typecheckIface, typecheckWholeCoreBindings ) -import GHC.Iface.Load ( ifaceStats, writeIface ) +import GHC.Iface.Load ( ifaceStats, writeIface, flagsToIfCompression ) import GHC.Iface.Make import GHC.Iface.Recomp import GHC.Iface.Tidy @@ -612,7 +612,7 @@ extract_renamed_stuff mod_summary tc_result = do -- enables the option which keeps the renamed source. hieFile <- mkHieFile mod_summary tc_result (fromJust rn_info) let out_file = ml_hie_file $ ms_location mod_summary - liftIO $ writeHieFile out_file hieFile + liftIO $ writeHieFile (flagsToIfCompression dflags) out_file hieFile liftIO $ putDumpFileMaybe logger Opt_D_dump_hie "HIE AST" FormatHaskell (ppr $ hie_asts hieFile) -- Validate HIE files @@ -1207,7 +1207,7 @@ hscMaybeWriteIface logger dflags is_simple iface old_iface mod_location = do withTiming logger (text "WriteIface"<+>brackets (text iface_name)) (const ()) - (writeIface logger profile iface_name iface) + (writeIface logger profile (flagsToIfCompression dflags) iface_name iface) if (write_interface || force_write_interface) then do ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -1695,6 +1695,9 @@ dynamic_flags_deps = [ , make_ord_flag defFlag "fno-refinement-level-hole-fits" (noArg (\d -> d { refLevelHoleFits = Nothing })) + , make_ord_flag defFlag "fwrite-if-compression" + (intSuffix (\n d -> d { ifCompression = n })) + , make_dep_flag defGhcFlag "fllvm-pass-vectors-in-regs" (noArg id) "vectors registers are now passed in registers by default." ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -14,6 +14,7 @@ module GHC.Iface.Binary ( writeBinIface, readBinIface, readBinIfaceHeader, + CompressionIFace(..), getSymtabName, CheckHiWay(..), TraceBinIFace(..), @@ -48,7 +49,7 @@ import GHC.Types.SrcLoc import GHC.Platform import GHC.Settings.Constants import GHC.Utils.Fingerprint -import GHC.Iface.Type (IfaceType, getIfaceType, putIfaceType) +import GHC.Iface.Type (IfaceType(..), getIfaceType, putIfaceType, ifaceTypeSharedByte) import Control.Monad import Data.Array @@ -73,6 +74,21 @@ data TraceBinIFace = TraceBinIFace (SDoc -> IO ()) | QuietBinIFace +data CompressionIFace + = NormalCompression + -- ^ Perform the normal compression operations, + -- such as deduplicating 'Name's and 'FastString's + | SafeExtraCompression + -- ^ Perform some extra compression steps that have minimal impact + -- on the run-time of 'ghc'. + -- + -- This reduces the size of '.hi' files significantly in some cases + -- and reduces overall memory usage in certain scenarios. + | MaximalCompression + -- ^ Try to compress as much as possible. + -- + -- Yields the smallest '.hi' files but at the cost of additional run-time. + -- | Read an interface file header, checking the magic number, version, and -- way. Returns the hash of the source file and a BinHandle which points at the -- start of the rest of the interface file data. @@ -199,8 +215,8 @@ getTables name_cache bh = do -- | Write an interface file. -- -- See Note [Deduplication during iface binary serialisation] for details. -writeBinIface :: Profile -> TraceBinIFace -> FilePath -> ModIface -> IO () -writeBinIface profile traceBinIface hi_path mod_iface = do +writeBinIface :: Profile -> TraceBinIFace -> CompressionIFace -> FilePath -> ModIface -> IO () +writeBinIface profile traceBinIface compressionLevel hi_path mod_iface = do bh <- openBinMem initBinMemSize let platform = profilePlatform profile put_ bh (binaryInterfaceMagic platform) @@ -214,7 +230,7 @@ writeBinIface profile traceBinIface hi_path mod_iface = do extFields_p_p <- tellBinWriter bh put_ bh extFields_p_p - putWithUserData traceBinIface bh mod_iface + putWithUserData traceBinIface compressionLevel bh mod_iface extFields_p <- tellBinWriter bh putAt bh extFields_p_p extFields_p @@ -228,9 +244,9 @@ writeBinIface profile traceBinIface hi_path mod_iface = do -- is necessary if you want to serialise Names or FastStrings. -- It also writes a symbol table and the dictionary. -- This segment should be read using `getWithUserData`. -putWithUserData :: Binary a => TraceBinIFace -> WriteBinHandle -> a -> IO () -putWithUserData traceBinIface bh payload = do - (name_count, fs_count, _b) <- putWithTables bh (\bh' -> put bh' payload) +putWithUserData :: Binary a => TraceBinIFace -> CompressionIFace -> WriteBinHandle -> a -> IO () +putWithUserData traceBinIface compressionLevel bh payload = do + (name_count, fs_count, _b) <- putWithTables compressionLevel bh (\bh' -> put bh' payload) case traceBinIface of QuietBinIFace -> return () @@ -253,12 +269,12 @@ putWithUserData traceBinIface bh payload = do -- It returns (number of names, number of FastStrings, payload write result) -- -- See Note [Order of deduplication tables during iface binary serialisation] -putWithTables :: WriteBinHandle -> (WriteBinHandle -> IO b) -> IO (Int, Int, b) -putWithTables bh' put_payload = do +putWithTables :: CompressionIFace -> WriteBinHandle -> (WriteBinHandle -> IO b) -> IO (Int, Int, b) +putWithTables compressionLevel bh' put_payload = do -- Initialise deduplicating tables. (fast_wt, fsWriter) <- initFastStringWriterTable (name_wt, nameWriter) <- initNameWriterTable - (ifaceType_wt, ifaceTypeWriter) <- initWriteIfaceType + (ifaceType_wt, ifaceTypeWriter) <- initWriteIfaceType compressionLevel -- Initialise the 'WriterUserData'. let writerUserData = mkWriterUserData @@ -485,15 +501,33 @@ initReadIfaceTypeTable ud = do , mkReaderFromTable = \tbl -> mkReader (getGenericSymtab tbl) } -initWriteIfaceType :: IO (WriterTable, BinaryWriter IfaceType) -initWriteIfaceType = do +initWriteIfaceType :: CompressionIFace -> IO (WriterTable, BinaryWriter IfaceType) +initWriteIfaceType compressionLevel = do sym_tab <- initGenericSymbolTable @(Map IfaceType) pure ( WriterTable { putTable = putGenericSymbolTable sym_tab (lazyPut' putIfaceType) } - , mkWriter $ putGenericSymTab sym_tab + , mkWriter $ ifaceWriter sym_tab ) + where + ifaceWriter sym_tab = case compressionLevel of + NormalCompression -> literalIfaceTypeSerialiser + SafeExtraCompression -> ifaceTyConAppSerialiser sym_tab + MaximalCompression -> fullIfaceTypeSerialiser sym_tab + + ifaceTyConAppSerialiser sym_tab bh ty = case ty of + IfaceTyConApp {} -> do + put_ bh ifaceTypeSharedByte + putGenericSymTab sym_tab bh ty + _ -> putIfaceType bh ty + + + fullIfaceTypeSerialiser sym_tab bh ty = do + put_ bh ifaceTypeSharedByte + putGenericSymTab sym_tab bh ty + + literalIfaceTypeSerialiser = putIfaceType initNameReaderTable :: NameCache -> IO (ReaderTable Name) ===================================== compiler/GHC/Iface/Ext/Binary.hs ===================================== @@ -43,7 +43,7 @@ import System.Directory ( createDirectoryIfMissing ) import System.FilePath ( takeDirectory ) import GHC.Iface.Ext.Types -import GHC.Iface.Binary (initWriteIfaceType, putAllTables, initReadIfaceTypeTable) +import GHC.Iface.Binary (initWriteIfaceType, putAllTables, initReadIfaceTypeTable, CompressionIFace) import GHC.Iface.Type (IfaceType) import System.IO.Unsafe (unsafeInterleaveIO) import qualified GHC.Utils.Binary as Binary @@ -73,8 +73,8 @@ putBinLine bh xs = do -- | Write a `HieFile` to the given `FilePath`, with a proper header and -- symbol tables for `Name`s and `FastString`s -writeHieFile :: FilePath -> HieFile -> IO () -writeHieFile hie_file_path hiefile = do +writeHieFile :: CompressionIFace -> FilePath -> HieFile -> IO () +writeHieFile compression hie_file_path hiefile = do bh0 <- openBinMem initBinMemSize -- Write the header: hieHeader followed by the @@ -85,7 +85,7 @@ writeHieFile hie_file_path hiefile = do (fs_tbl, fs_w) <- initFastStringWriterTable (name_tbl, name_w) <- initWriteNameTable - (iface_tbl, iface_w) <- initWriteIfaceType + (iface_tbl, iface_w) <- initWriteIfaceType compression let bh = setWriterUserData bh0 $ mkWriterUserData [ mkSomeBinaryWriter @IfaceType iface_w ===================================== compiler/GHC/Iface/Load.hs ===================================== @@ -26,6 +26,7 @@ module GHC.Iface.Load ( loadInterface, loadSysInterface, loadUserInterface, loadPluginInterface, findAndReadIface, readIface, writeIface, + flagsToIfCompression, moduleFreeHolesPrecise, needWiredInHomeIface, loadWiredInHomeIface, @@ -965,11 +966,19 @@ read_file logger name_cache unit_state dflags wanted_mod file_path = do -- | Write interface file -writeIface :: Logger -> Profile -> FilePath -> ModIface -> IO () -writeIface logger profile hi_file_path new_iface +writeIface :: Logger -> Profile -> CompressionIFace -> FilePath -> ModIface -> IO () +writeIface logger profile compression_level hi_file_path new_iface = do createDirectoryIfMissing True (takeDirectory hi_file_path) let printer = TraceBinIFace (debugTraceMsg logger 3) - writeBinIface profile printer hi_file_path new_iface + writeBinIface profile printer compression_level hi_file_path new_iface + +flagsToIfCompression :: DynFlags -> CompressionIFace +flagsToIfCompression dflags + | n <= 1 = NormalCompression + | n == 2 = SafeExtraCompression + -- n >= 3 + | otherwise = MaximalCompression + where n = ifCompression dflags -- | @readIface@ tries just the one file. -- ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -34,7 +34,7 @@ module GHC.Iface.Type ( ifTyConBinderVar, ifTyConBinderName, -- Binary utilities - putIfaceType, getIfaceType, + putIfaceType, getIfaceType, ifaceTypeSharedByte, -- Equality testing isIfaceLiftedTypeKind, @@ -92,12 +92,13 @@ import GHC.Utils.Misc import GHC.Utils.Panic import {-# SOURCE #-} GHC.Tc.Utils.TcType ( isMetaTyVar, isTyConableTyVar ) -import Control.DeepSeq +import Data.Maybe (isJust) import Data.Proxy -import Control.Monad ((<$!>)) -import Control.Arrow (first) import qualified Data.Semigroup as Semi -import Data.Maybe (isJust) +import Data.Word (Word8) +import Control.Arrow (first) +import Control.DeepSeq +import Control.Monad ((<$!>)) {- ************************************************************************ @@ -2197,12 +2198,35 @@ ppr_parend_preds :: [IfacePredType] -> SDoc ppr_parend_preds preds = parens (fsep (punctuate comma (map ppr preds))) instance Binary IfaceType where - put_ bh tyCon = case findUserDataWriter Proxy bh of - tbl -> putEntry tbl bh tyCon + put_ bh ty = + case findUserDataWriter Proxy bh of + tbl -> putEntry tbl bh ty - get bh = case findUserDataReader Proxy bh of - tbl -> getEntry tbl bh + get bh = getIfaceTypeShared bh +-- | This is the byte tag we expect to read when the next +-- value is not an 'IfaceType' value, but an offset into a +-- lookup value. +-- +-- Must not overlap with any byte tag in 'getIfaceType'. +ifaceTypeSharedByte :: Word8 +ifaceTypeSharedByte = 99 + +-- | Like 'getIfaceType' but checks for a specific byte tag +-- that indicates that we won't be able to read a 'IfaceType' value +-- but rather an offset into a lookup table. Consequentially, +-- we look up the value for the 'IfaceType' in the look up table. +-- +-- See Note [Deduplication during iface binary serialisation] +-- for details. +getIfaceTypeShared :: ReadBinHandle -> IO IfaceType +getIfaceTypeShared bh = do + start <- tellBinReader bh + tag <- getByte bh + if ifaceTypeSharedByte == tag + then case findUserDataReader Proxy bh of + tbl -> getEntry tbl bh + else seekBinReader bh start >> getIfaceType bh putIfaceType :: WriteBinHandle -> IfaceType -> IO () putIfaceType _ (IfaceFreeTyVar tv) ===================================== docs/users_guide/using-optimisation.rst ===================================== @@ -1777,3 +1777,23 @@ as such you shouldn't need to set any of them explicitly. A flag This flag sets the size (in bytes) threshold above which the second approach is used. You can disable the second approach entirely by setting the threshold to 0. + +.. ghc-flag:: -fwrite-if-compression=⟨n⟩ + :shortdesc: *default: 2.* Tweak the level of interface file compression. + :type: dynamic + :category: optimization + + :default: 2 + + This flag defines the level of compression of interface files when writing to disk. + The higher the flag, the more we deduplicate the interface file, at the cost of a higher compilation time. + Deduplication (when applied to :ghc-flag:`--make` mode and :ghc-flag:`--interactive` mode) decreases the size of interface files as well as reducing + the overall memory usage of GHC. + + Compression cannot be fully turned off, GHC always compresses interface files to a certain degree. + Currently, we support values of ``1``, ``2`` and ``3``. + Lower or higher values are clamped to ``1`` and ``3`` respectively. + + * ``1``: Compress as little as possible. No run-time impact, at the cost of interface file size and memory usage. + * ``2``: Apply compression with minimal run-time overhead, reducing the interface file size and memory usage. + * ``3``: Apply all possible compressions, minimal interface file sizes and memory usage, at the cost of run-time overhead. ===================================== testsuite/tests/iface/IfaceSharingIfaceType.hs ===================================== @@ -0,0 +1,44 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE OverloadedStrings #-} + +module IfaceSharingIfaceType (types) where + +import GHC.Data.FastString +import GHC.Builtin.Uniques +import GHC.Builtin.Names +import GHC.Builtin.Types +import GHC.Types.Name +import GHC.Types.SrcLoc +import GHC.Iface.Type +import GHC.CoreToIface +import GHC.Core.TyCo.Rep +import GHC + +[f1,f2,f3,f4,f5] = map mkVarOcc ["a", "b","c","d","e"] + +[u1,u2,u3,u4,u5] = map mkPreludeMiscIdUnique [10000..10004] + +names = [ mkExternalName u1 pRELUDE f1 noSrcSpan + , mkExternalName u2 pRELUDE f2 noSrcSpan + , mkExternalName u3 pRELUDE f3 noSrcSpan + , mkExternalName u4 pRELUDE f4 noSrcSpan + , mkExternalName u5 pRELUDE f5 noSrcSpan ] + +-- Int +intIfaceTy = toIfaceType intTy + +wordIfaceTy = toIfaceType wordTy + +listIntTy = toIfaceType (mkListTy intTy) + +funTy = (intTy `mkVisFunTyMany` wordTy `mkVisFunTyMany` mkListTy intTy) + +funIfaceTy = toIfaceType funTy + +reallyBigFunTy = toIfaceType (funTy `mkVisFunTyMany` funTy `mkVisFunTyMany` funTy `mkVisFunTyMany` funTy) + +forallIfaceTy = toIfaceType (dataConType justDataCon) + + +types = [intIfaceTy, wordIfaceTy, listIntTy, funIfaceTy, reallyBigFunTy, forallIfaceTy] + ===================================== testsuite/tests/iface/IfaceSharingName.hs ===================================== @@ -0,0 +1,21 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE OverloadedStrings #-} + +module IfaceSharingName where + +import Lib +import GHC.Data.FastString +import GHC.Builtin.Uniques +import GHC.Builtin.Names +import GHC.Types.Name +import GHC.Types.SrcLoc + +[f1,f2,f3,f4,f5] = map mkVarOcc ["a", "b","c","d","e"] + +[u1,u2,u3,u4,u5] = map mkPreludeMiscIdUnique [10000..10004] + +names = [ mkExternalName u1 pRELUDE f1 noSrcSpan + , mkExternalName u2 pRELUDE f2 noSrcSpan + , mkExternalName u3 pRELUDE f3 noSrcSpan + , mkExternalName u4 pRELUDE f4 noSrcSpan + , mkExternalName u5 pRELUDE f5 noSrcSpan ] ===================================== testsuite/tests/iface/Lib.hs ===================================== @@ -0,0 +1,15 @@ +module Lib where + +import GHC.Utils.Binary +import GHC.Iface.Binary +import qualified Data.ByteString as B +import System.Environment +import Data.Maybe + +testSize :: Binary a => CompressionIFace -> a -> IO Int +testSize compLvl payload = do + args <- getArgs + bh <- openBinMem 1024 + putWithUserData QuietBinIFace compLvl bh payload + withBinBuffer bh (\b -> return (B.length b)) + ===================================== testsuite/tests/iface/Makefile ===================================== @@ -0,0 +1,4 @@ +TOP=../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + ===================================== testsuite/tests/iface/all.T ===================================== @@ -0,0 +1,24 @@ +test( 'if_faststring' + , [ stat_from_file('normal', 5, 'NORMALSIZE') + , stat_from_file('medium', 5, 'MEDIUMSIZE') + , stat_from_file('full', 5, 'FULLSIZE') + , extra_files(["Lib.hs"])] + , compile_and_run + , ['-package ghc']) + +test( 'if_name' + , [ stat_from_file('normal', 5, 'NORMALSIZE') + , stat_from_file('medium', 5, 'MEDIUMSIZE') + , stat_from_file('full', 5, 'FULLSIZE') + , extra_files(["Lib.hs", "IfaceSharingName.hs"])] + , compile_and_run + , ['-package ghc']) + +test( 'if_ifacetype' + , [ stat_from_file('normal', 5, 'NORMALSIZE') + , stat_from_file('medium', 5, 'MEDIUMSIZE') + , stat_from_file('full', 5, 'FULLSIZE') + , extra_files(["Lib.hs", "IfaceSharingIfaceType.hs"])] + , compile_and_run + , ['-package ghc']) + ===================================== testsuite/tests/iface/if_faststring.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE OverloadedStrings #-} + +import Lib +import GHC.Data.FastString +import GHC.Iface.Binary + +main :: IO () +main = do + sz <- testSize MaximalCompression (concat (replicate 1000 ["abc", "cde", "efg" :: FastString])) + writeFile "FULLSIZE" (show sz) + sz <- testSize SafeExtraCompression (concat (replicate 1000 ["abc", "cde", "efg" :: FastString])) + writeFile "MEDIUMSIZE" (show sz) + sz <- testSize NormalCompression (concat (replicate 1000 ["abc", "cde", "efg" :: FastString])) + writeFile "NORMALSIZE" (show sz) ===================================== testsuite/tests/iface/if_ifacetype.hs ===================================== @@ -0,0 +1,13 @@ +import Lib +import IfaceSharingIfaceType +import GHC.Iface.Binary + +main :: IO () +main = do + sz <- testSize MaximalCompression (concat (replicate 500 types)) + writeFile "FULLSIZE" (show sz) + sz <- testSize SafeExtraCompression (concat (replicate 500 types)) + writeFile "MEDIUMSIZE" (show sz) + sz <- testSize NormalCompression (concat (replicate 500 types)) + writeFile "NORMALSIZE" (show sz) + ===================================== testsuite/tests/iface/if_name.hs ===================================== @@ -0,0 +1,12 @@ +import Lib +import IfaceSharingName +import GHC.Iface.Binary + +main :: IO () +main = do + sz <- testSize MaximalCompression (concat (replicate 1000 names)) + writeFile "FULLSIZE" (show sz) + sz <- testSize SafeExtraCompression (concat (replicate 1000 names)) + writeFile "MEDIUMSIZE" (show sz) + sz <- testSize NormalCompression (concat (replicate 1000 names)) + writeFile "NORMALSIZE" (show sz) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/33f6125fb1f3b2e264e85013fa07d25f1a9e9043...225793249eadf0d3b6ab3a7e520e59e661610409 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/33f6125fb1f3b2e264e85013fa07d25f1a9e9043...225793249eadf0d3b6ab3a7e520e59e661610409 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 08:23:29 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Wed, 08 May 2024 04:23:29 -0400 Subject: [Git][ghc/ghc][wip/fendor/ghc-iface-sharing-avoid-reserialisation] 4 commits: Add run-time configurability of .hi file compression Message-ID: <663b368121e44_37d05317847e4211fc@gitlab.mail> Hannes Siebenhandl pushed to branch wip/fendor/ghc-iface-sharing-avoid-reserialisation at Glasgow Haskell Compiler / GHC Commits: c1c6fed5 by Matthew Pickering at 2024-05-08T09:12:52+02:00 Add run-time configurability of .hi file compression Introduce the flag `-fwrite-if-compression=<n>` which allows to configure the compression level of writing .hi files. The motivation is that some deduplication operations are too expensive for the average use case. Hence, we introduce multiple compression levels with variable impact on performance, but still reduce the memory residency and `.hi` file size on disk considerably. We introduce three compression levels: * `1`: `Normal` mode. This is the least amount of compression. It deduplicates only `Name` and `FastString`s, and is naturally the fastest compression mode. * `2`: `Safe` mode. It has a noticeable impact on .hi file size and is marginally slower than `Normal` mode. In general, it should be safe to always use `Safe` mode. * `3`: `Full` deduplication mode. Deduplicate as much as we can, resulting in minimal .hi files, but at the cost of additional compilation time. Reading .hi files doesn't need to know the initial compression level, and can always deserialise a `ModIface`, as we write out a byte that indicates the next value has been deduplicated. This allows users to experiment with different compression levels for packages, without recompilation of dependencies. Note, the deduplication also has an additional side effect of reduced memory consumption to implicit sharing of deduplicated elements. See https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for example where that matters. ------------------------- Metric Decrease: MultiLayerModulesDefsGhciWithCore T16875 T21839c T24471 hard_hole_fits libdir ------------------------- - - - - - 22579324 by Matthew Pickering at 2024-05-08T09:14:20+02:00 Introduce regression tests for `.hi` file sizes Add regression tests to track how `-fwrite-if-compression` levels affect the size of `.hi` files. - - - - - 09bc2896 by Fendor at 2024-05-08T10:22:49+02:00 Improve sharing of duplicated values in `ModIface` As a `ModIface` contains often duplicated values that are not necessarily shared, we improve sharing by serialising the `ModIface` to an in-memory byte array. Serialisation uses deduplication tables, and deserialisation implicitly shares duplicated values. This helps reducing the peak memory usage while compiling in `--make` mode. The peak memory usage is especially reduced when generating interface files with core expressions (`-fwrite-if-simplified-core`). On agda, this reduces the peak memory usage: * `2.2 GB` to `1.9 GB` for a ghci session. On `lib:Cabal`, we report: * `570 MB` to `500 MB` for a ghci session * `790 MB` to `667 MB` for compiling `lib:Cabal` with ghc There is a small impact on execution time, around 2% on the agda code base. - - - - - 83bb2979 by Fendor at 2024-05-08T10:22:49+02:00 Avoid unneccessarily re-serialising the `ModIface` To reduce memory usage of `ModIface`, we serialise `ModIface` to an in-memory byte array, which implicitly shares duplicated values. This serailised byte array can be reused to avoid work when we actually write the `ModIface` to disk. We introduce a new field to `ModIface` which allows us to save the byte array, and write it to disk if the `ModIface` wasn't changed after the initial serialisation. This requires us to change absolute offsets, for example to jump to the deduplication table for `Name` or `FastString` with relative offsets, as the deduplication byte array doesn't contain header information, such as fingerprints. To allow us to dump the binary blob to disk, we need to replace all absolute offsets with relative ones. This leads to new primitives for `ModIface`, which help to construct relative offsets. Bump Haddock submodule, to account for interface file changes. ------------------------- Metric Increase: MultiComponentModules MultiLayerModules T10421 T13035 T13701 T13719 T14697 T18730 T9198 mhu-perf ------------------------- These metric increases may look bad, but they are all completely benign, we simply allocate 1 MB per module for `shareIface`. As this allocation is quite quick, it has a neglible impact on run-time performance. - - - - - 28 changed files: - compiler/GHC.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Ext/Fields.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Unit/Module/ModIface.hs - compiler/GHC/Utils/Binary.hs - docs/users_guide/using-optimisation.rst - + testsuite/tests/iface/IfaceSharingIfaceType.hs - + testsuite/tests/iface/IfaceSharingName.hs - + testsuite/tests/iface/Lib.hs - + testsuite/tests/iface/Makefile - + testsuite/tests/iface/all.T - + testsuite/tests/iface/if_faststring.hs - + testsuite/tests/iface/if_ifacetype.hs - + testsuite/tests/iface/if_name.hs - testsuite/tests/plugins/simple-plugin/Simple/RemovePlugin.hs - utils/haddock Changes: ===================================== compiler/GHC.hs ===================================== @@ -98,7 +98,32 @@ module GHC ( lookupGlobalName, findGlobalAnns, mkNamePprCtxForModule, - ModIface, ModIface_(..), + ModIface, + mi_module, + mi_sig_of, + mi_hsc_src, + mi_src_hash, + mi_hi_bytes, + mi_deps, + mi_usages, + mi_exports, + mi_used_th, + mi_fixities, + mi_warns, + mi_anns, + mi_insts, + mi_fam_insts, + mi_rules, + mi_decls, + mi_extra_decls, + mi_globals, + mi_hpc, + mi_trust, + mi_trust_pkg, + mi_complete_matches, + mi_docs, + mi_final_exts, + mi_ext_fields, SafeHaskellMode(..), -- * Printing ===================================== compiler/GHC/Driver/DynFlags.hs ===================================== @@ -207,6 +207,7 @@ data DynFlags = DynFlags { dmdUnboxWidth :: !Int, -- ^ Whether DmdAnal should optimistically put an -- Unboxed demand on returned products with at most -- this number of fields + ifCompression :: Int, specConstrThreshold :: Maybe Int, -- ^ Threshold for SpecConstr specConstrCount :: Maybe Int, -- ^ Max number of specialisations for any one function specConstrRecursive :: Int, -- ^ Max number of specialisations for recursive types @@ -546,6 +547,7 @@ defaultDynFlags mySettings = maxPmCheckModels = 30, simplTickFactor = 100, dmdUnboxWidth = 3, -- Default: Assume an unboxed demand on function bodies returning a triple + ifCompression = 2, -- Default: Apply safe compressions specConstrThreshold = Just 2000, specConstrCount = Just 3, specConstrRecursive = 3, ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -163,7 +163,7 @@ import GHC.JS.Syntax import GHC.IfaceToCore ( typecheckIface, typecheckWholeCoreBindings ) -import GHC.Iface.Load ( ifaceStats, writeIface ) +import GHC.Iface.Load ( ifaceStats, writeIface, flagsToIfCompression ) import GHC.Iface.Make import GHC.Iface.Recomp import GHC.Iface.Tidy @@ -612,7 +612,7 @@ extract_renamed_stuff mod_summary tc_result = do -- enables the option which keeps the renamed source. hieFile <- mkHieFile mod_summary tc_result (fromJust rn_info) let out_file = ml_hie_file $ ms_location mod_summary - liftIO $ writeHieFile out_file hieFile + liftIO $ writeHieFile (flagsToIfCompression dflags) out_file hieFile liftIO $ putDumpFileMaybe logger Opt_D_dump_hie "HIE AST" FormatHaskell (ppr $ hie_asts hieFile) -- Validate HIE files @@ -966,10 +966,11 @@ loadByteCode iface mod_sum = do -------------------------------------------------------------- + -- Knot tying! See Note [Knot-tying typecheckIface] -- See Note [ModDetails and --make mode] initModDetails :: HscEnv -> ModIface -> IO ModDetails -initModDetails hsc_env iface = +initModDetails hsc_env iface = do fixIO $ \details' -> do let act hpt = addToHpt hpt (moduleName $ mi_module iface) (HomeModInfo iface details' emptyHomeModInfoLinkable) @@ -1207,7 +1208,7 @@ hscMaybeWriteIface logger dflags is_simple iface old_iface mod_location = do withTiming logger (text "WriteIface"<+>brackets (text iface_name)) (const ()) - (writeIface logger profile iface_name iface) + (writeIface logger profile (flagsToIfCompression dflags) iface_name iface) if (write_interface || force_write_interface) then do ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -1695,6 +1695,9 @@ dynamic_flags_deps = [ , make_ord_flag defFlag "fno-refinement-level-hole-fits" (noArg (\d -> d { refLevelHoleFits = Nothing })) + , make_ord_flag defFlag "fwrite-if-compression" + (intSuffix (\n d -> d { ifCompression = n })) + , make_dep_flag defGhcFlag "fllvm-pass-vectors-in-regs" (noArg id) "vectors registers are now passed in registers by default." ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -14,9 +14,12 @@ module GHC.Iface.Binary ( writeBinIface, readBinIface, readBinIfaceHeader, + CompressionIFace(..), getSymtabName, CheckHiWay(..), TraceBinIFace(..), + getIfaceWithExtFields, + putIfaceWithExtFields, getWithUserData, putWithUserData, @@ -48,7 +51,7 @@ import GHC.Types.SrcLoc import GHC.Platform import GHC.Settings.Constants import GHC.Utils.Fingerprint -import GHC.Iface.Type (IfaceType, getIfaceType, putIfaceType) +import GHC.Iface.Type (IfaceType(..), getIfaceType, putIfaceType, ifaceTypeSharedByte) import Control.Monad import Data.Array @@ -60,6 +63,8 @@ import Data.Map.Strict (Map) import Data.Word import System.IO.Unsafe import Data.Typeable (Typeable) +import qualified GHC.Data.Strict as Strict +import Data.Function ((&)) -- --------------------------------------------------------------------------- @@ -73,6 +78,21 @@ data TraceBinIFace = TraceBinIFace (SDoc -> IO ()) | QuietBinIFace +data CompressionIFace + = NormalCompression + -- ^ Perform the normal compression operations, + -- such as deduplicating 'Name's and 'FastString's + | SafeExtraCompression + -- ^ Perform some extra compression steps that have minimal impact + -- on the run-time of 'ghc'. + -- + -- This reduces the size of '.hi' files significantly in some cases + -- and reduces overall memory usage in certain scenarios. + | MaximalCompression + -- ^ Try to compress as much as possible. + -- + -- Yields the smallest '.hi' files but at the cost of additional run-time. + -- | Read an interface file header, checking the magic number, version, and -- way. Returns the hash of the source file and a BinHandle which points at the -- start of the rest of the interface file data. @@ -140,17 +160,27 @@ readBinIface readBinIface profile name_cache checkHiWay traceBinIface hi_path = do (src_hash, bh) <- readBinIfaceHeader profile name_cache checkHiWay traceBinIface hi_path - extFields_p <- get bh + mod_iface <- getIfaceWithExtFields name_cache bh - mod_iface <- getWithUserData name_cache bh + return $ mod_iface + & addSourceFingerprint src_hash - seekBinReader bh extFields_p - extFields <- get bh - return mod_iface - { mi_ext_fields = extFields - , mi_src_hash = src_hash - } +getIfaceWithExtFields :: NameCache -> ReadBinHandle -> IO ModIface +getIfaceWithExtFields name_cache bh = do + start <- tellBinReader bh + extFields_p_rel <- getRelBin bh + + mod_iface <- getWithUserData name_cache bh + + seekBinReader bh start + seekBinReaderRel bh extFields_p_rel + extFields <- get bh + modIfaceData <- freezeBinHandle2 bh start + pure $ mod_iface + & set_mi_ext_fields extFields + & set_mi_hi_bytes (FullIfaceBinHandle $ Strict.Just modIfaceData) + -- | This performs a get action after reading the dictionary and symbol -- table. It is necessary to run this before trying to deserialise any @@ -179,7 +209,7 @@ getTables name_cache bh = do -- add it to the 'ReaderUserData' of 'ReadBinHandle'. decodeReaderTable :: Typeable a => ReaderTable a -> ReadBinHandle -> IO ReadBinHandle decodeReaderTable tbl bh0 = do - table <- Binary.forwardGet bh (getTable tbl bh0) + table <- Binary.forwardGetRel bh (getTable tbl bh0) let binaryReader = mkReaderFromTable tbl table pure $ addReaderToUserData binaryReader bh0 @@ -199,8 +229,8 @@ getTables name_cache bh = do -- | Write an interface file. -- -- See Note [Deduplication during iface binary serialisation] for details. -writeBinIface :: Profile -> TraceBinIFace -> FilePath -> ModIface -> IO () -writeBinIface profile traceBinIface hi_path mod_iface = do +writeBinIface :: Profile -> TraceBinIFace -> CompressionIFace -> FilePath -> ModIface -> IO () +writeBinIface profile traceBinIface compressionLevel hi_path mod_iface = do bh <- openBinMem initBinMemSize let platform = profilePlatform profile put_ bh (binaryInterfaceMagic platform) @@ -211,26 +241,31 @@ writeBinIface profile traceBinIface hi_path mod_iface = do put_ bh tag put_ bh (mi_src_hash mod_iface) - extFields_p_p <- tellBinWriter bh - put_ bh extFields_p_p - - putWithUserData traceBinIface bh mod_iface - - extFields_p <- tellBinWriter bh - putAt bh extFields_p_p extFields_p - seekBinWriter bh extFields_p - put_ bh (mi_ext_fields mod_iface) + putIfaceWithExtFields traceBinIface compressionLevel bh mod_iface -- And send the result to the file writeBinMem bh hi_path +-- | Puts the 'ModIface' to the 'WriteBinHandle'. +-- +-- This avoids serialisation of the 'ModIface' if the fields 'mi_hi_bytes' contains a +-- 'Just' value. This fields can only be populated by reading the 'ModIface' using +-- 'getIfaceWithExtFields' and not modifying it in any way afterwards. +putIfaceWithExtFields :: TraceBinIFace -> CompressionIFace -> WriteBinHandle -> ModIface -> IO () +putIfaceWithExtFields traceBinIface compressionLevel bh mod_iface = + case mi_hi_bytes mod_iface of + FullIfaceBinHandle Strict.Nothing -> do + forwardPutRel_ bh (\_ -> put_ bh (mi_ext_fields mod_iface)) $ do + putWithUserData traceBinIface compressionLevel bh mod_iface + FullIfaceBinHandle (Strict.Just binData) -> putFullBinData bh binData + -- | Put a piece of data with an initialised `UserData` field. This -- is necessary if you want to serialise Names or FastStrings. -- It also writes a symbol table and the dictionary. -- This segment should be read using `getWithUserData`. -putWithUserData :: Binary a => TraceBinIFace -> WriteBinHandle -> a -> IO () -putWithUserData traceBinIface bh payload = do - (name_count, fs_count, _b) <- putWithTables bh (\bh' -> put bh' payload) +putWithUserData :: Binary a => TraceBinIFace -> CompressionIFace -> WriteBinHandle -> a -> IO () +putWithUserData traceBinIface compressionLevel bh payload = do + (name_count, fs_count, _b) <- putWithTables compressionLevel bh (\bh' -> put bh' payload) case traceBinIface of QuietBinIFace -> return () @@ -253,12 +288,12 @@ putWithUserData traceBinIface bh payload = do -- It returns (number of names, number of FastStrings, payload write result) -- -- See Note [Order of deduplication tables during iface binary serialisation] -putWithTables :: WriteBinHandle -> (WriteBinHandle -> IO b) -> IO (Int, Int, b) -putWithTables bh' put_payload = do +putWithTables :: CompressionIFace -> WriteBinHandle -> (WriteBinHandle -> IO b) -> IO (Int, Int, b) +putWithTables compressionLevel bh' put_payload = do -- Initialise deduplicating tables. (fast_wt, fsWriter) <- initFastStringWriterTable (name_wt, nameWriter) <- initNameWriterTable - (ifaceType_wt, ifaceTypeWriter) <- initWriteIfaceType + (ifaceType_wt, ifaceTypeWriter) <- initWriteIfaceType compressionLevel -- Initialise the 'WriterUserData'. let writerUserData = mkWriterUserData @@ -293,7 +328,7 @@ putAllTables _ [] act = do a <- act pure ([], a) putAllTables bh (x : xs) act = do - (r, (res, a)) <- forwardPut bh (const $ putTable x bh) $ do + (r, (res, a)) <- forwardPutRel bh (const $ putTable x bh) $ do putAllTables bh xs act pure (r : res, a) @@ -445,7 +480,7 @@ to the table we need to deserialise first. What deduplication tables exist and the order of serialisation is currently statically specified in 'putWithTables'. 'putWithTables' also takes care of the serialisation of used deduplication tables. The deserialisation of the deduplication tables happens 'getTables', using 'Binary' utility -functions such as 'forwardGet'. +functions such as 'forwardGetRel'. Here, a visualisation of the table structure we currently have (ignoring 'ExtensibleFields'): @@ -485,15 +520,32 @@ initReadIfaceTypeTable ud = do , mkReaderFromTable = \tbl -> mkReader (getGenericSymtab tbl) } -initWriteIfaceType :: IO (WriterTable, BinaryWriter IfaceType) -initWriteIfaceType = do +initWriteIfaceType :: CompressionIFace -> IO (WriterTable, BinaryWriter IfaceType) +initWriteIfaceType compressionLevel = do sym_tab <- initGenericSymbolTable @(Map IfaceType) pure ( WriterTable { putTable = putGenericSymbolTable sym_tab (lazyPut' putIfaceType) } - , mkWriter $ putGenericSymTab sym_tab + , mkWriter $ ifaceWriter sym_tab ) + where + ifaceWriter sym_tab = case compressionLevel of + NormalCompression -> literalIfaceTypeSerialiser + SafeExtraCompression -> ifaceTyConAppSerialiser sym_tab + MaximalCompression -> fullIfaceTypeSerialiser sym_tab + + ifaceTyConAppSerialiser sym_tab bh ty = case ty of + IfaceTyConApp {} -> do + put_ bh ifaceTypeSharedByte + putGenericSymTab sym_tab bh ty + _ -> putIfaceType bh ty + + fullIfaceTypeSerialiser sym_tab bh ty = do + put_ bh ifaceTypeSharedByte + putGenericSymTab sym_tab bh ty + + literalIfaceTypeSerialiser = putIfaceType initNameReaderTable :: NameCache -> IO (ReaderTable Name) ===================================== compiler/GHC/Iface/Ext/Binary.hs ===================================== @@ -43,7 +43,7 @@ import System.Directory ( createDirectoryIfMissing ) import System.FilePath ( takeDirectory ) import GHC.Iface.Ext.Types -import GHC.Iface.Binary (initWriteIfaceType, putAllTables, initReadIfaceTypeTable) +import GHC.Iface.Binary (initWriteIfaceType, putAllTables, initReadIfaceTypeTable, CompressionIFace) import GHC.Iface.Type (IfaceType) import System.IO.Unsafe (unsafeInterleaveIO) import qualified GHC.Utils.Binary as Binary @@ -73,8 +73,8 @@ putBinLine bh xs = do -- | Write a `HieFile` to the given `FilePath`, with a proper header and -- symbol tables for `Name`s and `FastString`s -writeHieFile :: FilePath -> HieFile -> IO () -writeHieFile hie_file_path hiefile = do +writeHieFile :: CompressionIFace -> FilePath -> HieFile -> IO () +writeHieFile compression hie_file_path hiefile = do bh0 <- openBinMem initBinMemSize -- Write the header: hieHeader followed by the @@ -85,7 +85,7 @@ writeHieFile hie_file_path hiefile = do (fs_tbl, fs_w) <- initFastStringWriterTable (name_tbl, name_w) <- initWriteNameTable - (iface_tbl, iface_w) <- initWriteIfaceType + (iface_tbl, iface_w) <- initWriteIfaceType compression let bh = setWriterUserData bh0 $ mkWriterUserData [ mkSomeBinaryWriter @IfaceType iface_w @@ -235,7 +235,7 @@ readHieFileContents bh0 name_cache = do get bh1 where get_dictionary tbl bin_handle = do - fsTable <- Binary.forwardGet bin_handle (getTable tbl bin_handle) + fsTable <- Binary.forwardGetRel bin_handle (getTable tbl bin_handle) let fsReader = mkReaderFromTable tbl fsTable bhFs = addReaderToUserData fsReader bin_handle ===================================== compiler/GHC/Iface/Ext/Fields.hs ===================================== @@ -41,7 +41,7 @@ instance Binary ExtensibleFields where -- to point to the start of each payload: forM_ header_entries $ \(field_p_p, dat) -> do field_p <- tellBinWriter bh - putAt bh field_p_p field_p + putAtRel bh field_p_p field_p seekBinWriter bh field_p put_ bh dat @@ -50,11 +50,11 @@ instance Binary ExtensibleFields where -- Get the names and field pointers: header_entries <- replicateM n $ - (,) <$> get bh <*> get bh + (,) <$> get bh <*> getRelBin bh -- Seek to and get each field's payload: fields <- forM header_entries $ \(name, field_p) -> do - seekBinReader bh field_p + seekBinReaderRel bh field_p dat <- get bh return (name, dat) ===================================== compiler/GHC/Iface/Load.hs ===================================== @@ -26,6 +26,7 @@ module GHC.Iface.Load ( loadInterface, loadSysInterface, loadUserInterface, loadPluginInterface, findAndReadIface, readIface, writeIface, + flagsToIfCompression, moduleFreeHolesPrecise, needWiredInHomeIface, loadWiredInHomeIface, @@ -116,6 +117,7 @@ import System.FilePath import System.Directory import GHC.Driver.Env.KnotVars import GHC.Iface.Errors.Types +import Data.Function ((&)) {- ************************************************************************ @@ -514,14 +516,12 @@ loadInterface doc_str mod from ; new_eps_anns <- tcIfaceAnnotations (mi_anns iface) ; new_eps_complete_matches <- tcIfaceCompleteMatches (mi_complete_matches iface) - ; let { final_iface = iface { - mi_decls = panic "No mi_decls in PIT", - mi_insts = panic "No mi_insts in PIT", - mi_fam_insts = panic "No mi_fam_insts in PIT", - mi_rules = panic "No mi_rules in PIT", - mi_anns = panic "No mi_anns in PIT" - } - } + ; let final_iface = iface + & set_mi_decls (panic "No mi_decls in PIT") + & set_mi_insts (panic "No mi_insts in PIT") + & set_mi_fam_insts (panic "No mi_fam_insts in PIT") + & set_mi_rules (panic "No mi_rules in PIT") + & set_mi_anns (panic "No mi_anns in PIT") ; let bad_boot = mi_boot iface == IsBoot && isJust (lookupKnotVars (if_rec_types gbl_env) mod) @@ -965,11 +965,19 @@ read_file logger name_cache unit_state dflags wanted_mod file_path = do -- | Write interface file -writeIface :: Logger -> Profile -> FilePath -> ModIface -> IO () -writeIface logger profile hi_file_path new_iface +writeIface :: Logger -> Profile -> CompressionIFace -> FilePath -> ModIface -> IO () +writeIface logger profile compression_level hi_file_path new_iface = do createDirectoryIfMissing True (takeDirectory hi_file_path) let printer = TraceBinIFace (debugTraceMsg logger 3) - writeBinIface profile printer hi_file_path new_iface + writeBinIface profile printer compression_level hi_file_path new_iface + +flagsToIfCompression :: DynFlags -> CompressionIFace +flagsToIfCompression dflags + | n <= 1 = NormalCompression + | n == 2 = SafeExtraCompression + -- n >= 3 + | otherwise = MaximalCompression + where n = ifCompression dflags -- | @readIface@ tries just the one file. -- @@ -1009,13 +1017,13 @@ readIface dflags name_cache wanted_mod file_path = do -- See Note [GHC.Prim] in primops.txt.pp. ghcPrimIface :: ModIface ghcPrimIface - = empty_iface { - mi_exports = ghcPrimExports, - mi_decls = [], - mi_fixities = fixities, - mi_final_exts = (mi_final_exts empty_iface){ mi_fix_fn = mkIfaceFixCache fixities }, - mi_docs = Just ghcPrimDeclDocs -- See Note [GHC.Prim Docs] - } + = empty_iface + & set_mi_exports ghcPrimExports + & set_mi_decls [] + & set_mi_fixities fixities + & set_mi_final_exts ((mi_final_exts empty_iface){ mi_fix_fn = mkIfaceFixCache fixities }) + & set_mi_docs (Just ghcPrimDeclDocs) -- See Note [GHC.Prim Docs] + where empty_iface = emptyFullModIface gHC_PRIM @@ -1099,7 +1107,7 @@ pprModIfaceSimple unit_state iface = -- -- The UnitState is used to pretty-print units pprModIface :: UnitState -> ModIface -> SDoc -pprModIface unit_state iface at ModIface{ mi_final_exts = exts } +pprModIface unit_state iface = vcat [ text "interface" <+> ppr (mi_module iface) <+> pp_hsc_src (mi_hsc_src iface) <+> (if mi_orphan exts then text "[orphan module]" else Outputable.empty) @@ -1140,6 +1148,7 @@ pprModIface unit_state iface at ModIface{ mi_final_exts = exts } , text "extensible fields:" $$ nest 2 (pprExtensibleFields (mi_ext_fields iface)) ] where + exts = mi_final_exts iface pp_hsc_src HsBootFile = text "[boot]" pp_hsc_src HsigFile = text "[hsig]" pp_hsc_src HsSrcFile = Outputable.empty ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -69,10 +69,13 @@ import GHC.Types.HpcInfo import GHC.Types.CompleteMatch import GHC.Types.SourceText import GHC.Types.SrcLoc ( unLoc ) +import GHC.Types.Name.Cache import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Logger +import GHC.Utils.Binary +import GHC.Iface.Binary import GHC.Data.FastString import GHC.Data.Maybe @@ -141,14 +144,44 @@ mkFullIface hsc_env partial_iface mb_stg_infos mb_cmm_infos = do full_iface <- {-# SCC "addFingerprints" #-} - addFingerprints hsc_env partial_iface{ mi_decls = decls } + addFingerprints hsc_env (set_mi_decls decls partial_iface) -- Debug printing let unit_state = hsc_units hsc_env putDumpFileMaybe (hsc_logger hsc_env) Opt_D_dump_hi "FINAL INTERFACE" FormatText (pprModIface unit_state full_iface) + final_iface <- shareIface (hsc_NC hsc_env) (flagsToIfCompression $ hsc_dflags hsc_env) full_iface + return final_iface + +-- | Compress an 'ModIface' and share as many values as possible, depending on the 'CompressionIFace' level. +-- See Note [Sharing of ModIface]. +-- +-- We compress the 'ModIface' by serialising the 'ModIface' to an in-memory byte array, and then deserialising it. +-- The deserialisation will deduplicate certain values depending on the 'CompressionIFace' level. +-- See Note [Deduplication during iface binary serialisation] for how we do that. +-- +-- Additionally, we cache the serialised byte array, so if the 'ModIface' is not modified +-- after calling 'shareIface', 'writeBinIface' will reuse that buffer without serialising the 'ModIface' again. +-- Modifying the 'ModIface' forces us to re-serialise it again. +shareIface :: NameCache -> CompressionIFace -> ModIface -> IO ModIface +shareIface _ NormalCompression mi = do + -- In 'NormalCompression', the sharing isn't reducing the memory usage, as 'Name's and 'FastString's are + -- already shared, and at this compression level, we don't compress/share anything else. + -- Thus, for a brief moment we simply double the memory residency for no reason. + -- Therefore, we only try to share expensive values if the compression mode is higher than + -- 'NormalCompression' + pure mi +shareIface nc compressionLevel mi = do + bh <- openBinMem (1024 * 1024) + start <- tellBinWriter bh + putIfaceWithExtFields QuietBinIFace compressionLevel bh mi + rbh <- shrinkBinBuffer bh + seekBinReader rbh start + res <- getIfaceWithExtFields nc rbh + let resiface = restoreFromOldModIface mi res + forceModIface resiface + return resiface - return full_iface updateDecl :: [IfaceDecl] -> Maybe StgCgInfos -> Maybe CmmCgInfos -> [IfaceDecl] updateDecl decls Nothing Nothing = decls @@ -302,40 +335,40 @@ mkIface_ hsc_env icomplete_matches = map mkIfaceCompleteMatch complete_matches !rdrs = maybeGlobalRdrEnv rdr_env - ModIface { - mi_module = this_mod, + emptyPartialModIface this_mod -- Need to record this because it depends on the -instantiated-with flag -- which could change - mi_sig_of = if semantic_mod == this_mod + & set_mi_sig_of ( if semantic_mod == this_mod then Nothing - else Just semantic_mod, - mi_hsc_src = hsc_src, - mi_deps = deps, - mi_usages = usages, - mi_exports = mkIfaceExports exports, + else Just semantic_mod) + & set_mi_hsc_src ( hsc_src) + & set_mi_deps ( deps) + & set_mi_usages ( usages) + & set_mi_exports ( mkIfaceExports exports) -- Sort these lexicographically, so that -- the result is stable across compilations - mi_insts = sortBy cmp_inst iface_insts, - mi_fam_insts = sortBy cmp_fam_inst iface_fam_insts, - mi_rules = sortBy cmp_rule iface_rules, - - mi_fixities = fixities, - mi_warns = warns, - mi_anns = annotations, - mi_globals = rdrs, - mi_used_th = used_th, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_hpc = isHpcUsed hpc_info, - mi_trust = trust_info, - mi_trust_pkg = pkg_trust_req, - mi_complete_matches = icomplete_matches, - mi_docs = docs, - mi_final_exts = (), - mi_ext_fields = emptyExtensibleFields, - mi_src_hash = ms_hs_hash mod_summary - } + & set_mi_insts ( sortBy cmp_inst iface_insts) + & set_mi_fam_insts ( sortBy cmp_fam_inst iface_fam_insts) + & set_mi_rules ( sortBy cmp_rule iface_rules) + + & set_mi_fixities ( fixities) + & set_mi_warns ( warns) + & set_mi_anns ( annotations) + & set_mi_globals ( rdrs) + & set_mi_used_th ( used_th) + & set_mi_decls ( decls) + & set_mi_extra_decls ( extra_decls) + & set_mi_hpc ( isHpcUsed hpc_info) + & set_mi_trust ( trust_info) + & set_mi_trust_pkg ( pkg_trust_req) + & set_mi_complete_matches ( icomplete_matches) + & set_mi_docs ( docs) + & set_mi_final_exts ( ()) + & set_mi_ext_fields ( emptyExtensibleFields) + & set_mi_src_hash ( ms_hs_hash mod_summary) + & set_mi_hi_bytes ( PartialIfaceBinHandle) + where cmp_rule = lexicalCompareFS `on` ifRuleName -- Compare these lexicographically by OccName, *not* by unique, @@ -502,3 +535,22 @@ That is, in Y, In the result of mkIfaceExports, the names are grouped by defining module, so we may need to split up a single Avail into multiple ones. -} + +{- +Note [Sharing of ModIface] +~~~~~~~~~~~~~~~~~~~~~~~~~~ +A 'ModIface' contains many duplicated values such as 'Name', 'FastString' and 'IfaceType'. +'Name's and 'FastString's are already deduplicated by default using the 'NameCache' and +'FastStringTable' respectively. +However, 'IfaceType' can be quite expensive in terms of memory usage. +To improve the sharing of 'IfaceType', we introduced deduplication tables during +serialisation of 'ModIface', see Note [Deduplication during iface binary serialisation]. + +We can improve the sharing of 'ModIface' at run-time as well, by serialising the 'ModIface' to +an in-memory buffer, and then deserialising it again. +This implicitly shares duplicated values. + +To avoid re-serialising the 'ModIface' when writing it to disk, we save the serialised 'ModIface' buffer +in 'mi_hi_bytes_' field of said 'ModIface'. This buffer is written to disk directly in 'putIfaceWithExtFields'. +If we have to modify the 'ModIface' after 'shareIface' is called, the buffer needs to be discarded. +-} ===================================== compiler/GHC/Iface/Recomp.hs ===================================== @@ -83,6 +83,7 @@ import Data.Ord import Data.Containers.ListUtils import Data.Bifunctor import GHC.Iface.Errors.Ppr +import qualified GHC.Data.Strict as Strict {- ----------------------------------------------- @@ -1283,7 +1284,9 @@ addFingerprints hsc_env iface0 , mi_fix_fn = fix_fn , mi_hash_fn = lookupOccEnv local_env } - final_iface = iface0 { mi_decls = sorted_decls, mi_extra_decls = sorted_extra_decls, mi_final_exts = final_iface_exts } + final_iface = completePartialModIface iface0 + (sorted_decls) (sorted_extra_decls) (final_iface_exts) + -- return final_iface ===================================== compiler/GHC/Iface/Rename.hs ===================================== @@ -44,6 +44,7 @@ import GHC.Utils.Panic import qualified Data.Traversable as T import Data.IORef +import Data.Function ((&)) tcRnMsgMaybe :: IO (Either (Messages TcRnMessage) a) -> TcM a tcRnMsgMaybe do_this = do @@ -108,13 +109,14 @@ rnModIface hsc_env insts nsubst iface = deps <- rnDependencies (mi_deps iface) -- TODO: -- mi_rules - return iface { mi_module = mod - , mi_sig_of = sig_of - , mi_insts = insts - , mi_fam_insts = fams - , mi_exports = exports - , mi_decls = decls - , mi_deps = deps } + return $ iface + & set_mi_module mod + & set_mi_sig_of sig_of + & set_mi_insts insts + & set_mi_fam_insts fams + & set_mi_exports exports + & set_mi_decls decls + & set_mi_deps deps -- | Rename just the exports of a 'ModIface'. Useful when we're doing -- shaping prior to signature merging. ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -34,7 +34,7 @@ module GHC.Iface.Type ( ifTyConBinderVar, ifTyConBinderName, -- Binary utilities - putIfaceType, getIfaceType, + putIfaceType, getIfaceType, ifaceTypeSharedByte, -- Equality testing isIfaceLiftedTypeKind, @@ -92,12 +92,13 @@ import GHC.Utils.Misc import GHC.Utils.Panic import {-# SOURCE #-} GHC.Tc.Utils.TcType ( isMetaTyVar, isTyConableTyVar ) -import Control.DeepSeq +import Data.Maybe (isJust) import Data.Proxy -import Control.Monad ((<$!>)) -import Control.Arrow (first) import qualified Data.Semigroup as Semi -import Data.Maybe (isJust) +import Data.Word (Word8) +import Control.Arrow (first) +import Control.DeepSeq +import Control.Monad ((<$!>)) {- ************************************************************************ @@ -2197,12 +2198,35 @@ ppr_parend_preds :: [IfacePredType] -> SDoc ppr_parend_preds preds = parens (fsep (punctuate comma (map ppr preds))) instance Binary IfaceType where - put_ bh tyCon = case findUserDataWriter Proxy bh of - tbl -> putEntry tbl bh tyCon + put_ bh ty = + case findUserDataWriter Proxy bh of + tbl -> putEntry tbl bh ty - get bh = case findUserDataReader Proxy bh of - tbl -> getEntry tbl bh + get bh = getIfaceTypeShared bh +-- | This is the byte tag we expect to read when the next +-- value is not an 'IfaceType' value, but an offset into a +-- lookup value. +-- +-- Must not overlap with any byte tag in 'getIfaceType'. +ifaceTypeSharedByte :: Word8 +ifaceTypeSharedByte = 99 + +-- | Like 'getIfaceType' but checks for a specific byte tag +-- that indicates that we won't be able to read a 'IfaceType' value +-- but rather an offset into a lookup table. Consequentially, +-- we look up the value for the 'IfaceType' in the look up table. +-- +-- See Note [Deduplication during iface binary serialisation] +-- for details. +getIfaceTypeShared :: ReadBinHandle -> IO IfaceType +getIfaceTypeShared bh = do + start <- tellBinReader bh + tag <- getByte bh + if ifaceTypeSharedByte == tag + then case findUserDataReader Proxy bh of + tbl -> getEntry tbl bh + else seekBinReader bh start >> getIfaceType bh putIfaceType :: WriteBinHandle -> IfaceType -> IO () putIfaceType _ (IfaceFreeTyVar tv) ===================================== compiler/GHC/Tc/Errors/Hole.hs ===================================== @@ -76,7 +76,7 @@ import GHC.Tc.Utils.Unify ( tcSubTypeSigma ) import GHC.HsToCore.Docs ( extractDocs ) import GHC.Hs.Doc -import GHC.Unit.Module.ModIface ( ModIface_(..) ) +import GHC.Unit.Module.ModIface ( mi_docs ) import GHC.Iface.Load ( loadInterfaceForName ) import GHC.Builtin.Utils (knownKeyNames) ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -1562,7 +1562,8 @@ lookupDeclDoc nm = do -- Wasn't in the current module. Try searching other external ones! mIface <- getExternalModIface nm case mIface of - Just ModIface { mi_docs = Just Docs{docs_decls = dmap} } -> + Just iface + | Just Docs{docs_decls = dmap} <- mi_docs iface -> pure $ renderHsDocStrings . map hsDocString <$> lookupUniqMap dmap nm _ -> pure Nothing @@ -1578,7 +1579,8 @@ lookupArgDoc i nm = do Nothing -> do mIface <- getExternalModIface nm case mIface of - Just ModIface { mi_docs = Just Docs{docs_args = amap} } -> + Just iface + | Just Docs{docs_args = amap} <- mi_docs iface-> pure $ renderHsDocString . hsDocString <$> (lookupUniqMap amap nm >>= IntMap.lookup i) _ -> pure Nothing ===================================== compiler/GHC/Tc/Utils/Backpack.hs ===================================== @@ -87,6 +87,7 @@ import Control.Monad import Data.List (find) import GHC.Iface.Errors.Types +import Data.Function ((&)) checkHsigDeclM :: ModIface -> TyThing -> TyThing -> TcRn () checkHsigDeclM sig_iface sig_thing real_thing = do @@ -369,8 +370,8 @@ tcRnMergeSignatures hsc_env hpm orig_tcg_env iface = thinModIface :: [AvailInfo] -> ModIface -> ModIface thinModIface avails iface = - iface { - mi_exports = avails, + iface + & set_mi_exports avails -- mi_fixities = ..., -- mi_warns = ..., -- mi_anns = ..., @@ -378,10 +379,9 @@ thinModIface avails iface = -- perhaps there might be two IfaceTopBndr that are the same -- OccName but different Name. Requires better understanding -- of invariants here. - mi_decls = exported_decls ++ non_exported_decls ++ dfun_decls + & set_mi_decls (exported_decls ++ non_exported_decls ++ dfun_decls) -- mi_insts = ..., -- mi_fam_insts = ..., - } where decl_pred occs decl = nameOccName (ifName decl) `elemOccSet` occs filter_decls occs = filter (decl_pred occs . snd) (mi_decls iface) ===================================== compiler/GHC/Unit/Module/ModIface.hs ===================================== @@ -7,7 +7,61 @@ module GHC.Unit.Module.ModIface ( ModIface - , ModIface_ (..) + , ModIface_ + , restoreFromOldModIface + , addSourceFingerprint + , mi_module + , mi_sig_of + , mi_hsc_src + , mi_src_hash + , mi_hi_bytes + , mi_deps + , mi_usages + , mi_exports + , mi_used_th + , mi_fixities + , mi_warns + , mi_anns + , mi_insts + , mi_fam_insts + , mi_rules + , mi_decls + , mi_extra_decls + , mi_globals + , mi_hpc + , mi_trust + , mi_trust_pkg + , mi_complete_matches + , mi_docs + , mi_final_exts + , mi_ext_fields + , set_mi_module + , set_mi_sig_of + , set_mi_hsc_src + , set_mi_src_hash + , set_mi_hi_bytes + , set_mi_deps + , set_mi_usages + , set_mi_exports + , set_mi_used_th + , set_mi_fixities + , set_mi_warns + , set_mi_anns + , set_mi_insts + , set_mi_fam_insts + , set_mi_rules + , set_mi_decls + , set_mi_extra_decls + , set_mi_globals + , set_mi_hpc + , set_mi_trust + , set_mi_trust_pkg + , set_mi_complete_matches + , set_mi_docs + , set_mi_final_exts + , set_mi_ext_fields + , completePartialModIface + , IfaceBinHandle(..) , PartialModIface , ModIfaceBackend (..) , IfaceDeclExts @@ -58,6 +112,7 @@ import GHC.Utils.Binary import Control.DeepSeq import Control.Exception +import qualified GHC.Data.Strict as Strict {- Note [Interface file stages] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -139,7 +194,9 @@ type family IfaceBackendExts (phase :: ModIfacePhase) = bk | bk -> phase where IfaceBackendExts 'ModIfaceCore = () IfaceBackendExts 'ModIfaceFinal = ModIfaceBackend - +data IfaceBinHandle (phase :: ModIfacePhase) where + PartialIfaceBinHandle :: IfaceBinHandle 'ModIfaceCore + FullIfaceBinHandle :: Strict.Maybe FullBinData -> IfaceBinHandle 'ModIfaceFinal -- | A 'ModIface' plus a 'ModDetails' summarises everything we know -- about a compiled module. The 'ModIface' is the stuff *before* linking, @@ -153,62 +210,65 @@ type family IfaceBackendExts (phase :: ModIfacePhase) = bk | bk -> phase where -- -- See Note [Strictness in ModIface] to learn about why some fields are -- strict and others are not. +-- +-- See Note [Private fields in ModIface] to learn why we don't export any of the +-- fields. data ModIface_ (phase :: ModIfacePhase) = ModIface { - mi_module :: !Module, -- ^ Name of the module we are for - mi_sig_of :: !(Maybe Module), -- ^ Are we a sig of another mod? + mi_module_ :: !Module, -- ^ Name of the module we are for + mi_sig_of_ :: !(Maybe Module), -- ^ Are we a sig of another mod? - mi_hsc_src :: !HscSource, -- ^ Boot? Signature? + mi_hsc_src_ :: !HscSource, -- ^ Boot? Signature? - mi_deps :: Dependencies, + mi_deps_ :: Dependencies, -- ^ The dependencies of the module. This is -- consulted for directly-imported modules, but not -- for anything else (hence lazy) - mi_usages :: [Usage], + mi_usages_ :: [Usage], -- ^ Usages; kept sorted so that it's easy to decide -- whether to write a new iface file (changing usages -- doesn't affect the hash of this module) -- NOT STRICT! we read this field lazily from the interface file -- It is *only* consulted by the recompilation checker - mi_exports :: ![IfaceExport], + mi_exports_ :: ![IfaceExport], -- ^ Exports -- Kept sorted by (mod,occ), to make version comparisons easier -- Records the modules that are the declaration points for things -- exported by this module, and the 'OccName's of those things - mi_used_th :: !Bool, + mi_used_th_ :: !Bool, -- ^ Module required TH splices when it was compiled. -- This disables recompilation avoidance (see #481). - mi_fixities :: [(OccName,Fixity)], + mi_fixities_ :: [(OccName,Fixity)], -- ^ Fixities -- NOT STRICT! we read this field lazily from the interface file - mi_warns :: IfaceWarnings, + mi_warns_ :: IfaceWarnings, -- ^ Warnings -- NOT STRICT! we read this field lazily from the interface file - mi_anns :: [IfaceAnnotation], + mi_anns_ :: [IfaceAnnotation], -- ^ Annotations -- NOT STRICT! we read this field lazily from the interface file - mi_decls :: [IfaceDeclExts phase], + mi_decls_ :: [IfaceDeclExts phase], -- ^ Type, class and variable declarations -- The hash of an Id changes if its fixity or deprecations change -- (as well as its type of course) -- Ditto data constructors, class operations, except that -- the hash of the parent class/tycon changes - mi_extra_decls :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo], + mi_extra_decls_ :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo], -- ^ Extra variable definitions which are **NOT** exposed but when -- combined with mi_decls allows us to restart code generation. -- See Note [Interface Files with Core Definitions] and Note [Interface File with Core: Sharing RHSs] - mi_globals :: !(Maybe IfGlobalRdrEnv), + mi_globals_ :: !(Maybe IfGlobalRdrEnv), -- ^ Binds all the things defined at the top level in -- the /original source/ code for this module. which -- is NOT the same as mi_exports, nor mi_decls (which @@ -224,36 +284,36 @@ data ModIface_ (phase :: ModIfacePhase) -- 'HomeModInfo', but that leads to more plumbing. -- Instance declarations and rules - mi_insts :: [IfaceClsInst], -- ^ Sorted class instance - mi_fam_insts :: [IfaceFamInst], -- ^ Sorted family instances - mi_rules :: [IfaceRule], -- ^ Sorted rules + mi_insts_ :: [IfaceClsInst], -- ^ Sorted class instance + mi_fam_insts_ :: [IfaceFamInst], -- ^ Sorted family instances + mi_rules_ :: [IfaceRule], -- ^ Sorted rules - mi_hpc :: !AnyHpcUsage, + mi_hpc_ :: !AnyHpcUsage, -- ^ True if this program uses Hpc at any point in the program. - mi_trust :: !IfaceTrustInfo, + mi_trust_ :: !IfaceTrustInfo, -- ^ Safe Haskell Trust information for this module. - mi_trust_pkg :: !Bool, + mi_trust_pkg_ :: !Bool, -- ^ Do we require the package this module resides in be trusted -- to trust this module? This is used for the situation where a -- module is Safe (so doesn't require the package be trusted -- itself) but imports some trustworthy modules from its own -- package (which does require its own package be trusted). -- See Note [Trust Own Package] in GHC.Rename.Names - mi_complete_matches :: ![IfaceCompleteMatch], + mi_complete_matches_ :: ![IfaceCompleteMatch], - mi_docs :: !(Maybe Docs), + mi_docs_ :: !(Maybe Docs), -- ^ Docstrings and related data for use by haddock, the ghci -- @:doc@ command, and other tools. -- -- @Just _@ @<=>@ the module was built with @-haddock at . - mi_final_exts :: !(IfaceBackendExts phase), + mi_final_exts_ :: !(IfaceBackendExts phase), -- ^ Either `()` or `ModIfaceBackend` for -- a fully instantiated interface. - mi_ext_fields :: !ExtensibleFields, + mi_ext_fields_ :: !ExtensibleFields, -- ^ Additional optional fields, where the Map key represents -- the field name, resulting in a (size, serialized data) pair. -- Because the data is intended to be serialized through the @@ -262,8 +322,13 @@ data ModIface_ (phase :: ModIfacePhase) -- chosen over `ByteString`s. -- - mi_src_hash :: !Fingerprint + mi_src_hash_ :: !Fingerprint, -- ^ Hash of the .hs source, used for recompilation checking. + mi_hi_bytes_ :: !(IfaceBinHandle phase) + -- ^ A serialised in-memory buffer of this 'ModIface'. + -- If this handle is given, we can avoid serialising the 'ModIface' + -- when writing this 'ModIface' to disk, and write this buffer to disk instead. + -- See Note [Sharing of ModIface]. } {- @@ -343,33 +408,34 @@ renameFreeHoles fhs insts = -- See Note [Strictness in ModIface] about where we use lazyPut vs put instance Binary ModIface where put_ bh (ModIface { - mi_module = mod, - mi_sig_of = sig_of, - mi_hsc_src = hsc_src, - mi_src_hash = _src_hash, -- Don't `put_` this in the instance + mi_module_ = mod, + mi_sig_of_ = sig_of, + mi_hsc_src_ = hsc_src, + mi_src_hash_ = _src_hash, -- Don't `put_` this in the instance -- because we are going to write it -- out separately in the actual file - mi_deps = deps, - mi_usages = usages, - mi_exports = exports, - mi_used_th = used_th, - mi_fixities = fixities, - mi_warns = warns, - mi_anns = anns, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_insts = insts, - mi_fam_insts = fam_insts, - mi_rules = rules, - mi_hpc = hpc_info, - mi_trust = trust, - mi_trust_pkg = trust_pkg, - mi_complete_matches = complete_matches, - mi_docs = docs, - mi_ext_fields = _ext_fields, -- Don't `put_` this in the instance so we + mi_hi_bytes_ = _hi_bytes, -- TODO: explain + mi_deps_ = deps, + mi_usages_ = usages, + mi_exports_ = exports, + mi_used_th_ = used_th, + mi_fixities_ = fixities, + mi_warns_ = warns, + mi_anns_ = anns, + mi_decls_ = decls, + mi_extra_decls_ = extra_decls, + mi_insts_ = insts, + mi_fam_insts_ = fam_insts, + mi_rules_ = rules, + mi_hpc_ = hpc_info, + mi_trust_ = trust, + mi_trust_pkg_ = trust_pkg, + mi_complete_matches_ = complete_matches, + mi_docs_ = docs, + mi_ext_fields_ = _ext_fields, -- Don't `put_` this in the instance so we -- can deal with it's pointer in the header -- when we write the actual file - mi_final_exts = ModIfaceBackend { + mi_final_exts_ = ModIfaceBackend { mi_iface_hash = iface_hash, mi_mod_hash = mod_hash, mi_flag_hash = flag_hash, @@ -444,33 +510,34 @@ instance Binary ModIface where complete_matches <- get bh docs <- lazyGetMaybe bh return (ModIface { - mi_module = mod, - mi_sig_of = sig_of, - mi_hsc_src = hsc_src, - mi_src_hash = fingerprint0, -- placeholder because this is dealt + mi_module_ = mod, + mi_sig_of_ = sig_of, + mi_hsc_src_ = hsc_src, + mi_src_hash_ = fingerprint0, -- placeholder because this is dealt -- with specially when the file is read - mi_deps = deps, - mi_usages = usages, - mi_exports = exports, - mi_used_th = used_th, - mi_anns = anns, - mi_fixities = fixities, - mi_warns = warns, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_globals = Nothing, - mi_insts = insts, - mi_fam_insts = fam_insts, - mi_rules = rules, - mi_hpc = hpc_info, - mi_trust = trust, - mi_trust_pkg = trust_pkg, + mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing, + mi_deps_ = deps, + mi_usages_ = usages, + mi_exports_ = exports, + mi_used_th_ = used_th, + mi_anns_ = anns, + mi_fixities_ = fixities, + mi_warns_ = warns, + mi_decls_ = decls, + mi_extra_decls_ = extra_decls, + mi_globals_ = Nothing, + mi_insts_ = insts, + mi_fam_insts_ = fam_insts, + mi_rules_ = rules, + mi_hpc_ = hpc_info, + mi_trust_ = trust, + mi_trust_pkg_ = trust_pkg, -- And build the cached values - mi_complete_matches = complete_matches, - mi_docs = docs, - mi_ext_fields = emptyExtensibleFields, -- placeholder because this is dealt + mi_complete_matches_ = complete_matches, + mi_docs_ = docs, + mi_ext_fields_ = emptyExtensibleFields, -- placeholder because this is dealt -- with specially when the file is read - mi_final_exts = ModIfaceBackend { + mi_final_exts_ = ModIfaceBackend { mi_iface_hash = iface_hash, mi_mod_hash = mod_hash, mi_flag_hash = flag_hash, @@ -487,42 +554,45 @@ instance Binary ModIface where mi_hash_fn = mkIfaceHashCache decls }}) + -- | The original names declared of a certain module that are exported type IfaceExport = AvailInfo emptyPartialModIface :: Module -> PartialModIface emptyPartialModIface mod - = ModIface { mi_module = mod, - mi_sig_of = Nothing, - mi_hsc_src = HsSrcFile, - mi_src_hash = fingerprint0, - mi_deps = noDependencies, - mi_usages = [], - mi_exports = [], - mi_used_th = False, - mi_fixities = [], - mi_warns = IfWarnSome [] [], - mi_anns = [], - mi_insts = [], - mi_fam_insts = [], - mi_rules = [], - mi_decls = [], - mi_extra_decls = Nothing, - mi_globals = Nothing, - mi_hpc = False, - mi_trust = noIfaceTrustInfo, - mi_trust_pkg = False, - mi_complete_matches = [], - mi_docs = Nothing, - mi_final_exts = (), - mi_ext_fields = emptyExtensibleFields + = ModIface { mi_module_ = mod, + mi_sig_of_ = Nothing, + mi_hsc_src_ = HsSrcFile, + mi_src_hash_ = fingerprint0, + mi_hi_bytes_ = PartialIfaceBinHandle, + mi_deps_ = noDependencies, + mi_usages_ = [], + mi_exports_ = [], + mi_used_th_ = False, + mi_fixities_ = [], + mi_warns_ = IfWarnSome [] [], + mi_anns_ = [], + mi_insts_ = [], + mi_fam_insts_ = [], + mi_rules_ = [], + mi_decls_ = [], + mi_extra_decls_ = Nothing, + mi_globals_ = Nothing, + mi_hpc_ = False, + mi_trust_ = noIfaceTrustInfo, + mi_trust_pkg_ = False, + mi_complete_matches_ = [], + mi_docs_ = Nothing, + mi_final_exts_ = (), + mi_ext_fields_ = emptyExtensibleFields } emptyFullModIface :: Module -> ModIface emptyFullModIface mod = (emptyPartialModIface mod) - { mi_decls = [] - , mi_final_exts = ModIfaceBackend + { mi_decls_ = [] + , mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing + , mi_final_exts_ = ModIfaceBackend { mi_iface_hash = fingerprint0, mi_mod_hash = fingerprint0, mi_flag_hash = fingerprint0, @@ -557,36 +627,36 @@ emptyIfaceHashCache _occ = Nothing instance ( NFData (IfaceBackendExts (phase :: ModIfacePhase)) , NFData (IfaceDeclExts (phase :: ModIfacePhase)) ) => NFData (ModIface_ phase) where - rnf (ModIface{ mi_module, mi_sig_of, mi_hsc_src, mi_deps, mi_usages - , mi_exports, mi_used_th, mi_fixities, mi_warns, mi_anns - , mi_decls, mi_extra_decls, mi_globals, mi_insts - , mi_fam_insts, mi_rules, mi_hpc, mi_trust, mi_trust_pkg - , mi_complete_matches, mi_docs, mi_final_exts - , mi_ext_fields, mi_src_hash }) - = rnf mi_module - `seq` rnf mi_sig_of - `seq` mi_hsc_src - `seq` mi_deps - `seq` mi_usages - `seq` mi_exports - `seq` rnf mi_used_th - `seq` mi_fixities - `seq` rnf mi_warns - `seq` rnf mi_anns - `seq` rnf mi_decls - `seq` rnf mi_extra_decls - `seq` rnf mi_globals - `seq` rnf mi_insts - `seq` rnf mi_fam_insts - `seq` rnf mi_rules - `seq` rnf mi_hpc - `seq` mi_trust - `seq` rnf mi_trust_pkg - `seq` rnf mi_complete_matches - `seq` rnf mi_docs - `seq` mi_final_exts - `seq` mi_ext_fields - `seq` rnf mi_src_hash + rnf (ModIface{ mi_module_, mi_sig_of_, mi_hsc_src_, mi_deps_, mi_usages_ + , mi_exports_, mi_used_th_, mi_fixities_, mi_warns_, mi_anns_ + , mi_decls_, mi_extra_decls_, mi_globals_, mi_insts_ + , mi_fam_insts_, mi_rules_, mi_hpc_, mi_trust_, mi_trust_pkg_ + , mi_complete_matches_, mi_docs_, mi_final_exts_ + , mi_ext_fields_, mi_src_hash_ }) + = rnf mi_module_ + `seq` rnf mi_sig_of_ + `seq` mi_hsc_src_ + `seq` mi_deps_ + `seq` mi_usages_ + `seq` mi_exports_ + `seq` rnf mi_used_th_ + `seq` mi_fixities_ + `seq` rnf mi_warns_ + `seq` rnf mi_anns_ + `seq` rnf mi_decls_ + `seq` rnf mi_extra_decls_ + `seq` rnf mi_globals_ + `seq` rnf mi_insts_ + `seq` rnf mi_fam_insts_ + `seq` rnf mi_rules_ + `seq` rnf mi_hpc_ + `seq` mi_trust_ + `seq` rnf mi_trust_pkg_ + `seq` rnf mi_complete_matches_ + `seq` rnf mi_docs_ + `seq` mi_final_exts_ + `seq` mi_ext_fields_ + `seq` rnf mi_src_hash_ `seq` () instance NFData (ModIfaceBackend) where @@ -626,5 +696,226 @@ type WhetherHasOrphans = Bool -- | Does this module define family instances? type WhetherHasFamInst = Bool +-- ---------------------------------------------------------------------------- +-- Modify a 'ModIface'. +-- ---------------------------------------------------------------------------- + +{- +Note [Private fields in ModIface] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The fields of 'ModIface' are private, e.g., not exported, to make the API +impossible to misuse. A 'ModIface' can be "compressed" in-memory using +'shareIface', which serialises the 'ModIface' to an in-memory buffer. +This has the advantage of reducing memory usage of 'ModIface', reducing the +overall memory usage of GHC. +See Note [Sharing of ModIface]. + +This in-memory buffer can be reused, if and only if the 'ModIface' is not +modified after it has been "compressed"/shared via 'shareIface'. Instead of +serialising 'ModIface', we simply write the in-memory buffer to disk directly. + +However, we can't rely that a 'ModIface' isn't modified after 'shareIface' has +been called. Thus, we make all fields of 'ModIface' private and modification +only happens via exported update functions, such as 'set_mi_decls'. +These functions unconditionally clear any in-memory buffer if used, forcing us +to serialise the 'ModIface' to disk again. +-} + +-- | Given a 'PartialModIface', turn it into a 'ModIface' by completing +-- missing fields. +completePartialModIface :: PartialModIface + -> [(Fingerprint, IfaceDecl)] + -> Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] + -> ModIfaceBackend + -> ModIface +completePartialModIface partial decls extra_decls final_exts = partial + { mi_decls_ = decls + , mi_extra_decls_ = extra_decls + , mi_final_exts_ = final_exts + , mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing + } + +-- | Add a source fingerprint to a 'ModIface_' without invalidating the byte array +-- buffer 'mi_hi_bytes'. +-- This is a variant of 'set_mi_src_hash' which does invalidate the buffer. +-- +-- The 'mi_src_hash' is computed outside of 'ModIface_' based on the 'ModSummary'. +addSourceFingerprint :: Fingerprint -> ModIface_ phase -> ModIface_ phase +addSourceFingerprint val iface = iface { mi_src_hash_ = val } + +-- | Copy fields that aren't serialised to disk to the new 'ModIface_'. +-- This includes especially hashes that are usually stored in the interface +-- file header and 'mi_globals'. +-- +-- We need this function after calling 'shareIface', to make sure the +-- 'ModIface_' doesn't lose any information. This function does not discard +-- the in-memory byte array buffer 'mi_hi_bytes'. +restoreFromOldModIface :: ModIface_ phase -> ModIface_ phase -> ModIface_ phase +restoreFromOldModIface old new = new + { mi_globals_ = mi_globals_ old + , mi_hsc_src_ = mi_hsc_src_ old + , mi_src_hash_ = mi_src_hash_ old + } + +set_mi_module :: Module -> ModIface_ phase -> ModIface_ phase +set_mi_module val iface = clear_mi_hi_bytes $ iface { mi_module_ = val } + +set_mi_sig_of :: Maybe Module -> ModIface_ phase -> ModIface_ phase +set_mi_sig_of val iface = clear_mi_hi_bytes $ iface { mi_sig_of_ = val } + +set_mi_hsc_src :: HscSource -> ModIface_ phase -> ModIface_ phase +set_mi_hsc_src val iface = clear_mi_hi_bytes $ iface { mi_hsc_src_ = val } + +set_mi_src_hash :: Fingerprint -> ModIface_ phase -> ModIface_ phase +set_mi_src_hash val iface = clear_mi_hi_bytes $ iface { mi_src_hash_ = val } + +set_mi_hi_bytes :: IfaceBinHandle phase -> ModIface_ phase -> ModIface_ phase +set_mi_hi_bytes val iface = iface { mi_hi_bytes_ = val } + +set_mi_deps :: Dependencies -> ModIface_ phase -> ModIface_ phase +set_mi_deps val iface = clear_mi_hi_bytes $ iface { mi_deps_ = val } + +set_mi_usages :: [Usage] -> ModIface_ phase -> ModIface_ phase +set_mi_usages val iface = clear_mi_hi_bytes $ iface { mi_usages_ = val } + +set_mi_exports :: [IfaceExport] -> ModIface_ phase -> ModIface_ phase +set_mi_exports val iface = clear_mi_hi_bytes $ iface { mi_exports_ = val } + +set_mi_used_th :: Bool -> ModIface_ phase -> ModIface_ phase +set_mi_used_th val iface = clear_mi_hi_bytes $ iface { mi_used_th_ = val } + +set_mi_fixities :: [(OccName, Fixity)] -> ModIface_ phase -> ModIface_ phase +set_mi_fixities val iface = clear_mi_hi_bytes $ iface { mi_fixities_ = val } + +set_mi_warns :: IfaceWarnings -> ModIface_ phase -> ModIface_ phase +set_mi_warns val iface = clear_mi_hi_bytes $ iface { mi_warns_ = val } + +set_mi_anns :: [IfaceAnnotation] -> ModIface_ phase -> ModIface_ phase +set_mi_anns val iface = clear_mi_hi_bytes $ iface { mi_anns_ = val } + +set_mi_insts :: [IfaceClsInst] -> ModIface_ phase -> ModIface_ phase +set_mi_insts val iface = clear_mi_hi_bytes $ iface { mi_insts_ = val } + +set_mi_fam_insts :: [IfaceFamInst] -> ModIface_ phase -> ModIface_ phase +set_mi_fam_insts val iface = clear_mi_hi_bytes $ iface { mi_fam_insts_ = val } + +set_mi_rules :: [IfaceRule] -> ModIface_ phase -> ModIface_ phase +set_mi_rules val iface = clear_mi_hi_bytes $ iface { mi_rules_ = val } + +set_mi_decls :: [IfaceDeclExts phase] -> ModIface_ phase -> ModIface_ phase +set_mi_decls val iface = clear_mi_hi_bytes $ iface { mi_decls_ = val } + +set_mi_extra_decls :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] -> ModIface_ phase -> ModIface_ phase +set_mi_extra_decls val iface = clear_mi_hi_bytes $ iface { mi_extra_decls_ = val } + +set_mi_globals :: Maybe IfGlobalRdrEnv -> ModIface_ phase -> ModIface_ phase +set_mi_globals val iface = clear_mi_hi_bytes $ iface { mi_globals_ = val } + +set_mi_hpc :: AnyHpcUsage -> ModIface_ phase -> ModIface_ phase +set_mi_hpc val iface = clear_mi_hi_bytes $ iface { mi_hpc_ = val } + +set_mi_trust :: IfaceTrustInfo -> ModIface_ phase -> ModIface_ phase +set_mi_trust val iface = clear_mi_hi_bytes $ iface { mi_trust_ = val } + +set_mi_trust_pkg :: Bool -> ModIface_ phase -> ModIface_ phase +set_mi_trust_pkg val iface = clear_mi_hi_bytes $ iface { mi_trust_pkg_ = val } + +set_mi_complete_matches :: [IfaceCompleteMatch] -> ModIface_ phase -> ModIface_ phase +set_mi_complete_matches val iface = clear_mi_hi_bytes $ iface { mi_complete_matches_ = val } + +set_mi_docs :: Maybe Docs -> ModIface_ phase -> ModIface_ phase +set_mi_docs val iface = clear_mi_hi_bytes $ iface { mi_docs_ = val } + +set_mi_final_exts :: IfaceBackendExts phase -> ModIface_ phase -> ModIface_ phase +set_mi_final_exts val iface = clear_mi_hi_bytes $ iface { mi_final_exts_ = val } + +set_mi_ext_fields :: ExtensibleFields -> ModIface_ phase -> ModIface_ phase +set_mi_ext_fields val iface = clear_mi_hi_bytes $ iface { mi_ext_fields_ = val } + +-- | Invalidate any byte array buffer we might have. +clear_mi_hi_bytes :: ModIface_ phase -> ModIface_ phase +clear_mi_hi_bytes iface = iface + { mi_hi_bytes_ = case mi_hi_bytes iface of + PartialIfaceBinHandle -> PartialIfaceBinHandle + FullIfaceBinHandle _ -> FullIfaceBinHandle Strict.Nothing + } + +-- ---------------------------------------------------------------------------- +-- Accessor functions of 'ModIface'. +-- We use these as 'ModIface''s fields are private. +-- ---------------------------------------------------------------------------- + +mi_module :: ModIface_ phase -> Module +mi_module = mi_module_ + +mi_sig_of :: ModIface_ phase -> Maybe Module +mi_sig_of = mi_sig_of_ + +mi_hsc_src :: ModIface_ phase -> HscSource +mi_hsc_src = mi_hsc_src_ + +mi_deps :: ModIface_ phase -> Dependencies +mi_deps = mi_deps_ + +mi_usages :: ModIface_ phase -> [Usage] +mi_usages = mi_usages_ + +mi_exports :: ModIface_ phase -> [IfaceExport] +mi_exports = mi_exports_ + +mi_used_th :: ModIface_ phase -> Bool +mi_used_th = mi_used_th_ + +mi_fixities :: ModIface_ phase -> [(OccName, Fixity)] +mi_fixities = mi_fixities_ + +mi_warns :: ModIface_ phase -> IfaceWarnings +mi_warns = mi_warns_ + +mi_anns :: ModIface_ phase -> [IfaceAnnotation] +mi_anns = mi_anns_ + +mi_decls :: ModIface_ phase -> [IfaceDeclExts phase] +mi_decls = mi_decls_ + +mi_extra_decls :: ModIface_ phase -> Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] +mi_extra_decls = mi_extra_decls_ + +mi_globals :: ModIface_ phase -> Maybe IfGlobalRdrEnv +mi_globals = mi_globals_ + +mi_insts :: ModIface_ phase -> [IfaceClsInst] +mi_insts = mi_insts_ + +mi_fam_insts :: ModIface_ phase -> [IfaceFamInst] +mi_fam_insts = mi_fam_insts_ + +mi_rules :: ModIface_ phase -> [IfaceRule] +mi_rules = mi_rules_ + +mi_hpc :: ModIface_ phase -> AnyHpcUsage +mi_hpc = mi_hpc_ + +mi_trust :: ModIface_ phase -> IfaceTrustInfo +mi_trust = mi_trust_ + +mi_trust_pkg :: ModIface_ phase -> Bool +mi_trust_pkg = mi_trust_pkg_ + +mi_complete_matches :: ModIface_ phase -> [IfaceCompleteMatch] +mi_complete_matches = mi_complete_matches_ + +mi_docs :: ModIface_ phase -> Maybe Docs +mi_docs = mi_docs_ + +mi_final_exts :: ModIface_ phase -> IfaceBackendExts phase +mi_final_exts = mi_final_exts_ + +mi_ext_fields :: ModIface_ phase -> ExtensibleFields +mi_ext_fields = mi_ext_fields_ +mi_src_hash :: ModIface_ phase -> Fingerprint +mi_src_hash = mi_src_hash_ +mi_hi_bytes :: ModIface_ phase -> IfaceBinHandle phase +mi_hi_bytes = mi_hi_bytes_ ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -19,7 +19,7 @@ -- http://www.cs.york.ac.uk/fp/nhc98/ module GHC.Utils.Binary - ( {-type-} Bin, + ( {-type-} Bin, RelBin(..), getRelBin, {-class-} Binary(..), {-type-} ReadBinHandle, WriteBinHandle, SymbolTable, Dictionary, @@ -32,10 +32,14 @@ module GHC.Utils.Binary seekBinWriter, seekBinReader, + seekBinReaderRel, tellBinReader, tellBinWriter, castBin, withBinBuffer, + freezeWriteHandle, + shrinkBinBuffer, + thawReadHandle, foldGet, foldGet', @@ -44,7 +48,9 @@ module GHC.Utils.Binary readBinMemN, putAt, getAt, + putAtRel, forwardPut, forwardPut_, forwardGet, + forwardPutRel, forwardPutRel_, forwardGetRel, -- * For writing instances putByte, @@ -99,6 +105,9 @@ module GHC.Utils.Binary BindingName(..), simpleBindingNameWriter, simpleBindingNameReader, + FullBinData(..), freezeBinHandle, thawBinHandle, putFullBinData, + freezeBinHandle2, + BinArray, ) where import GHC.Prelude @@ -123,7 +132,7 @@ import Foreign hiding (shiftL, shiftR, void) import Data.Array import Data.Array.IO import Data.Array.Unsafe -import Data.ByteString (ByteString) +import Data.ByteString (ByteString, copy) import Data.Coerce import qualified Data.ByteString.Internal as BS import qualified Data.ByteString.Unsafe as BS @@ -153,7 +162,6 @@ import GHC.ForeignPtr ( unsafeWithForeignPtr ) import Unsafe.Coerce (unsafeCoerce) import GHC.Data.TrieMap - type BinArray = ForeignPtr Word8 #if !MIN_VERSION_base(4,15,0) @@ -193,6 +201,51 @@ dataHandle (BinData size bin) = do handleData :: WriteBinHandle -> IO BinData handleData (WriteBinMem _ ixr _ binr) = BinData <$> readFastMutInt ixr <*> readIORef binr +--------------------------------------------------------------- +-- FullBinData +--------------------------------------------------------------- + +data FullBinData = FullBinData + { fbd_readerUserData :: ReaderUserData + , fbd_off_s :: {-# UNPACK #-} !Int + -- ^ start offset + , fbd_off_e :: {-# UNPACK #-} !Int + -- ^ end offset + , fbd_size :: {-# UNPACK #-} !Int + -- ^ total buffer size + , fbd_buffer :: {-# UNPACK #-} !BinArray + } + +-- Equality and Ord assume that two distinct buffers are different, even if they compare the same things. +instance Eq FullBinData where + (FullBinData _ b c d e) == (FullBinData _ b1 c1 d1 e1) = b == b1 && c == c1 && d == d1 && e == e1 + +instance Ord FullBinData where + compare (FullBinData _ b c d e) (FullBinData _ b1 c1 d1 e1) = + compare b b1 `mappend` compare c c1 `mappend` compare d d1 `mappend` compare e e1 + +putFullBinData :: WriteBinHandle -> FullBinData -> IO () +putFullBinData bh (FullBinData _ o1 o2 _sz ba) = do + let sz = o2 - o1 + putPrim bh sz $ \dest -> + unsafeWithForeignPtr (ba `plusForeignPtr` o1) $ \orig -> + copyBytes dest orig sz + +freezeBinHandle :: Bin () -> ReadBinHandle -> IO FullBinData +freezeBinHandle (BinPtr len) (ReadBinMem user_data ixr sz binr) = do + ix <- readFastMutInt ixr + pure (FullBinData user_data ix len sz binr) + +freezeBinHandle2 :: ReadBinHandle -> Bin () -> IO FullBinData +freezeBinHandle2 (ReadBinMem user_data ixr sz binr) (BinPtr start) = do + ix <- readFastMutInt ixr + pure (FullBinData user_data start ix sz binr) + +thawBinHandle :: FullBinData -> IO ReadBinHandle +thawBinHandle (FullBinData user_data ix _end sz ba) = do + ixr <- newFastMutInt ix + return $ ReadBinMem user_data ixr sz ba + --------------------------------------------------------------- -- BinHandle --------------------------------------------------------------- @@ -286,9 +339,47 @@ unsafeUnpackBinBuffer (BS.BS arr len) = do newtype Bin a = BinPtr Int deriving (Eq, Ord, Show, Bounded) +-- | Like a 'Bin' but is used to store relative offset pointers. +-- Relative offset pointers store a relative location, but also contain an +-- anchor that allow to obtain the absolute offset. +data RelBin a = RelBin + { relBin_anchor :: {-# UNPACK #-} !(Bin a) + -- ^ Absolute position from where we read 'relBin_offset'. + , relBin_offset :: {-# UNPACK #-} !(RelBinPtr a) + -- ^ Relative offset to 'relBin_anchor'. + -- The absolute position of the 'RelBin' is @relBin_anchor + relBin_offset@ + } + deriving (Eq, Ord, Show, Bounded) + +-- | A 'RelBinPtr' is like a 'Bin', but contains a relative offset pointer +-- instead of an absolute offset. +newtype RelBinPtr a = RelBinPtr (Bin a) + deriving (Eq, Ord, Show, Bounded) + castBin :: Bin a -> Bin b castBin (BinPtr i) = BinPtr i +-- | Read a relative offset location and wrap it in 'RelBin'. +-- +-- The resulting 'RelBin' can be translated into an absolute offset location using +-- 'makeAbsoluteBin' +getRelBin :: ReadBinHandle -> IO (RelBin a) +getRelBin bh = do + start <- tellBinReader bh + off <- get bh + pure $ RelBin start off + +makeAbsoluteBin :: RelBin a -> Bin a +makeAbsoluteBin (RelBin (BinPtr !start) (RelBinPtr (BinPtr !offset))) = + BinPtr $ start + offset + +makeRelativeBin :: RelBin a -> RelBinPtr a +makeRelativeBin (RelBin _ offset) = offset + +toRelBin :: Bin (RelBinPtr a) -> Bin a -> RelBin a +toRelBin (BinPtr !start) (BinPtr !goal) = + RelBin (BinPtr start) (RelBinPtr $ BinPtr $ goal - start) + --------------------------------------------------------------- -- class Binary --------------------------------------------------------------- @@ -309,6 +400,9 @@ class Binary a where putAt :: Binary a => WriteBinHandle -> Bin a -> a -> IO () putAt bh p x = do seekBinWriter bh p; put_ bh x; return () +putAtRel :: WriteBinHandle -> Bin (RelBinPtr a) -> Bin a -> IO () +putAtRel bh from to = putAt bh from (makeRelativeBin $ toRelBin from to) + getAt :: Binary a => ReadBinHandle -> Bin a -> IO a getAt bh p = do seekBinReader bh p; get bh @@ -327,6 +421,44 @@ openBinMem size , wbm_arr_r = arr_r } +-- | Freeze the given 'WriteBinHandle' and turn it into an equivalent 'ReadBinHandle'. +-- +-- The current offset of the 'WriteBinHandle' is maintained in the new 'ReadBinHandle'. +freezeWriteHandle :: WriteBinHandle -> IO ReadBinHandle +freezeWriteHandle wbm = do + rbm_off_r <- newFastMutInt =<< readFastMutInt (wbm_off_r wbm) + rbm_sz_r <- readFastMutInt (wbm_sz_r wbm) + rbm_arr_r <- readIORef (wbm_arr_r wbm) + pure $ ReadBinMem + { rbm_userData = noReaderUserData + , rbm_off_r = rbm_off_r + , rbm_sz_r = rbm_sz_r + , rbm_arr_r = rbm_arr_r + } + +-- Copy the BinBuffer to a new BinBuffer which is exactly the right size. +-- This performs a copy of the underlying buffer. +-- The buffer may be truncated if the offset is not at the end of the written +-- output. +-- +-- UserData is also discarded during the copy +-- You should just use this when translating a Put handle into a Get handle. +shrinkBinBuffer :: WriteBinHandle -> IO ReadBinHandle +shrinkBinBuffer bh = withBinBuffer bh $ \bs -> do + unsafeUnpackBinBuffer (copy bs) + +thawReadHandle :: ReadBinHandle -> IO WriteBinHandle +thawReadHandle rbm = do + wbm_off_r <- newFastMutInt =<< readFastMutInt (rbm_off_r rbm) + wbm_sz_r <- newFastMutInt (rbm_sz_r rbm) + wbm_arr_r <- newIORef (rbm_arr_r rbm) + pure $ WriteBinMem + { wbm_userData = noWriterUserData + , wbm_off_r = wbm_off_r + , wbm_sz_r = wbm_sz_r + , wbm_arr_r = wbm_arr_r + } + tellBinWriter :: WriteBinHandle -> IO (Bin a) tellBinWriter (WriteBinMem _ r _ _) = do ix <- readFastMutInt r; return (BinPtr ix) @@ -352,12 +484,19 @@ seekBinNoExpandWriter (WriteBinMem _ ix_r sz_r _) (BinPtr !p) = do else writeFastMutInt ix_r p -- | SeekBin but without calling expandBin -seekBinReader :: ReadBinHandle -> Bin a -> IO () +seekBinReader :: HasCallStack => ReadBinHandle -> Bin a -> IO () seekBinReader (ReadBinMem _ ix_r sz_r _) (BinPtr !p) = do if (p > sz_r) then panic "seekBinReader: seek out of range" else writeFastMutInt ix_r p +seekBinReaderRel :: HasCallStack => ReadBinHandle -> RelBin a -> IO () +seekBinReaderRel (ReadBinMem _ ix_r sz_r _) relBin = do + let (BinPtr !p) = makeAbsoluteBin relBin + if (p > sz_r) + then panic "seekBinReaderRel: seek out of range" + else writeFastMutInt ix_r p + writeBinMem :: WriteBinHandle -> FilePath -> IO () writeBinMem (WriteBinMem _ ix_r _ arr_r) fn = do h <- openBinaryFile fn WriteMode @@ -1078,12 +1217,17 @@ instance Binary (Bin a) where put_ bh (BinPtr i) = putWord32 bh (fromIntegral i :: Word32) get bh = do i <- getWord32 bh; return (BinPtr (fromIntegral (i :: Word32))) +-- Instance uses fixed-width encoding to allow inserting +-- Bin placeholders in the stream. +instance Binary (RelBinPtr a) where + put_ bh (RelBinPtr i) = put_ bh i + get bh = RelBinPtr <$> get bh -- ----------------------------------------------------------------------------- -- Forward reading/writing --- | "forwardPut put_A put_B" outputs A after B but allows A to be read before B --- by using a forward reference +-- | @'forwardPut' put_A put_B@ outputs A after B but allows A to be read before B +-- by using a forward reference. forwardPut :: WriteBinHandle -> (b -> IO a) -> IO b -> IO (a,b) forwardPut bh put_A put_B = do -- write placeholder pointer to A @@ -1106,7 +1250,9 @@ forwardPut_ :: WriteBinHandle -> (b -> IO a) -> IO b -> IO () forwardPut_ bh put_A put_B = void $ forwardPut bh put_A put_B -- | Read a value stored using a forward reference -forwardGet :: ReadBinHandle -> IO a -> IO a +-- +-- The forward reference is expected to be an absolute offset. +forwardGet :: HasCallStack => ReadBinHandle -> IO a -> IO a forwardGet bh get_A = do -- read forward reference p <- get bh -- a BinPtr @@ -1118,6 +1264,48 @@ forwardGet bh get_A = do seekBinReader bh p_a pure r +-- | @'forwardPutRel' put_A put_B@ outputs A after B but allows A to be read before B +-- by using a forward reference. +-- +-- This forward reference is a relative offset that allows us to skip over the +-- result of 'put_A'. +forwardPutRel :: WriteBinHandle -> (b -> IO a) -> IO b -> IO (a,b) +forwardPutRel bh put_A put_B = do + -- write placeholder pointer to A + pre_a <- tellBinWriter bh + put_ bh pre_a + + -- write B + r_b <- put_B + + -- update A's pointer + a <- tellBinWriter bh + putAtRel bh pre_a a + seekBinNoExpandWriter bh a + + -- write A + r_a <- put_A r_b + pure (r_a,r_b) + +-- | Like 'forwardGetRel', but discard the result. +forwardPutRel_ :: WriteBinHandle -> (b -> IO a) -> IO b -> IO () +forwardPutRel_ bh put_A put_B = void $ forwardPutRel bh put_A put_B + +-- | Read a value stored using a forward reference. +-- +-- The forward reference is expected to be a relative offset. +forwardGetRel :: ReadBinHandle -> IO a -> IO a +forwardGetRel bh get_A = do + -- read forward reference + p <- getRelBin bh + -- store current position + p_a <- tellBinReader bh + -- go read the forward value, then seek back + seekBinReader bh $ makeAbsoluteBin p + r <- get_A + seekBinReader bh p_a + pure r + -- ----------------------------------------------------------------------------- -- Lazy reading/writing @@ -1127,19 +1315,19 @@ lazyPut = lazyPut' put_ lazyGet :: Binary a => ReadBinHandle -> IO a lazyGet = lazyGet' get -lazyPut' :: HasDebugCallStack => (WriteBinHandle -> a -> IO ()) -> WriteBinHandle -> a -> IO () +lazyPut' :: (WriteBinHandle -> a -> IO ()) -> WriteBinHandle -> a -> IO () lazyPut' f bh a = do -- output the obj with a ptr to skip over it: pre_a <- tellBinWriter bh put_ bh pre_a -- save a slot for the ptr f bh a -- dump the object q <- tellBinWriter bh -- q = ptr to after object - putAt bh pre_a q -- fill in slot before a with ptr to q + putAtRel bh pre_a q -- fill in slot before a with ptr to q seekBinWriter bh q -- finally carry on writing at q lazyGet' :: HasDebugCallStack => (ReadBinHandle -> IO a) -> ReadBinHandle -> IO a lazyGet' f bh = do - p <- get bh -- a BinPtr + p <- getRelBin bh -- a BinPtr p_a <- tellBinReader bh a <- unsafeInterleaveIO $ do -- NB: Use a fresh rbm_off_r variable in the child thread, for thread @@ -1148,7 +1336,7 @@ lazyGet' f bh = do let bh' = bh { rbm_off_r = off_r } seekBinReader bh' p_a f bh' - seekBinReader bh p -- skip over the object for now + seekBinReader bh (makeAbsoluteBin p) -- skip over the object for now return a -- | Serialize the constructor strictly but lazily serialize a value inside a @@ -1442,13 +1630,13 @@ putGenericSymbolTable gen_sym_tab serialiser bh = do mapM_ (\n -> serialiser bh n) (reverse todo) loop snd <$> - (forwardPut bh (const $ readFastMutInt symtab_next >>= put_ bh) $ + (forwardPutRel bh (const $ readFastMutInt symtab_next >>= put_ bh) $ loop) -- | Read the elements of a 'GenericSymbolTable' from disk into a 'SymbolTable'. getGenericSymbolTable :: forall a . (ReadBinHandle -> IO a) -> ReadBinHandle -> IO (SymbolTable a) getGenericSymbolTable deserialiser bh = do - sz <- forwardGet bh (get bh) :: IO Int + sz <- forwardGetRel bh (get bh) :: IO Int mut_arr <- newArray_ (0, sz-1) :: IO (IOArray Int a) forM_ [0..(sz-1)] $ \i -> do f <- deserialiser bh ===================================== docs/users_guide/using-optimisation.rst ===================================== @@ -1777,3 +1777,23 @@ as such you shouldn't need to set any of them explicitly. A flag This flag sets the size (in bytes) threshold above which the second approach is used. You can disable the second approach entirely by setting the threshold to 0. + +.. ghc-flag:: -fwrite-if-compression=⟨n⟩ + :shortdesc: *default: 2.* Tweak the level of interface file compression. + :type: dynamic + :category: optimization + + :default: 2 + + This flag defines the level of compression of interface files when writing to disk. + The higher the flag, the more we deduplicate the interface file, at the cost of a higher compilation time. + Deduplication (when applied to :ghc-flag:`--make` mode and :ghc-flag:`--interactive` mode) decreases the size of interface files as well as reducing + the overall memory usage of GHC. + + Compression cannot be fully turned off, GHC always compresses interface files to a certain degree. + Currently, we support values of ``1``, ``2`` and ``3``. + Lower or higher values are clamped to ``1`` and ``3`` respectively. + + * ``1``: Compress as little as possible. No run-time impact, at the cost of interface file size and memory usage. + * ``2``: Apply compression with minimal run-time overhead, reducing the interface file size and memory usage. + * ``3``: Apply all possible compressions, minimal interface file sizes and memory usage, at the cost of run-time overhead. ===================================== testsuite/tests/iface/IfaceSharingIfaceType.hs ===================================== @@ -0,0 +1,44 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE OverloadedStrings #-} + +module IfaceSharingIfaceType (types) where + +import GHC.Data.FastString +import GHC.Builtin.Uniques +import GHC.Builtin.Names +import GHC.Builtin.Types +import GHC.Types.Name +import GHC.Types.SrcLoc +import GHC.Iface.Type +import GHC.CoreToIface +import GHC.Core.TyCo.Rep +import GHC + +[f1,f2,f3,f4,f5] = map mkVarOcc ["a", "b","c","d","e"] + +[u1,u2,u3,u4,u5] = map mkPreludeMiscIdUnique [10000..10004] + +names = [ mkExternalName u1 pRELUDE f1 noSrcSpan + , mkExternalName u2 pRELUDE f2 noSrcSpan + , mkExternalName u3 pRELUDE f3 noSrcSpan + , mkExternalName u4 pRELUDE f4 noSrcSpan + , mkExternalName u5 pRELUDE f5 noSrcSpan ] + +-- Int +intIfaceTy = toIfaceType intTy + +wordIfaceTy = toIfaceType wordTy + +listIntTy = toIfaceType (mkListTy intTy) + +funTy = (intTy `mkVisFunTyMany` wordTy `mkVisFunTyMany` mkListTy intTy) + +funIfaceTy = toIfaceType funTy + +reallyBigFunTy = toIfaceType (funTy `mkVisFunTyMany` funTy `mkVisFunTyMany` funTy `mkVisFunTyMany` funTy) + +forallIfaceTy = toIfaceType (dataConType justDataCon) + + +types = [intIfaceTy, wordIfaceTy, listIntTy, funIfaceTy, reallyBigFunTy, forallIfaceTy] + ===================================== testsuite/tests/iface/IfaceSharingName.hs ===================================== @@ -0,0 +1,21 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE OverloadedStrings #-} + +module IfaceSharingName where + +import Lib +import GHC.Data.FastString +import GHC.Builtin.Uniques +import GHC.Builtin.Names +import GHC.Types.Name +import GHC.Types.SrcLoc + +[f1,f2,f3,f4,f5] = map mkVarOcc ["a", "b","c","d","e"] + +[u1,u2,u3,u4,u5] = map mkPreludeMiscIdUnique [10000..10004] + +names = [ mkExternalName u1 pRELUDE f1 noSrcSpan + , mkExternalName u2 pRELUDE f2 noSrcSpan + , mkExternalName u3 pRELUDE f3 noSrcSpan + , mkExternalName u4 pRELUDE f4 noSrcSpan + , mkExternalName u5 pRELUDE f5 noSrcSpan ] ===================================== testsuite/tests/iface/Lib.hs ===================================== @@ -0,0 +1,15 @@ +module Lib where + +import GHC.Utils.Binary +import GHC.Iface.Binary +import qualified Data.ByteString as B +import System.Environment +import Data.Maybe + +testSize :: Binary a => CompressionIFace -> a -> IO Int +testSize compLvl payload = do + args <- getArgs + bh <- openBinMem 1024 + putWithUserData QuietBinIFace compLvl bh payload + withBinBuffer bh (\b -> return (B.length b)) + ===================================== testsuite/tests/iface/Makefile ===================================== @@ -0,0 +1,4 @@ +TOP=../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + ===================================== testsuite/tests/iface/all.T ===================================== @@ -0,0 +1,24 @@ +test( 'if_faststring' + , [ stat_from_file('normal', 5, 'NORMALSIZE') + , stat_from_file('medium', 5, 'MEDIUMSIZE') + , stat_from_file('full', 5, 'FULLSIZE') + , extra_files(["Lib.hs"])] + , compile_and_run + , ['-package ghc']) + +test( 'if_name' + , [ stat_from_file('normal', 5, 'NORMALSIZE') + , stat_from_file('medium', 5, 'MEDIUMSIZE') + , stat_from_file('full', 5, 'FULLSIZE') + , extra_files(["Lib.hs", "IfaceSharingName.hs"])] + , compile_and_run + , ['-package ghc']) + +test( 'if_ifacetype' + , [ stat_from_file('normal', 5, 'NORMALSIZE') + , stat_from_file('medium', 5, 'MEDIUMSIZE') + , stat_from_file('full', 5, 'FULLSIZE') + , extra_files(["Lib.hs", "IfaceSharingIfaceType.hs"])] + , compile_and_run + , ['-package ghc']) + ===================================== testsuite/tests/iface/if_faststring.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE OverloadedStrings #-} + +import Lib +import GHC.Data.FastString +import GHC.Iface.Binary + +main :: IO () +main = do + sz <- testSize MaximalCompression (concat (replicate 1000 ["abc", "cde", "efg" :: FastString])) + writeFile "FULLSIZE" (show sz) + sz <- testSize SafeExtraCompression (concat (replicate 1000 ["abc", "cde", "efg" :: FastString])) + writeFile "MEDIUMSIZE" (show sz) + sz <- testSize NormalCompression (concat (replicate 1000 ["abc", "cde", "efg" :: FastString])) + writeFile "NORMALSIZE" (show sz) ===================================== testsuite/tests/iface/if_ifacetype.hs ===================================== @@ -0,0 +1,13 @@ +import Lib +import IfaceSharingIfaceType +import GHC.Iface.Binary + +main :: IO () +main = do + sz <- testSize MaximalCompression (concat (replicate 500 types)) + writeFile "FULLSIZE" (show sz) + sz <- testSize SafeExtraCompression (concat (replicate 500 types)) + writeFile "MEDIUMSIZE" (show sz) + sz <- testSize NormalCompression (concat (replicate 500 types)) + writeFile "NORMALSIZE" (show sz) + ===================================== testsuite/tests/iface/if_name.hs ===================================== @@ -0,0 +1,12 @@ +import Lib +import IfaceSharingName +import GHC.Iface.Binary + +main :: IO () +main = do + sz <- testSize MaximalCompression (concat (replicate 1000 names)) + writeFile "FULLSIZE" (show sz) + sz <- testSize SafeExtraCompression (concat (replicate 1000 names)) + writeFile "MEDIUMSIZE" (show sz) + sz <- testSize NormalCompression (concat (replicate 1000 names)) + writeFile "NORMALSIZE" (show sz) ===================================== testsuite/tests/plugins/simple-plugin/Simple/RemovePlugin.hs ===================================== @@ -64,9 +64,10 @@ metaPlugin' _ meta = pprPanic "meta" (showAstData BlankSrcSpan BlankEpAnnotation interfaceLoadPlugin' :: [CommandLineOption] -> ModIface -> IfM lcl ModIface interfaceLoadPlugin' [name, "interface"] iface - = return $ iface { mi_exports = filter (availNotNamedAs name) - (mi_exports iface) - } + = return $ set_mi_exports (filter (availNotNamedAs name) + (mi_exports iface)) + iface + interfaceLoadPlugin' _ iface = return iface availNotNamedAs :: String -> AvailInfo -> Bool ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit c9bc29c6a708483d2abc3d8ec9262510ce87ca61 +Subproject commit 6f9e0cc9ae9f2dfbd671e5970ec9d7bbf9a9dcf1 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dec1e9db27abe78634da636691952a3348f5587c...83bb297994a3dfe2aaa980d45323e6ae33b8ba85 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dec1e9db27abe78634da636691952a3348f5587c...83bb297994a3dfe2aaa980d45323e6ae33b8ba85 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 08:33:52 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Wed, 08 May 2024 04:33:52 -0400 Subject: [Git][ghc/ghc][wip/document-system-io] Add exception explanation to withFile Message-ID: <663b38f014c45_37d05319894b825160@gitlab.mail> Jade pushed to branch wip/document-system-io at Glasgow Haskell Compiler / GHC Commits: db782d97 by Jade at 2024-05-08T10:33:32+02:00 Add exception explanation to withFile - - - - - 1 changed file: - libraries/ghc-internal/src/GHC/Internal/IO/StdHandles.hs Changes: ===================================== libraries/ghc-internal/src/GHC/Internal/IO/StdHandles.hs ===================================== @@ -90,6 +90,13 @@ openBinaryFile = POSIX.openBinaryFile -- | The computation @'withFile' path mode action@ opens the file and runs @action@ -- with the obtained handle before closing the file. +-- +-- Even when an exception is raised within the 'action', the file will still be closed. +-- This is why @'withFile' path mode act@ is preferable to +-- +-- @'openFile' path mode >>= (\\hdl -> act hdl >>= 'System.IO.hClose' hdl)@ +-- +-- See also: 'System.IO.bracket' withFile :: FilePath -- ^ The path to the file that should be opened -> IOMode -- ^ The mode in which the file should be opened @@ -108,6 +115,13 @@ withFile = POSIX.withFile -- and runs @action@ with the obtained handle before closing the binary file. -- -- This is different from 'withFile' as in that it does not use any file encoding. +-- +-- Even when an exception is raised within the 'action', the file will still be closed. +-- This is why @'withBinaryFile' path mode act@ is preferable to +-- +-- @'openBinaryFile' path mode >>= (\\hdl -> act hdl >>= 'System.IO.hClose' hdl)@ +-- +-- See also: 'System.IO.bracket' withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r #if defined(mingw32_HOST_OS) withBinaryFile = POSIX.withBinaryFile wf View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/db782d979d5db894c37c02bbf69acdae0021ee65 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/db782d979d5db894c37c02bbf69acdae0021ee65 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 08:43:54 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 08 May 2024 04:43:54 -0400 Subject: [Git][ghc/ghc][wip/ghc-9.10] driver: always merge objects when possible Message-ID: <663b3b4ab9d4c_37d0531bafe4026439@gitlab.mail> Matthew Pickering pushed to branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: d5f45368 by Cheng Shao at 2024-05-08T09:39:29+01:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ (cherry picked from commit 631cefec222e2db951c58db0b15a8d80ef5549cb) - - - - - 1 changed file: - compiler/GHC/Driver/Pipeline/Execute.hs Changes: ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -1040,13 +1040,17 @@ this is accomplished with the `ld -r` command. We rely on this for two ends: The command used for object linking is set using the -pgmlm and -optlm command-line options. -Sadly, the LLD linker that we use on Windows does not support the `-r` flag -needed to support object merging (see #21068). For this reason on Windows we do -not support GHCi objects. To deal with foreign stubs we build a static archive -of all of a module's object files instead merging them. Consequently, we can -end up producing `.o` files which are in fact static archives. However, -toolchains generally don't have a problem with this as they use file headers, -not the filename, to determine the nature of inputs. +However, `ld -r` is broken in some cases: + + * The LLD linker that we use on Windows does not support the `-r` + flag needed to support object merging (see #21068). For this reason + on Windows we do not support GHCi objects. + +In these cases, we bundle a module's own object file with its foreign +stub's object file, instead of merging them. Consequently, we can end +up producing `.o` files which are in fact static archives. This can +only work if `ar -L` is supported, so the archive `.o` files can be +properly added to the final static library. Note that this has somewhat non-obvious consequences when producing initializers and finalizers. See Note [Initializers and finalizers in Cmm] @@ -1072,7 +1076,7 @@ via gcc. -- | See Note [Object merging]. joinObjectFiles :: HscEnv -> [FilePath] -> FilePath -> IO () joinObjectFiles hsc_env o_files output_fn - | can_merge_objs && not dashLSupported = do + | can_merge_objs = do let toolSettings' = toolSettings dflags ldIsGnuLd = toolSettings_ldIsGnuLd toolSettings' ld_r args = GHC.SysTools.runMergeObjects (hsc_logger hsc_env) (hsc_tmpfs hsc_env) (hsc_dflags hsc_env) ( View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d5f453687549b700acf84a0cefed0efd7e274224 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d5f453687549b700acf84a0cefed0efd7e274224 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 08:46:15 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Wed, 08 May 2024 04:46:15 -0400 Subject: [Git][ghc/ghc][wip/fendor/ghc-iface-sharing-avoid-reserialisation] Avoid unneccessarily re-serialising the `ModIface` Message-ID: <663b3bd7e2a2c_37d0531d632dc2825b@gitlab.mail> Hannes Siebenhandl pushed to branch wip/fendor/ghc-iface-sharing-avoid-reserialisation at Glasgow Haskell Compiler / GHC Commits: 5a4e116a by Fendor at 2024-05-08T10:45:54+02:00 Avoid unneccessarily re-serialising the `ModIface` To reduce memory usage of `ModIface`, we serialise `ModIface` to an in-memory byte array, which implicitly shares duplicated values. This serailised byte array can be reused to avoid work when we actually write the `ModIface` to disk. We introduce a new field to `ModIface` which allows us to save the byte array, and write it to disk if the `ModIface` wasn't changed after the initial serialisation. This requires us to change absolute offsets, for example to jump to the deduplication table for `Name` or `FastString` with relative offsets, as the deduplication byte array doesn't contain header information, such as fingerprints. To allow us to dump the binary blob to disk, we need to replace all absolute offsets with relative ones. This leads to new primitives for `ModIface`, which help to construct relative offsets. Bump Haddock submodule, to account for interface file changes. ------------------------- Metric Increase: MultiComponentModules MultiLayerModules T10421 T13035 T13701 T13719 T14697 T18730 T9198 mhu-perf ------------------------- These metric increases may look bad, but they are all completely benign, we simply allocate 1 MB per module for `shareIface`. As this allocation is quite quick, it has a neglible impact on run-time performance. - - - - - 15 changed files: - compiler/GHC.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Ext/Fields.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Unit/Module/ModIface.hs - compiler/GHC/Utils/Binary.hs - testsuite/tests/plugins/simple-plugin/Simple/RemovePlugin.hs - utils/haddock Changes: ===================================== compiler/GHC.hs ===================================== @@ -98,7 +98,32 @@ module GHC ( lookupGlobalName, findGlobalAnns, mkNamePprCtxForModule, - ModIface, ModIface_(..), + ModIface, + mi_module, + mi_sig_of, + mi_hsc_src, + mi_src_hash, + mi_hi_bytes, + mi_deps, + mi_usages, + mi_exports, + mi_used_th, + mi_fixities, + mi_warns, + mi_anns, + mi_insts, + mi_fam_insts, + mi_rules, + mi_decls, + mi_extra_decls, + mi_globals, + mi_hpc, + mi_trust, + mi_trust_pkg, + mi_complete_matches, + mi_docs, + mi_final_exts, + mi_ext_fields, SafeHaskellMode(..), -- * Printing ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -63,6 +63,8 @@ import Data.Map.Strict (Map) import Data.Word import System.IO.Unsafe import Data.Typeable (Typeable) +import qualified GHC.Data.Strict as Strict +import Data.Function ((&)) -- --------------------------------------------------------------------------- @@ -160,21 +162,24 @@ readBinIface profile name_cache checkHiWay traceBinIface hi_path = do mod_iface <- getIfaceWithExtFields name_cache bh - return mod_iface - { mi_src_hash = src_hash - } + return $ mod_iface + & addSourceFingerprint src_hash + getIfaceWithExtFields :: NameCache -> ReadBinHandle -> IO ModIface getIfaceWithExtFields name_cache bh = do - extFields_p <- get bh + start <- tellBinReader bh + extFields_p_rel <- getRelBin bh mod_iface <- getWithUserData name_cache bh - seekBinReader bh extFields_p + seekBinReader bh start + seekBinReaderRel bh extFields_p_rel extFields <- get bh - pure mod_iface - { mi_ext_fields = extFields - } + modIfaceData <- freezeBinHandle2 bh start + pure $ mod_iface + & set_mi_ext_fields extFields + & set_mi_hi_bytes (FullIfaceBinHandle $ Strict.Just modIfaceData) -- | This performs a get action after reading the dictionary and symbol @@ -204,7 +209,7 @@ getTables name_cache bh = do -- add it to the 'ReaderUserData' of 'ReadBinHandle'. decodeReaderTable :: Typeable a => ReaderTable a -> ReadBinHandle -> IO ReadBinHandle decodeReaderTable tbl bh0 = do - table <- Binary.forwardGet bh (getTable tbl bh0) + table <- Binary.forwardGetRel bh (getTable tbl bh0) let binaryReader = mkReaderFromTable tbl table pure $ addReaderToUserData binaryReader bh0 @@ -241,11 +246,18 @@ writeBinIface profile traceBinIface compressionLevel hi_path mod_iface = do -- And send the result to the file writeBinMem bh hi_path --- | Puts the 'ModIface' +-- | Puts the 'ModIface' to the 'WriteBinHandle'. +-- +-- This avoids serialisation of the 'ModIface' if the fields 'mi_hi_bytes' contains a +-- 'Just' value. This fields can only be populated by reading the 'ModIface' using +-- 'getIfaceWithExtFields' and not modifying it in any way afterwards. putIfaceWithExtFields :: TraceBinIFace -> CompressionIFace -> WriteBinHandle -> ModIface -> IO () putIfaceWithExtFields traceBinIface compressionLevel bh mod_iface = - forwardPut_ bh (\_ -> put_ bh (mi_ext_fields mod_iface)) $ do - putWithUserData traceBinIface compressionLevel bh mod_iface + case mi_hi_bytes mod_iface of + FullIfaceBinHandle Strict.Nothing -> do + forwardPutRel_ bh (\_ -> put_ bh (mi_ext_fields mod_iface)) $ do + putWithUserData traceBinIface compressionLevel bh mod_iface + FullIfaceBinHandle (Strict.Just binData) -> putFullBinData bh binData -- | Put a piece of data with an initialised `UserData` field. This -- is necessary if you want to serialise Names or FastStrings. @@ -316,7 +328,7 @@ putAllTables _ [] act = do a <- act pure ([], a) putAllTables bh (x : xs) act = do - (r, (res, a)) <- forwardPut bh (const $ putTable x bh) $ do + (r, (res, a)) <- forwardPutRel bh (const $ putTable x bh) $ do putAllTables bh xs act pure (r : res, a) @@ -468,7 +480,7 @@ to the table we need to deserialise first. What deduplication tables exist and the order of serialisation is currently statically specified in 'putWithTables'. 'putWithTables' also takes care of the serialisation of used deduplication tables. The deserialisation of the deduplication tables happens 'getTables', using 'Binary' utility -functions such as 'forwardGet'. +functions such as 'forwardGetRel'. Here, a visualisation of the table structure we currently have (ignoring 'ExtensibleFields'): @@ -529,7 +541,6 @@ initWriteIfaceType compressionLevel = do putGenericSymTab sym_tab bh ty _ -> putIfaceType bh ty - fullIfaceTypeSerialiser sym_tab bh ty = do put_ bh ifaceTypeSharedByte putGenericSymTab sym_tab bh ty ===================================== compiler/GHC/Iface/Ext/Binary.hs ===================================== @@ -235,7 +235,7 @@ readHieFileContents bh0 name_cache = do get bh1 where get_dictionary tbl bin_handle = do - fsTable <- Binary.forwardGet bin_handle (getTable tbl bin_handle) + fsTable <- Binary.forwardGetRel bin_handle (getTable tbl bin_handle) let fsReader = mkReaderFromTable tbl fsTable bhFs = addReaderToUserData fsReader bin_handle ===================================== compiler/GHC/Iface/Ext/Fields.hs ===================================== @@ -41,7 +41,7 @@ instance Binary ExtensibleFields where -- to point to the start of each payload: forM_ header_entries $ \(field_p_p, dat) -> do field_p <- tellBinWriter bh - putAt bh field_p_p field_p + putAtRel bh field_p_p field_p seekBinWriter bh field_p put_ bh dat @@ -50,11 +50,11 @@ instance Binary ExtensibleFields where -- Get the names and field pointers: header_entries <- replicateM n $ - (,) <$> get bh <*> get bh + (,) <$> get bh <*> getRelBin bh -- Seek to and get each field's payload: fields <- forM header_entries $ \(name, field_p) -> do - seekBinReader bh field_p + seekBinReaderRel bh field_p dat <- get bh return (name, dat) ===================================== compiler/GHC/Iface/Load.hs ===================================== @@ -117,6 +117,7 @@ import System.FilePath import System.Directory import GHC.Driver.Env.KnotVars import GHC.Iface.Errors.Types +import Data.Function ((&)) {- ************************************************************************ @@ -515,14 +516,12 @@ loadInterface doc_str mod from ; new_eps_anns <- tcIfaceAnnotations (mi_anns iface) ; new_eps_complete_matches <- tcIfaceCompleteMatches (mi_complete_matches iface) - ; let { final_iface = iface { - mi_decls = panic "No mi_decls in PIT", - mi_insts = panic "No mi_insts in PIT", - mi_fam_insts = panic "No mi_fam_insts in PIT", - mi_rules = panic "No mi_rules in PIT", - mi_anns = panic "No mi_anns in PIT" - } - } + ; let final_iface = iface + & set_mi_decls (panic "No mi_decls in PIT") + & set_mi_insts (panic "No mi_insts in PIT") + & set_mi_fam_insts (panic "No mi_fam_insts in PIT") + & set_mi_rules (panic "No mi_rules in PIT") + & set_mi_anns (panic "No mi_anns in PIT") ; let bad_boot = mi_boot iface == IsBoot && isJust (lookupKnotVars (if_rec_types gbl_env) mod) @@ -1018,13 +1017,13 @@ readIface dflags name_cache wanted_mod file_path = do -- See Note [GHC.Prim] in primops.txt.pp. ghcPrimIface :: ModIface ghcPrimIface - = empty_iface { - mi_exports = ghcPrimExports, - mi_decls = [], - mi_fixities = fixities, - mi_final_exts = (mi_final_exts empty_iface){ mi_fix_fn = mkIfaceFixCache fixities }, - mi_docs = Just ghcPrimDeclDocs -- See Note [GHC.Prim Docs] - } + = empty_iface + & set_mi_exports ghcPrimExports + & set_mi_decls [] + & set_mi_fixities fixities + & set_mi_final_exts ((mi_final_exts empty_iface){ mi_fix_fn = mkIfaceFixCache fixities }) + & set_mi_docs (Just ghcPrimDeclDocs) -- See Note [GHC.Prim Docs] + where empty_iface = emptyFullModIface gHC_PRIM @@ -1108,7 +1107,7 @@ pprModIfaceSimple unit_state iface = -- -- The UnitState is used to pretty-print units pprModIface :: UnitState -> ModIface -> SDoc -pprModIface unit_state iface at ModIface{ mi_final_exts = exts } +pprModIface unit_state iface = vcat [ text "interface" <+> ppr (mi_module iface) <+> pp_hsc_src (mi_hsc_src iface) <+> (if mi_orphan exts then text "[orphan module]" else Outputable.empty) @@ -1149,6 +1148,7 @@ pprModIface unit_state iface at ModIface{ mi_final_exts = exts } , text "extensible fields:" $$ nest 2 (pprExtensibleFields (mi_ext_fields iface)) ] where + exts = mi_final_exts iface pp_hsc_src HsBootFile = text "[boot]" pp_hsc_src HsigFile = text "[hsig]" pp_hsc_src HsSrcFile = Outputable.empty ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -144,7 +144,7 @@ mkFullIface hsc_env partial_iface mb_stg_infos mb_cmm_infos = do full_iface <- {-# SCC "addFingerprints" #-} - addFingerprints hsc_env partial_iface{ mi_decls = decls } + addFingerprints hsc_env (set_mi_decls decls partial_iface) -- Debug printing let unit_state = hsc_units hsc_env @@ -153,8 +153,24 @@ mkFullIface hsc_env partial_iface mb_stg_infos mb_cmm_infos = do final_iface <- shareIface (hsc_NC hsc_env) (flagsToIfCompression $ hsc_dflags hsc_env) full_iface return final_iface +-- | Compress an 'ModIface' and share as many values as possible, depending on the 'CompressionIFace' level. +-- See Note [Sharing of ModIface]. +-- +-- We compress the 'ModIface' by serialising the 'ModIface' to an in-memory byte array, and then deserialising it. +-- The deserialisation will deduplicate certain values depending on the 'CompressionIFace' level. +-- See Note [Deduplication during iface binary serialisation] for how we do that. +-- +-- Additionally, we cache the serialised byte array, so if the 'ModIface' is not modified +-- after calling 'shareIface', 'writeBinIface' will reuse that buffer without serialising the 'ModIface' again. +-- Modifying the 'ModIface' forces us to re-serialise it again. shareIface :: NameCache -> CompressionIFace -> ModIface -> IO ModIface -shareIface _ NormalCompression mi = pure mi +shareIface _ NormalCompression mi = do + -- In 'NormalCompression', the sharing isn't reducing the memory usage, as 'Name's and 'FastString's are + -- already shared, and at this compression level, we don't compress/share anything else. + -- Thus, for a brief moment we simply double the memory residency for no reason. + -- Therefore, we only try to share expensive values if the compression mode is higher than + -- 'NormalCompression' + pure mi shareIface nc compressionLevel mi = do bh <- openBinMem (1024 * 1024) start <- tellBinWriter bh @@ -162,10 +178,7 @@ shareIface nc compressionLevel mi = do rbh <- shrinkBinBuffer bh seekBinReader rbh start res <- getIfaceWithExtFields nc rbh - let resiface = res - { mi_src_hash = mi_src_hash mi - , mi_globals = mi_globals mi - } + let resiface = restoreFromOldModIface mi res forceModIface resiface return resiface @@ -322,40 +335,40 @@ mkIface_ hsc_env icomplete_matches = map mkIfaceCompleteMatch complete_matches !rdrs = maybeGlobalRdrEnv rdr_env - ModIface { - mi_module = this_mod, + emptyPartialModIface this_mod -- Need to record this because it depends on the -instantiated-with flag -- which could change - mi_sig_of = if semantic_mod == this_mod + & set_mi_sig_of ( if semantic_mod == this_mod then Nothing - else Just semantic_mod, - mi_hsc_src = hsc_src, - mi_deps = deps, - mi_usages = usages, - mi_exports = mkIfaceExports exports, + else Just semantic_mod) + & set_mi_hsc_src ( hsc_src) + & set_mi_deps ( deps) + & set_mi_usages ( usages) + & set_mi_exports ( mkIfaceExports exports) -- Sort these lexicographically, so that -- the result is stable across compilations - mi_insts = sortBy cmp_inst iface_insts, - mi_fam_insts = sortBy cmp_fam_inst iface_fam_insts, - mi_rules = sortBy cmp_rule iface_rules, - - mi_fixities = fixities, - mi_warns = warns, - mi_anns = annotations, - mi_globals = rdrs, - mi_used_th = used_th, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_hpc = isHpcUsed hpc_info, - mi_trust = trust_info, - mi_trust_pkg = pkg_trust_req, - mi_complete_matches = icomplete_matches, - mi_docs = docs, - mi_final_exts = (), - mi_ext_fields = emptyExtensibleFields, - mi_src_hash = ms_hs_hash mod_summary - } + & set_mi_insts ( sortBy cmp_inst iface_insts) + & set_mi_fam_insts ( sortBy cmp_fam_inst iface_fam_insts) + & set_mi_rules ( sortBy cmp_rule iface_rules) + + & set_mi_fixities ( fixities) + & set_mi_warns ( warns) + & set_mi_anns ( annotations) + & set_mi_globals ( rdrs) + & set_mi_used_th ( used_th) + & set_mi_decls ( decls) + & set_mi_extra_decls ( extra_decls) + & set_mi_hpc ( isHpcUsed hpc_info) + & set_mi_trust ( trust_info) + & set_mi_trust_pkg ( pkg_trust_req) + & set_mi_complete_matches ( icomplete_matches) + & set_mi_docs ( docs) + & set_mi_final_exts ( ()) + & set_mi_ext_fields ( emptyExtensibleFields) + & set_mi_src_hash ( ms_hs_hash mod_summary) + & set_mi_hi_bytes ( PartialIfaceBinHandle) + where cmp_rule = lexicalCompareFS `on` ifRuleName -- Compare these lexicographically by OccName, *not* by unique, @@ -522,3 +535,22 @@ That is, in Y, In the result of mkIfaceExports, the names are grouped by defining module, so we may need to split up a single Avail into multiple ones. -} + +{- +Note [Sharing of ModIface] +~~~~~~~~~~~~~~~~~~~~~~~~~~ +A 'ModIface' contains many duplicated values such as 'Name', 'FastString' and 'IfaceType'. +'Name's and 'FastString's are already deduplicated by default using the 'NameCache' and +'FastStringTable' respectively. +However, 'IfaceType' can be quite expensive in terms of memory usage. +To improve the sharing of 'IfaceType', we introduced deduplication tables during +serialisation of 'ModIface', see Note [Deduplication during iface binary serialisation]. + +We can improve the sharing of 'ModIface' at run-time as well, by serialising the 'ModIface' to +an in-memory buffer, and then deserialising it again. +This implicitly shares duplicated values. + +To avoid re-serialising the 'ModIface' when writing it to disk, we save the serialised 'ModIface' buffer +in 'mi_hi_bytes_' field of said 'ModIface'. This buffer is written to disk directly in 'putIfaceWithExtFields'. +If we have to modify the 'ModIface' after 'shareIface' is called, the buffer needs to be discarded. +-} ===================================== compiler/GHC/Iface/Recomp.hs ===================================== @@ -1283,7 +1283,9 @@ addFingerprints hsc_env iface0 , mi_fix_fn = fix_fn , mi_hash_fn = lookupOccEnv local_env } - final_iface = iface0 { mi_decls = sorted_decls, mi_extra_decls = sorted_extra_decls, mi_final_exts = final_iface_exts } + final_iface = completePartialModIface iface0 + (sorted_decls) (sorted_extra_decls) (final_iface_exts) + -- return final_iface ===================================== compiler/GHC/Iface/Rename.hs ===================================== @@ -44,6 +44,7 @@ import GHC.Utils.Panic import qualified Data.Traversable as T import Data.IORef +import Data.Function ((&)) tcRnMsgMaybe :: IO (Either (Messages TcRnMessage) a) -> TcM a tcRnMsgMaybe do_this = do @@ -108,13 +109,14 @@ rnModIface hsc_env insts nsubst iface = deps <- rnDependencies (mi_deps iface) -- TODO: -- mi_rules - return iface { mi_module = mod - , mi_sig_of = sig_of - , mi_insts = insts - , mi_fam_insts = fams - , mi_exports = exports - , mi_decls = decls - , mi_deps = deps } + return $ iface + & set_mi_module mod + & set_mi_sig_of sig_of + & set_mi_insts insts + & set_mi_fam_insts fams + & set_mi_exports exports + & set_mi_decls decls + & set_mi_deps deps -- | Rename just the exports of a 'ModIface'. Useful when we're doing -- shaping prior to signature merging. ===================================== compiler/GHC/Tc/Errors/Hole.hs ===================================== @@ -76,7 +76,7 @@ import GHC.Tc.Utils.Unify ( tcSubTypeSigma ) import GHC.HsToCore.Docs ( extractDocs ) import GHC.Hs.Doc -import GHC.Unit.Module.ModIface ( ModIface_(..) ) +import GHC.Unit.Module.ModIface ( mi_docs ) import GHC.Iface.Load ( loadInterfaceForName ) import GHC.Builtin.Utils (knownKeyNames) ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -1562,7 +1562,8 @@ lookupDeclDoc nm = do -- Wasn't in the current module. Try searching other external ones! mIface <- getExternalModIface nm case mIface of - Just ModIface { mi_docs = Just Docs{docs_decls = dmap} } -> + Just iface + | Just Docs{docs_decls = dmap} <- mi_docs iface -> pure $ renderHsDocStrings . map hsDocString <$> lookupUniqMap dmap nm _ -> pure Nothing @@ -1578,7 +1579,8 @@ lookupArgDoc i nm = do Nothing -> do mIface <- getExternalModIface nm case mIface of - Just ModIface { mi_docs = Just Docs{docs_args = amap} } -> + Just iface + | Just Docs{docs_args = amap} <- mi_docs iface-> pure $ renderHsDocString . hsDocString <$> (lookupUniqMap amap nm >>= IntMap.lookup i) _ -> pure Nothing ===================================== compiler/GHC/Tc/Utils/Backpack.hs ===================================== @@ -87,6 +87,7 @@ import Control.Monad import Data.List (find) import GHC.Iface.Errors.Types +import Data.Function ((&)) checkHsigDeclM :: ModIface -> TyThing -> TyThing -> TcRn () checkHsigDeclM sig_iface sig_thing real_thing = do @@ -369,8 +370,8 @@ tcRnMergeSignatures hsc_env hpm orig_tcg_env iface = thinModIface :: [AvailInfo] -> ModIface -> ModIface thinModIface avails iface = - iface { - mi_exports = avails, + iface + & set_mi_exports avails -- mi_fixities = ..., -- mi_warns = ..., -- mi_anns = ..., @@ -378,10 +379,9 @@ thinModIface avails iface = -- perhaps there might be two IfaceTopBndr that are the same -- OccName but different Name. Requires better understanding -- of invariants here. - mi_decls = exported_decls ++ non_exported_decls ++ dfun_decls + & set_mi_decls (exported_decls ++ non_exported_decls ++ dfun_decls) -- mi_insts = ..., -- mi_fam_insts = ..., - } where decl_pred occs decl = nameOccName (ifName decl) `elemOccSet` occs filter_decls occs = filter (decl_pred occs . snd) (mi_decls iface) ===================================== compiler/GHC/Unit/Module/ModIface.hs ===================================== @@ -7,7 +7,61 @@ module GHC.Unit.Module.ModIface ( ModIface - , ModIface_ (..) + , ModIface_ + , restoreFromOldModIface + , addSourceFingerprint + , mi_module + , mi_sig_of + , mi_hsc_src + , mi_src_hash + , mi_hi_bytes + , mi_deps + , mi_usages + , mi_exports + , mi_used_th + , mi_fixities + , mi_warns + , mi_anns + , mi_insts + , mi_fam_insts + , mi_rules + , mi_decls + , mi_extra_decls + , mi_globals + , mi_hpc + , mi_trust + , mi_trust_pkg + , mi_complete_matches + , mi_docs + , mi_final_exts + , mi_ext_fields + , set_mi_module + , set_mi_sig_of + , set_mi_hsc_src + , set_mi_src_hash + , set_mi_hi_bytes + , set_mi_deps + , set_mi_usages + , set_mi_exports + , set_mi_used_th + , set_mi_fixities + , set_mi_warns + , set_mi_anns + , set_mi_insts + , set_mi_fam_insts + , set_mi_rules + , set_mi_decls + , set_mi_extra_decls + , set_mi_globals + , set_mi_hpc + , set_mi_trust + , set_mi_trust_pkg + , set_mi_complete_matches + , set_mi_docs + , set_mi_final_exts + , set_mi_ext_fields + , completePartialModIface + , IfaceBinHandle(..) , PartialModIface , ModIfaceBackend (..) , IfaceDeclExts @@ -58,6 +112,7 @@ import GHC.Utils.Binary import Control.DeepSeq import Control.Exception +import qualified GHC.Data.Strict as Strict {- Note [Interface file stages] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -139,7 +194,9 @@ type family IfaceBackendExts (phase :: ModIfacePhase) = bk | bk -> phase where IfaceBackendExts 'ModIfaceCore = () IfaceBackendExts 'ModIfaceFinal = ModIfaceBackend - +data IfaceBinHandle (phase :: ModIfacePhase) where + PartialIfaceBinHandle :: IfaceBinHandle 'ModIfaceCore + FullIfaceBinHandle :: Strict.Maybe FullBinData -> IfaceBinHandle 'ModIfaceFinal -- | A 'ModIface' plus a 'ModDetails' summarises everything we know -- about a compiled module. The 'ModIface' is the stuff *before* linking, @@ -153,62 +210,65 @@ type family IfaceBackendExts (phase :: ModIfacePhase) = bk | bk -> phase where -- -- See Note [Strictness in ModIface] to learn about why some fields are -- strict and others are not. +-- +-- See Note [Private fields in ModIface] to learn why we don't export any of the +-- fields. data ModIface_ (phase :: ModIfacePhase) = ModIface { - mi_module :: !Module, -- ^ Name of the module we are for - mi_sig_of :: !(Maybe Module), -- ^ Are we a sig of another mod? + mi_module_ :: !Module, -- ^ Name of the module we are for + mi_sig_of_ :: !(Maybe Module), -- ^ Are we a sig of another mod? - mi_hsc_src :: !HscSource, -- ^ Boot? Signature? + mi_hsc_src_ :: !HscSource, -- ^ Boot? Signature? - mi_deps :: Dependencies, + mi_deps_ :: Dependencies, -- ^ The dependencies of the module. This is -- consulted for directly-imported modules, but not -- for anything else (hence lazy) - mi_usages :: [Usage], + mi_usages_ :: [Usage], -- ^ Usages; kept sorted so that it's easy to decide -- whether to write a new iface file (changing usages -- doesn't affect the hash of this module) -- NOT STRICT! we read this field lazily from the interface file -- It is *only* consulted by the recompilation checker - mi_exports :: ![IfaceExport], + mi_exports_ :: ![IfaceExport], -- ^ Exports -- Kept sorted by (mod,occ), to make version comparisons easier -- Records the modules that are the declaration points for things -- exported by this module, and the 'OccName's of those things - mi_used_th :: !Bool, + mi_used_th_ :: !Bool, -- ^ Module required TH splices when it was compiled. -- This disables recompilation avoidance (see #481). - mi_fixities :: [(OccName,Fixity)], + mi_fixities_ :: [(OccName,Fixity)], -- ^ Fixities -- NOT STRICT! we read this field lazily from the interface file - mi_warns :: IfaceWarnings, + mi_warns_ :: IfaceWarnings, -- ^ Warnings -- NOT STRICT! we read this field lazily from the interface file - mi_anns :: [IfaceAnnotation], + mi_anns_ :: [IfaceAnnotation], -- ^ Annotations -- NOT STRICT! we read this field lazily from the interface file - mi_decls :: [IfaceDeclExts phase], + mi_decls_ :: [IfaceDeclExts phase], -- ^ Type, class and variable declarations -- The hash of an Id changes if its fixity or deprecations change -- (as well as its type of course) -- Ditto data constructors, class operations, except that -- the hash of the parent class/tycon changes - mi_extra_decls :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo], + mi_extra_decls_ :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo], -- ^ Extra variable definitions which are **NOT** exposed but when -- combined with mi_decls allows us to restart code generation. -- See Note [Interface Files with Core Definitions] and Note [Interface File with Core: Sharing RHSs] - mi_globals :: !(Maybe IfGlobalRdrEnv), + mi_globals_ :: !(Maybe IfGlobalRdrEnv), -- ^ Binds all the things defined at the top level in -- the /original source/ code for this module. which -- is NOT the same as mi_exports, nor mi_decls (which @@ -224,36 +284,36 @@ data ModIface_ (phase :: ModIfacePhase) -- 'HomeModInfo', but that leads to more plumbing. -- Instance declarations and rules - mi_insts :: [IfaceClsInst], -- ^ Sorted class instance - mi_fam_insts :: [IfaceFamInst], -- ^ Sorted family instances - mi_rules :: [IfaceRule], -- ^ Sorted rules + mi_insts_ :: [IfaceClsInst], -- ^ Sorted class instance + mi_fam_insts_ :: [IfaceFamInst], -- ^ Sorted family instances + mi_rules_ :: [IfaceRule], -- ^ Sorted rules - mi_hpc :: !AnyHpcUsage, + mi_hpc_ :: !AnyHpcUsage, -- ^ True if this program uses Hpc at any point in the program. - mi_trust :: !IfaceTrustInfo, + mi_trust_ :: !IfaceTrustInfo, -- ^ Safe Haskell Trust information for this module. - mi_trust_pkg :: !Bool, + mi_trust_pkg_ :: !Bool, -- ^ Do we require the package this module resides in be trusted -- to trust this module? This is used for the situation where a -- module is Safe (so doesn't require the package be trusted -- itself) but imports some trustworthy modules from its own -- package (which does require its own package be trusted). -- See Note [Trust Own Package] in GHC.Rename.Names - mi_complete_matches :: ![IfaceCompleteMatch], + mi_complete_matches_ :: ![IfaceCompleteMatch], - mi_docs :: !(Maybe Docs), + mi_docs_ :: !(Maybe Docs), -- ^ Docstrings and related data for use by haddock, the ghci -- @:doc@ command, and other tools. -- -- @Just _@ @<=>@ the module was built with @-haddock at . - mi_final_exts :: !(IfaceBackendExts phase), + mi_final_exts_ :: !(IfaceBackendExts phase), -- ^ Either `()` or `ModIfaceBackend` for -- a fully instantiated interface. - mi_ext_fields :: !ExtensibleFields, + mi_ext_fields_ :: !ExtensibleFields, -- ^ Additional optional fields, where the Map key represents -- the field name, resulting in a (size, serialized data) pair. -- Because the data is intended to be serialized through the @@ -262,8 +322,13 @@ data ModIface_ (phase :: ModIfacePhase) -- chosen over `ByteString`s. -- - mi_src_hash :: !Fingerprint + mi_src_hash_ :: !Fingerprint, -- ^ Hash of the .hs source, used for recompilation checking. + mi_hi_bytes_ :: !(IfaceBinHandle phase) + -- ^ A serialised in-memory buffer of this 'ModIface'. + -- If this handle is given, we can avoid serialising the 'ModIface' + -- when writing this 'ModIface' to disk, and write this buffer to disk instead. + -- See Note [Sharing of ModIface]. } {- @@ -343,33 +408,34 @@ renameFreeHoles fhs insts = -- See Note [Strictness in ModIface] about where we use lazyPut vs put instance Binary ModIface where put_ bh (ModIface { - mi_module = mod, - mi_sig_of = sig_of, - mi_hsc_src = hsc_src, - mi_src_hash = _src_hash, -- Don't `put_` this in the instance + mi_module_ = mod, + mi_sig_of_ = sig_of, + mi_hsc_src_ = hsc_src, + mi_src_hash_ = _src_hash, -- Don't `put_` this in the instance -- because we are going to write it -- out separately in the actual file - mi_deps = deps, - mi_usages = usages, - mi_exports = exports, - mi_used_th = used_th, - mi_fixities = fixities, - mi_warns = warns, - mi_anns = anns, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_insts = insts, - mi_fam_insts = fam_insts, - mi_rules = rules, - mi_hpc = hpc_info, - mi_trust = trust, - mi_trust_pkg = trust_pkg, - mi_complete_matches = complete_matches, - mi_docs = docs, - mi_ext_fields = _ext_fields, -- Don't `put_` this in the instance so we + mi_hi_bytes_ = _hi_bytes, -- TODO: explain + mi_deps_ = deps, + mi_usages_ = usages, + mi_exports_ = exports, + mi_used_th_ = used_th, + mi_fixities_ = fixities, + mi_warns_ = warns, + mi_anns_ = anns, + mi_decls_ = decls, + mi_extra_decls_ = extra_decls, + mi_insts_ = insts, + mi_fam_insts_ = fam_insts, + mi_rules_ = rules, + mi_hpc_ = hpc_info, + mi_trust_ = trust, + mi_trust_pkg_ = trust_pkg, + mi_complete_matches_ = complete_matches, + mi_docs_ = docs, + mi_ext_fields_ = _ext_fields, -- Don't `put_` this in the instance so we -- can deal with it's pointer in the header -- when we write the actual file - mi_final_exts = ModIfaceBackend { + mi_final_exts_ = ModIfaceBackend { mi_iface_hash = iface_hash, mi_mod_hash = mod_hash, mi_flag_hash = flag_hash, @@ -444,33 +510,34 @@ instance Binary ModIface where complete_matches <- get bh docs <- lazyGetMaybe bh return (ModIface { - mi_module = mod, - mi_sig_of = sig_of, - mi_hsc_src = hsc_src, - mi_src_hash = fingerprint0, -- placeholder because this is dealt + mi_module_ = mod, + mi_sig_of_ = sig_of, + mi_hsc_src_ = hsc_src, + mi_src_hash_ = fingerprint0, -- placeholder because this is dealt -- with specially when the file is read - mi_deps = deps, - mi_usages = usages, - mi_exports = exports, - mi_used_th = used_th, - mi_anns = anns, - mi_fixities = fixities, - mi_warns = warns, - mi_decls = decls, - mi_extra_decls = extra_decls, - mi_globals = Nothing, - mi_insts = insts, - mi_fam_insts = fam_insts, - mi_rules = rules, - mi_hpc = hpc_info, - mi_trust = trust, - mi_trust_pkg = trust_pkg, + mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing, + mi_deps_ = deps, + mi_usages_ = usages, + mi_exports_ = exports, + mi_used_th_ = used_th, + mi_anns_ = anns, + mi_fixities_ = fixities, + mi_warns_ = warns, + mi_decls_ = decls, + mi_extra_decls_ = extra_decls, + mi_globals_ = Nothing, + mi_insts_ = insts, + mi_fam_insts_ = fam_insts, + mi_rules_ = rules, + mi_hpc_ = hpc_info, + mi_trust_ = trust, + mi_trust_pkg_ = trust_pkg, -- And build the cached values - mi_complete_matches = complete_matches, - mi_docs = docs, - mi_ext_fields = emptyExtensibleFields, -- placeholder because this is dealt + mi_complete_matches_ = complete_matches, + mi_docs_ = docs, + mi_ext_fields_ = emptyExtensibleFields, -- placeholder because this is dealt -- with specially when the file is read - mi_final_exts = ModIfaceBackend { + mi_final_exts_ = ModIfaceBackend { mi_iface_hash = iface_hash, mi_mod_hash = mod_hash, mi_flag_hash = flag_hash, @@ -487,42 +554,45 @@ instance Binary ModIface where mi_hash_fn = mkIfaceHashCache decls }}) + -- | The original names declared of a certain module that are exported type IfaceExport = AvailInfo emptyPartialModIface :: Module -> PartialModIface emptyPartialModIface mod - = ModIface { mi_module = mod, - mi_sig_of = Nothing, - mi_hsc_src = HsSrcFile, - mi_src_hash = fingerprint0, - mi_deps = noDependencies, - mi_usages = [], - mi_exports = [], - mi_used_th = False, - mi_fixities = [], - mi_warns = IfWarnSome [] [], - mi_anns = [], - mi_insts = [], - mi_fam_insts = [], - mi_rules = [], - mi_decls = [], - mi_extra_decls = Nothing, - mi_globals = Nothing, - mi_hpc = False, - mi_trust = noIfaceTrustInfo, - mi_trust_pkg = False, - mi_complete_matches = [], - mi_docs = Nothing, - mi_final_exts = (), - mi_ext_fields = emptyExtensibleFields + = ModIface { mi_module_ = mod, + mi_sig_of_ = Nothing, + mi_hsc_src_ = HsSrcFile, + mi_src_hash_ = fingerprint0, + mi_hi_bytes_ = PartialIfaceBinHandle, + mi_deps_ = noDependencies, + mi_usages_ = [], + mi_exports_ = [], + mi_used_th_ = False, + mi_fixities_ = [], + mi_warns_ = IfWarnSome [] [], + mi_anns_ = [], + mi_insts_ = [], + mi_fam_insts_ = [], + mi_rules_ = [], + mi_decls_ = [], + mi_extra_decls_ = Nothing, + mi_globals_ = Nothing, + mi_hpc_ = False, + mi_trust_ = noIfaceTrustInfo, + mi_trust_pkg_ = False, + mi_complete_matches_ = [], + mi_docs_ = Nothing, + mi_final_exts_ = (), + mi_ext_fields_ = emptyExtensibleFields } emptyFullModIface :: Module -> ModIface emptyFullModIface mod = (emptyPartialModIface mod) - { mi_decls = [] - , mi_final_exts = ModIfaceBackend + { mi_decls_ = [] + , mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing + , mi_final_exts_ = ModIfaceBackend { mi_iface_hash = fingerprint0, mi_mod_hash = fingerprint0, mi_flag_hash = fingerprint0, @@ -557,36 +627,36 @@ emptyIfaceHashCache _occ = Nothing instance ( NFData (IfaceBackendExts (phase :: ModIfacePhase)) , NFData (IfaceDeclExts (phase :: ModIfacePhase)) ) => NFData (ModIface_ phase) where - rnf (ModIface{ mi_module, mi_sig_of, mi_hsc_src, mi_deps, mi_usages - , mi_exports, mi_used_th, mi_fixities, mi_warns, mi_anns - , mi_decls, mi_extra_decls, mi_globals, mi_insts - , mi_fam_insts, mi_rules, mi_hpc, mi_trust, mi_trust_pkg - , mi_complete_matches, mi_docs, mi_final_exts - , mi_ext_fields, mi_src_hash }) - = rnf mi_module - `seq` rnf mi_sig_of - `seq` mi_hsc_src - `seq` mi_deps - `seq` mi_usages - `seq` mi_exports - `seq` rnf mi_used_th - `seq` mi_fixities - `seq` rnf mi_warns - `seq` rnf mi_anns - `seq` rnf mi_decls - `seq` rnf mi_extra_decls - `seq` rnf mi_globals - `seq` rnf mi_insts - `seq` rnf mi_fam_insts - `seq` rnf mi_rules - `seq` rnf mi_hpc - `seq` mi_trust - `seq` rnf mi_trust_pkg - `seq` rnf mi_complete_matches - `seq` rnf mi_docs - `seq` mi_final_exts - `seq` mi_ext_fields - `seq` rnf mi_src_hash + rnf (ModIface{ mi_module_, mi_sig_of_, mi_hsc_src_, mi_deps_, mi_usages_ + , mi_exports_, mi_used_th_, mi_fixities_, mi_warns_, mi_anns_ + , mi_decls_, mi_extra_decls_, mi_globals_, mi_insts_ + , mi_fam_insts_, mi_rules_, mi_hpc_, mi_trust_, mi_trust_pkg_ + , mi_complete_matches_, mi_docs_, mi_final_exts_ + , mi_ext_fields_, mi_src_hash_ }) + = rnf mi_module_ + `seq` rnf mi_sig_of_ + `seq` mi_hsc_src_ + `seq` mi_deps_ + `seq` mi_usages_ + `seq` mi_exports_ + `seq` rnf mi_used_th_ + `seq` mi_fixities_ + `seq` rnf mi_warns_ + `seq` rnf mi_anns_ + `seq` rnf mi_decls_ + `seq` rnf mi_extra_decls_ + `seq` rnf mi_globals_ + `seq` rnf mi_insts_ + `seq` rnf mi_fam_insts_ + `seq` rnf mi_rules_ + `seq` rnf mi_hpc_ + `seq` mi_trust_ + `seq` rnf mi_trust_pkg_ + `seq` rnf mi_complete_matches_ + `seq` rnf mi_docs_ + `seq` mi_final_exts_ + `seq` mi_ext_fields_ + `seq` rnf mi_src_hash_ `seq` () instance NFData (ModIfaceBackend) where @@ -626,5 +696,226 @@ type WhetherHasOrphans = Bool -- | Does this module define family instances? type WhetherHasFamInst = Bool +-- ---------------------------------------------------------------------------- +-- Modify a 'ModIface'. +-- ---------------------------------------------------------------------------- + +{- +Note [Private fields in ModIface] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The fields of 'ModIface' are private, e.g., not exported, to make the API +impossible to misuse. A 'ModIface' can be "compressed" in-memory using +'shareIface', which serialises the 'ModIface' to an in-memory buffer. +This has the advantage of reducing memory usage of 'ModIface', reducing the +overall memory usage of GHC. +See Note [Sharing of ModIface]. + +This in-memory buffer can be reused, if and only if the 'ModIface' is not +modified after it has been "compressed"/shared via 'shareIface'. Instead of +serialising 'ModIface', we simply write the in-memory buffer to disk directly. + +However, we can't rely that a 'ModIface' isn't modified after 'shareIface' has +been called. Thus, we make all fields of 'ModIface' private and modification +only happens via exported update functions, such as 'set_mi_decls'. +These functions unconditionally clear any in-memory buffer if used, forcing us +to serialise the 'ModIface' to disk again. +-} + +-- | Given a 'PartialModIface', turn it into a 'ModIface' by completing +-- missing fields. +completePartialModIface :: PartialModIface + -> [(Fingerprint, IfaceDecl)] + -> Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] + -> ModIfaceBackend + -> ModIface +completePartialModIface partial decls extra_decls final_exts = partial + { mi_decls_ = decls + , mi_extra_decls_ = extra_decls + , mi_final_exts_ = final_exts + , mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing + } + +-- | Add a source fingerprint to a 'ModIface_' without invalidating the byte array +-- buffer 'mi_hi_bytes'. +-- This is a variant of 'set_mi_src_hash' which does invalidate the buffer. +-- +-- The 'mi_src_hash' is computed outside of 'ModIface_' based on the 'ModSummary'. +addSourceFingerprint :: Fingerprint -> ModIface_ phase -> ModIface_ phase +addSourceFingerprint val iface = iface { mi_src_hash_ = val } + +-- | Copy fields that aren't serialised to disk to the new 'ModIface_'. +-- This includes especially hashes that are usually stored in the interface +-- file header and 'mi_globals'. +-- +-- We need this function after calling 'shareIface', to make sure the +-- 'ModIface_' doesn't lose any information. This function does not discard +-- the in-memory byte array buffer 'mi_hi_bytes'. +restoreFromOldModIface :: ModIface_ phase -> ModIface_ phase -> ModIface_ phase +restoreFromOldModIface old new = new + { mi_globals_ = mi_globals_ old + , mi_hsc_src_ = mi_hsc_src_ old + , mi_src_hash_ = mi_src_hash_ old + } + +set_mi_module :: Module -> ModIface_ phase -> ModIface_ phase +set_mi_module val iface = clear_mi_hi_bytes $ iface { mi_module_ = val } + +set_mi_sig_of :: Maybe Module -> ModIface_ phase -> ModIface_ phase +set_mi_sig_of val iface = clear_mi_hi_bytes $ iface { mi_sig_of_ = val } + +set_mi_hsc_src :: HscSource -> ModIface_ phase -> ModIface_ phase +set_mi_hsc_src val iface = clear_mi_hi_bytes $ iface { mi_hsc_src_ = val } + +set_mi_src_hash :: Fingerprint -> ModIface_ phase -> ModIface_ phase +set_mi_src_hash val iface = clear_mi_hi_bytes $ iface { mi_src_hash_ = val } + +set_mi_hi_bytes :: IfaceBinHandle phase -> ModIface_ phase -> ModIface_ phase +set_mi_hi_bytes val iface = iface { mi_hi_bytes_ = val } + +set_mi_deps :: Dependencies -> ModIface_ phase -> ModIface_ phase +set_mi_deps val iface = clear_mi_hi_bytes $ iface { mi_deps_ = val } + +set_mi_usages :: [Usage] -> ModIface_ phase -> ModIface_ phase +set_mi_usages val iface = clear_mi_hi_bytes $ iface { mi_usages_ = val } + +set_mi_exports :: [IfaceExport] -> ModIface_ phase -> ModIface_ phase +set_mi_exports val iface = clear_mi_hi_bytes $ iface { mi_exports_ = val } + +set_mi_used_th :: Bool -> ModIface_ phase -> ModIface_ phase +set_mi_used_th val iface = clear_mi_hi_bytes $ iface { mi_used_th_ = val } + +set_mi_fixities :: [(OccName, Fixity)] -> ModIface_ phase -> ModIface_ phase +set_mi_fixities val iface = clear_mi_hi_bytes $ iface { mi_fixities_ = val } + +set_mi_warns :: IfaceWarnings -> ModIface_ phase -> ModIface_ phase +set_mi_warns val iface = clear_mi_hi_bytes $ iface { mi_warns_ = val } + +set_mi_anns :: [IfaceAnnotation] -> ModIface_ phase -> ModIface_ phase +set_mi_anns val iface = clear_mi_hi_bytes $ iface { mi_anns_ = val } + +set_mi_insts :: [IfaceClsInst] -> ModIface_ phase -> ModIface_ phase +set_mi_insts val iface = clear_mi_hi_bytes $ iface { mi_insts_ = val } + +set_mi_fam_insts :: [IfaceFamInst] -> ModIface_ phase -> ModIface_ phase +set_mi_fam_insts val iface = clear_mi_hi_bytes $ iface { mi_fam_insts_ = val } + +set_mi_rules :: [IfaceRule] -> ModIface_ phase -> ModIface_ phase +set_mi_rules val iface = clear_mi_hi_bytes $ iface { mi_rules_ = val } + +set_mi_decls :: [IfaceDeclExts phase] -> ModIface_ phase -> ModIface_ phase +set_mi_decls val iface = clear_mi_hi_bytes $ iface { mi_decls_ = val } + +set_mi_extra_decls :: Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] -> ModIface_ phase -> ModIface_ phase +set_mi_extra_decls val iface = clear_mi_hi_bytes $ iface { mi_extra_decls_ = val } + +set_mi_globals :: Maybe IfGlobalRdrEnv -> ModIface_ phase -> ModIface_ phase +set_mi_globals val iface = clear_mi_hi_bytes $ iface { mi_globals_ = val } + +set_mi_hpc :: AnyHpcUsage -> ModIface_ phase -> ModIface_ phase +set_mi_hpc val iface = clear_mi_hi_bytes $ iface { mi_hpc_ = val } + +set_mi_trust :: IfaceTrustInfo -> ModIface_ phase -> ModIface_ phase +set_mi_trust val iface = clear_mi_hi_bytes $ iface { mi_trust_ = val } + +set_mi_trust_pkg :: Bool -> ModIface_ phase -> ModIface_ phase +set_mi_trust_pkg val iface = clear_mi_hi_bytes $ iface { mi_trust_pkg_ = val } + +set_mi_complete_matches :: [IfaceCompleteMatch] -> ModIface_ phase -> ModIface_ phase +set_mi_complete_matches val iface = clear_mi_hi_bytes $ iface { mi_complete_matches_ = val } + +set_mi_docs :: Maybe Docs -> ModIface_ phase -> ModIface_ phase +set_mi_docs val iface = clear_mi_hi_bytes $ iface { mi_docs_ = val } + +set_mi_final_exts :: IfaceBackendExts phase -> ModIface_ phase -> ModIface_ phase +set_mi_final_exts val iface = clear_mi_hi_bytes $ iface { mi_final_exts_ = val } + +set_mi_ext_fields :: ExtensibleFields -> ModIface_ phase -> ModIface_ phase +set_mi_ext_fields val iface = clear_mi_hi_bytes $ iface { mi_ext_fields_ = val } + +-- | Invalidate any byte array buffer we might have. +clear_mi_hi_bytes :: ModIface_ phase -> ModIface_ phase +clear_mi_hi_bytes iface = iface + { mi_hi_bytes_ = case mi_hi_bytes iface of + PartialIfaceBinHandle -> PartialIfaceBinHandle + FullIfaceBinHandle _ -> FullIfaceBinHandle Strict.Nothing + } + +-- ---------------------------------------------------------------------------- +-- Accessor functions of 'ModIface'. +-- We use these as 'ModIface''s fields are private. +-- ---------------------------------------------------------------------------- + +mi_module :: ModIface_ phase -> Module +mi_module = mi_module_ + +mi_sig_of :: ModIface_ phase -> Maybe Module +mi_sig_of = mi_sig_of_ + +mi_hsc_src :: ModIface_ phase -> HscSource +mi_hsc_src = mi_hsc_src_ + +mi_deps :: ModIface_ phase -> Dependencies +mi_deps = mi_deps_ + +mi_usages :: ModIface_ phase -> [Usage] +mi_usages = mi_usages_ + +mi_exports :: ModIface_ phase -> [IfaceExport] +mi_exports = mi_exports_ + +mi_used_th :: ModIface_ phase -> Bool +mi_used_th = mi_used_th_ + +mi_fixities :: ModIface_ phase -> [(OccName, Fixity)] +mi_fixities = mi_fixities_ + +mi_warns :: ModIface_ phase -> IfaceWarnings +mi_warns = mi_warns_ + +mi_anns :: ModIface_ phase -> [IfaceAnnotation] +mi_anns = mi_anns_ + +mi_decls :: ModIface_ phase -> [IfaceDeclExts phase] +mi_decls = mi_decls_ + +mi_extra_decls :: ModIface_ phase -> Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] +mi_extra_decls = mi_extra_decls_ + +mi_globals :: ModIface_ phase -> Maybe IfGlobalRdrEnv +mi_globals = mi_globals_ + +mi_insts :: ModIface_ phase -> [IfaceClsInst] +mi_insts = mi_insts_ + +mi_fam_insts :: ModIface_ phase -> [IfaceFamInst] +mi_fam_insts = mi_fam_insts_ + +mi_rules :: ModIface_ phase -> [IfaceRule] +mi_rules = mi_rules_ + +mi_hpc :: ModIface_ phase -> AnyHpcUsage +mi_hpc = mi_hpc_ + +mi_trust :: ModIface_ phase -> IfaceTrustInfo +mi_trust = mi_trust_ + +mi_trust_pkg :: ModIface_ phase -> Bool +mi_trust_pkg = mi_trust_pkg_ + +mi_complete_matches :: ModIface_ phase -> [IfaceCompleteMatch] +mi_complete_matches = mi_complete_matches_ + +mi_docs :: ModIface_ phase -> Maybe Docs +mi_docs = mi_docs_ + +mi_final_exts :: ModIface_ phase -> IfaceBackendExts phase +mi_final_exts = mi_final_exts_ + +mi_ext_fields :: ModIface_ phase -> ExtensibleFields +mi_ext_fields = mi_ext_fields_ +mi_src_hash :: ModIface_ phase -> Fingerprint +mi_src_hash = mi_src_hash_ +mi_hi_bytes :: ModIface_ phase -> IfaceBinHandle phase +mi_hi_bytes = mi_hi_bytes_ ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -19,7 +19,7 @@ -- http://www.cs.york.ac.uk/fp/nhc98/ module GHC.Utils.Binary - ( {-type-} Bin, + ( {-type-} Bin, RelBin(..), getRelBin, {-class-} Binary(..), {-type-} ReadBinHandle, WriteBinHandle, SymbolTable, Dictionary, @@ -32,6 +32,7 @@ module GHC.Utils.Binary seekBinWriter, seekBinReader, + seekBinReaderRel, tellBinReader, tellBinWriter, castBin, @@ -47,7 +48,9 @@ module GHC.Utils.Binary readBinMemN, putAt, getAt, + putAtRel, forwardPut, forwardPut_, forwardGet, + forwardPutRel, forwardPutRel_, forwardGetRel, -- * For writing instances putByte, @@ -102,6 +105,9 @@ module GHC.Utils.Binary BindingName(..), simpleBindingNameWriter, simpleBindingNameReader, + FullBinData(..), freezeBinHandle, thawBinHandle, putFullBinData, + freezeBinHandle2, + BinArray, ) where import GHC.Prelude @@ -156,7 +162,6 @@ import GHC.ForeignPtr ( unsafeWithForeignPtr ) import Unsafe.Coerce (unsafeCoerce) import GHC.Data.TrieMap - type BinArray = ForeignPtr Word8 #if !MIN_VERSION_base(4,15,0) @@ -196,6 +201,51 @@ dataHandle (BinData size bin) = do handleData :: WriteBinHandle -> IO BinData handleData (WriteBinMem _ ixr _ binr) = BinData <$> readFastMutInt ixr <*> readIORef binr +--------------------------------------------------------------- +-- FullBinData +--------------------------------------------------------------- + +data FullBinData = FullBinData + { fbd_readerUserData :: ReaderUserData + , fbd_off_s :: {-# UNPACK #-} !Int + -- ^ start offset + , fbd_off_e :: {-# UNPACK #-} !Int + -- ^ end offset + , fbd_size :: {-# UNPACK #-} !Int + -- ^ total buffer size + , fbd_buffer :: {-# UNPACK #-} !BinArray + } + +-- Equality and Ord assume that two distinct buffers are different, even if they compare the same things. +instance Eq FullBinData where + (FullBinData _ b c d e) == (FullBinData _ b1 c1 d1 e1) = b == b1 && c == c1 && d == d1 && e == e1 + +instance Ord FullBinData where + compare (FullBinData _ b c d e) (FullBinData _ b1 c1 d1 e1) = + compare b b1 `mappend` compare c c1 `mappend` compare d d1 `mappend` compare e e1 + +putFullBinData :: WriteBinHandle -> FullBinData -> IO () +putFullBinData bh (FullBinData _ o1 o2 _sz ba) = do + let sz = o2 - o1 + putPrim bh sz $ \dest -> + unsafeWithForeignPtr (ba `plusForeignPtr` o1) $ \orig -> + copyBytes dest orig sz + +freezeBinHandle :: Bin () -> ReadBinHandle -> IO FullBinData +freezeBinHandle (BinPtr len) (ReadBinMem user_data ixr sz binr) = do + ix <- readFastMutInt ixr + pure (FullBinData user_data ix len sz binr) + +freezeBinHandle2 :: ReadBinHandle -> Bin () -> IO FullBinData +freezeBinHandle2 (ReadBinMem user_data ixr sz binr) (BinPtr start) = do + ix <- readFastMutInt ixr + pure (FullBinData user_data start ix sz binr) + +thawBinHandle :: FullBinData -> IO ReadBinHandle +thawBinHandle (FullBinData user_data ix _end sz ba) = do + ixr <- newFastMutInt ix + return $ ReadBinMem user_data ixr sz ba + --------------------------------------------------------------- -- BinHandle --------------------------------------------------------------- @@ -289,9 +339,47 @@ unsafeUnpackBinBuffer (BS.BS arr len) = do newtype Bin a = BinPtr Int deriving (Eq, Ord, Show, Bounded) +-- | Like a 'Bin' but is used to store relative offset pointers. +-- Relative offset pointers store a relative location, but also contain an +-- anchor that allow to obtain the absolute offset. +data RelBin a = RelBin + { relBin_anchor :: {-# UNPACK #-} !(Bin a) + -- ^ Absolute position from where we read 'relBin_offset'. + , relBin_offset :: {-# UNPACK #-} !(RelBinPtr a) + -- ^ Relative offset to 'relBin_anchor'. + -- The absolute position of the 'RelBin' is @relBin_anchor + relBin_offset@ + } + deriving (Eq, Ord, Show, Bounded) + +-- | A 'RelBinPtr' is like a 'Bin', but contains a relative offset pointer +-- instead of an absolute offset. +newtype RelBinPtr a = RelBinPtr (Bin a) + deriving (Eq, Ord, Show, Bounded) + castBin :: Bin a -> Bin b castBin (BinPtr i) = BinPtr i +-- | Read a relative offset location and wrap it in 'RelBin'. +-- +-- The resulting 'RelBin' can be translated into an absolute offset location using +-- 'makeAbsoluteBin' +getRelBin :: ReadBinHandle -> IO (RelBin a) +getRelBin bh = do + start <- tellBinReader bh + off <- get bh + pure $ RelBin start off + +makeAbsoluteBin :: RelBin a -> Bin a +makeAbsoluteBin (RelBin (BinPtr !start) (RelBinPtr (BinPtr !offset))) = + BinPtr $ start + offset + +makeRelativeBin :: RelBin a -> RelBinPtr a +makeRelativeBin (RelBin _ offset) = offset + +toRelBin :: Bin (RelBinPtr a) -> Bin a -> RelBin a +toRelBin (BinPtr !start) (BinPtr !goal) = + RelBin (BinPtr start) (RelBinPtr $ BinPtr $ goal - start) + --------------------------------------------------------------- -- class Binary --------------------------------------------------------------- @@ -312,6 +400,9 @@ class Binary a where putAt :: Binary a => WriteBinHandle -> Bin a -> a -> IO () putAt bh p x = do seekBinWriter bh p; put_ bh x; return () +putAtRel :: WriteBinHandle -> Bin (RelBinPtr a) -> Bin a -> IO () +putAtRel bh from to = putAt bh from (makeRelativeBin $ toRelBin from to) + getAt :: Binary a => ReadBinHandle -> Bin a -> IO a getAt bh p = do seekBinReader bh p; get bh @@ -393,12 +484,19 @@ seekBinNoExpandWriter (WriteBinMem _ ix_r sz_r _) (BinPtr !p) = do else writeFastMutInt ix_r p -- | SeekBin but without calling expandBin -seekBinReader :: ReadBinHandle -> Bin a -> IO () +seekBinReader :: HasCallStack => ReadBinHandle -> Bin a -> IO () seekBinReader (ReadBinMem _ ix_r sz_r _) (BinPtr !p) = do if (p > sz_r) then panic "seekBinReader: seek out of range" else writeFastMutInt ix_r p +seekBinReaderRel :: HasCallStack => ReadBinHandle -> RelBin a -> IO () +seekBinReaderRel (ReadBinMem _ ix_r sz_r _) relBin = do + let (BinPtr !p) = makeAbsoluteBin relBin + if (p > sz_r) + then panic "seekBinReaderRel: seek out of range" + else writeFastMutInt ix_r p + writeBinMem :: WriteBinHandle -> FilePath -> IO () writeBinMem (WriteBinMem _ ix_r _ arr_r) fn = do h <- openBinaryFile fn WriteMode @@ -1119,12 +1217,17 @@ instance Binary (Bin a) where put_ bh (BinPtr i) = putWord32 bh (fromIntegral i :: Word32) get bh = do i <- getWord32 bh; return (BinPtr (fromIntegral (i :: Word32))) +-- Instance uses fixed-width encoding to allow inserting +-- Bin placeholders in the stream. +instance Binary (RelBinPtr a) where + put_ bh (RelBinPtr i) = put_ bh i + get bh = RelBinPtr <$> get bh -- ----------------------------------------------------------------------------- -- Forward reading/writing --- | "forwardPut put_A put_B" outputs A after B but allows A to be read before B --- by using a forward reference +-- | @'forwardPut' put_A put_B@ outputs A after B but allows A to be read before B +-- by using a forward reference. forwardPut :: WriteBinHandle -> (b -> IO a) -> IO b -> IO (a,b) forwardPut bh put_A put_B = do -- write placeholder pointer to A @@ -1147,7 +1250,9 @@ forwardPut_ :: WriteBinHandle -> (b -> IO a) -> IO b -> IO () forwardPut_ bh put_A put_B = void $ forwardPut bh put_A put_B -- | Read a value stored using a forward reference -forwardGet :: ReadBinHandle -> IO a -> IO a +-- +-- The forward reference is expected to be an absolute offset. +forwardGet :: HasCallStack => ReadBinHandle -> IO a -> IO a forwardGet bh get_A = do -- read forward reference p <- get bh -- a BinPtr @@ -1159,6 +1264,48 @@ forwardGet bh get_A = do seekBinReader bh p_a pure r +-- | @'forwardPutRel' put_A put_B@ outputs A after B but allows A to be read before B +-- by using a forward reference. +-- +-- This forward reference is a relative offset that allows us to skip over the +-- result of 'put_A'. +forwardPutRel :: WriteBinHandle -> (b -> IO a) -> IO b -> IO (a,b) +forwardPutRel bh put_A put_B = do + -- write placeholder pointer to A + pre_a <- tellBinWriter bh + put_ bh pre_a + + -- write B + r_b <- put_B + + -- update A's pointer + a <- tellBinWriter bh + putAtRel bh pre_a a + seekBinNoExpandWriter bh a + + -- write A + r_a <- put_A r_b + pure (r_a,r_b) + +-- | Like 'forwardGetRel', but discard the result. +forwardPutRel_ :: WriteBinHandle -> (b -> IO a) -> IO b -> IO () +forwardPutRel_ bh put_A put_B = void $ forwardPutRel bh put_A put_B + +-- | Read a value stored using a forward reference. +-- +-- The forward reference is expected to be a relative offset. +forwardGetRel :: ReadBinHandle -> IO a -> IO a +forwardGetRel bh get_A = do + -- read forward reference + p <- getRelBin bh + -- store current position + p_a <- tellBinReader bh + -- go read the forward value, then seek back + seekBinReader bh $ makeAbsoluteBin p + r <- get_A + seekBinReader bh p_a + pure r + -- ----------------------------------------------------------------------------- -- Lazy reading/writing @@ -1168,19 +1315,19 @@ lazyPut = lazyPut' put_ lazyGet :: Binary a => ReadBinHandle -> IO a lazyGet = lazyGet' get -lazyPut' :: HasDebugCallStack => (WriteBinHandle -> a -> IO ()) -> WriteBinHandle -> a -> IO () +lazyPut' :: (WriteBinHandle -> a -> IO ()) -> WriteBinHandle -> a -> IO () lazyPut' f bh a = do -- output the obj with a ptr to skip over it: pre_a <- tellBinWriter bh put_ bh pre_a -- save a slot for the ptr f bh a -- dump the object q <- tellBinWriter bh -- q = ptr to after object - putAt bh pre_a q -- fill in slot before a with ptr to q + putAtRel bh pre_a q -- fill in slot before a with ptr to q seekBinWriter bh q -- finally carry on writing at q lazyGet' :: HasDebugCallStack => (ReadBinHandle -> IO a) -> ReadBinHandle -> IO a lazyGet' f bh = do - p <- get bh -- a BinPtr + p <- getRelBin bh -- a BinPtr p_a <- tellBinReader bh a <- unsafeInterleaveIO $ do -- NB: Use a fresh rbm_off_r variable in the child thread, for thread @@ -1189,7 +1336,7 @@ lazyGet' f bh = do let bh' = bh { rbm_off_r = off_r } seekBinReader bh' p_a f bh' - seekBinReader bh p -- skip over the object for now + seekBinReader bh (makeAbsoluteBin p) -- skip over the object for now return a -- | Serialize the constructor strictly but lazily serialize a value inside a @@ -1483,13 +1630,13 @@ putGenericSymbolTable gen_sym_tab serialiser bh = do mapM_ (\n -> serialiser bh n) (reverse todo) loop snd <$> - (forwardPut bh (const $ readFastMutInt symtab_next >>= put_ bh) $ + (forwardPutRel bh (const $ readFastMutInt symtab_next >>= put_ bh) $ loop) -- | Read the elements of a 'GenericSymbolTable' from disk into a 'SymbolTable'. getGenericSymbolTable :: forall a . (ReadBinHandle -> IO a) -> ReadBinHandle -> IO (SymbolTable a) getGenericSymbolTable deserialiser bh = do - sz <- forwardGet bh (get bh) :: IO Int + sz <- forwardGetRel bh (get bh) :: IO Int mut_arr <- newArray_ (0, sz-1) :: IO (IOArray Int a) forM_ [0..(sz-1)] $ \i -> do f <- deserialiser bh ===================================== testsuite/tests/plugins/simple-plugin/Simple/RemovePlugin.hs ===================================== @@ -64,9 +64,10 @@ metaPlugin' _ meta = pprPanic "meta" (showAstData BlankSrcSpan BlankEpAnnotation interfaceLoadPlugin' :: [CommandLineOption] -> ModIface -> IfM lcl ModIface interfaceLoadPlugin' [name, "interface"] iface - = return $ iface { mi_exports = filter (availNotNamedAs name) - (mi_exports iface) - } + = return $ set_mi_exports (filter (availNotNamedAs name) + (mi_exports iface)) + iface + interfaceLoadPlugin' _ iface = return iface availNotNamedAs :: String -> AvailInfo -> Bool ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit c9bc29c6a708483d2abc3d8ec9262510ce87ca61 +Subproject commit 6f9e0cc9ae9f2dfbd671e5970ec9d7bbf9a9dcf1 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5a4e116a2842dba90e87c55cb66875221a18225f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5a4e116a2842dba90e87c55cb66875221a18225f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 11:03:02 2024 From: gitlab at gitlab.haskell.org (Jade (@Jade)) Date: Wed, 08 May 2024 07:03:02 -0400 Subject: [Git][ghc/ghc][wip/document-system-io] Documentation: Improve documentation for symbols exported from System.IO Message-ID: <663b5be5ee365_6129d50445c506ca@gitlab.mail> Jade pushed to branch wip/document-system-io at Glasgow Haskell Compiler / GHC Commits: a4307517 by Jade at 2024-05-08T13:02:23+02:00 Documentation: Improve documentation for symbols exported from System.IO - - - - - 8 changed files: - libraries/base/src/GHC/IO/Handle.hs - libraries/base/src/GHC/IO/StdHandles.hs - libraries/base/src/System/IO.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle/Text.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs - libraries/ghc-internal/src/GHC/Internal/IO/StdHandles.hs - libraries/ghc-internal/src/GHC/Internal/System/IO.hs Changes: ===================================== libraries/base/src/GHC/IO/Handle.hs ===================================== @@ -73,4 +73,4 @@ module GHC.IO.Handle hPutBufNonBlocking ) where -import GHC.Internal.IO.Handle \ No newline at end of file +import GHC.Internal.IO.Handle ===================================== libraries/base/src/GHC/IO/StdHandles.hs ===================================== @@ -26,4 +26,4 @@ module GHC.IO.StdHandles withFileBlocking ) where -import GHC.Internal.IO.StdHandles \ No newline at end of file +import GHC.Internal.IO.StdHandles ===================================== libraries/base/src/System/IO.hs ===================================== @@ -199,3 +199,16 @@ import GHC.Internal.System.IO -- It follows that an attempt to write to a file (using 'writeFile', for -- example) that was earlier opened by 'readFile' will usually result in -- failure with 'GHC.Internal.System.IO.Error.isAlreadyInUseError'. + +-- $stdio_examples +-- Note: Some of the examples in this module do not work "as is" in ghci. +-- This is because using 'stdin' in combination with lazy IO +-- does not work well in interactive mode. +-- +-- lines starting with @>@ indicate 'stdin' and @^D@ signales EOF. +-- +-- >>> foo +-- > input +-- output +-- > input^D +-- output ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle.hs ===================================== @@ -74,6 +74,7 @@ import GHC.Internal.Real import GHC.Internal.Data.Maybe import GHC.Internal.Data.Typeable + -- --------------------------------------------------------------------------- -- Closing a handle @@ -468,6 +469,9 @@ hTell handle = -- handle. Each of these operations returns `True' if the handle has -- the specified property, and `False' otherwise. +-- | @'hIsOpen' hdl@ returns whether the handle is open. +-- If the 'haType' of @hdl@ is 'ClosedHandle' or 'SemiClosedHandle' this returns 'False' +-- and 'True' otherwise. hIsOpen :: Handle -> IO Bool hIsOpen handle = withHandle_ "hIsOpen" handle $ \ handle_ -> do @@ -476,6 +480,9 @@ hIsOpen handle = SemiClosedHandle -> return False _ -> return True +-- | @'hIsOpen' hdl@ returns whether the handle is closed. +-- If the 'haType' of @hdl@ is 'ClosedHandle' this returns 'True' +-- and 'False' otherwise. hIsClosed :: Handle -> IO Bool hIsClosed handle = withHandle_ "hIsClosed" handle $ \ handle_ -> do @@ -493,6 +500,7 @@ hIsClosed handle = return (not (ho || hc)) -} +-- | @'hIsReadable' hdl@ returns whether it is possible to read from the handle. hIsReadable :: Handle -> IO Bool hIsReadable (DuplexHandle _ _ _) = return True hIsReadable handle = @@ -502,6 +510,7 @@ hIsReadable handle = SemiClosedHandle -> ioe_semiclosedHandle htype -> return (isReadableHandleType htype) +-- | @'hIsWritable' hdl@ returns whether it is possible to write to the handle. hIsWritable :: Handle -> IO Bool hIsWritable (DuplexHandle _ _ _) = return True hIsWritable handle = @@ -524,6 +533,7 @@ hGetBuffering handle = -- of a semi-closed handle to be queried. -- sof 6/98 return (haBufferMode handle_) -- could be stricter.. +-- | @'hIsSeekable' hdl@ returns whether it is possible to 'hSeek' with the given handle. hIsSeekable :: Handle -> IO Bool hIsSeekable handle = withHandle_ "hIsSeekable" handle $ \ handle_ at Handle__{..} -> do @@ -775,4 +785,3 @@ showHandle' filepath is_duplex h = where def :: Int def = bufSize buf - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle/Text.hs ===================================== @@ -484,8 +484,9 @@ getSomeCharacters handle_ at Handle__{..} buf at Buffer{..} = -- | The 'hGetContents'' operation reads all input on the given handle -- before returning it as a 'String' and closing the handle. -- +-- This is a strict version of 'hGetContents' +-- -- @since base-4.15.0.0 - hGetContents' :: Handle -> IO String hGetContents' handle = do es <- wantReadableHandle "hGetContents'" handle (strictRead handle) @@ -565,7 +566,7 @@ lazyBuffersToString CRLF = loop '\0' where -- -- This operation may fail with: -- --- * 'isFullError' if the device is full; or +-- * 'isFullError' if the device is full. -- -- * 'isPermissionError' if another system resource limit would be exceeded. @@ -623,16 +624,28 @@ hPutcBuffered handle_ at Handle__{..} c = do -- | Computation 'hPutStr' @hdl s@ writes the string -- @s@ to the file or channel managed by @hdl at . -- +-- Note that 'hPutStr' is not concurrency safe unless the 'BufferMode' of +-- @hdl@ is set to 'LineBuffering': +-- +-- >>> let f = forkIO . hPutStr stdout +-- >>> in do hSetBuffering stdout NoBuffering; f "This is a longer string"; f ":D"; f "Hello Haskell"; pure () +-- This: HDiesl lao lHoansgkeerl lstring +-- +-- >>> let f = forkIO . hPutStr stdout +-- >>> in do hSetBuffering stdout LineBuffering; f "This is a longer string"; f ":D"; f "Hello Haskell"; pure () +-- This is a longer string:DHello Haskell +-- -- This operation may fail with: -- --- * 'isFullError' if the device is full; or +-- * 'isFullError' if the device is full. -- -- * 'isPermissionError' if another system resource limit would be exceeded. - hPutStr :: Handle -> String -> IO () hPutStr handle str = hPutStr' handle str False -- | The same as 'hPutStr', but adds a newline character. +-- +-- This operation may fail with the same errors, and has the same issues with concurrency, as 'hPutStr'! hPutStrLn :: Handle -> String -> IO () hPutStrLn handle str = hPutStr' handle str True @@ -1176,4 +1189,3 @@ illegalBufferSize handle fn sz = InvalidArgument fn ("illegal buffer size " ++ showsPrec 9 sz []) Nothing Nothing) - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs ===================================== @@ -162,21 +162,29 @@ data HandleType | AppendHandle | ReadWriteHandle +-- | @'isReadableHandleType' hdlType@ returns 'True' if +-- @hdlType@ is one of 'ReadHandle' and 'ReadWriteHandle'. isReadableHandleType :: HandleType -> Bool isReadableHandleType ReadHandle = True isReadableHandleType ReadWriteHandle = True isReadableHandleType _ = False +-- | @'isWritableHandleType' hdlType@ returns 'True' if +-- @hdlType@ is one of 'AppendHandle', 'WriteHandle' and 'ReadWriteHandle'. isWritableHandleType :: HandleType -> Bool isWritableHandleType AppendHandle = True isWritableHandleType WriteHandle = True isWritableHandleType ReadWriteHandle = True isWritableHandleType _ = False +-- | @'isReadWriteHandleType' hdlType@ returns 'True' if +-- @hdlType@ is 'ReadWriteHandle'. isReadWriteHandleType :: HandleType -> Bool isReadWriteHandleType ReadWriteHandle{} = True isReadWriteHandleType _ = False +-- | @'isAppendHandleType' hdlType@ returns 'True' if +-- @hdlType@ is 'AppendHandle'. isAppendHandleType :: HandleType -> Bool isAppendHandleType AppendHandle = True isAppendHandleType _ = False @@ -450,4 +458,3 @@ instance Show Handle where showHandle :: FilePath -> String -> String showHandle file = showString "{handle: " . showString file . showString "}" - ===================================== libraries/ghc-internal/src/GHC/Internal/IO/StdHandles.hs ===================================== @@ -29,72 +29,120 @@ import GHC.Internal.IO.IOMode import GHC.Internal.IO.Handle.Types import qualified GHC.Internal.IO.Handle.FD as POSIX + +-- windows only imports #if defined(mingw32_HOST_OS) import GHC.Internal.IO.SubSystem import qualified GHC.Internal.IO.Handle.Windows as Win import GHC.Internal.IO.Handle.Internals (hClose_impl) +#endif + +-- | 'stdin' is a handle managing the programs standard input. stdin :: Handle +#if defined(mingw32_HOST_OS) stdin = POSIX.stdin Win.stdin +#else +stdin = POSIX.stdin +#endif +-- | 'stdout' is a handle managing the programs standard output. stdout :: Handle +#if defined(mingw32_HOST_OS) stdout = POSIX.stdout Win.stdout +#else +stdout = POSIX.stdout +#endif +-- | 'stderr' is a handle managing the programs standard error. stderr :: Handle +#if defined(mingw32_HOST_OS) stderr = POSIX.stderr Win.stderr +#else +stderr = POSIX.stderr +#endif -openFile :: FilePath -> IOMode -> IO Handle +-- | The computation @'openFile' path mode@ returns a file handle that can be +-- used to interact with the file. +openFile + :: FilePath -- ^ The path to the file that should be opened + -> IOMode -- ^ The mode in which the file should be opened + -> IO Handle +#if defined(mingw32_HOST_OS) openFile = POSIX.openFile Win.openFile +#else +openFile = POSIX.openFile +#endif +-- | The computation @'openBinaryFile' path mode@ returns a file handle that can be +-- used to interact with the binary file. +-- +-- This is different from 'openFile' as in that it does not use any file encoding. +openBinaryFile + :: FilePath -- ^ The path to the binary file that should be opened + -> IOMode -- ^ The mode in which the binary file should be opened + -> IO Handle +#if defined(mingw32_HOST_OS) +openBinaryFile = POSIX.openBinaryFile Win.openBinaryFile +#else +openBinaryFile = POSIX.openBinaryFile +#endif + +-- | The computation @'withFile' path mode action@ opens the file and runs @action@ +-- with the obtained handle before closing the file. +-- +-- Even when an exception is raised within the 'action', the file will still be closed. +-- This is why @'withFile' path mode act@ is preferable to +-- +-- @'openFile' path mode >>= (\\hdl -> act hdl >>= 'System.IO.hClose' hdl)@ +-- +-- See also: 'System.IO.bracket' +withFile + :: FilePath -- ^ The path to the file that should be opened + -> IOMode -- ^ The mode in which the file should be opened + -> (Handle -> IO r) -- ^ The action to run with the obtained handle + -> IO r +#if defined(mingw32_HOST_OS) -- TODO: implement as for POSIX -withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFile = POSIX.withFile wf where wf path mode act = bracket (Win.openFile path mode) hClose_impl act +#else +withFile = POSIX.withFile +#endif -openBinaryFile :: FilePath -> IOMode -> IO Handle -openBinaryFile = POSIX.openBinaryFile Win.openBinaryFile - +-- | The computation @'withBinaryFile' path mode action@ opens the binary file +-- and runs @action@ with the obtained handle before closing the binary file. +-- +-- This is different from 'withFile' as in that it does not use any file encoding. +-- +-- Even when an exception is raised within the 'action', the file will still be closed. +-- This is why @'withBinaryFile' path mode act@ is preferable to +-- +-- @'openBinaryFile' path mode >>= (\\hdl -> act hdl >>= 'System.IO.hClose' hdl)@ +-- +-- See also: 'System.IO.bracket' withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r +#if defined(mingw32_HOST_OS) withBinaryFile = POSIX.withBinaryFile wf where wf path mode act = bracket (Win.openBinaryFile path mode) hClose_impl act +#else +withBinaryFile = POSIX.withBinaryFile +#endif openFileBlocking :: FilePath -> IOMode -> IO Handle +#if defined(mingw32_HOST_OS) openFileBlocking = POSIX.openFileBlocking Win.openFileBlocking +#else +openFileBlocking = POSIX.openFileBlocking +#endif withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r +#if defined(mingw32_HOST_OS) withFileBlocking = POSIX.withFileBlocking wf where wf path mode act = bracket (Win.openFileBlocking path mode) hClose_impl act - #else - -stdin :: Handle -stdin = POSIX.stdin - -stdout :: Handle -stdout = POSIX.stdout - -stderr :: Handle -stderr = POSIX.stderr - -openFile :: FilePath -> IOMode -> IO Handle -openFile = POSIX.openFile - -withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r -withFile = POSIX.withFile - -openBinaryFile :: FilePath -> IOMode -> IO Handle -openBinaryFile = POSIX.openBinaryFile - -withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r -withBinaryFile = POSIX.withBinaryFile - -openFileBlocking :: FilePath -> IOMode -> IO Handle -openFileBlocking = POSIX.openFileBlocking - -withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFileBlocking = POSIX.withFileBlocking - #endif ===================================== libraries/ghc-internal/src/GHC/Internal/System/IO.hs ===================================== @@ -257,24 +257,50 @@ import GHC.Internal.Text.Read import GHC.Internal.IO.StdHandles import GHC.Internal.Show import GHC.Internal.MVar - --- ----------------------------------------------------------------------------- +----------------------------------------------------------------------------- -- Standard IO -- | Write a character to the standard output device --- (same as 'hPutChar' 'stdout'). - +-- +-- 'putChar' is implemented as @'hPutChar' 'stdout'@. +-- +-- This operation may fail with the same errors as 'hPutChar'. +-- +-- ==== __Examples__ +-- +-- Note that the following do not put a newline. +-- +-- >>> putChar 'x' +-- x +-- +-- >>> putChar '\0042' +-- * putChar :: Char -> IO () putChar c = hPutChar stdout c -- | Write a string to the standard output device --- (same as 'hPutStr' 'stdout'). - +-- +-- 'putStr' is implemented as @'hPutStr' 'stdout'@. +-- +-- +-- This operation may fail with the same errors, and has the same issues with concurrency, as 'hPutStr'! +-- +-- ==== __Examples__ +-- +-- Note that the following do not put a newline. +-- +-- >>> putStr "Hello, World!" +-- Hello, World! +-- +-- >>> putStr "\0052\0042\0050" +-- 4*2 +-- putStr :: String -> IO () putStr s = hPutStr stdout s -- | The same as 'putStr', but adds a newline character. - +-- +-- This operation may fail with the same errors, and has the same issues with concurrency, as 'hPutStr'! putStrLn :: String -> IO () putStrLn s = hPutStrLn stdout s @@ -284,94 +310,242 @@ putStrLn s = hPutStrLn stdout s -- converts values to strings for output using the 'show' operation and -- adds a newline. -- --- For example, a program to print the first 20 integers and their +-- 'print' is implemented as @'putStrLn' '.' 'show'@ +-- +-- This operation may fail with the same errors, and has the same issues with concurrency, as 'hPutStr'! +-- +-- ==== __Examples__ +-- +-- >>> print [1, 2, 3] +-- [1,2,3] +-- +-- Be careful when using 'print' for outputting strings, +-- as this will invoke 'show' and cause strings to be printed +-- with quotation marks and non-ascii symbols escaped. +-- +-- >>> print "λ :D" +-- "\995 :D" +-- +-- A program to print the first 8 integers and their -- powers of 2 could be written as: -- --- > main = print ([(n, 2^n) | n <- [0..19]]) - +-- >>> print [(n, 2^n) | n <- [0..8]] +-- [(0,1),(1,2),(2,4),(3,8),(4,16),(5,32),(6,64),(7,128),(8,256)] print :: Show a => a -> IO () print x = putStrLn (show x) --- | Read a character from the standard input device --- (same as 'hGetChar' 'stdin'). - +-- | Read a single character from the standard input device. +-- +-- 'getChar' is implemented as @'hGetChar' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetChar'. +-- +-- ==== __Examples__ +-- +-- >>> getChar +-- a'a' +-- +-- >>> getChar +-- > +-- '\n' getChar :: IO Char getChar = hGetChar stdin --- | Read a line from the standard input device --- (same as 'hGetLine' 'stdin'). - +-- | Read a line from the standard input device. +-- +-- 'getLine' is implemented as @'hGetLine' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetLine'. +-- +-- ==== __Examples__ +-- +-- >>> getLine +-- > Hello World! +-- "Hello World!" +-- +-- >>> getLine +-- > +-- "" getLine :: IO String getLine = hGetLine stdin -- | The 'getContents' operation returns all user input as a single string, --- which is read lazily as it is needed --- (same as 'hGetContents' 'stdin'). - +-- which is read lazily as it is needed. +-- +-- 'getContents' is implemented as @'hGetContents' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetContents'. +-- +-- ==== __Examples__ +-- +-- >>> getContents >>= putStr +-- > aaabbbccc :D +-- aaabbbccc :D +-- > I hope you have a great day +-- I hope you have a great day +-- > ^D +-- +-- >>> getContents >>= print . length +-- > abc +-- > <3 +-- > def ^D +-- 11 getContents :: IO String getContents = hGetContents stdin -- | The 'getContents'' operation returns all user input as a single string, -- which is fully read before being returned --- (same as 'hGetContents'' 'stdin'). +-- +-- 'getContents'' is implemented as @'hGetContents'' 'stdin'@. +-- +-- This operation may fail with the same errors as 'hGetContents''. +-- +-- ==== __Examples__ +-- +-- >>> getContents' >>= putStr +-- > aaabbbccc :D +-- > I hope you have a great day +-- aaabbbccc :D +-- I hope you have a great day +-- +-- >>> getContents' >>= print . length +-- > abc +-- > <3 +-- > def ^D +-- 11 -- -- @since base-4.15.0.0 - getContents' :: IO String getContents' = hGetContents' stdin --- | The 'interact' function takes a function of type @String->String@ --- as its argument. The entire input from the standard input device is --- passed to this function as its argument, and the resulting string is --- output on the standard output device. - +-- | @'interact' f@ takes the entire input from 'stdin' and applies @f@ to it. +-- The resulting string is written to the 'stdout' device. +-- +-- Note that this operation is lazy, which allows to produce output +-- even before all has been consumed. +-- +-- This operation may fail with the same errors as 'getContents' and 'putStr'. +-- +-- ==== __Examples__ +-- +-- >>> interact (\str -> str ++ str) +-- > hi :) +-- hi :) +-- > ^D +-- hi :) +-- +-- >>> interact (const ":D") +-- :D +-- +-- >>> interact (show . words) +-- > hello world! +-- > I hope you have a great day +-- > ^D +-- ["hello","world!","I","hope","you","have","a","great","day"] interact :: (String -> String) -> IO () interact f = do s <- getContents putStr (f s) -- | The 'readFile' function reads a file and -- returns the contents of the file as a string. +-- -- The file is read lazily, on demand, as with 'getContents'. - +-- +-- This operation may fail with the same errors as 'hGetContents' and 'openFile'. +-- +-- ==== __Examples__ +-- +-- >>> readFile "~/hello_world" +-- "Greetings!" +-- +-- >>> take 5 <$> readFile "/dev/zero" +-- "\NUL\NUL\NUL\NUL\NUL" readFile :: FilePath -> IO String readFile name = openFile name ReadMode >>= hGetContents -- | The 'readFile'' function reads a file and -- returns the contents of the file as a string. --- The file is fully read before being returned, as with 'getContents''. +-- +-- This is identical to 'readFile', but the file is fully read before being returned, +-- as with 'getContents''. -- -- @since base-4.15.0.0 - readFile' :: FilePath -> IO String -- There's a bit of overkill here—both withFile and -- hGetContents' will close the file in the end. readFile' name = withFile name ReadMode hGetContents' --- | The computation 'writeFile' @file str@ function writes the string @str@, +-- | The computation @'writeFile' file str@ function writes the string @str@, -- to the file @file at . +-- +-- This operation may fail with the same errors as 'hPutStr' and 'withFile'. +-- +-- ==== __Examples__ +-- +-- >>> writeFile "hello" "world" >> readFile "hello" +-- "world" +-- +-- >>> writeFile "~/" "D:" +-- *** Exception: ~/: withFile: inappropriate type (Is a directory) writeFile :: FilePath -> String -> IO () writeFile f txt = withFile f WriteMode (\ hdl -> hPutStr hdl txt) --- | The computation 'appendFile' @file str@ function appends the string @str@, +-- | The computation @'appendFile' file str@ function appends the string @str@, -- to the file @file at . -- -- Note that 'writeFile' and 'appendFile' write a literal string -- to a file. To write a value of any printable type, as with 'print', -- use the 'show' function to convert the value to a string first. -- --- > main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]]) - +-- This operation may fail with the same errors as 'hPutStr' and 'withFile'. +-- +-- ==== __Examples__ +-- +-- The following example could be more efficently written by acquiring a handle +-- instead with 'openFile' and using the computations capable of writing to handles +-- such as 'hPutStr'. +-- +-- >>> let fn = "hello_world" +-- >>> in writeFile fn "hello" >> appendFile fn " world!" >> (readFile fn >>= putStrLn) +-- "hello world!" +-- +-- >>> let fn = "foo"; output = readFile' fn >>= putStrLn +-- >>> in output >> appendFile fn (show [1,2,3]) >> output +-- this is what's in the file +-- this is what's in the file[1,2,3] appendFile :: FilePath -> String -> IO () appendFile f txt = withFile f AppendMode (\ hdl -> hPutStr hdl txt) -- | The 'readLn' function combines 'getLine' and 'readIO'. - +-- +-- This operation may fail with the same errors as 'getLine' and 'readIO'. +-- +-- ==== __Examples__ +-- +-- >>> fmap (+ 5) readLn +-- > 25 +-- 30 +-- +-- >>> readLn :: IO String +-- > this is not a string literal +-- *** Exception: user error (Prelude.readIO: no parse) readLn :: Read a => IO a readLn = getLine >>= readIO -- | The 'readIO' function is similar to 'read' except that it signals -- parse failure to the 'IO' monad instead of terminating the program. - +-- +-- This operation may fail with: +-- +-- * 'GHC.Internal.System.IO.Error.isUserError' if there is no unambiguous parse. +-- +-- ==== __Examples__ +-- +-- >>> fmap (+ 1) (readIO "1") +-- 2 +-- +-- >>> readIO "not quite ()" :: IO () +-- *** Exception: user error (Prelude.readIO: no parse) readIO :: Read a => String -> IO a readIO s = case (do { (x,t) <- reads s ; ("","") <- lex t ; @@ -380,7 +554,7 @@ readIO s = case (do { (x,t) <- reads s ; [] -> ioError (userError "Prelude.readIO: no parse") _ -> ioError (userError "Prelude.readIO: ambiguous parse") --- | The Unicode encoding of the current locale +-- | The encoding of the current locale. -- -- This is the initial locale encoding: if it has been subsequently changed by -- 'GHC.Internal.IO.Encoding.setLocaleEncoding' this value will not reflect that change. @@ -393,21 +567,22 @@ localeEncoding = initLocaleEncoding -- This operation may fail with: -- -- * 'GHC.Internal.System.IO.Error.isEOFError' if the end of file has been reached. - hReady :: Handle -> IO Bool hReady h = hWaitForInput h 0 -- | Computation 'hPrint' @hdl t@ writes the string representation of @t@ --- given by the 'shows' function to the file or channel managed by @hdl@ +-- given by the 'show' function to the file or channel managed by @hdl@ -- and appends a newline. -- --- This operation may fail with: +-- This operation may fail with the same errors as 'hPutStrLn' -- --- * 'GHC.Internal.System.IO.Error.isFullError' if the device is full; or +-- ==== __Examples__ -- --- * 'GHC.Internal.System.IO.Error.isPermissionError' if another system resource limit --- would be exceeded. - +-- >>> hPrint stdout [1,2,3] +-- [1,2,3] +-- +-- >>> hPrint stdin [4,5,6] +-- *** Exception: : hPutStr: illegal operation (handle is not open for writing) hPrint :: Show a => Handle -> a -> IO () hPrint hdl = hPutStrLn hdl . show @@ -415,9 +590,50 @@ hPrint hdl = hPutStrLn hdl . show -- --------------------------------------------------------------------------- -- fixIO --- | The implementation of 'GHC.Internal.Control.Monad.Fix.mfix' for 'IO'. If the function --- passed to 'fixIO' inspects its argument, the resulting action will throw --- 'FixIOException'. +-- | The implementation of 'Control.Monad.Fix.mfix' for 'IO'. +-- +-- This operation may fail with: +-- +-- * 'FixIOException' if the function passed to 'fixIO' inspects its argument. +-- +-- ==== __Examples__ +-- +-- the IO-action is only executed once. The recursion is only on the values. +-- +-- >>> take 3 <$> fixIO (\x -> putStr ":D" >> (:x) <$> readLn @Int) +-- :D +-- 2 +-- [2,2,2] +-- +-- If we are strict in the value, just as with 'Data.Function.fix', we do not get termination: +-- +-- >>> fixIO (\x -> putStr x >> pure ('x' : x)) +-- * hangs forever * +-- +-- We can tie the knot of a structure within 'IO' using 'fixIO': +-- +-- @ +-- data Node = MkNode Int (IORef Node) +-- +-- foo :: IO () +-- foo = do +-- p \<- fixIO (\p -> newIORef (MkNode 0 p)) +-- q <- output p +-- r <- output q +-- _ <- output r +-- pure () +-- +-- output :: IORef Node -> IO (IORef Node) +-- output ref = do +-- MkNode x p <- readIORef ref +-- print x +-- pure p +-- @ +-- +-- >>> foo +-- 0 +-- 0 +-- 0 fixIO :: (a -> IO a) -> IO a fixIO k = do m <- newEmptyMVar @@ -465,7 +681,6 @@ fixIO k = do -- @O_EXCL@ flags are used to prevent this attack, but note that -- @O_EXCL@ is sometimes not supported on NFS filesystems, so if you -- rely on this behaviour it is best to use local filesystems only. --- openTempFile :: FilePath -- ^ Directory in which to create the file -> String -- ^ File name template. If the template is \"foo.ext\" then -- the created file will be \"fooXXX.ext\" where XXX is some View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a4307517981a34544821ac54faee0c0346a6a026 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a4307517981a34544821ac54faee0c0346a6a026 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 12:08:53 2024 From: gitlab at gitlab.haskell.org (Andrei Borzenkov (@sand-witch)) Date: Wed, 08 May 2024 08:08:53 -0400 Subject: [Git][ghc/ghc][wip/sand-witch/improve-pat-to-ty] Improve pattern to type pattern transformation (23739) Message-ID: <663b6b558cf9d_6129d105b4cc733eb@gitlab.mail> Andrei Borzenkov pushed to branch wip/sand-witch/improve-pat-to-ty at Glasgow Haskell Compiler / GHC Commits: cd1f4663 by Andrei Borzenkov at 2024-05-08T16:08:33+04:00 Improve pattern to type pattern transformation (23739) `pat_to_type_pat` function now can handle more patterns: - TuplePat - ListPat - LitPat - NPat - ConPat Allowing these new constructors in type patterns significantly increases possible shapes of type patterns without `type` keyword. This patch also changes how lookups in `lookupOccRnConstr` are performed, because we need to fall back into types when we didn't find a constructor on data level to perform `ConPat` to type transformation properly. - - - - - 15 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Utils/Env.hs - testsuite/tests/rename/should_fail/T19843c.stderr - testsuite/tests/type-data/should_fail/TDPattern.stderr - + testsuite/tests/typecheck/should_compile/T23739a.hs - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T23739b.hs - + testsuite/tests/typecheck/should_fail/T23739b.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -38,6 +38,7 @@ module GHC.Hs.Type ( HsWildCardBndrs(..), HsPatSigType(..), HsPSRn(..), HsTyPat(..), HsTyPatRn(..), + HsTyPatRnBuilder(..), tpBuilderExplicitTV, tpBuilderPatSig, buildHsTyPatRn, builderFromHsTyPatRn, HsSigType(..), LHsSigType, LHsSigWcType, LHsWcType, HsTupleSort(..), HsContext, LHsContext, fromMaybeContext, @@ -128,6 +129,7 @@ import Data.Maybe import Data.Data (Data) import qualified Data.Semigroup as S +import GHC.Data.Bag {- ************************************************************************ @@ -245,6 +247,51 @@ data HsTyPatRn = HsTPRn } deriving Data +-- | A variant of HsTyPatRn that uses Bags for efficient concatenation. +-- See Note [Implicit and explicit type variable binders] in GHC.Rename.Pat +data HsTyPatRnBuilder = + HsTPRnB { + hstpb_nwcs :: Bag Name, + hstpb_imp_tvs :: Bag Name, + hstpb_exp_tvs :: Bag Name + } + +tpBuilderExplicitTV :: Name -> HsTyPatRnBuilder +tpBuilderExplicitTV name = mempty {hstpb_exp_tvs = unitBag name} + +tpBuilderPatSig :: HsPSRn -> HsTyPatRnBuilder +tpBuilderPatSig HsPSRn {hsps_nwcs, hsps_imp_tvs} = + mempty { + hstpb_nwcs = listToBag hsps_nwcs, + hstpb_imp_tvs = listToBag hsps_imp_tvs + } + +instance Semigroup HsTyPatRnBuilder where + HsTPRnB nwcs1 imp_tvs1 exptvs1 <> HsTPRnB nwcs2 imp_tvs2 exptvs2 = + HsTPRnB + (nwcs1 `unionBags` nwcs2) + (imp_tvs1 `unionBags` imp_tvs2) + (exptvs1 `unionBags` exptvs2) + +instance Monoid HsTyPatRnBuilder where + mempty = HsTPRnB emptyBag emptyBag emptyBag + +buildHsTyPatRn :: HsTyPatRnBuilder -> HsTyPatRn +buildHsTyPatRn HsTPRnB {hstpb_nwcs, hstpb_imp_tvs, hstpb_exp_tvs} = + HsTPRn { + hstp_nwcs = bagToList hstpb_nwcs, + hstp_imp_tvs = bagToList hstpb_imp_tvs, + hstp_exp_tvs = bagToList hstpb_exp_tvs + } + +builderFromHsTyPatRn :: HsTyPatRn -> HsTyPatRnBuilder +builderFromHsTyPatRn HsTPRn{hstp_nwcs, hstp_imp_tvs, hstp_exp_tvs} = + HsTPRnB { + hstpb_nwcs = listToBag hstp_nwcs, + hstpb_imp_tvs = listToBag hstp_imp_tvs, + hstpb_exp_tvs = listToBag hstp_exp_tvs + } + type instance XXHsPatSigType (GhcPass _) = DataConCantHappen type instance XXHsTyPat (GhcPass _) = DataConCantHappen ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -1031,8 +1031,32 @@ lookupOccRn = lookupOccRn' WL_Anything -- lookupOccRnConstr looks up an occurrence of a RdrName and displays -- constructors and pattern synonyms as suggestions if it is not in scope +-- +-- There is a fallback to the type level, when the first lookup fails. +-- This is required to implement a pat-to-type transformation +-- (See Note [Pattern to type (P2T) conversion] in GHC.Tc.Gen.Pat) +-- Consider this example: +-- +-- data VisProxy a where VP :: forall a -> VisProxy a +-- +-- f :: VisProxy Int -> () +-- f (VP Int) = () +-- +-- Here `Int` is actually a type, but it stays on position where +-- we expect a data constructor. +-- +-- In all other cases we just use this additional lookup for better +-- error messaging (See Note [Promotion]). lookupOccRnConstr :: RdrName -> RnM Name -lookupOccRnConstr = lookupOccRn' WL_Constructor +lookupOccRnConstr rdr_name + = do { mb_gre <- lookupOccRn_maybe rdr_name + ; case mb_gre of + Just gre -> return $ greName gre + Nothing -> do + { mb_ty_gre <- lookup_promoted rdr_name + ; case mb_ty_gre of + Just gre -> return $ greName gre + Nothing -> reportUnboundName' WL_Constructor rdr_name} } -- lookupOccRnRecField looks up an occurrence of a RdrName and displays -- record fields as suggestions if it is not in scope ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -71,7 +71,6 @@ import GHC.Types.SourceText import GHC.Utils.Misc import GHC.Data.FastString ( uniqCompareFS ) import GHC.Data.List.SetOps( removeDups ) -import GHC.Data.Bag ( Bag, unitBag, unionBags, emptyBag, listToBag, bagToList ) import GHC.Utils.Outputable import GHC.Utils.Panic.Plain import GHC.Types.SrcLoc @@ -89,7 +88,6 @@ import Data.Functor.Identity ( Identity (..) ) import qualified Data.List.NonEmpty as NE import Data.Maybe import Data.Ratio -import qualified Data.Semigroup as S import Control.Monad.Trans.Writer.CPS import Control.Monad.Trans.Class import Control.Monad.Trans.Reader @@ -1242,43 +1240,6 @@ lookupTypeOccTPRnM rdr_name = liftRnFV $ do name <- lookupTypeOccRn rdr_name pure (name, unitFV name) --- | A variant of HsTyPatRn that uses Bags for efficient concatenation. --- See Note [Implicit and explicit type variable binders] -data HsTyPatRnBuilder = - HsTPRnB { - hstpb_nwcs :: Bag Name, - hstpb_imp_tvs :: Bag Name, - hstpb_exp_tvs :: Bag Name - } - -tpb_exp_tv :: Name -> HsTyPatRnBuilder -tpb_exp_tv name = mempty {hstpb_exp_tvs = unitBag name} - -tpb_hsps :: HsPSRn -> HsTyPatRnBuilder -tpb_hsps HsPSRn {hsps_nwcs, hsps_imp_tvs} = - mempty { - hstpb_nwcs = listToBag hsps_nwcs, - hstpb_imp_tvs = listToBag hsps_imp_tvs - } - -instance Semigroup HsTyPatRnBuilder where - HsTPRnB nwcs1 imp_tvs1 exptvs1 <> HsTPRnB nwcs2 imp_tvs2 exptvs2 = - HsTPRnB - (nwcs1 `unionBags` nwcs2) - (imp_tvs1 `unionBags` imp_tvs2) - (exptvs1 `unionBags` exptvs2) - -instance Monoid HsTyPatRnBuilder where - mempty = HsTPRnB emptyBag emptyBag emptyBag - -buildHsTyPatRn :: HsTyPatRnBuilder -> HsTyPatRn -buildHsTyPatRn HsTPRnB {hstpb_nwcs, hstpb_imp_tvs, hstpb_exp_tvs} = - HsTPRn { - hstp_nwcs = bagToList hstpb_nwcs, - hstp_imp_tvs = bagToList hstpb_imp_tvs, - hstp_exp_tvs = bagToList hstpb_exp_tvs - } - rn_lty_pat :: LHsType GhcPs -> TPRnM (LHsType GhcRn) rn_lty_pat (L l hs_ty) = do hs_ty' <- rn_ty_pat hs_ty @@ -1292,7 +1253,7 @@ rn_ty_pat_var lrdr@(L l rdr) = do then do -- binder name <- liftTPRnCps $ newPatName (LamMk True) lrdr - tellTPB (tpb_exp_tv name) + tellTPB (tpBuilderExplicitTV name) pure (L l name) else do -- usage @@ -1413,7 +1374,7 @@ rn_ty_pat (HsKindSig an ty ki) = do ~(HsPS hsps ki') <- liftRnWithCont $ rnHsPatSigKind AlwaysBind ctxt (HsPS noAnn ki) ty' <- rn_lty_pat ty - tellTPB (tpb_hsps hsps) + tellTPB (tpBuilderPatSig hsps) pure (HsKindSig an ty' ki') rn_ty_pat (HsSpliceTy _ splice) = do ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -56,7 +56,6 @@ import GHC.Types.Name.Env import GHC.Types.Name.Reader import GHC.Types.SrcLoc import GHC.Types.Var.Env ( emptyTidyEnv, mkInScopeSet ) -import GHC.Types.SourceText import GHC.Data.Maybe import GHC.Utils.Misc import GHC.Utils.Outputable as Outputable @@ -899,18 +898,12 @@ expr_to_type earg = where unwrap_op_tv (L _ (HsTyVar _ _ op_id)) = return op_id unwrap_op_tv _ = failWith $ TcRnIllformedTypeArgument (L l e) - go (L l e@(HsOverLit _ lit)) = - do { tylit <- case ol_val lit of - HsIntegral n -> return $ HsNumTy NoSourceText (il_value n) - HsIsString _ s -> return $ HsStrTy NoSourceText s - HsFractional _ -> failWith $ TcRnIllformedTypeArgument (L l e) - ; return (L l (HsTyLit noExtField tylit)) } - go (L l e@(HsLit _ lit)) = - do { tylit <- case lit of - HsChar _ c -> return $ HsCharTy NoSourceText c - HsString _ s -> return $ HsStrTy NoSourceText s - _ -> failWith $ TcRnIllformedTypeArgument (L l e) - ; return (L l (HsTyLit noExtField tylit)) } + go (L l (HsOverLit _ lit)) + | Just tylit <- tyLitFromOverloadedLit (ol_val lit) + = return (L l (HsTyLit noExtField tylit)) + go (L l (HsLit _ lit)) + | Just tylit <- tyLitFromLit lit + = return (L l (HsTyLit noExtField tylit)) go (L l (ExplicitTuple _ tup_args boxity)) -- Neither unboxed tuples (#e1,e2#) nor tuple sections (e1,,e2,) can be promoted | isBoxed boxity ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -37,8 +37,6 @@ import GHC.Hs import GHC.Hs.Syn.Type import GHC.Tc.Gen.HsType -import GHC.Rename.Unbound ( unknownNameSuggestions, WhatLooking(..) ) - import GHC.Tc.Gen.Bind( chooseInferredQuantifiers ) import GHC.Tc.Gen.Sig( tcUserTypeSig, tcInstSig ) import GHC.Tc.TyCl.PatSyn( patSynBuilderOcc ) @@ -78,15 +76,14 @@ import GHC.Builtin.Types( multiplicityTy ) import GHC.Builtin.Names import GHC.Builtin.Names.TH( liftStringName, liftName ) -import GHC.Driver.Env import GHC.Driver.DynFlags import GHC.Utils.Misc import GHC.Utils.Outputable as Outputable import GHC.Utils.Panic -import qualified GHC.LanguageExtensions as LangExt import GHC.Data.Maybe import Control.Monad +import GHC.Rename.Unbound (WhatLooking(WL_Anything)) @@ -1164,46 +1161,11 @@ tc_infer_id id_name AGlobal (AConLike (RealDataCon con)) -> tcInferDataCon con AGlobal (AConLike (PatSynCon ps)) -> tcInferPatSyn id_name ps - (tcTyThingTyCon_maybe -> Just tc) -> fail_tycon tc -- TyCon or TcTyCon - ATyVar name _ -> fail_tyvar name + (tcTyThingTyCon_maybe -> Just tc) -> failIllegalTyCon WL_Anything tc -- TyCon or TcTyCon + ATyVar name _ -> failIllegalTyVal name _ -> failWithTc $ TcRnExpectedValueId thing } where - fail_tycon tc = do - gre <- getGlobalRdrEnv - let nm = tyConName tc - pprov = case lookupGRE_Name gre nm of - Just gre -> nest 2 (pprNameProvenance gre) - Nothing -> empty - err | isClassTyCon tc = ClassTE - | otherwise = TyConTE - fail_with_msg dataName nm pprov err - - fail_tyvar nm = - let pprov = nest 2 (text "bound at" <+> ppr (getSrcLoc nm)) - in fail_with_msg varName nm pprov TyVarTE - - fail_with_msg whatName nm pprov err = do - (import_errs, hints) <- get_suggestions whatName - unit_state <- hsc_units <$> getTopEnv - let - -- TODO: unfortunate to have to convert to SDoc here. - -- This should go away once we refactor ErrInfo. - hint_msg = vcat $ map ppr hints - import_err_msg = vcat $ map ppr import_errs - info = ErrInfo { errInfoContext = pprov, errInfoSupplementary = import_err_msg $$ hint_msg } - failWithTc $ TcRnMessageWithInfo unit_state ( - mkDetailedMessage info (TcRnIllegalTermLevelUse nm err)) - - get_suggestions ns = do - required_type_arguments <- xoptM LangExt.RequiredTypeArguments - if required_type_arguments && isVarNameSpace ns - then return ([], []) -- See Note [Suppress hints with RequiredTypeArguments] - else do - let occ = mkOccNameFS ns (occNameFS (occName id_name)) - lcl_env <- getLocalRdrEnv - unknownNameSuggestions lcl_env WL_Anything (mkRdrUnqual occ) - return_id id = return (HsVar noExtField (noLocA id), idType id) {- Note [Suppress hints with RequiredTypeArguments] ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -73,7 +73,10 @@ module GHC.Tc.Gen.HsType ( HoleMode(..), -- Error messages - funAppCtxt, addTyConFlavCtxt + funAppCtxt, addTyConFlavCtxt, + + -- Utils + tyLitFromLit, tyLitFromOverloadedLit, ) where import GHC.Prelude hiding ( head, init, last, tail ) @@ -140,6 +143,7 @@ import qualified Data.List.NonEmpty as NE import Data.List ( mapAccumL ) import Control.Monad import Data.Tuple( swap ) +import GHC.Types.SourceText {- ---------------------------- @@ -4689,3 +4693,22 @@ addTyConFlavCtxt :: Name -> TyConFlavour tc -> TcM a -> TcM a addTyConFlavCtxt name flav = addErrCtxt $ hsep [ text "In the", ppr flav , text "declaration for", quotes (ppr name) ] + +{- +************************************************************************ +* * + Utils for constructing TyLit +* * +************************************************************************ +-} + + +tyLitFromLit :: HsLit GhcRn -> Maybe (HsTyLit GhcRn) +tyLitFromLit (HsString x str) = Just (HsStrTy x str) +tyLitFromLit (HsChar x char) = Just (HsCharTy x char) +tyLitFromLit _ = Nothing + +tyLitFromOverloadedLit :: OverLitVal -> Maybe (HsTyLit GhcRn) +tyLitFromOverloadedLit (HsIntegral n) = Just $ HsNumTy NoSourceText (il_value n) +tyLitFromOverloadedLit (HsIsString _ s) = Just $ HsStrTy NoSourceText s +tyLitFromOverloadedLit HsFractional{} = Nothing ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -78,6 +78,8 @@ import Language.Haskell.Syntax.Basic (FieldLabelString(..)) import Data.List( partition ) import Data.Maybe (isJust) +import Control.Monad.Trans.Writer.CPS +import Control.Monad.Trans.Class {- ************************************************************************ @@ -504,56 +506,109 @@ tc_forall_pat tv _ pat thing_inside ; let pat' = XPat $ ExpansionPat pat (EmbTyPat arg_ty tp) ; return (pat', result) } + -- Convert a Pat into the equivalent HsTyPat. -- See `expr_to_type` (GHC.Tc.Gen.App) for the HsExpr counterpart. -- The `TcM` monad is only used to fail on ill-formed type patterns. pat_to_type_pat :: Pat GhcRn -> TcM (HsTyPat GhcRn) -pat_to_type_pat (EmbTyPat _ tp) = return tp -pat_to_type_pat (VarPat _ lname) = return (HsTP x b) +pat_to_type_pat pat = do + (ty, x) <- runWriterT (pat_to_type pat) + pure (HsTP (buildHsTyPatRn x) ty) + +pat_to_type :: Pat GhcRn -> WriterT HsTyPatRnBuilder TcM (LHsType GhcRn) +pat_to_type (EmbTyPat _ (HsTP x t)) = + do { tell (builderFromHsTyPatRn x) + ; return t } +pat_to_type (VarPat _ lname) = + do { tell (tpBuilderExplicitTV (unLoc lname)) + ; return b } where b = noLocA (HsTyVar noAnn NotPromoted lname) - x = HsTPRn { hstp_nwcs = [] - , hstp_imp_tvs = [] - , hstp_exp_tvs = [unLoc lname] } -pat_to_type_pat (WildPat _) = return (HsTP x b) +pat_to_type (WildPat _) = return b where b = noLocA (HsWildCardTy noExtField) - x = HsTPRn { hstp_nwcs = [] - , hstp_imp_tvs = [] - , hstp_exp_tvs = [] } -pat_to_type_pat (SigPat _ pat sig_ty) - = do { HsTP x_hstp t <- pat_to_type_pat (unLoc pat) +pat_to_type (SigPat _ pat sig_ty) + = do { t <- pat_to_type (unLoc pat) ; let { !(HsPS x_hsps k) = sig_ty - ; x = append_hstp_hsps x_hstp x_hsps ; b = noLocA (HsKindSig noAnn t k) } - ; return (HsTP x b) } - where - -- Quadratic for nested signatures ((p :: t1) :: t2) - -- but those are unlikely to occur in practice. - append_hstp_hsps :: HsTyPatRn -> HsPSRn -> HsTyPatRn - append_hstp_hsps t p - = HsTPRn { hstp_nwcs = hstp_nwcs t ++ hsps_nwcs p - , hstp_imp_tvs = hstp_imp_tvs t ++ hsps_imp_tvs p - , hstp_exp_tvs = hstp_exp_tvs t } -pat_to_type_pat (ParPat _ pat) - = do { HsTP x t <- pat_to_type_pat (unLoc pat) - ; return (HsTP x (noLocA (HsParTy noAnn t))) } -pat_to_type_pat (SplicePat (HsUntypedSpliceTop mod_finalizers pat) splice) = do - { HsTP x t <- pat_to_type_pat pat - ; return (HsTP x (noLocA (HsSpliceTy (HsUntypedSpliceTop mod_finalizers t) splice))) } -pat_to_type_pat pat = - -- There are other cases to handle (ConPat, ListPat, TuplePat, etc), but these - -- would always be rejected by the unification in `tcHsTyPat`, so it's fine to - -- skip them here. This won't continue to be the case when visible forall is - -- permitted in data constructors: - -- - -- data T a where { Typed :: forall a -> a -> T a } - -- g :: T Int -> Int - -- g (Typed Int x) = x -- Note the `Int` type pattern - -- - -- See ticket #18389. When this feature lands, it would be best to extend - -- `pat_to_type_pat` to handle as many pattern forms as possible. + ; tell (tpBuilderPatSig x_hsps) + ; return b } +pat_to_type (ParPat _ pat) + = do { t <- pat_to_type (unLoc pat) + ; return (noLocA (HsParTy noAnn t)) } +pat_to_type (SplicePat (HsUntypedSpliceTop mod_finalizers pat) splice) = do + { t <- pat_to_type pat + ; return (noLocA (HsSpliceTy (HsUntypedSpliceTop mod_finalizers t) splice)) } + +pat_to_type (TuplePat _ pats Boxed) + = do { tys <- traverse (pat_to_type . unLoc) pats + ; let t = noLocA (HsExplicitTupleTy noExtField tys) + ; pure t } +pat_to_type (ListPat _ pats) + = do { tys <- traverse (pat_to_type . unLoc) pats + ; let t = noLocA (HsExplicitListTy NoExtField NotPromoted tys) + ; pure t } + +pat_to_type (LitPat _ lit) + | Just ty_lit <- tyLitFromLit lit + = do { let t = noLocA (HsTyLit noExtField ty_lit) + ; pure t } +pat_to_type (NPat _ (L _ lit) _ _) + | Just ty_lit <- tyLitFromOverloadedLit (ol_val lit) + = do { let t = noLocA (HsTyLit noExtField ty_lit) + ; pure t} + +pat_to_type (ConPat _ lname (InfixCon left right)) + = do { lty <- pat_to_type (unLoc left) + ; rty <- pat_to_type (unLoc right) + ; let { t = noLocA (HsOpTy noAnn NotPromoted lty lname rty)} + ; pure t } +pat_to_type (ConPat _ lname (PrefixCon invis_args vis_args)) + = do { let { appHead = noLocA (HsTyVar noAnn NotPromoted lname)} + ; ty_invis <- foldM apply_invis_arg appHead invis_args + ; tys_vis <- traverse (pat_to_type . unLoc) vis_args + ; let t = foldl' mkHsAppTy ty_invis tys_vis + ; pure t } + where + apply_invis_arg :: LHsType GhcRn -> HsConPatTyArg GhcRn -> WriterT HsTyPatRnBuilder TcM (LHsType GhcRn) + apply_invis_arg !t (HsConPatTyArg _ (HsTP argx arg)) + = do { tell (builderFromHsTyPatRn argx) + ; pure (mkHsAppKindTy noExtField t arg)} + +pat_to_type pat = lift $ failWith $ TcRnIllformedTypePattern pat -- This failure is the only use of the TcM monad in `pat_to_type_pat` +{- +Note [Pattern to type (P2T) conversion] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider this: + + data T a b where + MkT :: forall a. forall b -> a -> b -> T a b + -- NB: `a` is invisible, but `b` is required + + f (MkT @[Int] (Maybe Bool) x y) = ... + +The second type argument of `MkT` is Required, so we write it without +an `@` sign in the pattern match. So the (Maybe Bool) will be + * parsed and renamed as a term pattern + * converted to a type when typechecking the pattern-match: the P2T conversion + +This is the only place we have P2T. In type-lambdas, the "pattern" is always a +type variable: + + f :: forall a -> a -> blah + f b (x::b) = ... + +The `b` argument must be a simple variable; we can't pattern-match on types. + +The function `pat_to_type` does the P2T conversion: + pat_to_type :: Pat GhcRn -> WriterT HsTyPatRnBuilder TcM (LHsType GhcRn) + +It is arranged as a writer monad, where the `HsTyPatRnBuilder` accumulates the +binders bound by the type. (We could discover these binders by a subsequent +traversal, that would mean writing another traversal.) +-} + tc_ty_pat :: HsTyPat GhcRn -> TcTyVar -> TcM r -> TcM (TcType, r) tc_ty_pat tp tv thing_inside = do { (sig_wcs, sig_ibs, arg_ty) <- tcHsTyPat tp (varType tv) ===================================== compiler/GHC/Tc/Utils/Env.hs ===================================== @@ -28,6 +28,7 @@ module GHC.Tc.Utils.Env( tcLookupLocatedClass, tcLookupAxiom, lookupGlobal, lookupGlobal_maybe, addTypecheckedBinds, + failIllegalTyCon, failIllegalTyVal, -- Local environment tcExtendKindEnv, tcExtendKindEnvList, @@ -137,6 +138,7 @@ import Data.List ( intercalate ) import Control.Monad import GHC.Iface.Errors.Types import GHC.Types.Error +import GHC.Rename.Unbound ( unknownNameSuggestions, WhatLooking(..) ) {- ********************************************************************* * * @@ -278,6 +280,7 @@ tcLookupConLike name = do thing <- tcLookupGlobal name case thing of AConLike cl -> return cl + ATyCon tc -> failIllegalTyCon WL_Constructor tc _ -> wrongThingErr WrongThingConLike (AGlobal thing) name tcLookupRecSelParent :: HsRecUpdParent GhcRn -> TcM RecSelParent @@ -349,6 +352,45 @@ tcGetInstEnvs = do { eps <- getEps instance MonadThings (IOEnv (Env TcGblEnv TcLclEnv)) where lookupThing = tcLookupGlobal +-- Illegal term-level use of type things +failIllegalTyCon :: WhatLooking -> TyCon -> TcM a +failIllegalTyVal :: Name -> TcM a +(failIllegalTyCon, failIllegalTyVal) = (fail_tycon, fail_tyvar) + where + fail_tycon what_looking tc = do + gre <- getGlobalRdrEnv + let nm = tyConName tc + pprov = case lookupGRE_Name gre nm of + Just gre -> nest 2 (pprNameProvenance gre) + Nothing -> empty + err | isClassTyCon tc = ClassTE + | otherwise = TyConTE + fail_with_msg what_looking dataName nm pprov err + + fail_tyvar nm = + let pprov = nest 2 (text "bound at" <+> ppr (getSrcLoc nm)) + in fail_with_msg WL_Anything varName nm pprov TyVarTE + + fail_with_msg what_looking whatName nm pprov err = do + (import_errs, hints) <- get_suggestions what_looking whatName nm + unit_state <- hsc_units <$> getTopEnv + let + -- TODO: unfortunate to have to convert to SDoc here. + -- This should go away once we refactor ErrInfo. + hint_msg = vcat $ map ppr hints + import_err_msg = vcat $ map ppr import_errs + info = ErrInfo { errInfoContext = pprov, errInfoSupplementary = import_err_msg $$ hint_msg } + failWithTc $ TcRnMessageWithInfo unit_state ( + mkDetailedMessage info (TcRnIllegalTermLevelUse nm err)) + + get_suggestions what_looking ns nm = do + required_type_arguments <- xoptM LangExt.RequiredTypeArguments + if required_type_arguments && isVarNameSpace ns + then return ([], []) -- See Note [Suppress hints with RequiredTypeArguments] + else do + let occ = mkOccNameFS ns (occNameFS (occName nm)) + lcl_env <- getLocalRdrEnv + unknownNameSuggestions lcl_env what_looking (mkRdrUnqual occ) {- ************************************************************************ * * ===================================== testsuite/tests/rename/should_fail/T19843c.stderr ===================================== @@ -1,4 +1,7 @@ +T19843c.hs:6:6: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Map’ + • imported from ‘Data.Map’ at T19843c.hs:3:1-22 + (and originally defined in ‘Data.Map.Internal’) + • In the pattern: Map k v + In an equation for ‘foo’: foo (Map k v) = undefined -T19843c.hs:6:6: error: [GHC-76037] - Not in scope: data constructor ‘Map.Map’ - NB: the module ‘Data.Map’ does not export ‘Map’. ===================================== testsuite/tests/type-data/should_fail/TDPattern.stderr ===================================== @@ -1,3 +1,6 @@ +TDPattern.hs:7:3: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Zero’ + • defined at TDPattern.hs:4:17 + • In the pattern: Zero + In an equation for ‘f’: f Zero = 0 -TDPattern.hs:7:3: [GHC-76037] - Not in scope: data constructor ‘Zero’ ===================================== testsuite/tests/typecheck/should_compile/T23739a.hs ===================================== @@ -0,0 +1,65 @@ +{-# LANGUAGE TypeAbstractions, + ExplicitNamespaces, + RequiredTypeArguments, + DataKinds, + NoListTuplePuns, + OverloadedStrings #-} + +module T23739a where + +import Data.Tuple.Experimental +import GHC.TypeLits + +{- +This code aims to test pattern-to-type transformation +(See Note [Pattern to type (P2T) conversion] in GHC.Tc.Gen.Pat) + +However it relies on a questionable feature, that allows us to have +equality constraint in scope of type pattern checking. The test +doesn't establish such behavior, it just abuses it to examine P2T +transformation. + +In the happy future with `forall->` in GADTs we should +rewrite this test using it. +-} + +f1 :: forall a -> a ~ (Int, Bool) => Unit +f1 (b,c) = () + +f2 :: forall a -> a ~ (Int : Bool : Double : []) => Unit +f2 [a,b,c] = () + +f3 :: forall a -> a ~ [Int, Bool, Double] => Unit +f3 [a,b,c] = () + +f4 :: forall a -> a ~ [Int, Bool, Double] => Unit +f4 (a : b : c : []) = () + +f5 :: forall a -> a ~ "blah" => Unit +f5 "blah" = () + +f6 :: forall a -> a ~ 'c' => Unit +f6 'c' = () + +f7 :: forall a -> a ~ UnconsSymbol "blah" => Unit +f7 (Just ('b', "lah")) = () + +f8 :: forall a -> Unit +f8 _ = () + +f9 :: forall a -> a ~ 42 => Unit +f9 42 = () + +f10 :: forall a -> a ~ () => Unit +f10 () = () + +f11 :: forall a -> a ~ Int => Unit +f11 Int = () + +f12 :: forall a -> a ~ (Left @Bool @(Maybe b) True) => Unit +f12 (Left @Bool @(Maybe a) True) = () + +data Tup a = MkTup a a + +f13 :: forall a -> a ~ (Int, MkTup 'f' 'g', 42, True, [1,2,3,4,5], (), "blah", "wombat", 'd', UnconsSymbol "corner") => Unit +f13 (Int, 'f' `MkTup` 'g', 42, True, 1 : 2 : 3 : [4,5], () ,"blah", x, 'd', Just ('c', "orner")) = () ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -915,3 +915,4 @@ test('WarnDefaultedExceptionContext', normal, compile, ['-Wdefaulted-exception-c test('T24470b', normal, compile, ['']) test('T24566', [], makefile_test, []) test('T23764', normal, compile, ['']) +test('T23739a', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T23739b.hs ===================================== @@ -0,0 +1,14 @@ + +module T23739b where + +import Data.Tuple.Experimental +import GHC.TypeLits + +g1 :: Int -> Unit +g1 Int = () + +g2 :: Int +g2 = Int{} + +g3 :: Int +g3 = Int ===================================== testsuite/tests/typecheck/should_fail/T23739b.stderr ===================================== @@ -0,0 +1,21 @@ +T23739b.hs:8:4: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Int’ + • imported from ‘Prelude’ at T23739b.hs:2:8-14 + (and originally defined in ‘GHC.Types’) + • In the pattern: Int + In an equation for ‘g1’: g1 Int = () + +T23739b.hs:11:6: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Int’ + • imported from ‘Prelude’ at T23739b.hs:2:8-14 + (and originally defined in ‘GHC.Types’) + • In the expression: Int {} + In an equation for ‘g2’: g2 = Int {} + +T23739b.hs:14:6: error: [GHC-01928] + • Illegal term-level use of the type constructor ‘Int’ + • imported from ‘Prelude’ at T23739b.hs:2:8-14 + (and originally defined in ‘GHC.Types’) + • In the expression: Int + In an equation for ‘g3’: g3 = Int + ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -725,4 +725,4 @@ test('T17594g', normal, compile_fail, ['']) test('T24470a', normal, compile_fail, ['']) test('T24553', normal, compile_fail, ['']) - +test('T23739b', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cd1f46638626f18ce39cd157640ad2e37dbb9102 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cd1f46638626f18ce39cd157640ad2e37dbb9102 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 12:53:52 2024 From: gitlab at gitlab.haskell.org (Serge S. Gulin (@gulin.serge)) Date: Wed, 08 May 2024 08:53:52 -0400 Subject: [Git][ghc/ghc][wip/T24504] IPE: WIP: Replace closure_desc string representation in logs output on Word32 Message-ID: <663b75e060b07_6129d178f40079735@gitlab.mail> Serge S. Gulin pushed to branch wip/T24504 at Glasgow Haskell Compiler / GHC Commits: cc014222 by Serge S. Gulin at 2024-05-08T15:52:42+03:00 IPE: WIP: Replace closure_desc string representation in logs output on Word32 - - - - - 9 changed files: - rts/IPE.c - rts/Trace.c - rts/eventlog/EventLog.c - rts/include/rts/Constants.h - rts/include/rts/IPE.h - testsuite/tests/rts/ipe/ipeEventLog.stderr - testsuite/tests/rts/ipe/ipeEventLog_fromMap.stderr - testsuite/tests/rts/ipe/ipeMap.c - testsuite/tests/rts/ipe/ipe_lib.c Changes: ===================================== rts/IPE.c ===================================== @@ -176,6 +176,10 @@ void registerInfoProvList(IpeBufferListNode *node) { } } +void formatClosureDescIpe(const InfoProvEnt *ipe_buf, char *str_buf) { + snprintf(str_buf, sizeof(str_buf), "%u", ipe_buf->prov.closure_desc); +} + bool lookupIPE(const StgInfoTable *info, InfoProvEnt *out) { updateIpeMap(); IpeMapEntry *map_ent = (IpeMapEntry *) lookupHashTable(ipeMap, (StgWord)info); ===================================== rts/Trace.c ===================================== @@ -688,9 +688,12 @@ void traceIPE(const InfoProvEnt *ipe) if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) { ACQUIRE_LOCK(&trace_utx); + char closure_desc_buf[CLOSURE_DESC_BUFFER_SIZE] = {}; + formatClosureDescIpe(ipe, closure_desc_buf); + tracePreface(); - debugBelch("IPE: table_name %s, closure_desc %d, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", - ipe->prov.table_name, ipe->prov.closure_desc, ipe->prov.ty_desc, + debugBelch("IPE: table_name %s, closure_desc %s, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", + ipe->prov.table_name, closure_desc_buf, ipe->prov.ty_desc, ipe->prov.label, ipe->prov.unit_id, ipe->prov.module, ipe->prov.src_file, ipe->prov.src_span); ===================================== rts/eventlog/EventLog.c ===================================== @@ -1441,11 +1441,14 @@ void postTickyCounterSamples(StgEntCounter *counters) #endif /* TICKY_TICKY */ void postIPE(const InfoProvEnt *ipe) { + char closure_desc_buf[CLOSURE_DESC_BUFFER_SIZE] = {}; + formatClosureDescIpe(ipe, closure_desc_buf); + // See Note [Maximum event length]. const StgWord MAX_IPE_STRING_LEN = 65535; ACQUIRE_LOCK(&eventBufMutex); StgWord table_name_len = MIN(strlen(ipe->prov.table_name), MAX_IPE_STRING_LEN); - StgWord closure_desc_len = MIN(strlen(ipe->prov.closure_desc), MAX_IPE_STRING_LEN); + StgWord closure_desc_len = MIN(strlen(closure_desc_buf), MAX_IPE_STRING_LEN); StgWord ty_desc_len = MIN(strlen(ipe->prov.ty_desc), MAX_IPE_STRING_LEN); StgWord label_len = MIN(strlen(ipe->prov.label), MAX_IPE_STRING_LEN); StgWord module_len = MIN(strlen(ipe->prov.module), MAX_IPE_STRING_LEN); @@ -1462,7 +1465,7 @@ void postIPE(const InfoProvEnt *ipe) postPayloadSize(&eventBuf, len); postWord64(&eventBuf, (StgWord) INFO_PTR_TO_STRUCT(ipe->info)); postStringLen(&eventBuf, ipe->prov.table_name, table_name_len); - postStringLen(&eventBuf, ipe->prov.closure_desc, closure_desc_len); + postStringLen(&eventBuf, closure_desc_buf, closure_desc_len); postStringLen(&eventBuf, ipe->prov.ty_desc, ty_desc_len); postStringLen(&eventBuf, ipe->prov.label, label_len); postStringLen(&eventBuf, ipe->prov.module, module_len); ===================================== rts/include/rts/Constants.h ===================================== @@ -347,3 +347,10 @@ * we can have static arrays of this size in the RTS for speed. */ #define MAX_NUMA_NODES 16 + +/* + * closure_desc of InfoProv is now uint32_t at all platforms, but + * we have to keep its stringified representation. + * It is known that maximum lenght of uint32_t in string is 10 chars (4294967295) + 1 NULL. + */ +#define CLOSURE_DESC_BUFFER_SIZE 11 ===================================== rts/include/rts/IPE.h ===================================== @@ -89,5 +89,11 @@ typedef struct IpeBufferListNode_ { void registerInfoProvList(IpeBufferListNode *node); +// We leave it in old format to keep compatibility with existing https://github.com/haskell/ghc-events +// See: https://github.com/haskell/ghc-events/commit/cce6a35677f5f99b44c21d86febd295b909ef1ce +// The format depends on tooling. At the moment of commit all tooling expects a stringified unsigned int. +// I.e. 10 -> "10". No padding zeroes. No prefixes. +void formatClosureDescIpe(const InfoProvEnt *ipe_buf, char *str_buf); + // Returns true on success, initializes `out`. bool lookupIPE(const StgInfoTable *info, InfoProvEnt *out); ===================================== testsuite/tests/rts/ipe/ipeEventLog.stderr ===================================== @@ -1,20 +1,20 @@ -7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 -7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 -7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 -7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 -7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 -7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 -7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 -7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 -7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 -7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 -7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 -7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 -7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 -7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 -7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 -7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 -7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 -7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 -7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 -7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc 0, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc 1, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc 2, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc 3, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc 4, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc 5, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc 6, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc 7, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc 8, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc 9, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc 0, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc 1, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc 2, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc 3, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc 4, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc 5, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc 6, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc 7, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc 8, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc 9, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 ===================================== testsuite/tests/rts/ipe/ipeEventLog_fromMap.stderr ===================================== @@ -1,20 +1,20 @@ -7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 -7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 -7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 -7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 -7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 -7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 -7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 -7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 -7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 -7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 -7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 -7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 -7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 -7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 -7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 -7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 -7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 -7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 -7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 -7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc 9, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc 8, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc 7, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc 6, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc 5, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc 4, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc 3, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc 2, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc 1, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc 0, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc 9, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc 8, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc 7, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc 6, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc 5, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc 4, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc 3, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc 2, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc 1, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc 0, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 ===================================== testsuite/tests/rts/ipe/ipeMap.c ===================================== @@ -68,10 +68,13 @@ HaskellObj shouldFindOneIfItHasBeenRegistered(Capability *cap) { registerInfoProvList(node); - InfoProvEnt result = lookupIPE_("shouldFindOneIfItHasBeenRegistered", get_itbl(fortyTwo)); + const InfoProvEnt result = lookupIPE_("shouldFindOneIfItHasBeenRegistered", get_itbl(fortyTwo)); + + char closure_desc_buf[CLOSURE_DESC_BUFFER_SIZE] = {}; + formatClosureDescIpe(&result, closure_desc_buf); assertStringsEqual(result.prov.table_name, "table_name_042"); - assertStringsEqual(result.prov.closure_desc, "closure_desc_042"); + assertStringsEqual(closure_desc_buf, "42"); assertStringsEqual(result.prov.ty_desc, "ty_desc_042"); assertStringsEqual(result.prov.label, "label_042"); assertStringsEqual(result.prov.unit_id, "unit-id"); ===================================== testsuite/tests/rts/ipe/ipe_lib.c ===================================== @@ -33,10 +33,7 @@ IpeBufferEntry makeAnyProvEntry(Capability *cap, StringTable *st, int i) { snprintf(tableName, tableNameLength, "table_name_%03i", i); provEnt.table_name = add_string(st, tableName); - unsigned int closureDescLength = strlen("closure_desc_") + 3 /* digits */ + 1 /* null character */; - char *closureDesc = malloc(sizeof(char) * closureDescLength); - snprintf(closureDesc, closureDescLength, "closure_desc_%03i", i); - provEnt.closure_desc = add_string(st, closureDesc); + provEnt.closure_desc = i; unsigned int tyDescLength = strlen("ty_desc_") + 3 /* digits */ + 1 /* null character */; char *tyDesc = malloc(sizeof(char) * tyDescLength); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cc01422218031803a08b4f384f8e600a7d270fa4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cc01422218031803a08b4f384f8e600a7d270fa4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 12:56:36 2024 From: gitlab at gitlab.haskell.org (Serge S. Gulin (@gulin.serge)) Date: Wed, 08 May 2024 08:56:36 -0400 Subject: [Git][ghc/ghc][wip/T24504] IPE: WIP: Replace closure_desc string representation in logs output on Word32 Message-ID: <663b76849b7dc_6129d18afa88809d@gitlab.mail> Serge S. Gulin pushed to branch wip/T24504 at Glasgow Haskell Compiler / GHC Commits: 35c18d88 by Serge S. Gulin at 2024-05-08T15:56:24+03:00 IPE: WIP: Replace closure_desc string representation in logs output on Word32 - - - - - 9 changed files: - rts/IPE.c - rts/Trace.c - rts/eventlog/EventLog.c - rts/include/rts/Constants.h - rts/include/rts/IPE.h - testsuite/tests/rts/ipe/ipeEventLog.stderr - testsuite/tests/rts/ipe/ipeEventLog_fromMap.stderr - testsuite/tests/rts/ipe/ipeMap.c - testsuite/tests/rts/ipe/ipe_lib.c Changes: ===================================== rts/IPE.c ===================================== @@ -176,6 +176,10 @@ void registerInfoProvList(IpeBufferListNode *node) { } } +void formatClosureDescIpe(const InfoProvEnt *ipe_buf, char *str_buf) { + snprintf(str_buf, CLOSURE_DESC_BUFFER_SIZE, "%u", ipe_buf->prov.closure_desc); +} + bool lookupIPE(const StgInfoTable *info, InfoProvEnt *out) { updateIpeMap(); IpeMapEntry *map_ent = (IpeMapEntry *) lookupHashTable(ipeMap, (StgWord)info); ===================================== rts/Trace.c ===================================== @@ -688,9 +688,12 @@ void traceIPE(const InfoProvEnt *ipe) if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) { ACQUIRE_LOCK(&trace_utx); + char closure_desc_buf[CLOSURE_DESC_BUFFER_SIZE] = {}; + formatClosureDescIpe(ipe, closure_desc_buf); + tracePreface(); - debugBelch("IPE: table_name %s, closure_desc %d, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", - ipe->prov.table_name, ipe->prov.closure_desc, ipe->prov.ty_desc, + debugBelch("IPE: table_name %s, closure_desc %s, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", + ipe->prov.table_name, closure_desc_buf, ipe->prov.ty_desc, ipe->prov.label, ipe->prov.unit_id, ipe->prov.module, ipe->prov.src_file, ipe->prov.src_span); ===================================== rts/eventlog/EventLog.c ===================================== @@ -1441,11 +1441,14 @@ void postTickyCounterSamples(StgEntCounter *counters) #endif /* TICKY_TICKY */ void postIPE(const InfoProvEnt *ipe) { + char closure_desc_buf[CLOSURE_DESC_BUFFER_SIZE] = {}; + formatClosureDescIpe(ipe, closure_desc_buf); + // See Note [Maximum event length]. const StgWord MAX_IPE_STRING_LEN = 65535; ACQUIRE_LOCK(&eventBufMutex); StgWord table_name_len = MIN(strlen(ipe->prov.table_name), MAX_IPE_STRING_LEN); - StgWord closure_desc_len = MIN(strlen(ipe->prov.closure_desc), MAX_IPE_STRING_LEN); + StgWord closure_desc_len = MIN(strlen(closure_desc_buf), MAX_IPE_STRING_LEN); StgWord ty_desc_len = MIN(strlen(ipe->prov.ty_desc), MAX_IPE_STRING_LEN); StgWord label_len = MIN(strlen(ipe->prov.label), MAX_IPE_STRING_LEN); StgWord module_len = MIN(strlen(ipe->prov.module), MAX_IPE_STRING_LEN); @@ -1462,7 +1465,7 @@ void postIPE(const InfoProvEnt *ipe) postPayloadSize(&eventBuf, len); postWord64(&eventBuf, (StgWord) INFO_PTR_TO_STRUCT(ipe->info)); postStringLen(&eventBuf, ipe->prov.table_name, table_name_len); - postStringLen(&eventBuf, ipe->prov.closure_desc, closure_desc_len); + postStringLen(&eventBuf, closure_desc_buf, closure_desc_len); postStringLen(&eventBuf, ipe->prov.ty_desc, ty_desc_len); postStringLen(&eventBuf, ipe->prov.label, label_len); postStringLen(&eventBuf, ipe->prov.module, module_len); ===================================== rts/include/rts/Constants.h ===================================== @@ -347,3 +347,10 @@ * we can have static arrays of this size in the RTS for speed. */ #define MAX_NUMA_NODES 16 + +/* + * closure_desc of InfoProv is now uint32_t at all platforms, but + * we have to keep its stringified representation. + * It is known that maximum lenght of uint32_t in string is 10 chars (4294967295) + 1 NULL. + */ +#define CLOSURE_DESC_BUFFER_SIZE 11 ===================================== rts/include/rts/IPE.h ===================================== @@ -89,5 +89,11 @@ typedef struct IpeBufferListNode_ { void registerInfoProvList(IpeBufferListNode *node); +// We leave it in old format to keep compatibility with existing https://github.com/haskell/ghc-events +// See: https://github.com/haskell/ghc-events/commit/cce6a35677f5f99b44c21d86febd295b909ef1ce +// The format depends on tooling. At the moment of commit all tooling expects a stringified unsigned int. +// I.e. 10 -> "10". No padding zeroes. No prefixes. +void formatClosureDescIpe(const InfoProvEnt *ipe_buf, char *str_buf); + // Returns true on success, initializes `out`. bool lookupIPE(const StgInfoTable *info, InfoProvEnt *out); ===================================== testsuite/tests/rts/ipe/ipeEventLog.stderr ===================================== @@ -1,20 +1,20 @@ -7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 -7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 -7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 -7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 -7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 -7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 -7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 -7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 -7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 -7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 -7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 -7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 -7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 -7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 -7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 -7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 -7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 -7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 -7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 -7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc 0, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc 1, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc 2, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc 3, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc 4, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc 5, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc 6, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc 7, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc 8, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc 9, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc 0, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc 1, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc 2, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc 3, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc 4, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc 5, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc 6, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc 7, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc 8, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc 9, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 ===================================== testsuite/tests/rts/ipe/ipeEventLog_fromMap.stderr ===================================== @@ -1,20 +1,20 @@ -7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 -7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 -7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 -7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 -7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 -7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 -7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 -7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 -7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 -7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 -7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 -7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 -7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 -7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 -7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 -7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 -7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 -7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 -7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 -7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc 9, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc 8, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc 7, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc 6, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc 5, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc 4, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc 3, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc 2, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc 1, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc 0, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc 9, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc 8, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc 7, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc 6, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc 5, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc 4, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc 3, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc 2, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc 1, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc 0, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 ===================================== testsuite/tests/rts/ipe/ipeMap.c ===================================== @@ -68,10 +68,13 @@ HaskellObj shouldFindOneIfItHasBeenRegistered(Capability *cap) { registerInfoProvList(node); - InfoProvEnt result = lookupIPE_("shouldFindOneIfItHasBeenRegistered", get_itbl(fortyTwo)); + const InfoProvEnt result = lookupIPE_("shouldFindOneIfItHasBeenRegistered", get_itbl(fortyTwo)); + + char closure_desc_buf[CLOSURE_DESC_BUFFER_SIZE] = {}; + formatClosureDescIpe(&result, closure_desc_buf); assertStringsEqual(result.prov.table_name, "table_name_042"); - assertStringsEqual(result.prov.closure_desc, "closure_desc_042"); + assertStringsEqual(closure_desc_buf, "42"); assertStringsEqual(result.prov.ty_desc, "ty_desc_042"); assertStringsEqual(result.prov.label, "label_042"); assertStringsEqual(result.prov.unit_id, "unit-id"); ===================================== testsuite/tests/rts/ipe/ipe_lib.c ===================================== @@ -33,10 +33,7 @@ IpeBufferEntry makeAnyProvEntry(Capability *cap, StringTable *st, int i) { snprintf(tableName, tableNameLength, "table_name_%03i", i); provEnt.table_name = add_string(st, tableName); - unsigned int closureDescLength = strlen("closure_desc_") + 3 /* digits */ + 1 /* null character */; - char *closureDesc = malloc(sizeof(char) * closureDescLength); - snprintf(closureDesc, closureDescLength, "closure_desc_%03i", i); - provEnt.closure_desc = add_string(st, closureDesc); + provEnt.closure_desc = i; unsigned int tyDescLength = strlen("ty_desc_") + 3 /* digits */ + 1 /* null character */; char *tyDesc = malloc(sizeof(char) * tyDescLength); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/35c18d88eb1f609b0194ababa826fa0073b9130f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/35c18d88eb1f609b0194ababa826fa0073b9130f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 13:30:34 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Wed, 08 May 2024 09:30:34 -0400 Subject: [Git][ghc/ghc][wip/fendor/os-string-modlocation] 194 commits: rts: Fix TSAN_ENABLED CPP guard Message-ID: <663b7e7ac7721_6129d1d9a994100337@gitlab.mail> Hannes Siebenhandl pushed to branch wip/fendor/os-string-modlocation at Glasgow Haskell Compiler / GHC Commits: c8a4c050 by Ben Gamari at 2024-04-02T12:50:35-04:00 rts: Fix TSAN_ENABLED CPP guard This should be `#if defined(TSAN_ENABLED)`, not `#if TSAN_ENABLED`, lest we suffer warnings. - - - - - e91dad93 by Cheng Shao at 2024-04-02T12:50:35-04:00 rts: fix errors when compiling with TSAN This commit fixes rts compilation errors when compiling with TSAN: - xxx_FENCE macros are redefined and trigger CPP warnings. - Use SIZEOF_W. WORD_SIZE_IN_BITS is provided by MachDeps.h which Cmm.h doesn't include by default. - - - - - a9ab9455 by Cheng Shao at 2024-04-02T12:50:35-04:00 rts: fix clang-specific errors when compiling with TSAN This commit fixes clang-specific rts compilation errors when compiling with TSAN: - clang doesn't have -Wtsan flag - Fix prototype of ghc_tsan_* helper functions - __tsan_atomic_* functions aren't clang built-ins and sanitizer/tsan_interface_atomic.h needs to be included - On macOS, TSAN runtime library is libclang_rt.tsan_osx_dynamic.dylib, not libtsan. -fsanitize-thread as a link-time flag will take care of linking the TSAN runtime library anyway so remove tsan as an rts extra library - - - - - 865bd717 by Cheng Shao at 2024-04-02T12:50:35-04:00 compiler: fix github link to __tsan_memory_order in a comment - - - - - 07cb627c by Cheng Shao at 2024-04-02T12:50:35-04:00 ci: improve TSAN CI jobs - Run TSAN jobs with +thread_sanitizer_cmm which enables Cmm instrumentation as well. - Run TSAN jobs in deb12 which ships gcc-12, a reasonably recent gcc that @bgamari confirms he's using in #GHC:matrix.org. Ideally we should be using latest clang release for latest improvements in sanitizers, though that's left as future work. - Mark TSAN jobs as manual+allow_failure in validate pipelines. The purpose is to demonstrate that we have indeed at least fixed building of TSAN mode in CI without blocking the patch to land, and once merged other people can begin playing with TSAN using their own dev setups and feature branches. - - - - - a1c18c7b by Andrei Borzenkov at 2024-04-02T12:51:11-04:00 Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy (#24299, #23639) This patch implements refactoring which is a prerequisite to updating kind checking of type patterns. This is a huge simplification of the main worker that checks kind of HsType. It also fixes the issues caused by previous code duplication, e.g. that we didn't add module finalizers from splices in inference mode. - - - - - 817e8936 by Rodrigo Mesquita at 2024-04-02T20:13:05-04:00 th: Hide the Language.Haskell.TH.Lib.Internal module from haddock Fixes #24562 - - - - - b36ee57b by Sylvain Henry at 2024-04-02T20:13:46-04:00 JS: reenable h$appendToHsString optimization (#24495) The optimization introducing h$appendToHsString wasn't kicking in anymore (while it did in 9.8.1) because of the changes introduced in #23270 (7e0c8b3bab30). This patch reenables the optimization by matching on case-expression, as done in Cmm for unpackCString# standard thunks. The test is also T24495 added in the next commits (two commits for ease of backporting to 9.8). - - - - - 527616e9 by Sylvain Henry at 2024-04-02T20:13:46-04:00 JS: fix h$appendToHsString implementation (#24495) h$appendToHsString needs to wrap its argument in an updatable thunk to behave like unpackAppendCString#. Otherwise if a SingleEntry thunk is passed, it is stored as-is in a CONS cell, making the resulting list impossible to deepseq (forcing the thunk doesn't update the contents of the CONS cell)! The added test checks that the optimization kicks in and that h$appendToHsString works as intended. Fix #24495 - - - - - faa30b41 by Simon Peyton Jones at 2024-04-02T20:14:22-04:00 Deal with duplicate tyvars in type declarations GHC was outright crashing before this fix: #24604 - - - - - e0b0c717 by Simon Peyton Jones at 2024-04-02T20:14:58-04:00 Try using MCoercion in exprIsConApp_maybe This is just a simple refactor that makes exprIsConApp_maybe a little bit more direct, simple, and efficient. Metrics: compile_time/bytes allocated geo. mean -0.1% minimum -2.0% maximum -0.0% Not a big gain, but worthwhile given that the code is, if anything, easier to grok. - - - - - 15f4d867 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Initial ./configure support for selecting I/O managers In this patch we just define new CPP vars, but don't yet use them or replace the existing approach. That will follow. The intention here is that every I/O manager can be enabled/disabled at GHC build time (subject to some constraints). More than one I/O manager can be enabled to be built. At least one I/O manager supporting the non-threaded RTS must be enabled as well as at least one supporting the non-threaded RTS. The I/O managers enabled here will become the choices available at runtime at RTS startup (in later patches). The choice can be made with RTS flags. There are separate sets of choices for the threaded and non-threaded RTS ways, because most I/O managers are specific to these ways. Furthermore we must establish a default I/O manager for the threaded and non-threaded RTS. Most I/O managers are platform-specific so there are checks to ensure each one can be enabled on the platform. Such checks are also where (in future) any system dependencies (e.g. libraries) can be checked. The output is a set of CPP flags (in the mk/config.h file), with one flag per named I/O manager: * IOMGR_BUILD_<name> : which ones should be built (some) * IOMGR_DEFAULT_NON_THREADED_<name> : which one is default (exactly one) * IOMGR_DEFAULT_THREADED_<name> : which one is default (exactly one) and a set of derived flags in IOManager.h * IOMGR_ENABLED_<name> : enabled for the current RTS way Note that IOMGR_BUILD_<name> just says that an I/O manager will be built for _some_ RTS way (i.e. threaded or non-threaded). The derived flags IOMGR_ENABLED_<name> in IOManager.h say if each I/O manager is enabled in the "current" RTS way. These are the ones that can be used for conditional compilation of the I/O manager code. Co-authored-by: Pi Delport <pi at well-typed.com> - - - - - 85b0f87a by Duncan Coutts at 2024-04-03T01:27:17-04:00 Change the handling of the RTS flag --io-manager= Now instead of it being just used on Windows to select between the WinIO vs the MIO or Win32-legacy I/O managers, it is now used on all platforms for selecting the I/O manager to use. Right now it remains the case that there is only an actual choice on Windows, but that will change later. Document the --io-manager flag in the user guide. This change is also reflected in the RTS flags types in the base library. Deprecate the export of IoSubSystem from GHC.RTS.Flags with a message to import it from GHC.IO.Subsystem. The way the 'IoSubSystem' is detected also changes. Instead of looking at the RTS flag, there is now a C bool global var in the RTS which gets set on startup when the I/O manager is selected. This bool var says whether the selected I/O manager classifies as "native" on Windows, which in practice means the WinIO I/O manager has been selected. Similarly, the is_io_mng_native_p RTS helper function is re-implemented in terms of the selected I/O manager, rather than based on the RTS flags. We do however remove the ./configure --native-io-manager flag because we're bringing the WinIO/MIO/Win32-legacy choice under the new general scheme for selecting I/O managers, and that new scheme involves no ./configure time user choices, just runtime RTS flag choices. - - - - - 1a8f020f by Duncan Coutts at 2024-04-03T01:27:17-04:00 Convert {init,stop,exit}IOManager to switch style Rather than ad-hoc cpp conitionals on THREADED_RTS and mingw32_HOST_OS, we use a style where we switch on the I/O manager impl, with cases for each I/O manager impl. - - - - - a5bad3d2 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Split up the CapIOManager content by I/O manager Using the new IOMGR_ENABLED_<name> CPP defines. - - - - - 1d36e609 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Convert initIOManagerAfterFork and wakeupIOManager to switch style - - - - - c2f26f36 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move most of waitRead#/Write# from cmm to C Moves it into the IOManager.c where we can follow the new pattern of switching on the selected I/O manager. - - - - - 457705a8 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move most of the delay# impl from cmm to C Moves it into the IOManager.c where we can follow the new pattern of switching on the selected I/O manager. Uses a new IOManager API: syncDelay, following the naming convention of sync* for thread-synchronous I/O & timer/delay operations. As part of porting from cmm to C, we maintain the rule that the why_blocked gets accessed using load acquire and store release atomic memory operations. There was one exception to this rule: in the delay# primop cmm code on posix (not win32), the why_blocked was being updated using a store relaxed, not a store release. I've no idea why. In this convesion I'm playing it safe here and using store release consistently. - - - - - e93058e0 by Duncan Coutts at 2024-04-03T01:27:18-04:00 insertIntoSleepingQueue is no longer public No longer defined in IOManager.h, just a private function in IOManager.c. Since it is no longer called from cmm code, just from syncDelay. It ought to get moved further into the select() I/O manager impl, rather than living in IOManager.c. On the other hand appendToIOBlockedQueue is still called from cmm code in the win32-legacy I/O manager primops async{Read,Write}#, and it is also used by the select() I/O manager. Update the CPP and comments to reflect this. - - - - - 60ce9910 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move anyPendingTimeoutsOrIO impl from .h to .c The implementation is eventually going to need to use more private things, which will drag in unwanted includes into IOManager.h, so it's better to move the impl out of the header file and into the .c file, at the slight cost of it no longer being inline. At the same time, change to the "switch (iomgr_type)" style. - - - - - f70b8108 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Take a simpler approach to gcc warnings in IOManager.c We have lots of functions with conditional implementations for different I/O managers. Some functions, for some I/O managers, naturally have implementations that do nothing or barf. When only one such I/O manager is enabled then the whole function implementation will have an implementation that does nothing or barfs. This then results in warnings from gcc that parameters are unused, or that the function should be marked with attribute noreturn (since barf does not return). The USED_IF_THREADS trick for fine-grained warning supression is fine for just two cases, but an equivalent here would need USED_IF_THE_ONLY_ENABLED_IOMGR_IS_X_OR_Y which would have combinitorial blowup. So we take a coarse grained approach and simply disable these two warnings for the whole file. So we use a GCC pragma, with its handy push/pop support: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsuggest-attribute=noreturn" #pragma GCC diagnostic ignored "-Wunused-parameter" ... #pragma GCC diagnostic pop - - - - - b48805b9 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add a new trace class for the iomanager It makes sense now for it to be separate from the scheduler class of tracers. Enabled with +RTS -Do. Document the -Do debug flag in the user guide. - - - - - f0c1f862 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Have the throwTo impl go via (new) IOManager APIs rather than directly operating on the IO manager's data structures. Specifically, when thowing an async exception to a thread that is blocked waiting for I/O or waiting for a timer, then we want to cancel that I/O waiting or cancel the timer. Currently this is done directly in removeFromQueues() in RaiseAsync.c. We want it to go via proper APIs both for modularity but also to let us support multiple I/O managers. So add sync{IO,Delay}Cancel, which is the cancellation for the corresponding sync{IO,Delay}. The implementations of these use the usual "switch (iomgr_type)" style. - - - - - 4f9e9c4e by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move awaitEvent into a proper IOManager API and have the scheduler use it. Previously the scheduler calls awaitEvent directly, and awaitEvent is implemented directly in the RTS I/O managers (select, win32). This relies on the old scheme where there's a single active I/O manager for each platform and RTS way. We want to move that to go via an API in IOManager.{h,c} which can then call out to the active I/O manager. Also take the opportunity to split awaitEvent into two. The existing awaitEvent has a bool wait parameter, to say if the call should be blocking or non-blocking. We split this into two separate functions: pollCompletedTimeoutsOrIO and awaitCompletedTimeoutsOrIO. We split them for a few reasons: they have different post-conditions (specifically the await version is supposed to guarantee that there are threads runnable when it completes). Secondly, it is also anticipated that in future I/O managers the implementations of the two cases will be simpler if they are separated. - - - - - 5ad4b30f by Duncan Coutts at 2024-04-03T01:27:18-04:00 Rename awaitEvent in select and win32 I/O managers These are now just called from IOManager.c and are the per-I/O manager backend impls (whereas previously awaitEvent was the entry point). Follow the new naming convention in the IOManager.{h,c} of awaitCompletedTimeoutsOrIO, with the I/O manager's name as a suffix: so awaitCompletedTimeoutsOrIO{Select,Win32}. - - - - - d30c6bc6 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Tidy up a couple things in Select.{h,c} Use the standard #include {Begin,End}Private.h style rather than RTS_PRIVATE on individual decls. And conditionally build the code for the select I/O manager based on the new CPP IOMGR_ENABLED_SELECT rather than on THREADED_RTS. - - - - - 4161f516 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add an IOManager API for scavenging TSO blocked_info When the GC scavenges a TSO it needs to scavenge the tso->blocked_info but the blocked_info is a big union and what lives there depends on the two->why_blocked, which for I/O-related reasons is something that in principle is the responsibility of the I/O manager and not the GC. So the right thing to do is for the GC to ask the I/O manager to sscavenge the blocked_info if it encounters any I/O-related why_blocked reasons. So we add scavengeTSOIOManager in IOManager.{h,c} with the usual style. Now as it happens, right now, there is no special scavenging to do, so the implementation of scavengeTSOIOManager is a fancy no-op. That's because the select I/O manager uses only the fd and target members, which are not GC pointers, and the win32-legacy I/O manager _ought_ to be using GC-managed heap objects for the StgAsyncIOResult but it is actually usingthe C heap, so again no GC pointers. If the win32-legacy were doing this more sensibly, then scavengeTSOIOManager would be the right place to do the GC magic. Future I/O managers will need GC heap objects in the tso->blocked_info and will make use of this functionality. - - - - - 94a87d21 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add I/O manager API notifyIOManagerCapabilitiesChanged Used in setNumCapabilities. It only does anything for MIO on Posix. Previously it always invoked Haskell code, but that code only did anything on non-Windows (and non-JS), and only threaded. That currently effectively means the MIO I/O manager on Posix. So now it only invokes it for the MIO Posix case. - - - - - 3be6d591 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Select an I/O manager early in RTS startup We need to select the I/O manager to use during startup before the per-cap I/O manager initialisation. - - - - - aaa294d0 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Make struct CapIOManager be fully opaque Provide an opaque (forward) definition in Capability.h (since the cap contains a *CapIOManager) and then only provide a full definition in a new file IOManagerInternals.h. This new file is only supposed to be included by the IOManager implementation, not by its users. So that means IOManager.c and individual I/O manager implementations. The posix/Signals.c still needs direct access, but that should be eliminated. Anything that needs direct access either needs to be clearly part of an I/O manager (e.g. the sleect() one) or go via a proper API. - - - - - 877a2a80 by Duncan Coutts at 2024-04-03T01:27:18-04:00 The select() I/O manager does have some global initialisation It's just to make sure an exception CAF is a GC root. - - - - - 9c51473b by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add tracing for the main I/O manager actions Using the new tracer class. Note: The unconditional definition of showIOManager should be compatible with the debugTrace change in 7c7d1f6. Co-authored-by: Pi Delport <pi at well-typed.com> - - - - - c7d3e3a3 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Include the default I/O manager in the +RTS --info output Document the extra +RTS --info output in the user guide - - - - - 8023bad4 by Duncan Coutts at 2024-04-03T01:27:18-04:00 waitRead# / waitWrite# do not work for win32-legacy I/O manager Previously it was unclear that they did not work because the code path was shared with other I/O managers (in particular select()). Following the code carefully shows that what actually happens is that the calling thread would block forever: the thread will be put into the blocked queue, but no other action is scheduled that will ever result in it getting unblocked. It's better to just fail loudly in case anyone accidentally calls it, also it's less confusing code. - - - - - 83a74d20 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Conditionally ignore some GCC warnings Some GCC versions don't know about some warnings, and they complain that we're ignoring unknown warnings. So we try to ignore the warning based on the GCC version. - - - - - 1adc6fa4 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Accept changes to base-exports All the changes are in fact not changes at all. Previously, the IoSubSystem data type was defined in GHC.RTS.Flags and exported from both GHC.RTS.Flags and GHC.IO.SubSystem. Now, the data type is defined in GHC.IO.SubSystem and still exported from both modules. Therefore, the same exports and same instances are still available from both modules. But the base-exports records only the defining module, and so it looks like a change when it is fully compatible. Related: we do add a deprecation to the export of the type via GHC.RTS.Flags, telling people to use the export from GHC.IO.SubSystem. Also the sort order for some unrelated Show instances changed. No idea why. The same changes apply in the other versions, with a few more changes due to sort order weirdness. - - - - - 8d950968 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Accept metric decrease in T12227 I can't think of any good reason that anything in this MR should have changed the number of allocations, up or down. (Yes this is an empty commit.) Metric Decrease: T12227 - - - - - e869605e by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Several improvements to the handling of coercions * Make `mkSymCo` and `mkInstCo` smarter Fixes #23642 * Fix return role of `SelCo` in the coercion optimiser. Fixes #23617 * Make the coercion optimiser `opt_trans_rule` work better for newtypes Fixes #23619 - - - - - 1efd0714 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 FloatOut: improve floating for join point See the new Note [Floating join point bindings]. * Completely get rid of the complicated join_ceiling nonsense, which I have never understood. * Do not float join points at all, except perhaps to top level. * Some refactoring around wantToFloat, to treat Rec and NonRec more uniformly - - - - - 9c00154d by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Improve eta-expansion through call stacks See Note [Eta expanding through CallStacks] in GHC.Core.Opt.Arity This is a one-line change, that fixes an inconsistency - || isCallStackPredTy ty + || isCallStackPredTy ty || isCallStackTy ty - - - - - 95a9a172 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Spelling, layout, pretty-printing only - - - - - bdf1660f by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Improve exprIsConApp_maybe a little Eliminate a redundant case at birth. This sometimes reduces Simplifier iterations. See Note [Case elim in exprIsConApp_maybe]. - - - - - 609cd32c by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Inline GHC.HsToCore.Pmc.Solver.Types.trvVarInfo When exploring compile-time regressions after meddling with the Simplifier, I discovered that GHC.HsToCore.Pmc.Solver.Types.trvVarInfo was very delicately balanced. It's a small, heavily used, overloaded function and it's important that it inlines. By a fluke it was before, but at various times in my journey it stopped doing so. So I just added an INLINE pragma to it; no sense in depending on a delicately-balanced fluke. - - - - - ae24c9bc by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Slight improvement in WorkWrap Ensure that WorkWrap preserves lambda binders, in case of join points. Sadly I have forgotten why I made this change (it was while I was doing a lot of meddling in the Simplifier, but * it does no harm, * it is slightly more efficient, and * presumably it made something better! Anyway I have kept it in a separate commit. - - - - - e9297181 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Use named record fields for the CastIt { ... } data constructor This is a pure refactor - - - - - b4581e23 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Remove a long-commented-out line Pure refactoring - - - - - e026bdf2 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The main changes are below. There are also many new or rewritten Notes. Avoiding simplifying repeatedly ~~~~~~~~~~~~~~~ See Note [Avoiding simplifying repeatedly] * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env. Currently used only for the next point: avoiding repeatedly simplifying coercions. * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] * Improve the case-merge transformation: - Move the main code to `GHC.Core.Utils.mergeCaseAlts`, to join `filterAlts` and friends. See Note [Merge Nested Cases] in GHC.Core.Utils. - Add a new case for `tagToEnum#`; see wrinkle (MC3). - Add a new case to look through join points: see wrinkle (MC4) postInlineUnconditionally ~~~~~~~~~~~~~~~~~~~~~~~~~ * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. * Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. * Improve occurrence analyis for bottoming function calls, to help postInlineUnconditionally. See Note [Bottoming function calls] in GHC.Core.Opt.OccurAnal Inlining generally ~~~~~~~~~~~~~~~~~~ * In GHC.Core.Opt.Simplify.Utils.interestingCallContext, use RhsCtxt NonRecursive (not BoringCtxt) for a plain-seq case. See Note [Seq is boring] Also, wrinkle (SB1), inline in that `seq` context only for INLINE functions (UnfWhen guidance). * In GHC.Core.Opt.Simplify.Utils.interestingArg, - return ValueArg for OtherCon [c1,c2, ...], but - return NonTrivArg for OtherCon [] This makes a function a little less likely to inline if all we know is that the argument is evaluated, but nothing else. * isConLikeUnfolding is no longer true for OtherCon {}. This propagates to exprIsConLike. Con-like-ness has /positive/ information. Join points ~~~~~~~~~~~ * Be very careful about inlining join points. See these two long Notes Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline * When making join points, don't do so if the join point is so small it will immediately be inlined; check uncondInlineJoin. * In GHC.Core.Opt.Simplify.Inline.tryUnfolding, improve the inlining heuristics for join points. In general we /do not/ want to inline join points /even if they are small/. See Note [Duplicating join points] GHC.Core.Opt.Simplify.Iteration. But sometimes we do: see Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline; and the new `isBetterUnfoldingThan` function. * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * In GHC.Core.Unfold.sizeExpr, make jumps small, so that we don't penalise having a non-inlined join point. Performance changes ~~~~~~~~~~~~~~~~~~~ * Binary sizes fall by around 2.6%, according to nofib. * Compile times improve slightly. Here are the figures over 1%. I investiate the biggest differnce in T18304. It's a very small module, just a few hundred nodes. The large percentage difffence is due to a single function that didn't quite inline before, and does now, making code size a bit bigger. I decided gains outweighed the losses. Metrics: compile_time/bytes allocated (changes over +/- 1%) ------------------------------------------------ CoOpt_Singletons(normal) -9.2% GOOD LargeRecord(normal) -23.5% GOOD MultiComponentModulesRecomp(normal) +1.2% MultiLayerModulesTH_OneShot(normal) +4.1% BAD PmSeriesS(normal) -3.8% PmSeriesV(normal) -1.5% T11195(normal) -1.3% T12227(normal) -20.4% GOOD T12545(normal) -3.2% T12707(normal) -2.1% GOOD T13253(normal) -1.2% T13253-spj(normal) +8.1% BAD T13386(normal) -3.1% GOOD T14766(normal) -2.6% GOOD T15164(normal) -1.4% T15304(normal) +1.2% T15630(normal) -8.2% T15630a(normal) NEW T15703(normal) -14.7% GOOD T16577(normal) -2.3% GOOD T17516(normal) -39.7% GOOD T18140(normal) +1.2% T18223(normal) -17.1% GOOD T18282(normal) -5.0% GOOD T18304(normal) +10.8% BAD T18923(normal) -2.9% GOOD T1969(normal) +1.0% T19695(normal) -1.5% T20049(normal) -12.7% GOOD T21839c(normal) -4.1% GOOD T3064(normal) -1.5% T3294(normal) +1.2% BAD T4801(normal) +1.2% T5030(normal) -15.2% GOOD T5321Fun(normal) -2.2% GOOD T6048(optasm) -16.8% GOOD T783(normal) -1.2% T8095(normal) -6.0% GOOD T9630(normal) -4.7% GOOD T9961(normal) +1.9% BAD WWRec(normal) -1.4% info_table_map_perf(normal) -1.3% parsing001(normal) +1.5% geo. mean -2.0% minimum -39.7% maximum +10.8% * Runtimes generally improve. In the testsuite perf/should_run gives: Metrics: runtime/bytes allocated ------------------------------------------ Conversions(normal) -0.3% T13536a(optasm) -41.7% GOOD T4830(normal) -0.1% haddock.Cabal(normal) -0.1% haddock.base(normal) -0.1% haddock.compiler(normal) -0.1% geo. mean -0.8% minimum -41.7% maximum +0.0% * For runtime, nofib is a better test. The news is mostly good. Here are the number more than +/- 0.1%: # bytes allocated ==========================++========== imaginary/digits-of-e1 || -14.40% imaginary/digits-of-e2 || -4.41% imaginary/paraffins || -0.17% imaginary/rfib || -0.15% imaginary/wheel-sieve2 || -0.10% real/compress || -0.47% real/fluid || -0.10% real/fulsom || +0.14% real/gamteb || -1.47% real/gg || -0.20% real/infer || +0.24% real/pic || -0.23% real/prolog || -0.36% real/scs || -0.46% real/smallpt || +4.03% shootout/k-nucleotide || -20.23% shootout/n-body || -0.42% shootout/spectral-norm || -0.13% spectral/boyer2 || -3.80% spectral/constraints || -0.27% spectral/hartel/ida || -0.82% spectral/mate || -20.34% spectral/para || +0.46% spectral/rewrite || +1.30% spectral/sphere || -0.14% ==========================++========== geom mean || -0.59% real/smallpt has a huge nest of local definitions, and I could not pin down a reason for a regression. But there are three big wins! Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12707 T13386 T13536a T14766 T15703 T16577 T17516 T18223 T18282 T18923 T21839c T20049 T5321Fun T5030 T6048 T8095 T9630 T783 Metric Increase: MultiLayerModulesTH_OneShot T13253-spj T18304 T18698a T9961 T3294 - - - - - 27db3c5e by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Testsuite message changes from simplifier improvements - - - - - 271a7812 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Account for bottoming functions in OccurAnal This fixes #24582, a small but long-standing bug - - - - - 0fde229f by Ben Gamari at 2024-04-04T07:04:58-04:00 testsuite: Introduce template-haskell-exports test - - - - - 0c4a9686 by Luite Stegeman at 2024-04-04T07:05:39-04:00 Update correct counter in bumpTickyAllocd - - - - - 5f085d3a by Fendor at 2024-04-04T14:47:33-04:00 Replace `SizedSeq` with `FlatBag` for flattened structure LinkedLists are notoriously memory ineffiecient when all we do is traversing a structure. As 'UnlinkedBCO' has been identified as a data structure that impacts the overall memory usage of GHCi sessions, we avoid linked lists and prefer flattened structure for storing. We introduce a new memory efficient representation of sequential elements that has special support for the cases: * Empty * Singleton * Tuple Elements This improves sharing in the 'Empty' case and avoids the overhead of 'Array' until its constant overhead is justified. - - - - - 82cfe10c by Fendor at 2024-04-04T14:47:33-04:00 Compact FlatBag array representation `Array` contains three additional `Word`'s we do not need in `FlatBag`. Move `FlatBag` to `SmallArray`. Expand the API of SmallArray by `sizeofSmallArray` and add common traversal functions, such as `mapSmallArray` and `foldMapSmallArray`. Additionally, allow users to force the elements of a `SmallArray` via `rnfSmallArray`. - - - - - 36a75b80 by Andrei Borzenkov at 2024-04-04T14:48:10-04:00 Change how invisible patterns represented in haskell syntax and TH AST (#24557) Before this patch: data ArgPat p = InvisPat (LHsType p) | VisPat (LPat p) With this patch: data Pat p = ... | InvisPat (LHsType p) ... And the same transformation in the TH land. The rest of the changes is just updating code to handle new AST and writing tests to check if it is possible to create invalid states using TH. Metric Increase: MultiLayerModulesTH_OneShot - - - - - 28009fbc by Matthew Pickering at 2024-04-04T14:48:46-04:00 Fix off by one error in seekBinNoExpand and seekBin - - - - - 9b9e031b by Ben Gamari at 2024-04-04T21:30:08-04:00 compiler: Allow more types in GHCForeignImportPrim For many, many years `GHCForeignImportPrim` has suffered from the rather restrictive limitation of not allowing any non-trivial types in arguments or results. This limitation was justified by the code generator allegely barfing in the presence of such types. However, this restriction appears to originate well before the NCG rewrite and the new NCG does not appear to have any trouble with such types (see the added `T24598` test). Lift this restriction. Fixes #24598. - - - - - 1324b862 by Alan Zimmerman at 2024-04-04T21:30:44-04:00 EPA: Use EpaLocation not SrcSpan in ForeignDecls This allows us to update them for makeDeltaAst in ghc-exactprint - - - - - 19883a23 by Alan Zimmerman at 2024-04-05T16:58:17-04:00 EPA: Use EpaLocation for RecFieldsDotDot So we can update it to a delta position in makeDeltaAst if needed. - - - - - e8724327 by Matthew Pickering at 2024-04-05T16:58:53-04:00 Remove accidentally committed test.hs - - - - - 88cb3e10 by Fendor at 2024-04-08T09:03:34-04:00 Avoid UArray when indexing is not required `UnlinkedBCO`'s can occur many times in the heap. Each `UnlinkedBCO` references two `UArray`'s but never indexes them. They are only needed to encode the elements into a `ByteArray#`. The three words for the lower bound, upper bound and number of elements are essentially unused, thus we replace `UArray` with a wrapper around `ByteArray#`. This saves us up to three words for each `UnlinkedBCO`. Further, to avoid re-allocating these words for `ResolvedBCO`, we repeat the procedure for `ResolvedBCO` and add custom `Binary` and `Show` instances. For example, agda's repl session has around 360_000 UnlinkedBCO's, so avoiding these three words is already saving us around 8MB residency. - - - - - f2cc1107 by Fendor at 2024-04-08T09:04:11-04:00 Never UNPACK `FastMutInt` for counting z-encoded `FastString`s In `FastStringTable`, we count the number of z-encoded FastStrings that exist in a GHC session. We used to UNPACK the counters to not waste memory, but live retainer analysis showed that we allocate a lot of `FastMutInt`s, retained by `mkFastZString`. We lazily compute the `FastZString`, only incrementing the counter when the `FastZString` is forced. The function `mkFastStringWith` calls `mkZFastString` and boxes the `FastMutInt`, leading to the following core: mkFastStringWith = \ mk_fs _ -> = case stringTable of { FastStringTable _ n_zencs segments# _ -> ... case ((mk_fs (I# ...) (FastMutInt n_zencs)) `cast` <Co:2> :: ...) ... Marking this field as `NOUNPACK` avoids this reboxing, eliminating the allocation of a fresh `FastMutInt` on every `FastString` allocation. - - - - - c6def949 by Matthew Pickering at 2024-04-08T16:06:51-04:00 Force in_multi to avoid retaining entire hsc_env - - - - - fbb91a63 by Fendor at 2024-04-08T16:06:51-04:00 Eliminate name thunk in declaration fingerprinting Thunk analysis showed that we have about 100_000 thunks (in agda and `-fwrite-simplified-core`) pointing to the name of the name decl. Forcing this thunk fixes this issue. The thunk created here is retained by the thunk created by forkM, it is better to eagerly force this because the result (a `Name`) is already retained indirectly via the `IfaceDecl`. - - - - - 3b7b0c1c by Alan Zimmerman at 2024-04-08T16:07:27-04:00 EPA: Use EpaLocation in WarningTxt This allows us to use an EpDelta if needed when using makeDeltaAst. - - - - - 12b997df by Alan Zimmerman at 2024-04-08T16:07:27-04:00 EPA: Move DeltaPos and EpaLocation' into GHC.Types.SrcLoc This allows us to use a NoCommentsLocation for the possibly trailing comma location in a StringLiteral. This in turn allows us to correctly roundtrip via makeDeltaAst. - - - - - 868c8a78 by Fendor at 2024-04-09T08:51:50-04:00 Prefer packed representation for CompiledByteCode As there are many 'CompiledByteCode' objects alive during a GHCi session, representing its element in a more packed manner improves space behaviour at a minimal cost. When running GHCi on the agda codebase, we find around 380 live 'CompiledByteCode' objects. Packing their respective 'UnlinkedByteCode' can save quite some pointers. - - - - - be3bddde by Alan Zimmerman at 2024-04-09T08:52:26-04:00 EPA: Capture all comments in a ClassDecl Hopefully the final fix needed for #24533 - - - - - 3d0806fc by Jade at 2024-04-10T05:39:53-04:00 Validate -main-is flag using parseIdentifier Fixes #24368 - - - - - dd530bb7 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: free error message before returning Fixes a memory leak in rts/linker/PEi386.c - - - - - e008a19a by Alexis King at 2024-04-10T05:40:29-04:00 linker: Avoid linear search when looking up Haskell symbols via dlsym See the primary Note [Looking up symbols in the relevant objects] for a more in-depth explanation. When dynamically loading a Haskell symbol (typical when running a splice or GHCi expression), before this commit we would search for the symbol in all dynamic libraries that were loaded. However, this could be very inefficient when too many packages are loaded (which can happen if there are many package dependencies) because the time to lookup the would be linear in the number of packages loaded. This commit drastically improves symbol loading performance by introducing a mapping from units to the handles of corresponding loaded dlls. These handles are returned by dlopen when we load a dll, and can then be used to look up in a specific dynamic library. Looking up a given Name is now much more precise because we can get lookup its unit in the mapping and lookup the symbol solely in the handles of the dynamic libraries loaded for that unit. In one measurement, the wait time before the expression was executed went from +-38 seconds down to +-2s. This commit also includes Note [Symbols may not be found in pkgs_loaded], explaining the fallback to the old behaviour in case no dll can be found in the unit mapping for a given Name. Fixes #23415 Co-authored-by: Rodrigo Mesquita (@alt-romes) - - - - - dcfaa190 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: Make addDLL a wrapper around loadNativeObj Rewrite the implementation of `addDLL` as a wrapper around the more principled `loadNativeObj` rts linker function. The latter should be preferred while the former is preserved for backwards compatibility. `loadNativeObj` was previously only available on ELF platforms, so this commit further refactors the rts linker to transform loadNativeObj_ELF into loadNativeObj_POSIX, which is available in ELF and MachO platforms. The refactor made it possible to remove the `dl_mutex` mutex in favour of always using `linker_mutex` (rather than a combination of both). Lastly, we implement `loadNativeObj` for Windows too. - - - - - 12931698 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 Use symbol cache in internal interpreter too This commit makes the symbol cache that was used by the external interpreter available for the internal interpreter too. This follows from the analysis in #23415 that suggests the internal interpreter could benefit from this cache too, and that there is no good reason not to have the cache for it too. It also makes it a bit more uniform to have the symbol cache range over both the internal and external interpreter. This commit also refactors the cache into a function which is used by both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the caching logic to `lookupSymbolInDLL` too. - - - - - dccd3ea1 by Ben Gamari at 2024-04-10T05:40:29-04:00 testsuite: Add test for lookupSymbolInNativeObj - - - - - 1b1a92bd by Alan Zimmerman at 2024-04-10T05:41:05-04:00 EPA: Remove unnecessary XRec in CompleteMatchSig The XRec for [LIdP pass] is not needed for exact printing, remove it. - - - - - 6e18ce2b by Ben Gamari at 2024-04-12T08:16:09-04:00 users-guide: Clarify language extension documentation Over the years the users guide's language extension documentation has gone through quite a few refactorings. In the process some of the descriptions have been rendered non-sensical. For instance, the description of `NoImplicitPrelude` actually describes the semantics of `ImplicitPrelude`. To fix this we: * ensure that all extensions are named in their "positive" sense (e.g. `ImplicitPrelude` rather than `NoImplicitPrelude`). * rework the documentation to avoid flag-oriented wording like "enable" and "disable" * ensure that the polarity of the documentation is consistent with reality. Fixes #23895. - - - - - a933aff3 by Zubin Duggal at 2024-04-12T08:16:45-04:00 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - 23c3e624 by Andreas Klebinger at 2024-04-12T08:17:21-04:00 RTS: Emit warning when -M < -H Fixes #24487 - - - - - d23afb8c by Ben Gamari at 2024-04-12T08:17:56-04:00 testsuite: Add broken test for CApiFFI with -fprefer-bytecode See #24634. - - - - - a4bb3a51 by Ben Gamari at 2024-04-12T08:18:32-04:00 base: Deprecate GHC.Pack As proposed in #21461. Closes #21540. - - - - - 55eb8c98 by Ben Gamari at 2024-04-12T08:19:08-04:00 ghc-internal: Fix mentions of ghc-internal in deprecation warnings Closes #24609. - - - - - b0fbd181 by Ben Gamari at 2024-04-12T08:19:44-04:00 rts: Implement set_initial_registers for AArch64 Fixes #23680. - - - - - 14c9ec62 by Ben Gamari at 2024-04-12T08:20:20-04:00 ghcup-metadata: Use Debian 9 binaries on Ubuntu 16, 17 Closes #24646. - - - - - 35a1621e by Ben Gamari at 2024-04-12T08:20:55-04:00 Bump unix submodule to 2.8.5.1 Closes #24640. - - - - - a1c24df0 by Finley McIlwaine at 2024-04-12T08:21:31-04:00 Correct default -funfolding-use-threshold in docs - - - - - 0255d03c by Oleg Grenrus at 2024-04-12T08:22:07-04:00 FastString is a __Modified__ UTF-8 - - - - - c3489547 by Matthew Pickering at 2024-04-12T13:13:44-04:00 rts: Improve tracing message when nursery is resized It is sometimes more useful to know how much bigger or smaller the nursery got when it is resized. In particular I am trying to investigate situations where we end up with fragmentation due to the nursery (#24577) - - - - - 5e4f4ba8 by Simon Peyton Jones at 2024-04-12T13:14:20-04:00 Don't generate wrappers for `type data` constructors with StrictData Previously, the logic for checking if a data constructor needs a wrapper or not would take into account whether the constructor's fields have explicit strictness (e.g., `data T = MkT !Int`), but the logic would _not_ take into account whether `StrictData` was enabled. This meant that something like `type data T = MkT Int` would incorrectly generate a wrapper for `MkT` if `StrictData` was enabled, leading to the horrible errors seen in #24620. To fix this, we disable generating wrappers for `type data` constructors altogether. Fixes #24620. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - dbdf1995 by Alex Mason at 2024-04-15T15:28:26+10:00 Implements MO_S_Mul2 and MO_U_Mul2 using the UMULH, UMULL and SMULH instructions for AArch64 Also adds a test for MO_S_Mul2 - - - - - 42bd0407 by Teo Camarasu at 2024-04-16T20:06:39-04:00 Make template-haskell a stage1 package Promoting template-haskell from a stage0 to a stage1 package means that we can much more easily refactor template-haskell. We implement this by duplicating the in-tree `template-haskell`. A new `template-haskell-next` library is autogenerated to mirror `template-haskell` `stage1:ghc` to depend on the new interface of the library including the `Binary` instances without adding an explicit dependency on `template-haskell`. This is controlled by the `bootstrap-th` cabal flag When building `template-haskell` modules as part of this vendoring we do not have access to quote syntax, so we cannot use variable quote notation (`'Just`). So we either replace these with hand-written `Name`s or hide the code behind CPP. We can remove the `th_hack` from hadrian, which was required when building stage0 packages using the in-tree `template-haskell` library. For more details see Note [Bootstrapping Template Haskell]. Resolves #23536 Co-Authored-By: Sebastian Graf <sgraf1337 at gmail.com> Co-Authored-By: Matthew Craven <5086-clyring at users.noreply.gitlab.haskell.org> - - - - - 3d973e47 by Ben Gamari at 2024-04-16T20:07:15-04:00 Bump parsec submodule to 3.1.17.0 - - - - - 9d38bfa0 by Simon Peyton Jones at 2024-04-16T20:07:51-04:00 Clone CoVars in CorePrep This MR addresses #24463. It's all explained in the new Note [Cloning CoVars and TyVars] - - - - - 0fe2b410 by Andreas Klebinger at 2024-04-16T20:08:27-04:00 NCG: Fix a bug where we errounously removed a required jump instruction. Add a new method to the Instruction class to check if we can eliminate a jump in favour of fallthrough control flow. Fixes #24507 - - - - - 9f99126a by Teo Camarasu at 2024-04-16T20:09:04-04:00 Fix documentation preview from doc-tarball job - Include all the .html files and assets in the job artefacts - Include all the .pdf files in the job artefacts - Mark the artefact as an "exposed" artefact meaning it turns up in the UI. Resolves #24651 - - - - - 3a0642ea by Ben Gamari at 2024-04-16T20:09:39-04:00 rts: Ignore EINTR while polling in timerfd itimer implementation While the RTS does attempt to mask signals, it may be that a foreign library unmasks them. This previously caused benign warnings which we now ignore. See #24610. - - - - - 9a53cd3f by Alan Zimmerman at 2024-04-16T20:10:15-04:00 EPA: Add additional comments field to AnnsModule This is used in exact printing to store comments coming after the `where` keyword but before any comments allocated to imports or decls. It is used in ghc-exactprint, see https://github.com/alanz/ghc-exactprint/commit/44bbed311fd8f0d053053fef195bf47c17d34fa7 - - - - - e5c43259 by Bryan Richter at 2024-04-16T20:10:51-04:00 Remove unrunnable FreeBSD CI jobs FreeBSD runner supply is inelastic. Currently there is only one, and it's unavailable because of a hardware issue. - - - - - 914eb49a by Ben Gamari at 2024-04-16T20:11:27-04:00 rel-eng: Fix mktemp usage in recompress-all We need a temporary directory, not a file. - - - - - f30e4984 by Teo Camarasu at 2024-04-16T20:12:03-04:00 Fix ghc API link in docs/index.html This was missing part of the unit ID meaning it would 404. Resolves #24674 - - - - - d7a3d6b5 by Ben Gamari at 2024-04-16T20:12:39-04:00 template-haskell: Declare TH.Lib.Internal as not-home Rather than `hide`. Closes #24659. - - - - - 5eaa46e7 by Matthew Pickering at 2024-04-19T02:14:55-04:00 testsuite: Rename isCross() predicate to needsTargetWrapper() isCross() was a misnamed because it assumed that all cross targets would provide a target wrapper, but the two most common cross targets (javascript, wasm) don't need a target wrapper. Therefore we rename this predicate to `needsTargetWrapper()` so situations in the testsuite where we can check whether running executables requires a target wrapper or not. - - - - - 55a9d699 by Simon Peyton Jones at 2024-04-19T02:15:32-04:00 Do not float HNFs out of lambdas This MR adjusts SetLevels so that it is less eager to float a HNF (lambda or constructor application) out of a lambda, unless it gets to top level. Data suggests that this change is a small net win: * nofib bytes-allocated falls by -0.09% (but a couple go up) * perf/should_compile bytes-allocated falls by -0.5% * perf/should_run bytes-allocated falls by -0.1% See !12410 for more detail. When fiddling elsewhere, I also found that this patch had a huge positive effect on the (very delicate) test perf/should_run/T21839r But that improvement doesn't show up in this MR by itself. Metric Decrease: MultiLayerModulesRecomp T15703 parsing001 - - - - - f0701585 by Alan Zimmerman at 2024-04-19T02:16:08-04:00 EPA: Fix comments in mkListSyntaxTy0 Also extend the test to confirm. Addresses #24669, 1 of 4 - - - - - b01c01d4 by Serge S. Gulin at 2024-04-19T02:16:51-04:00 JS: set image `x86_64-linux-deb11-emsdk-closure` for build - - - - - c90c6039 by Alan Zimmerman at 2024-04-19T02:17:27-04:00 EPA: Provide correct span for PatBind And remove unused parameter in checkPatBind Contributes to #24669 - - - - - 26036f96 by Alan Zimmerman at 2024-04-19T13:11:08-04:00 EPA: Fix span for PatBuilderAppType Include the location of the prefix @ in the span for InVisPat. Also removes unnecessary annotations from HsTP. Contributes to #24669 - - - - - dba03aab by Matthew Craven at 2024-04-19T13:11:44-04:00 testsuite: Give the pre_cmd for mhu-perf more time - - - - - d31fbf6c by Krzysztof Gogolewski at 2024-04-19T21:04:09-04:00 Fix quantification order for a `op` b and a %m -> b Fixes #23764 Implements https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0640-tyop-quantification-order.rst Updates haddock submodule. - - - - - 385cd1c4 by Sebastian Graf at 2024-04-19T21:04:45-04:00 Make `seq#` a magic Id and inline it in CorePrep (#24124) We can save much code and explanation in Tag Inference and StgToCmm by making `seq#` a known-key Magic Id in `GHC.Internal.IO` and inline this definition in CorePrep. See the updated `Note [seq# magic]`. I also implemented a new `Note [Flatten case-bind]` to get better code for otherwise nested case scrutinees. I renamed the contructors of `ArgInfo` to use an `AI` prefix in order to resolve the clash between `type CpeApp = CoreExpr` and the data constructor of `ArgInfo`, as well as fixed typos in `Note [CorePrep invariants]`. Fixes #24252 and #24124. - - - - - 275e41a9 by Jade at 2024-04-20T11:10:40-04:00 Put the newline after errors instead of before them This mainly has consequences for GHCi but also slightly alters how the output of GHC on the commandline looks. Fixes: #22499 - - - - - dd339c7a by Teo Camarasu at 2024-04-20T11:11:16-04:00 Remove unecessary stage0 packages Historically quite a few packages had to be stage0 as they depended on `template-haskell` and that was stage0. In #23536 we made it so that was no longer the case. This allows us to remove a bunch of packages from this list. A few still remain. A new version of `Win32` is required by `semaphore-compat`. Including `Win32` in the stage0 set requires also including `filepath` because otherwise Hadrian's dependency logic gets confused. Once our boot compiler has a newer version of `Win32` all of these will be able to be dropped. Resolves #24652 - - - - - 2f8e3a25 by Alan Zimmerman at 2024-04-20T11:11:52-04:00 EPA: Avoid duplicated comments in splice decls Contributes to #24669 - - - - - c70b9ddb by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fix typos and namings (fixes #24602) You may noted that I've also changed term of ``` , global "h$vt_double" ||= toJExpr IntV ``` See "IntV" and ``` WaitReadOp -> \[] [fd] -> pure $ PRPrimCall $ returnS (app "h$waidRead" [fd]) ``` See "h$waidRead" - - - - - 3db54f9b by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: trivial checks for variable presence (fixes #24602) - - - - - 777f108f by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fs module imported twice (by emscripten and by ghc-internal). ghc-internal import wrapped in a closure to prevent conflict with emscripten (fixes #24602) Better solution is to use some JavaScript module system like AMD, CommonJS or even UMD. It will be investigated at other issues. At first glance we should try UMD (See https://github.com/umdjs/umd) - - - - - a45a5712 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: thread.js requires h$fds and h$fdReady to be declared for static code analysis, minimal code copied from GHCJS (fixes #24602) I've just copied some old pieces of GHCJS from publicly available sources (See https://github.com/Taneb/shims/blob/a6dd0202dcdb86ad63201495b8b5d9763483eb35/src/io.js#L607). Also I didn't put details to h$fds. I took minimal and left only its object initialization: `var h$fds = {};` - - - - - ad90bf12 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: heap and stack overflows reporting defined as js hard failure (fixes #24602) These errors were treated as a hard failure for browser application. The fix is trivial: just throw error. - - - - - 5962fa52 by Serge S. Gulin at 2024-04-21T16:33:44+03:00 JS: Stubs for code without actual implementation detected by Google Closure Compiler (fixes #24602) These errors were fixed just by introducing stubbed functions with throw for further implementation. - - - - - a0694298 by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add externs to linker (fixes #24602) After enabling jsdoc and built-in google closure compiler types I was needed to deal with the following: 1. Define NodeJS-environment types. I've just copied minimal set of externs from semi-official repo (see https://github.com/externs/nodejs/blob/6c6882c73efcdceecf42e7ba11f1e3e5c9c041f0/v8/nodejs.js#L8). 2. Define Emscripten-environment types: `HEAP8`. Emscripten already provides some externs in our code but it supposed to be run in some module system. And its definitions do not work well in plain bundle. 3. We have some functions which purpose is to add to functions some contextual information via function properties. These functions should be marked as `modifies` to let google closure compiler remove calls if these functions are not used actually by call graph. Such functions are: `h$o`, `h$sti`, `h$init_closure`, `h$setObjInfo`. 4. STG primitives such as registries and stuff from `GHC.StgToJS`. `dXX` properties were already present at externs generator function but they are started from `7`, not from `1`. This message is related: `// fixme does closure compiler bite us here?` - - - - - e58bb29f by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: added both tests: for size and for correctness (fixes #24602) By some reason MacOS builds add to stderr messages like: Ignoring unexpected archive entry: __.SYMDEF ... However I left stderr to `/dev/null` for compatibility with linux CI builds. - - - - - 909f3a9c by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Disable js linker warning for empty symbol table to make js tests running consistent across environments - - - - - 83eb10da by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add special preprocessor for js files due of needing to keep jsdoc comments (fixes #24602) Our js files have defined google closure compiler types at jsdoc entries but these jsdoc entries are removed by cpp preprocessor. I considered that reusing them in javascript-backend would be a nice thing. Right now haskell processor uses `-traditional` option to deal with comments and `//` operators. But now there are following compiler options: `-C` and `-CC`. You can read about them at GCC (see https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#index-CC) and CLang (see https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-CC). It seems that `-CC` works better for javascript jsdoc than `-traditional`. At least it leaves `/* ... */` comments w/o changes. - - - - - e1cf8dc2 by brandon s allbery kf8nh at 2024-04-22T03:48:26-04:00 fix link in CODEOWNERS It seems that our local Gitlab no longer has documentation for the `CODEOWNERS` file, but the master documentation still does. Use that instead. - - - - - 593f4e04 by Fendor at 2024-04-23T10:19:14-04:00 Add performance regression test for '-fwrite-simplified-core' - - - - - 1ba39b05 by Fendor at 2024-04-23T10:19:14-04:00 Typecheck corebindings lazily during bytecode generation This delays typechecking the corebindings until the bytecode generation happens. We also avoid allocating a thunk that is retained by `unsafeInterleaveIO`. In general, we shouldn't retain values of the hydrated `Type`, as not evaluating the bytecode object keeps it alive. It is better if we retain the unhydrated `IfaceType`. See Note [Hydrating Modules] - - - - - e916fc92 by Alan Zimmerman at 2024-04-23T10:19:50-04:00 EPA: Keep comments in a CaseAlt match The comments now live in the surrounding location, not inside the Match. Make sure we keep them. Closes #24707 - - - - - d2b17f32 by Cheng Shao at 2024-04-23T15:01:22-04:00 driver: force merge objects when building dynamic objects This patch forces the driver to always merge objects when building dynamic objects even when ar -L is supported. It is an oversight of !8887: original rationale of that patch is favoring the relatively cheap ar -L operation over object merging when ar -L is supported, which makes sense but only if we are building static objects! Omitting check for whether we are building dynamic objects will result in broken .so files with undefined reference errors at executable link time when building GHC with llvm-ar. Fixes #22210. - - - - - 209d09f5 by Julian Ospald at 2024-04-23T15:02:03-04:00 Allow non-absolute values for bootstrap GHC variable Fixes #24682 - - - - - 3fff0977 by Matthew Pickering at 2024-04-23T15:02:38-04:00 Don't depend on registerPackage function in Cabal More recent versions of Cabal modify the behaviour of libAbiHash which breaks our usage of registerPackage. It is simpler to inline the part of registerPackage that we need and avoid any additional dependency and complication using the higher-level function introduces. - - - - - c62dc317 by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: remove obsolete ln script This commit removes an obsolete ln script in ghc-bignum/gmp. See 060251c24ad160264ae8553efecbb8bed2f06360 for its original intention, but it's been obsolete for a long time, especially since the removal of the make build system. Hence the house cleaning. - - - - - 6399d52b by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: update gmp to 6.3.0 This patch bumps the gmp-tarballs submodule and updates gmp to 6.3.0. The tarball format is now xz, and gmpsrc.patch has been patched into the tarball so hadrian no longer needs to deal with patching logic when building in-tree GMP. - - - - - 65b4b92f by Cheng Shao at 2024-04-25T01:32:02-04:00 hadrian: remove obsolete Patch logic This commit removes obsolete Patch logic from hadrian, given we no longer need to patch the gmp tarball when building in-tree GMP. - - - - - 71f28958 by Cheng Shao at 2024-04-25T01:32:02-04:00 autoconf: remove obsolete patch detection This commit removes obsolete deletection logic of the patch command from autoconf scripts, given we no longer need to patch anything in the GHC build process. - - - - - daeda834 by Sylvain Henry at 2024-04-25T01:32:43-04:00 JS: correctly handle RUBBISH literals (#24664) - - - - - 8a06ddf6 by Matthew Pickering at 2024-04-25T11:16:16-04:00 Linearise ghc-internal and base build This is achieved by requesting the final package database for ghc-internal, which mandates it is fully built as a dependency of configuring the `base` package. This is at the expense of cross-package parrallelism between ghc-internal and the base package. Fixes #24436 - - - - - 94da9365 by Andrei Borzenkov at 2024-04-25T11:16:54-04:00 Fix tuple puns renaming (24702) Move tuple renaming short cutter from `isBuiltInOcc_maybe` to `isPunOcc_maybe`, so we consider incoming module. I also fixed some hidden bugs that raised after the change was done. - - - - - fa03b1fb by Fendor at 2024-04-26T18:03:13-04:00 Refactor the Binary serialisation interface The goal is simplifiy adding deduplication tables to `ModIface` interface serialisation. We identify two main points of interest that make this difficult: 1. UserData hardcodes what `Binary` instances can have deduplication tables. Moreover, it heavily uses partial functions. 2. GHC.Iface.Binary hardcodes the deduplication tables for 'Name' and 'FastString', making it difficult to add more deduplication. Instead of having a single `UserData` record with fields for all the types that can have deduplication tables, we allow to provide custom serialisers for any `Typeable`. These are wrapped in existentials and stored in a `Map` indexed by their respective `TypeRep`. The `Binary` instance of the type to deduplicate still needs to explicitly look up the decoder via `findUserDataReader` and `findUserDataWriter`, which is no worse than the status-quo. `Map` was chosen as microbenchmarks indicate it is the fastest for a small number of keys (< 10). To generalise the deduplication table serialisation mechanism, we introduce the types `ReaderTable` and `WriterTable` which provide a simple interface that is sufficient to implement a general purpose deduplication mechanism for `writeBinIface` and `readBinIface`. This allows us to provide a list of deduplication tables for serialisation that can be extended more easily, for example for `IfaceTyCon`, see the issue https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for more motivation. In addition to this refactoring, we split `UserData` into `ReaderUserData` and `WriterUserData`, to avoid partial functions and reduce overall memory usage, as we need fewer mutable variables. Bump haddock submodule to accomodate for `UserData` split. ------------------------- Metric Increase: MultiLayerModulesTH_Make MultiLayerModulesRecomp T21839c ------------------------- - - - - - bac57298 by Fendor at 2024-04-26T18:03:13-04:00 Split `BinHandle` into `ReadBinHandle` and `WriteBinHandle` A `BinHandle` contains too much information for reading data. For example, it needs to keep a `FastMutInt` and a `IORef BinData`, when the non-mutable variants would suffice. Additionally, this change has the benefit that anyone can immediately tell whether the `BinHandle` is used for reading or writing. Bump haddock submodule BinHandle split. - - - - - 4d6394dd by Simon Peyton Jones at 2024-04-26T18:03:49-04:00 Fix missing escaping-kind check in tcPatSynSig Note [Escaping kind in type signatures] explains how we deal with escaping kinds in type signatures, e.g. f :: forall r (a :: TYPE r). a where the kind of the body is (TYPE r), but `r` is not in scope outside the forall-type. I had missed this subtlety in tcPatSynSig, leading to #24686. This MR fixes it; and a similar bug in tc_top_lhs_type. (The latter is tested by T24686a.) - - - - - 981c2c2c by Alan Zimmerman at 2024-04-26T18:04:25-04:00 EPA: check-exact: check that the roundtrip reproduces the source Closes #24670 - - - - - a8616747 by Andrew Lelechenko at 2024-04-26T18:05:01-04:00 Document that setEnv is not thread-safe - - - - - 1e41de83 by Bryan Richter at 2024-04-26T18:05:37-04:00 CI: Work around frequent Signal 9 errors - - - - - a6d5f9da by Naïm Favier at 2024-04-27T17:52:40-04:00 ghc-internal: add MonadFix instance for (,) Closes https://gitlab.haskell.org/ghc/ghc/-/issues/24288, implements CLC proposal https://github.com/haskell/core-libraries-committee/issues/238. Adds a MonadFix instance for tuples, permitting value recursion in the "native" writer monad and bringing consistency with the existing instance for transformers's WriterT (and, to a lesser extent, for Solo). - - - - - 64feadcd by Rodrigo Mesquita at 2024-04-27T17:53:16-04:00 bindist: Fix xattr cleaning The original fix (725343aa) was incorrect because it used the shell bracket syntax which is the quoting syntax in autoconf, making the test for existence be incorrect and therefore `xattr` was never run. Fixes #24554 - - - - - e2094df3 by damhiya at 2024-04-28T23:52:00+09:00 Make read accepts binary integer formats CLC proposal : https://github.com/haskell/core-libraries-committee/issues/177 - - - - - 1c2fd963 by Alan Zimmerman at 2024-04-29T23:17:00-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 - - - - - 4189d17e by Sylvain Henry at 2024-04-29T23:17:42-04:00 LLVM: better unreachable default destination in Switch (#24717) See added note. Co-authored-by: Siddharth Bhat <siddu.druid at gmail.com> - - - - - a3725c88 by Cheng Shao at 2024-04-29T23:18:20-04:00 ci: enable wasm jobs for MRs with wasm label This patch enables wasm jobs for MRs with wasm label. Previously the wasm label didn't actually have any effect on the CI pipeline, and full-ci needed to be applied to run wasm jobs which was a waste of runners when working on the wasm backend, hence the fix here. - - - - - 702f7964 by Matthew Pickering at 2024-04-29T23:18:56-04:00 Make interface files and object files depend on inplace .conf file A potential fix for #24737 - - - - - 728af21e by Cheng Shao at 2024-04-30T05:30:23-04:00 utils: remove obsolete vagrant scripts Vagrantfile has long been removed in !5288. This commit further removes the obsolete vagrant scripts in the tree. - - - - - 36f2c342 by Cheng Shao at 2024-04-30T05:31:00-04:00 Update autoconf scripts Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 - - - - - ecbf22a6 by Ben Gamari at 2024-04-30T05:31:36-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 7eab4e01 by Alan Zimmerman at 2024-05-04T16:14:55+01:00 EPA: Widen stmtslist to include last semicolon Closes #24754 - - - - - 06f7db40 by Teo Camarasu at 2024-05-05T00:19:38-04:00 doc: Fix type error in hs_try_putmvar example - - - - - af000532 by Moritz Schuler at 2024-05-05T06:30:58-04:00 Fix parsing of module names in CLI arguments closes issue #24732 - - - - - da74e9c9 by Ben Gamari at 2024-05-05T06:31:34-04:00 ghc-platform: Add Setup.hs The Hadrian bootstrapping script relies upon `Setup.hs` to drive its build. Addresses #24761. - - - - - 35d34fde by Alan Zimmerman at 2024-05-05T12:52:40-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 - - - - - 03c5dfbf by Simon Peyton Jones at 2024-05-05T12:53:15-04:00 Fix a float-out error Ticket #24768 showed that the Simplifier was accidentally destroying a join point. It turned out to be that we were sending a bottoming join point to the top, accidentally abstracting over /other/ join points. Easily fixed. - - - - - adba68e7 by John Ericson at 2024-05-05T19:35:56-04:00 Substitute bindist files with Hadrian not configure The `ghc-toolchain` overhaul will eventually replace all this stuff with something much more cleaned up, but I think it is still worth making this sort of cleanup in the meantime so other untanglings and dead code cleaning can procede. I was able to delete a fair amount of dead code doing this too. `LLVMTarget_CPP` is renamed to / merged with `LLVMTarget` because it wasn't actually turned into a valid CPP identifier. (Original to 1345c7cc42c45e63ab1726a8fd24a7e4d4222467, actually.) Progress on #23966 Co-Authored-By: Sylvain Henry <hsyl20 at gmail.com> - - - - - 18f4ff84 by Alan Zimmerman at 2024-05-05T19:36:32-04:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 - - - - - a19201d4 by Matthew Craven at 2024-05-06T19:54:29-04:00 Add test cases for #24664 ...since none are present in the original MR !12463 fixing this issue. - - - - - 46328a49 by Alan Zimmerman at 2024-05-06T19:55:05-04:00 EPA: preserve comments in data decls Closes #24771 - - - - - 3b51995c by Andrei Borzenkov at 2024-05-07T14:39:40-04:00 Rename Solo# data constructor to MkSolo# (#24673) - data Solo# a = (# a #) + data Solo# a = MkSolo# a And `(# foo #)` syntax now becomes just a syntactic sugar for `MkSolo# a`. - - - - - 4d59abf2 by Arsen Arsenović at 2024-05-07T14:40:24-04:00 Add the cmm_cpp_is_gcc predicate to the testsuite A future C-- test called T24474-cmm-override-g0 relies on the GCC-specific behaviour of -g3 implying -dD, which, in turn, leads to it emitting #defines past the preprocessing stage. Clang, at least, does not do this, so the test would fail if ran on Clang. As the behaviour here being tested is ``-optCmmP-g3'' undoing effects of the workaround we apply as a fix for bug #24474, and the workaround was for GCC-specific behaviour, the test needs to be marked as fragile on other compilers. - - - - - 25b0b404 by Arsen Arsenović at 2024-05-07T14:40:24-04:00 Split out the C-- preprocessor, and make it pass -g0 Previously, C-- was processed with the C preprocessor program. This means that it inherited flags passed via -optc. A flag that is somewhat often passed through -optc is -g. At certain -g levels (>=2), GCC starts emitting defines *after* preprocessing, for the purposes of debug info generation. This is not useful for the C-- compiler, and, in fact, causes lexer errors. We can suppress this effect (safely, if supported) via -g0. As a workaround, in older versions of GCC (<=10), GCC only emitted defines if a certain set of -g*3 flags was passed. Newer versions check the debug level. For the former, we filter out those -g*3 flags and, for the latter, we specify -g0 on top of that. As a compatible and effective solution, this change adds a C-- preprocessor distinct from the C compiler and preprocessor, but that keeps its flags. The command line produced for C-- preprocessing now looks like: $pgmCmmP $optCs_without_g3 $g0_if_supported $optCmmP Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/24474 - - - - - 4945c430 by Fendor at 2024-05-08T15:30:22+02:00 Migrate `Finder` component to `OsPath` For each module in a GHCi session, we keep alive one `ModLocation`. A `ModLocation` is fairly inefficiently packed, as `String`s are expensive in memory usage. While benchmarking the agda codebase, we concluded that we keep alive around 11MB of `FilePath`'s, solely retained by `ModLocation`. We provide a more densely packed encoding of `ModLocation`, by moving from `FilePath` to `OsPath`. Further, we migrate the full `Finder` component to `OsPath` to avoid unnecessary transformations. As the `Finder` component is well-encapsuled, this requires only a minimal amount of changes in other modules. Bump to haddock submodule for `ModLocation` changes. - - - - - 30 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - .gitlab/rel_eng/recompress-all - CODEOWNERS - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Dwarf.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dcd026a7f2979797ef2fffae41aa352b0034b6f1...4945c430808ee57e6c52b3f3dc126ada160338bd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dcd026a7f2979797ef2fffae41aa352b0034b6f1...4945c430808ee57e6c52b3f3dc126ada160338bd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 13:39:27 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Wed, 08 May 2024 09:39:27 -0400 Subject: [Git][ghc/ghc][wip/fendor/os-string-modlocation] Migrate `Finder` component to `OsPath` Message-ID: <663b808fc468d_6129d2033df41126aa@gitlab.mail> Hannes Siebenhandl pushed to branch wip/fendor/os-string-modlocation at Glasgow Haskell Compiler / GHC Commits: ac97f44a by Fendor at 2024-05-08T15:39:18+02:00 Migrate `Finder` component to `OsPath` For each module in a GHCi session, we keep alive one `ModLocation`. A `ModLocation` is fairly inefficiently packed, as `String`s are expensive in memory usage. While benchmarking the agda codebase, we concluded that we keep alive around 11MB of `FilePath`'s, solely retained by `ModLocation`. We provide a more densely packed encoding of `ModLocation`, by moving from `FilePath` to `OsPath`. Further, we migrate the full `Finder` component to `OsPath` to avoid unnecessary transformations. As the `Finder` component is well-encapsuled, this requires only a minimal amount of changes in other modules. Bump to haddock submodule for `ModLocation` changes. - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/CmmToAsm/Dwarf.hs - compiler/GHC/CmmToAsm/Wasm.hs - compiler/GHC/CoreToStg/Prep.hs - + compiler/GHC/Data/OsPath.hs - compiler/GHC/Data/Strict.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Config/Finder.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/MakeFile.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Errors.hs - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Stg/Debug.hs - compiler/GHC/Unit/Finder.hs - compiler/GHC/Unit/Finder/Types.hs - compiler/GHC/Unit/Module/Location.hs - compiler/GHC/Unit/Module/ModSummary.hs - compiler/ghc.cabal.in - ghc/GHCi/UI.hs - ghc/GHCi/UI/Info.hs - ghc/ghc-bin.cabal.in The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ac97f44ae6fd02a86991366db946b335ba949c34 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ac97f44ae6fd02a86991366db946b335ba949c34 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 13:41:17 2024 From: gitlab at gitlab.haskell.org (Hannes Siebenhandl (@fendor)) Date: Wed, 08 May 2024 09:41:17 -0400 Subject: [Git][ghc/ghc][wip/fendor/os-string-modlocation] Migrate `Finder` component to `OsPath` Message-ID: <663b80fd1f526_6129d2124b8c115944@gitlab.mail> Hannes Siebenhandl pushed to branch wip/fendor/os-string-modlocation at Glasgow Haskell Compiler / GHC Commits: c2e7d82c by Fendor at 2024-05-08T15:41:10+02:00 Migrate `Finder` component to `OsPath` For each module in a GHCi session, we keep alive one `ModLocation`. A `ModLocation` is fairly inefficiently packed, as `String`s are expensive in memory usage. While benchmarking the agda codebase, we concluded that we keep alive around 11MB of `FilePath`'s, solely retained by `ModLocation`. We provide a more densely packed encoding of `ModLocation`, by moving from `FilePath` to `OsPath`. Further, we migrate the full `Finder` component to `OsPath` to avoid unnecessary transformations. As the `Finder` component is well-encapsuled, this requires only a minimal amount of changes in other modules. Bump to haddock submodule for `ModLocation` changes. - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/CmmToAsm/Dwarf.hs - compiler/GHC/CmmToAsm/Wasm.hs - compiler/GHC/CoreToStg/Prep.hs - + compiler/GHC/Data/OsPath.hs - compiler/GHC/Data/Strict.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Config/Finder.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/MakeFile.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Errors.hs - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Stg/Debug.hs - compiler/GHC/Unit/Finder.hs - compiler/GHC/Unit/Finder/Types.hs - compiler/GHC/Unit/Module/Location.hs - compiler/GHC/Unit/Module/ModSummary.hs - compiler/ghc.cabal.in - ghc/GHCi/UI.hs - ghc/GHCi/UI/Info.hs - ghc/ghc-bin.cabal.in The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c2e7d82cf1328dd1d9b26f9b68e7b9aeaead2cd6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c2e7d82cf1328dd1d9b26f9b68e7b9aeaead2cd6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 14:41:57 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 08 May 2024 10:41:57 -0400 Subject: [Git][ghc/ghc][wip/T24466] Disable postInlineUnconditionally occ-once inlining Message-ID: <663b8f35805c1_6129d2b99d60144928@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24466 at Glasgow Haskell Compiler / GHC Commits: 2ab58b1d by Simon Peyton Jones at 2024-05-08T15:41:47+01:00 Disable postInlineUnconditionally occ-once inlining - - - - - 1 changed file: - compiler/GHC/Core/Opt/Simplify/Utils.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -48,7 +48,7 @@ import qualified GHC.Prelude as Partial (head) import GHC.Core import GHC.Types.Literal ( isLitRubbish ) import GHC.Core.Opt.Simplify.Env -import GHC.Core.Opt.Simplify.Inline( smallEnoughToInline ) +-- import GHC.Core.Opt.Simplify.Inline( smallEnoughToInline ) import GHC.Core.Opt.Stats ( Tick(..) ) import qualified GHC.Core.Subst import GHC.Core.Ppr @@ -1609,6 +1609,9 @@ postInlineUnconditionally env bind_cxt old_bndr bndr rhs | otherwise = case occ_info of OneOcc { occ_in_lam = in_lam, occ_int_cxt = int_cxt, occ_n_br = n_br } + | n_br == 1, NotInsideLam <- in_lam -- One syntactic occurrence + -> True -- See Note [Post-inline for single-use things] +{- -- See Note [Inline small things to avoid creating a thunk] | n_br >= 100 -> False -- See #23627 @@ -1630,7 +1633,7 @@ postInlineUnconditionally env bind_cxt old_bndr bndr rhs -> work_ok in_lam int_cxt && smallEnoughToInline uf_opts unfolding -- Multiple syntactic occurences; but lazy, and small enough to dup -- ToDo: consider discount on smallEnoughToInline if int_cxt is true - +-} IAmDead -> True -- This happens; for example, the case_bndr during case of -- known constructor: case (a,b) of x { (p,q) -> ... } -- Here x isn't mentioned in the RHS, so we don't want to @@ -1639,6 +1642,12 @@ postInlineUnconditionally env bind_cxt old_bndr bndr rhs _ -> False where + occ_info = idOccInfo old_bndr + unfolding = idUnfolding bndr + phase = sePhase env + active = isActive phase (idInlineActivation bndr) + -- See Note [pre/postInlineUnconditionally in gentle mode] +{- work_ok NotInsideLam _ = True work_ok IsInsideLam IsInteresting = isCheapUnfolding unfolding work_ok IsInsideLam NotInteresting = False @@ -1656,12 +1665,8 @@ postInlineUnconditionally env bind_cxt old_bndr bndr rhs -- is_unlifted = isUnliftedType (idType bndr) is_demanded = isStrUsedDmd (idDemandInfo bndr) - occ_info = idOccInfo old_bndr - unfolding = idUnfolding bndr uf_opts = seUnfoldingOpts env - phase = sePhase env - active = isActive phase (idInlineActivation bndr) - -- See Note [pre/postInlineUnconditionally in gentle mode] +-} {- Note [Inline small things to avoid creating a thunk] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2ab58b1df4b4ea102a68cb649ac33451d63b339b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2ab58b1df4b4ea102a68cb649ac33451d63b339b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 14:47:57 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 08 May 2024 10:47:57 -0400 Subject: [Git][ghc/ghc][wip/no-mi-globals] 308 commits: rts: expose HeapAlloc.h as public header Message-ID: <663b909db5355_6129d2d04eac1473b@gitlab.mail> Matthew Pickering pushed to branch wip/no-mi-globals at Glasgow Haskell Compiler / GHC Commits: dedcf102 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: expose HeapAlloc.h as public header This commit exposes HeapAlloc.h as a public header. The intention is to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in assertions in other public headers, and they may also be useful for user code. - - - - - d19441d7 by Cheng Shao at 2024-03-06T13:39:04-05:00 rts: assert pointer is indeed heap allocated in Bdescr() This commit adds an assertion to Bdescr() to assert the pointer is indeed heap allocated. This is useful to rule out RTS bugs that attempt to access non-existent block descriptor of a static closure, #24492 being one such example. - - - - - 9a656a04 by Ben Gamari at 2024-03-06T13:39:39-05:00 ghc-experimental: Add dummy dependencies to work around #23942 This is a temporary measure to improve CI reliability until a proper solution is developed. Works around #23942. - - - - - 1e84b924 by Simon Peyton Jones at 2024-03-06T13:39:39-05:00 Three compile perf improvements with deep nesting These were changes are all triggered by #24471. 1. Make GHC.Core.Opt.SetLevels.lvlMFE behave better when there are many free variables. See Note [Large free-variable sets]. 2. Make GHC.Core.Opt.Arity.floatIn a bit lazier in its Cost argument. This benefits the common case where the ArityType turns out to be nullary. See Note [Care with nested expressions] 3. Make GHC.CoreToStg.Prep.cpeArg behave for deeply-nested expressions. See Note [Eta expansion of arguments in CorePrep] wrinkle (EA2). Compile times go down by up to 4.5%, and much more in artificial cases. (Geo mean of compiler/perf changes is -0.4%.) Metric Decrease: CoOpt_Read T10421 T12425 - - - - - c4b13113 by Hécate Moonlight at 2024-03-06T13:40:17-05:00 Use "module" instead of "library" when applicable in base haddocks - - - - - 9cd9efb4 by Vladislav Zavialov at 2024-03-07T13:01:54+03:00 Rephrase error message to say "visible arguments" (#24318) * Main change: make the error message generated by mkFunTysMsg more accurate by changing "value arguments" to "visible arguments". * Refactor: define a new type synonym VisArity and use it instead of Arity in a few places. It might be the case that there other places in the compiler that should talk about visible arguments rather than value arguments, but I haven't tried to find them all, focusing only on the error message reported in the ticket. - - - - - d523a6a7 by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump array submodule - - - - - 7e55003c by Ben Gamari at 2024-03-07T19:40:45-05:00 Bump stm submodule - - - - - 32d337ef by Ben Gamari at 2024-03-07T19:40:45-05:00 Introduce exception context Here we introduce the `ExceptionContext` type and `ExceptionAnnotation` class, allowing dynamically-typed user-defined annotations to be attached to exceptions. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 - - - - - 39f3d922 by Ben Gamari at 2024-03-07T19:40:46-05:00 testsuite/interface-stability: Update documentation - - - - - fdea7ada by Ben Gamari at 2024-03-07T19:40:46-05:00 ghc-internal: comment formatting - - - - - 4fba42ef by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Default and warn ExceptionContext constraints - - - - - 3886a205 by Ben Gamari at 2024-03-07T19:40:46-05:00 base: Introduce exception backtraces Here we introduce the `Backtraces` type and associated machinery for attaching these via `ExceptionContext`. These has a few compile-time regressions (`T15703` and `T9872d`) due to the additional dependencies in the exception machinery. As well, there is a surprisingly large regression in the `size_hello_artifact` test. This appears to be due to various `Integer` and `Read` bits now being reachable at link-time. I believe it should be possible to avoid this but I have accepted the change for now to get the feature merged. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/199 GHC Proposal: https://github.com/ghc-proposals/ghc-proposals/pull/330 Metric Increase: T15703 T9872d size_hello_artifact - - - - - 18c5409f by Ben Gamari at 2024-03-07T19:40:46-05:00 users guide: Release notes for exception backtrace work - - - - - f849c5fc by Ben Gamari at 2024-03-07T19:40:46-05:00 compiler: Don't show ExceptionContext of GhcExceptions Most GhcExceptions are user-facing errors and therefore the ExceptionContext has little value. Ideally we would enable it in the DEBUG compiler but I am leaving this for future work. - - - - - dc646e6f by Sylvain Henry at 2024-03-07T19:40:46-05:00 Disable T9930fail for the JS target (cf #19174) - - - - - bfc09760 by Alan Zimmerman at 2024-03-07T19:41:22-05:00 Update showAstData to honour blanking of AnnParen Also tweak rendering of SrcSpan to remove extra blank line. - - - - - 50454a29 by Ben Gamari at 2024-03-08T03:32:42-05:00 ghc-internal: Eliminate GHC.Internal.Data.Kind This was simply reexporting things from `ghc-prim`. Instead reexport these directly from `Data.Kind`. Also add build ordering dependency to work around #23942. - - - - - 38a4b6ab by Ben Gamari at 2024-03-08T03:33:18-05:00 rts: Fix SET_HDR initialization of retainer set This fixes a regression in retainer set profiling introduced by b0293f78cb6acf2540389e22bdda420d0ab874da. Prior to that commit the heap traversal word would be initialized by `SET_HDR` using `LDV_RECORD_CREATE`. However, the commit added a `doingLDVProfiling` check in `LDV_RECORD_CREATE`, meaning that this initialization no longer happened. Given that this initialization was awkwardly indirectly anyways, I have fixed this by explicitly initializating the heap traversal word to `NULL` in `SET_PROF_HDR`. This is equivalent to the previous behavior, but much more direct. Fixes #24513. - - - - - 2859a637 by Ben Gamari at 2024-03-08T18:26:47-05:00 base: Use strerror_r instead of strerror As noted by #24344, `strerror` is not necessarily thread-safe. Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is safe to use. Fixes #24344. CLC discussion: https://github.com/haskell/core-libraries-committee/issues/249 - - - - - edb9bf77 by Jade at 2024-03-09T03:39:38-05:00 Error messages: Improve Error messages for Data constructors in type signatures. This patch improves the error messages from invalid type signatures by trying to guess what the user did and suggesting an appropriate fix. Partially fixes: #17879 - - - - - cfb197e3 by Patrick at 2024-03-09T03:40:15-05:00 HieAst: add module name #24493 The main purpose of this is to tuck the module name `xxx` in `module xxx where` into the hieAst. It should fix #24493. The following have been done: 1. Renamed and update the `tcg_doc_hdr :: Maybe (LHsDoc GhcRn)` to `tcg_hdr_info :: (Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))` To store the located module name information. 2. update the `RenamedSource` and `RenamedStuff` with extra `Maybe (XRec GhcRn ModuleName)` located module name information. 3. add test `testsuite/tests/hiefile/should_compile/T24493.hs` to ensure the module name is added and update several relevent tests. 4. accompanied submodule haddoc test update MR in https://gitlab.haskell.org/ghc/haddock/-/merge_requests/53 - - - - - 2341d81e by Vaibhav Sagar at 2024-03-09T03:40:54-05:00 GHC.Utils.Binary: fix a couple of typos - - - - - 5580e1bd by Ben Gamari at 2024-03-09T03:41:30-05:00 rts: Drop .wasm suffix from .prof file names This replicates the behavior on Windows, where `Hi.exe` will produce profiling output named `Hi.prof` instead of `Hi.exe.prof`. While in the area I also fixed the extension-stripping logic, which incorrectly rewrote `Hi.exefoo` to `Hi.foo`. Closes #24515. - - - - - 259495ee by Cheng Shao at 2024-03-09T03:41:30-05:00 testsuite: drop exe extension from .hp & .prof filenames See #24515 for details. - - - - - c477a8d2 by Ben Gamari at 2024-03-09T03:42:05-05:00 rts/linker: Enable GOT support on all platforms There is nothing platform-dependent about our GOT implementation and GOT support is needed by `T24171` on i386. - - - - - 2e592857 by Vladislav Zavialov at 2024-03-09T03:42:41-05:00 Drop outdated comment on TcRnIllformedTypePattern This should have been done in 0f0c53a501b but I missed it. - - - - - c554b4da by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Bounds check array write - - - - - 15c590a5 by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - e831ce31 by Ben Gamari at 2024-03-09T09:39:20-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 6948e24d by Ben Gamari at 2024-03-09T09:39:20-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 9204a04e by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Don't expose helper in header - - - - - 308926ff by Ben Gamari at 2024-03-09T09:39:20-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - bebdea05 by Ben Gamari at 2024-03-09T09:39:20-05:00 IPE: Expose unit ID in InfoTableProv Here we add the unit ID to the info table provenance structure. - - - - - 6519c9ad by Ben Gamari at 2024-03-09T09:39:35-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ed0b69dc by Ben Gamari at 2024-03-09T09:39:35-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 2b1faea9 by Vladislav Zavialov at 2024-03-09T17:38:21-05:00 docs: Update info on TypeAbstractions * Mention TypeAbstractions in 9.10.1-notes.rst * Set the status to "Experimental". * Add a "Since: GHC 9.x" comment to each section. - - - - - f8b88918 by Ben Gamari at 2024-03-09T21:21:46-05:00 ci-images: Bump Alpine image to bootstrap with 9.8.2 - - - - - 705e6927 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark T24171 as fragile due to #24512 I will fix this but not in time for 9.10.1-alpha1 - - - - - c74196e1 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Mark linker_unload_native as fragile In particular this fails on platforms without `dlinfo`. I plan to address this but not before 9.10.1-alpha1. - - - - - f4d87f7a by Ben Gamari at 2024-03-09T21:21:46-05:00 configure: Bump version to 9.10 - - - - - 88df9a5f by Ben Gamari at 2024-03-09T21:21:46-05:00 Bump transformers submodule to 0.6.1.1 - - - - - 8176d5e8 by Ben Gamari at 2024-03-09T21:21:46-05:00 testsuite: Increase ulimit for T18623 1 MByte was just too tight and failed intermittently on some platforms (e.g. CentOS 7). Bumping the limit to 8 MByte should provide sufficient headroom. Fixes #23139. - - - - - c74b38a3 by Ben Gamari at 2024-03-09T21:21:46-05:00 base: Bump version to 4.20.0.0 - - - - - b2937fc3 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-internal: Set initial version at 9.1001.0 This provides PVP compliance while maintaining a clear correspondence between GHC releases and `ghc-internal` versions. - - - - - 4ae7d868 by Ben Gamari at 2024-03-09T21:21:46-05:00 ghc-prim: Bump version to 0.11.0 - - - - - 50798dc6 by Ben Gamari at 2024-03-09T21:21:46-05:00 template-haskell: Bump version to 2.22.0.0 - - - - - 8564f976 by Ben Gamari at 2024-03-09T21:21:46-05:00 base-exports: Accommodate spurious whitespace changes in 32-bit output It appears that this was - - - - - 9d4f0e98 by Ben Gamari at 2024-03-09T21:21:46-05:00 users-guide: Move exception backtrace relnotes to 9.10 This was previously mistakenly added to the GHC 9.8 release notes. - - - - - 145eae60 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix name of Rocky8 artifact - - - - - 39c2a630 by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/rel_eng: Fix path of generate_jobs_metadata - - - - - aed034de by Ben Gamari at 2024-03-09T21:21:46-05:00 gitlab/upload: Rework recompression The old `combine` approach was quite fragile due to use of filename globbing. Moreover, it didn't parallelize well. This refactoring makes the goal more obvious, parallelizes better, and is more robust. - - - - - dc207d06 by Ben Gamari at 2024-03-10T08:56:08-04:00 configure: Bump GHC version to 9.11 Bumps haddock submodule. - - - - - 8b2513e8 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload code when profiling is enabled The heap census may contain references (e.g. `Counter.identity`) to static data which must be available when the census is reported at the end of execution. Fixes #24512. - - - - - 7810b4c3 by Ben Gamari at 2024-03-11T01:20:03-04:00 rts/linker: Don't unload native objects when dlinfo isn't available To do so is unsafe as we have no way of identifying references to symbols provided by the object. Fixes #24513. Fixes #23993. - - - - - 0590764c by Ben Gamari at 2024-03-11T01:20:39-04:00 rel_eng/upload: Purge both $rel_name/ and $ver/ This is necessary for prereleases, where GHCup accesses the release via `$ver/` - - - - - b85a4631 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Remove duplicate code normalising slashes - - - - - c91946f9 by Brandon Chinn at 2024-03-12T19:25:56-04:00 Simplify regexes with raw strings - - - - - 1a5f53c6 by Brandon Chinn at 2024-03-12T19:25:57-04:00 Don't normalize backslashes in characters - - - - - 7ea971d3 by Andrei Borzenkov at 2024-03-12T19:26:32-04:00 Fix compiler crash caused by implicit RHS quantification in type synonyms (#24470) - - - - - 39f3ac3e by Cheng Shao at 2024-03-12T19:27:11-04:00 Revert "compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms" This reverts commit 615eb855416ce536e02ed935ecc5a6f25519ae16. It was originally intended to fix #24449, but it was merely sweeping the bug under the rug. 3836a110577b5c9343915fd96c1b2c64217e0082 has properly fixed the fragile test, and we no longer need the C version of genSym. Furthermore, the C implementation causes trouble when compiling with clang that targets i386 due to alignment warning and libatomic linking issue, so it makes sense to revert it. - - - - - e6bfb85c by Cheng Shao at 2024-03-12T19:27:11-04:00 compiler: fix out-of-bound memory access of genSym on 32-bit This commit fixes an unnoticed out-of-bound memory access of genSym on 32-bit. ghc_unique_inc is 32-bit sized/aligned on 32-bit platforms, but we mistakenly treat it as a Word64 pointer in genSym, and therefore will accidentally load 2 garbage higher bytes, or with a small but non-zero chance, overwrite something else in the data section depends on how the linker places the data segments. This regression was introduced in !11802 and fixed here. - - - - - 77171cd1 by Ben Orchard at 2024-03-14T09:00:40-04:00 Note mutability of array and address access primops Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature: indexOffAddr :: Addr# -> Int# -> a readOffAddr :: Addr# -> Int# -> State# d -> (# State# d, a #) indexOffAddr# might seem like a free generality improvement, which it certainly is not! This change adds a brief note on mutability expectations for most index/read/write access primops. - - - - - 7da7f8f6 by Alan Zimmerman at 2024-03-14T09:01:15-04:00 EPA: Fix regression discarding comments in contexts Closes #24533 - - - - - 73be65ab by Fendor at 2024-03-19T01:42:53-04:00 Fix sharing of 'IfaceTyConInfo' during core to iface type translation During heap analysis, we noticed that during generation of 'mi_extra_decls' we have lots of duplicates for the instances: * `IfaceTyConInfo NotPromoted IfaceNormalTyCon` * `IfaceTyConInfo IsPromoted IfaceNormalTyCon` which should be shared instead of duplicated. This duplication increased the number of live bytes by around 200MB while loading the agda codebase into GHCi. These instances are created during `CoreToIface` translation, in particular `toIfaceTyCon`. The generated core looks like: toIfaceTyCon = \ tc_sjJw -> case $wtoIfaceTyCon tc_sjJw of { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) -> IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM) } whichs removes causes the sharing to work propery. Adding explicit sharing, with NOINLINE annotations, changes the core to: toIfaceTyCon = \ tc_sjJq -> case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) -> IfaceTyCon ww_sjNB ww1_sjNC } which looks much more like sharing is happening. We confirmed via ghc-debug that all duplications were eliminated and the number of live bytes are noticeably reduced. - - - - - bd8209eb by Alan Zimmerman at 2024-03-19T01:43:28-04:00 EPA: Address more 9.10.1-alpha1 regressions from recent changes Closes #24533 Hopefully for good this time - - - - - 31bf85ee by Fendor at 2024-03-19T14:48:08-04:00 Escape multiple arguments in the settings file Uses responseFile syntax. The issue arises when GHC is installed on windows into a location that has a space, for example the user name is 'Fake User'. The $topdir will also contain a space, consequentially. When we resolve the top dir in the string `-I$topdir/mingw/include`, then `words` will turn this single argument into `-I/C/Users/Fake` and `User/.../mingw/include` which trips up the flag argument parser of various tools such as gcc or clang. We avoid this by escaping the $topdir before replacing it in `initSettngs`. Additionally, we allow to escape spaces and quotation marks for arguments in `settings` file. Add regression test case to count the number of options after variable expansion and argument escaping took place. Additionally, we check that escaped spaces and double quotation marks are correctly parsed. - - - - - f45f700e by Matthew Pickering at 2024-03-19T14:48:44-04:00 Read global package database from settings file Before this patch, the global package database was always assumed to be in libdir </> package.conf.d. This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file. * The stage1 compiler needs to use stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * Cabal/cabal-install will work correctly because they query the global package database using `--print-global-package-db`. A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502 - - - - - 4c8f1794 by Matthew Pickering at 2024-03-19T14:48:44-04:00 hadrian: Remove stage1 testsuite wrappers logic Now instead of producing wrappers which pass the global package database argument to ghc and ghc-pkg, we write the location of the correct package database into the settings file so you can just use the intree compiler directly. - - - - - da0d8ba5 by Matthew Craven at 2024-03-19T14:49:20-04:00 Remove unused ghc-internal module "GHC.Internal.Constants" - - - - - b56d2761 by Matthew Craven at 2024-03-19T14:49:20-04:00 CorePrep: Rework lowering of BigNat# literals Don't use bigNatFromWord#, because that's terrible: * We shouldn't have to traverse a linked list at run-time to build a BigNat# literal. That's just silly! * The static List object we have to create is much larger than the actual BigNat#'s contents, bloating code size. * We have to read the corresponding interface file, which causes un-tracked implicit dependencies. (#23942) Instead, encode them into the appropriate platform-dependent sequence of bytes, and generate code that copies these bytes at run-time from an Addr# literal into a new ByteArray#. A ByteArray# literal would be the correct thing to generate, but these are not yet supported; see also #17747. Somewhat surprisingly, this change results in a slight reduction in compiler allocations, averaging around 0.5% on ghc's compiler performance tests, including when compiling programs that contain no bignum literals to begin with. The specific cause of this has not been investigated. Since this lowering no longer reads the interface file for GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer] is obsoleted. But the story of un-tracked built-in dependencies remains complex, and Note [Tracking dependencies on primitives] now exists to explain this complexity. Additionally, many empty imports have been modified to refer to this new note and comply with its guidance. Several empty imports necessary for other reasons have also been given brief explanations. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 349ea330 by Fendor at 2024-03-19T14:50:00-04:00 Eliminate thunk in 'IfaceTyCon' Heap analysis showed that `IfaceTyCon` retains a thunk to `IfaceTyConInfo`, defeating the sharing of the most common instances of `IfaceTyConInfo`. We make sure the indirection is removed by adding bang patterns to `IfaceTyCon`. Experimental results on the agda code base, where the `mi_extra_decls` were read from disk: Before this change, we observe around 8654045 instances of: `IfaceTyCon[Name,THUNK_1_0]` But these thunks almost exclusively point to a shared value! Forcing the thunk a little bit more, leads to `ghc-debug` reporting: `IfaceTyCon[Name:Name,IfaceTyConInfo]` and a noticeable reduction of live bytes (on agda ~10%). - - - - - 594bee0b by Krzysztof Gogolewski at 2024-03-19T14:50:36-04:00 Minor misc cleanups - GHC.HsToCore.Foreign.JavaScript: remove dropRuntimeRepArgs; boxed tuples don't take RuntimeRep args - GHC.HsToCore.Foreign.Call: avoid partial pattern matching - GHC.Stg.Unarise: strengthen the assertion; we can assert that non-rubbish literals are unary rather than just non-void - GHC.Tc.Gen.HsType: make sure the fsLit "literal" rule fires - users_guide/using-warnings.rst: remove -Wforall-identifier, now deprecated and does nothing - users_guide/using.rst: fix formatting - andy_cherry/test.T: remove expect_broken_for(23272...), 23272 is fixed The rest are simple cleanups. - - - - - cf55a54b by Ben Gamari at 2024-03-19T14:51:12-04:00 mk/relpath: Fix quoting Previously there were two instances in this script which lacked proper quoting. This resulted in `relpath` invocations in the binary distribution Makefile producing incorrect results on Windows, leading to confusing failures from `sed` and the production of empty package registrations. Fixes #24538. - - - - - 5ff88389 by Bryan Richter at 2024-03-19T14:51:48-04:00 testsuite: Disable T21336a on wasm - - - - - 60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian/bindist: Eliminate extraneous `dirname` invocation Previously we would call `dirname` twice per installed library file. We now instead reuse this result. This helps appreciably on Windows, where processes are quite expensive. - - - - - 616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00 hadrian: Package mingw toolchain in expected location This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89. Specifically, GHC expects to find the mingw32 toolchain in the binary distribution root. However, after this patch it was packaged in the `lib/` directory. - - - - - de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00 gitlab/rel_eng: More upload.sh tweaks - - - - - 1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_eng: Drop dead prepare_docs codepath - - - - - dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00 rel_env/recompress_all: unxz before recompressing Previously we would rather compress the xz *again*, before in addition compressing it with the desired scheme. Fixes #24545. - - - - - 9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00 mk-ghcup-metadata: Fix directory of testsuite tarball As reported in #24546, the `dlTest` artifact should be extracted into the `testsuite` directory. - - - - - 6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00 ghcup-metadata: Don't populate dlOutput unless necessary ghcup can apparently infer the output name of an artifact from its URL. Consequently, we should only include the `dlOutput` field when it would differ from the filename of `dlUri`. Fixes #24547. - - - - - 576f8b7e by Zubin Duggal at 2024-03-19T22:33:46-04:00 Revert "Apply shellcheck suggestion to SUBST_TOOLDIR" This reverts commit c82770f57977a2b5add6e1378f234f8dd6153392. The shellcheck suggestion is spurious and results in SUBST_TOOLDIR being a no-op. `set` sets positional arguments for bash, but we want to set the variable given as the first autoconf argument. Fixes #24542 Metric decreases because the paths in the settings file are now shorter, so we allocate less when we read the settings file. ------------------------- Metric Decrease: T12425 T13035 T9198 ------------------------- - - - - - cdfe6e01 by Fendor at 2024-03-19T22:34:22-04:00 Compact serialisation of IfaceAppArgs In #24563, we identified that IfaceAppArgs serialisation tags each cons cell element with a discriminator byte. These bytes add up quickly, blowing up interface files considerably when '-fwrite-if-simplified-core' is enabled. We compact the serialisation by writing out the length of 'IfaceAppArgs', followed by serialising the elements directly without any discriminator byte. This improvement can decrease the size of some interface files by up to 35%. - - - - - 97a2bb1c by Simon Peyton Jones at 2024-03-20T17:11:29+00:00 Expand untyped splices in tcPolyExprCheck Fixes #24559 - - - - - 5f275176 by Alan Zimmerman at 2024-03-20T22:44:12-04:00 EPA: Clean up Exactprint helper functions a bit - Introduce a helper lens to compose on `EpAnn a` vs `a` versions - Rename some prime versions of functions back to non-prime They were renamed during the rework - - - - - da2a10ce by Vladislav Zavialov at 2024-03-20T22:44:48-04:00 Type operators in promoteOccName (#24570) Type operators differ from term operators in that they are lexically classified as (type) constructors, not as (type) variables. Prior to this change, promoteOccName did not account for this difference, causing a scoping issue that affected RequiredTypeArguments. type (!@#) = Bool f = idee (!@#) -- Not in scope: ‘!@#’ (BUG) Now we have a special case in promoteOccName to account for this. - - - - - 247fc0fa by Preetham Gujjula at 2024-03-21T10:19:18-04:00 docs: Remove mention of non-existent Ord instance for Complex The documentation for Data.Complex says that the Ord instance for Complex Float is deficient, but there is no Ord instance for Complex a. The Eq instance for Complex Float is similarly deficient, so we use that as an example instead. - - - - - 6fafc51e by Andrei Borzenkov at 2024-03-21T10:19:54-04:00 Fix TH handling in `pat_to_type_pat` function (#24571) There was missing case for `SplicePat` in `pat_to_type_at` function, hence patterns with splicing that checked against `forall->` doesn't work properly because they fall into the "illegal pattern" case. Code example that is now accepted: g :: forall a -> () g $([p| a |]) = () - - - - - 52072f8e by Sylvain Henry at 2024-03-21T21:01:59-04:00 Type-check default declarations before deriving clauses (#24566) See added Note and #24566. Default declarations must be type-checked before deriving clauses. - - - - - 7dfdf3d9 by Sylvain Henry at 2024-03-21T21:02:40-04:00 Lexer: small perf changes - Use unsafeChr because we know our values to be valid - Remove some unnecessary use of `ord` (return Word8 values directly) - - - - - 864922ef by Sylvain Henry at 2024-03-21T21:02:40-04:00 JS: fix some comments - - - - - 3e0b2b1f by Sebastian Graf at 2024-03-21T21:03:16-04:00 Simplifier: Re-do dependency analysis in abstractFloats (#24551) In #24551, we abstracted a string literal binding over a type variable, triggering a CoreLint error when that binding floated to top-level. The solution implemented in this patch fixes this by re-doing dependency analysis on a simplified recursive let binding that is about to be type abstracted, in order to find the minimal set of type variables to abstract over. See wrinkle (AB5) of Note [Floating and type abstraction] for more details. Fixes #24551 - - - - - 8a8ac65a by Matthew Craven at 2024-03-23T00:20:52-04:00 Improve toInteger @Word32 on 64-bit platforms On 64-bit platforms, every Word32 fits in an Int, so we can convert to Int# without having to perform the overflow check integerFromWord# uses internally. - - - - - 0c48f2b9 by Apoorv Ingle at 2024-03-23T00:21:28-04:00 Fix for #24552 (see testcase T24552) Fixes for a bug in desugaring pattern synonyms matches, introduced while working on on expanding `do`-blocks in #18324 The `matchWrapper` unecessarily (and incorrectly) filtered out the default wild patterns in a match. Now the wild pattern alternative is simply ignored by the pm check as its origin is `Generated`. The current code now matches the expected semantics according to the language spec. - - - - - b72705e9 by Simon Peyton Jones at 2024-03-23T00:22:04-04:00 Print more info about kinds in error messages This fixes #24553, where GHC unhelpfully said error: [GHC-83865] • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’ See Note [Showing invisible bits of types in error messages] - - - - - 8f7cfc7e by Tristan Cacqueray at 2024-03-23T00:22:44-04:00 docs: remove the don't use float hint This hint is outdated, ``Complex Float`` are now specialised, and the heap space suggestion needs more nuance so it should be explained in the unboxed/storable array documentation. - - - - - 5bd8ed53 by Andreas Klebinger at 2024-03-23T16:18:33-04:00 NCG: Fix a bug in jump shortcutting. When checking if a jump has more than one destination account for the possibility of some jumps not being representable by a BlockId. We do so by having isJumpishInstr return a `Maybe BlockId` where Nothing represents non-BlockId jump destinations. Fixes #24507 - - - - - 8d67f247 by Ben Gamari at 2024-03-23T16:19:09-04:00 docs: Drop old release notes, add for 9.12.1 - - - - - 7db8c992 by Cheng Shao at 2024-03-25T13:45:46-04:00 rts: fix clang compilation on aarch64 This patch fixes function prototypes in ARMOutlineAtomicsSymbols.h which causes "error: address argument to atomic operation must be a pointer to _Atomic type" when compiling with clang on aarch64. - - - - - 237194ce by Sylvain Henry at 2024-03-25T13:46:27-04:00 Lexer: fix imports for Alex 3.5.1 (#24583) - - - - - 810660b7 by Cheng Shao at 2024-03-25T22:19:16-04:00 libffi-tarballs: bump libffi-tarballs submodule to libffi 3.4.6 This commit bumps the libffi-tarballs submodule to libffi 3.4.6, which includes numerous upstream libffi fixes, especially https://github.com/libffi/libffi/issues/760. - - - - - d2ba41e8 by Alan Zimmerman at 2024-03-25T22:19:51-04:00 EPA: do not duplicate comments in signature RHS - - - - - 32a8103f by Rodrigo Mesquita at 2024-03-26T21:16:12-04:00 configure: Use LDFLAGS when trying linkers A user may configure `LDFLAGS` but not `LD`. When choosing a linker, we will prefer `ldd`, then `ld.gold`, then `ld.bfd` -- however, we have to check for a working linker. If either of these fail, we try the next in line. However, we were not considering the `$LDFLAGS` when checking if these linkers worked. So we would pick a linker that does not support the current $LDFLAGS and fail further down the line when we used that linker with those flags. Fixes #24565, where `LDFLAGS=-Wl,-z,pack-relative-relocs` is not supported by `ld.gold` but that was being picked still. - - - - - bf65a7c3 by Rodrigo Mesquita at 2024-03-26T21:16:48-04:00 bindist: Clean xattrs of bin and lib at configure time For issue #21506, we started cleaning the extended attributes of binaries and libraries from the bindist *after* they were installed to workaround notarisation (#17418), as part of `make install`. However, the `ghc-toolchain` binary that is now shipped with the bindist must be run at `./configure` time. Since we only cleaned the xattributes of the binaries and libs after they were installed, in some situations users would be unable to run `ghc-toolchain` from the bindist, failing at configure time (#24554). In this commit we move the xattr cleaning logic to the configure script. Fixes #24554 - - - - - cfeb70d3 by Rodrigo Mesquita at 2024-03-26T21:17:24-04:00 Revert "NCG: Fix a bug in jump shortcutting." This reverts commit 5bd8ed53dcefe10b72acb5729789e19ceb22df66. Fixes #24586 - - - - - 13223f6d by Serge S. Gulin at 2024-03-27T07:28:51-04:00 JS: `h$rts_isProfiled` is removed from `profiling` and left its version at `rts/js/config.js` - - - - - 0acfe391 by Alan Zimmerman at 2024-03-27T07:29:27-04:00 EPA: Do not extend declaration range for trailine zero len semi The lexer inserts virtual semicolons having zero width. Do not use them to extend the list span of items in a list. - - - - - cd0fb82f by Alan Zimmerman at 2024-03-27T19:33:08+00:00 EPA: Fix FamDecl range The span was incorrect if opt_datafam_kind_sig was empty - - - - - f8f384a8 by Ben Gamari at 2024-03-29T01:23:03-04:00 Fix type of _get_osfhandle foreign import Fixes #24601. - - - - - 00d3ecf0 by Alan Zimmerman at 2024-03-29T12:19:10+00:00 EPA: Extend StringLiteral range to include trailing commas This goes slightly against the exact printing philosophy where trailing decorations should be in an annotation, but the practicalities of adding it to the WarningTxt environment, and the problems caused by deviating do not make a more principles approach worthwhile. - - - - - efab3649 by brandon s allbery kf8nh at 2024-03-31T20:04:01-04:00 clarify Note [Preproccesing invocations] - - - - - c8a4c050 by Ben Gamari at 2024-04-02T12:50:35-04:00 rts: Fix TSAN_ENABLED CPP guard This should be `#if defined(TSAN_ENABLED)`, not `#if TSAN_ENABLED`, lest we suffer warnings. - - - - - e91dad93 by Cheng Shao at 2024-04-02T12:50:35-04:00 rts: fix errors when compiling with TSAN This commit fixes rts compilation errors when compiling with TSAN: - xxx_FENCE macros are redefined and trigger CPP warnings. - Use SIZEOF_W. WORD_SIZE_IN_BITS is provided by MachDeps.h which Cmm.h doesn't include by default. - - - - - a9ab9455 by Cheng Shao at 2024-04-02T12:50:35-04:00 rts: fix clang-specific errors when compiling with TSAN This commit fixes clang-specific rts compilation errors when compiling with TSAN: - clang doesn't have -Wtsan flag - Fix prototype of ghc_tsan_* helper functions - __tsan_atomic_* functions aren't clang built-ins and sanitizer/tsan_interface_atomic.h needs to be included - On macOS, TSAN runtime library is libclang_rt.tsan_osx_dynamic.dylib, not libtsan. -fsanitize-thread as a link-time flag will take care of linking the TSAN runtime library anyway so remove tsan as an rts extra library - - - - - 865bd717 by Cheng Shao at 2024-04-02T12:50:35-04:00 compiler: fix github link to __tsan_memory_order in a comment - - - - - 07cb627c by Cheng Shao at 2024-04-02T12:50:35-04:00 ci: improve TSAN CI jobs - Run TSAN jobs with +thread_sanitizer_cmm which enables Cmm instrumentation as well. - Run TSAN jobs in deb12 which ships gcc-12, a reasonably recent gcc that @bgamari confirms he's using in #GHC:matrix.org. Ideally we should be using latest clang release for latest improvements in sanitizers, though that's left as future work. - Mark TSAN jobs as manual+allow_failure in validate pipelines. The purpose is to demonstrate that we have indeed at least fixed building of TSAN mode in CI without blocking the patch to land, and once merged other people can begin playing with TSAN using their own dev setups and feature branches. - - - - - a1c18c7b by Andrei Borzenkov at 2024-04-02T12:51:11-04:00 Merge tc_infer_hs_type and tc_hs_type into one function using ExpType philosophy (#24299, #23639) This patch implements refactoring which is a prerequisite to updating kind checking of type patterns. This is a huge simplification of the main worker that checks kind of HsType. It also fixes the issues caused by previous code duplication, e.g. that we didn't add module finalizers from splices in inference mode. - - - - - 817e8936 by Rodrigo Mesquita at 2024-04-02T20:13:05-04:00 th: Hide the Language.Haskell.TH.Lib.Internal module from haddock Fixes #24562 - - - - - b36ee57b by Sylvain Henry at 2024-04-02T20:13:46-04:00 JS: reenable h$appendToHsString optimization (#24495) The optimization introducing h$appendToHsString wasn't kicking in anymore (while it did in 9.8.1) because of the changes introduced in #23270 (7e0c8b3bab30). This patch reenables the optimization by matching on case-expression, as done in Cmm for unpackCString# standard thunks. The test is also T24495 added in the next commits (two commits for ease of backporting to 9.8). - - - - - 527616e9 by Sylvain Henry at 2024-04-02T20:13:46-04:00 JS: fix h$appendToHsString implementation (#24495) h$appendToHsString needs to wrap its argument in an updatable thunk to behave like unpackAppendCString#. Otherwise if a SingleEntry thunk is passed, it is stored as-is in a CONS cell, making the resulting list impossible to deepseq (forcing the thunk doesn't update the contents of the CONS cell)! The added test checks that the optimization kicks in and that h$appendToHsString works as intended. Fix #24495 - - - - - faa30b41 by Simon Peyton Jones at 2024-04-02T20:14:22-04:00 Deal with duplicate tyvars in type declarations GHC was outright crashing before this fix: #24604 - - - - - e0b0c717 by Simon Peyton Jones at 2024-04-02T20:14:58-04:00 Try using MCoercion in exprIsConApp_maybe This is just a simple refactor that makes exprIsConApp_maybe a little bit more direct, simple, and efficient. Metrics: compile_time/bytes allocated geo. mean -0.1% minimum -2.0% maximum -0.0% Not a big gain, but worthwhile given that the code is, if anything, easier to grok. - - - - - 15f4d867 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Initial ./configure support for selecting I/O managers In this patch we just define new CPP vars, but don't yet use them or replace the existing approach. That will follow. The intention here is that every I/O manager can be enabled/disabled at GHC build time (subject to some constraints). More than one I/O manager can be enabled to be built. At least one I/O manager supporting the non-threaded RTS must be enabled as well as at least one supporting the non-threaded RTS. The I/O managers enabled here will become the choices available at runtime at RTS startup (in later patches). The choice can be made with RTS flags. There are separate sets of choices for the threaded and non-threaded RTS ways, because most I/O managers are specific to these ways. Furthermore we must establish a default I/O manager for the threaded and non-threaded RTS. Most I/O managers are platform-specific so there are checks to ensure each one can be enabled on the platform. Such checks are also where (in future) any system dependencies (e.g. libraries) can be checked. The output is a set of CPP flags (in the mk/config.h file), with one flag per named I/O manager: * IOMGR_BUILD_<name> : which ones should be built (some) * IOMGR_DEFAULT_NON_THREADED_<name> : which one is default (exactly one) * IOMGR_DEFAULT_THREADED_<name> : which one is default (exactly one) and a set of derived flags in IOManager.h * IOMGR_ENABLED_<name> : enabled for the current RTS way Note that IOMGR_BUILD_<name> just says that an I/O manager will be built for _some_ RTS way (i.e. threaded or non-threaded). The derived flags IOMGR_ENABLED_<name> in IOManager.h say if each I/O manager is enabled in the "current" RTS way. These are the ones that can be used for conditional compilation of the I/O manager code. Co-authored-by: Pi Delport <pi at well-typed.com> - - - - - 85b0f87a by Duncan Coutts at 2024-04-03T01:27:17-04:00 Change the handling of the RTS flag --io-manager= Now instead of it being just used on Windows to select between the WinIO vs the MIO or Win32-legacy I/O managers, it is now used on all platforms for selecting the I/O manager to use. Right now it remains the case that there is only an actual choice on Windows, but that will change later. Document the --io-manager flag in the user guide. This change is also reflected in the RTS flags types in the base library. Deprecate the export of IoSubSystem from GHC.RTS.Flags with a message to import it from GHC.IO.Subsystem. The way the 'IoSubSystem' is detected also changes. Instead of looking at the RTS flag, there is now a C bool global var in the RTS which gets set on startup when the I/O manager is selected. This bool var says whether the selected I/O manager classifies as "native" on Windows, which in practice means the WinIO I/O manager has been selected. Similarly, the is_io_mng_native_p RTS helper function is re-implemented in terms of the selected I/O manager, rather than based on the RTS flags. We do however remove the ./configure --native-io-manager flag because we're bringing the WinIO/MIO/Win32-legacy choice under the new general scheme for selecting I/O managers, and that new scheme involves no ./configure time user choices, just runtime RTS flag choices. - - - - - 1a8f020f by Duncan Coutts at 2024-04-03T01:27:17-04:00 Convert {init,stop,exit}IOManager to switch style Rather than ad-hoc cpp conitionals on THREADED_RTS and mingw32_HOST_OS, we use a style where we switch on the I/O manager impl, with cases for each I/O manager impl. - - - - - a5bad3d2 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Split up the CapIOManager content by I/O manager Using the new IOMGR_ENABLED_<name> CPP defines. - - - - - 1d36e609 by Duncan Coutts at 2024-04-03T01:27:17-04:00 Convert initIOManagerAfterFork and wakeupIOManager to switch style - - - - - c2f26f36 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move most of waitRead#/Write# from cmm to C Moves it into the IOManager.c where we can follow the new pattern of switching on the selected I/O manager. - - - - - 457705a8 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move most of the delay# impl from cmm to C Moves it into the IOManager.c where we can follow the new pattern of switching on the selected I/O manager. Uses a new IOManager API: syncDelay, following the naming convention of sync* for thread-synchronous I/O & timer/delay operations. As part of porting from cmm to C, we maintain the rule that the why_blocked gets accessed using load acquire and store release atomic memory operations. There was one exception to this rule: in the delay# primop cmm code on posix (not win32), the why_blocked was being updated using a store relaxed, not a store release. I've no idea why. In this convesion I'm playing it safe here and using store release consistently. - - - - - e93058e0 by Duncan Coutts at 2024-04-03T01:27:18-04:00 insertIntoSleepingQueue is no longer public No longer defined in IOManager.h, just a private function in IOManager.c. Since it is no longer called from cmm code, just from syncDelay. It ought to get moved further into the select() I/O manager impl, rather than living in IOManager.c. On the other hand appendToIOBlockedQueue is still called from cmm code in the win32-legacy I/O manager primops async{Read,Write}#, and it is also used by the select() I/O manager. Update the CPP and comments to reflect this. - - - - - 60ce9910 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move anyPendingTimeoutsOrIO impl from .h to .c The implementation is eventually going to need to use more private things, which will drag in unwanted includes into IOManager.h, so it's better to move the impl out of the header file and into the .c file, at the slight cost of it no longer being inline. At the same time, change to the "switch (iomgr_type)" style. - - - - - f70b8108 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Take a simpler approach to gcc warnings in IOManager.c We have lots of functions with conditional implementations for different I/O managers. Some functions, for some I/O managers, naturally have implementations that do nothing or barf. When only one such I/O manager is enabled then the whole function implementation will have an implementation that does nothing or barfs. This then results in warnings from gcc that parameters are unused, or that the function should be marked with attribute noreturn (since barf does not return). The USED_IF_THREADS trick for fine-grained warning supression is fine for just two cases, but an equivalent here would need USED_IF_THE_ONLY_ENABLED_IOMGR_IS_X_OR_Y which would have combinitorial blowup. So we take a coarse grained approach and simply disable these two warnings for the whole file. So we use a GCC pragma, with its handy push/pop support: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsuggest-attribute=noreturn" #pragma GCC diagnostic ignored "-Wunused-parameter" ... #pragma GCC diagnostic pop - - - - - b48805b9 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add a new trace class for the iomanager It makes sense now for it to be separate from the scheduler class of tracers. Enabled with +RTS -Do. Document the -Do debug flag in the user guide. - - - - - f0c1f862 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Have the throwTo impl go via (new) IOManager APIs rather than directly operating on the IO manager's data structures. Specifically, when thowing an async exception to a thread that is blocked waiting for I/O or waiting for a timer, then we want to cancel that I/O waiting or cancel the timer. Currently this is done directly in removeFromQueues() in RaiseAsync.c. We want it to go via proper APIs both for modularity but also to let us support multiple I/O managers. So add sync{IO,Delay}Cancel, which is the cancellation for the corresponding sync{IO,Delay}. The implementations of these use the usual "switch (iomgr_type)" style. - - - - - 4f9e9c4e by Duncan Coutts at 2024-04-03T01:27:18-04:00 Move awaitEvent into a proper IOManager API and have the scheduler use it. Previously the scheduler calls awaitEvent directly, and awaitEvent is implemented directly in the RTS I/O managers (select, win32). This relies on the old scheme where there's a single active I/O manager for each platform and RTS way. We want to move that to go via an API in IOManager.{h,c} which can then call out to the active I/O manager. Also take the opportunity to split awaitEvent into two. The existing awaitEvent has a bool wait parameter, to say if the call should be blocking or non-blocking. We split this into two separate functions: pollCompletedTimeoutsOrIO and awaitCompletedTimeoutsOrIO. We split them for a few reasons: they have different post-conditions (specifically the await version is supposed to guarantee that there are threads runnable when it completes). Secondly, it is also anticipated that in future I/O managers the implementations of the two cases will be simpler if they are separated. - - - - - 5ad4b30f by Duncan Coutts at 2024-04-03T01:27:18-04:00 Rename awaitEvent in select and win32 I/O managers These are now just called from IOManager.c and are the per-I/O manager backend impls (whereas previously awaitEvent was the entry point). Follow the new naming convention in the IOManager.{h,c} of awaitCompletedTimeoutsOrIO, with the I/O manager's name as a suffix: so awaitCompletedTimeoutsOrIO{Select,Win32}. - - - - - d30c6bc6 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Tidy up a couple things in Select.{h,c} Use the standard #include {Begin,End}Private.h style rather than RTS_PRIVATE on individual decls. And conditionally build the code for the select I/O manager based on the new CPP IOMGR_ENABLED_SELECT rather than on THREADED_RTS. - - - - - 4161f516 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add an IOManager API for scavenging TSO blocked_info When the GC scavenges a TSO it needs to scavenge the tso->blocked_info but the blocked_info is a big union and what lives there depends on the two->why_blocked, which for I/O-related reasons is something that in principle is the responsibility of the I/O manager and not the GC. So the right thing to do is for the GC to ask the I/O manager to sscavenge the blocked_info if it encounters any I/O-related why_blocked reasons. So we add scavengeTSOIOManager in IOManager.{h,c} with the usual style. Now as it happens, right now, there is no special scavenging to do, so the implementation of scavengeTSOIOManager is a fancy no-op. That's because the select I/O manager uses only the fd and target members, which are not GC pointers, and the win32-legacy I/O manager _ought_ to be using GC-managed heap objects for the StgAsyncIOResult but it is actually usingthe C heap, so again no GC pointers. If the win32-legacy were doing this more sensibly, then scavengeTSOIOManager would be the right place to do the GC magic. Future I/O managers will need GC heap objects in the tso->blocked_info and will make use of this functionality. - - - - - 94a87d21 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add I/O manager API notifyIOManagerCapabilitiesChanged Used in setNumCapabilities. It only does anything for MIO on Posix. Previously it always invoked Haskell code, but that code only did anything on non-Windows (and non-JS), and only threaded. That currently effectively means the MIO I/O manager on Posix. So now it only invokes it for the MIO Posix case. - - - - - 3be6d591 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Select an I/O manager early in RTS startup We need to select the I/O manager to use during startup before the per-cap I/O manager initialisation. - - - - - aaa294d0 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Make struct CapIOManager be fully opaque Provide an opaque (forward) definition in Capability.h (since the cap contains a *CapIOManager) and then only provide a full definition in a new file IOManagerInternals.h. This new file is only supposed to be included by the IOManager implementation, not by its users. So that means IOManager.c and individual I/O manager implementations. The posix/Signals.c still needs direct access, but that should be eliminated. Anything that needs direct access either needs to be clearly part of an I/O manager (e.g. the sleect() one) or go via a proper API. - - - - - 877a2a80 by Duncan Coutts at 2024-04-03T01:27:18-04:00 The select() I/O manager does have some global initialisation It's just to make sure an exception CAF is a GC root. - - - - - 9c51473b by Duncan Coutts at 2024-04-03T01:27:18-04:00 Add tracing for the main I/O manager actions Using the new tracer class. Note: The unconditional definition of showIOManager should be compatible with the debugTrace change in 7c7d1f6. Co-authored-by: Pi Delport <pi at well-typed.com> - - - - - c7d3e3a3 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Include the default I/O manager in the +RTS --info output Document the extra +RTS --info output in the user guide - - - - - 8023bad4 by Duncan Coutts at 2024-04-03T01:27:18-04:00 waitRead# / waitWrite# do not work for win32-legacy I/O manager Previously it was unclear that they did not work because the code path was shared with other I/O managers (in particular select()). Following the code carefully shows that what actually happens is that the calling thread would block forever: the thread will be put into the blocked queue, but no other action is scheduled that will ever result in it getting unblocked. It's better to just fail loudly in case anyone accidentally calls it, also it's less confusing code. - - - - - 83a74d20 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Conditionally ignore some GCC warnings Some GCC versions don't know about some warnings, and they complain that we're ignoring unknown warnings. So we try to ignore the warning based on the GCC version. - - - - - 1adc6fa4 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Accept changes to base-exports All the changes are in fact not changes at all. Previously, the IoSubSystem data type was defined in GHC.RTS.Flags and exported from both GHC.RTS.Flags and GHC.IO.SubSystem. Now, the data type is defined in GHC.IO.SubSystem and still exported from both modules. Therefore, the same exports and same instances are still available from both modules. But the base-exports records only the defining module, and so it looks like a change when it is fully compatible. Related: we do add a deprecation to the export of the type via GHC.RTS.Flags, telling people to use the export from GHC.IO.SubSystem. Also the sort order for some unrelated Show instances changed. No idea why. The same changes apply in the other versions, with a few more changes due to sort order weirdness. - - - - - 8d950968 by Duncan Coutts at 2024-04-03T01:27:18-04:00 Accept metric decrease in T12227 I can't think of any good reason that anything in this MR should have changed the number of allocations, up or down. (Yes this is an empty commit.) Metric Decrease: T12227 - - - - - e869605e by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Several improvements to the handling of coercions * Make `mkSymCo` and `mkInstCo` smarter Fixes #23642 * Fix return role of `SelCo` in the coercion optimiser. Fixes #23617 * Make the coercion optimiser `opt_trans_rule` work better for newtypes Fixes #23619 - - - - - 1efd0714 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 FloatOut: improve floating for join point See the new Note [Floating join point bindings]. * Completely get rid of the complicated join_ceiling nonsense, which I have never understood. * Do not float join points at all, except perhaps to top level. * Some refactoring around wantToFloat, to treat Rec and NonRec more uniformly - - - - - 9c00154d by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Improve eta-expansion through call stacks See Note [Eta expanding through CallStacks] in GHC.Core.Opt.Arity This is a one-line change, that fixes an inconsistency - || isCallStackPredTy ty + || isCallStackPredTy ty || isCallStackTy ty - - - - - 95a9a172 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Spelling, layout, pretty-printing only - - - - - bdf1660f by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Improve exprIsConApp_maybe a little Eliminate a redundant case at birth. This sometimes reduces Simplifier iterations. See Note [Case elim in exprIsConApp_maybe]. - - - - - 609cd32c by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Inline GHC.HsToCore.Pmc.Solver.Types.trvVarInfo When exploring compile-time regressions after meddling with the Simplifier, I discovered that GHC.HsToCore.Pmc.Solver.Types.trvVarInfo was very delicately balanced. It's a small, heavily used, overloaded function and it's important that it inlines. By a fluke it was before, but at various times in my journey it stopped doing so. So I just added an INLINE pragma to it; no sense in depending on a delicately-balanced fluke. - - - - - ae24c9bc by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Slight improvement in WorkWrap Ensure that WorkWrap preserves lambda binders, in case of join points. Sadly I have forgotten why I made this change (it was while I was doing a lot of meddling in the Simplifier, but * it does no harm, * it is slightly more efficient, and * presumably it made something better! Anyway I have kept it in a separate commit. - - - - - e9297181 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Use named record fields for the CastIt { ... } data constructor This is a pure refactor - - - - - b4581e23 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Remove a long-commented-out line Pure refactoring - - - - - e026bdf2 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The main changes are below. There are also many new or rewritten Notes. Avoiding simplifying repeatedly ~~~~~~~~~~~~~~~ See Note [Avoiding simplifying repeatedly] * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env. Currently used only for the next point: avoiding repeatedly simplifying coercions. * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] * Improve the case-merge transformation: - Move the main code to `GHC.Core.Utils.mergeCaseAlts`, to join `filterAlts` and friends. See Note [Merge Nested Cases] in GHC.Core.Utils. - Add a new case for `tagToEnum#`; see wrinkle (MC3). - Add a new case to look through join points: see wrinkle (MC4) postInlineUnconditionally ~~~~~~~~~~~~~~~~~~~~~~~~~ * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. * Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. * Improve occurrence analyis for bottoming function calls, to help postInlineUnconditionally. See Note [Bottoming function calls] in GHC.Core.Opt.OccurAnal Inlining generally ~~~~~~~~~~~~~~~~~~ * In GHC.Core.Opt.Simplify.Utils.interestingCallContext, use RhsCtxt NonRecursive (not BoringCtxt) for a plain-seq case. See Note [Seq is boring] Also, wrinkle (SB1), inline in that `seq` context only for INLINE functions (UnfWhen guidance). * In GHC.Core.Opt.Simplify.Utils.interestingArg, - return ValueArg for OtherCon [c1,c2, ...], but - return NonTrivArg for OtherCon [] This makes a function a little less likely to inline if all we know is that the argument is evaluated, but nothing else. * isConLikeUnfolding is no longer true for OtherCon {}. This propagates to exprIsConLike. Con-like-ness has /positive/ information. Join points ~~~~~~~~~~~ * Be very careful about inlining join points. See these two long Notes Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline * When making join points, don't do so if the join point is so small it will immediately be inlined; check uncondInlineJoin. * In GHC.Core.Opt.Simplify.Inline.tryUnfolding, improve the inlining heuristics for join points. In general we /do not/ want to inline join points /even if they are small/. See Note [Duplicating join points] GHC.Core.Opt.Simplify.Iteration. But sometimes we do: see Note [Inlining join points] in GHC.Core.Opt.Simplify.Inline; and the new `isBetterUnfoldingThan` function. * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * In GHC.Core.Unfold.sizeExpr, make jumps small, so that we don't penalise having a non-inlined join point. Performance changes ~~~~~~~~~~~~~~~~~~~ * Binary sizes fall by around 2.6%, according to nofib. * Compile times improve slightly. Here are the figures over 1%. I investiate the biggest differnce in T18304. It's a very small module, just a few hundred nodes. The large percentage difffence is due to a single function that didn't quite inline before, and does now, making code size a bit bigger. I decided gains outweighed the losses. Metrics: compile_time/bytes allocated (changes over +/- 1%) ------------------------------------------------ CoOpt_Singletons(normal) -9.2% GOOD LargeRecord(normal) -23.5% GOOD MultiComponentModulesRecomp(normal) +1.2% MultiLayerModulesTH_OneShot(normal) +4.1% BAD PmSeriesS(normal) -3.8% PmSeriesV(normal) -1.5% T11195(normal) -1.3% T12227(normal) -20.4% GOOD T12545(normal) -3.2% T12707(normal) -2.1% GOOD T13253(normal) -1.2% T13253-spj(normal) +8.1% BAD T13386(normal) -3.1% GOOD T14766(normal) -2.6% GOOD T15164(normal) -1.4% T15304(normal) +1.2% T15630(normal) -8.2% T15630a(normal) NEW T15703(normal) -14.7% GOOD T16577(normal) -2.3% GOOD T17516(normal) -39.7% GOOD T18140(normal) +1.2% T18223(normal) -17.1% GOOD T18282(normal) -5.0% GOOD T18304(normal) +10.8% BAD T18923(normal) -2.9% GOOD T1969(normal) +1.0% T19695(normal) -1.5% T20049(normal) -12.7% GOOD T21839c(normal) -4.1% GOOD T3064(normal) -1.5% T3294(normal) +1.2% BAD T4801(normal) +1.2% T5030(normal) -15.2% GOOD T5321Fun(normal) -2.2% GOOD T6048(optasm) -16.8% GOOD T783(normal) -1.2% T8095(normal) -6.0% GOOD T9630(normal) -4.7% GOOD T9961(normal) +1.9% BAD WWRec(normal) -1.4% info_table_map_perf(normal) -1.3% parsing001(normal) +1.5% geo. mean -2.0% minimum -39.7% maximum +10.8% * Runtimes generally improve. In the testsuite perf/should_run gives: Metrics: runtime/bytes allocated ------------------------------------------ Conversions(normal) -0.3% T13536a(optasm) -41.7% GOOD T4830(normal) -0.1% haddock.Cabal(normal) -0.1% haddock.base(normal) -0.1% haddock.compiler(normal) -0.1% geo. mean -0.8% minimum -41.7% maximum +0.0% * For runtime, nofib is a better test. The news is mostly good. Here are the number more than +/- 0.1%: # bytes allocated ==========================++========== imaginary/digits-of-e1 || -14.40% imaginary/digits-of-e2 || -4.41% imaginary/paraffins || -0.17% imaginary/rfib || -0.15% imaginary/wheel-sieve2 || -0.10% real/compress || -0.47% real/fluid || -0.10% real/fulsom || +0.14% real/gamteb || -1.47% real/gg || -0.20% real/infer || +0.24% real/pic || -0.23% real/prolog || -0.36% real/scs || -0.46% real/smallpt || +4.03% shootout/k-nucleotide || -20.23% shootout/n-body || -0.42% shootout/spectral-norm || -0.13% spectral/boyer2 || -3.80% spectral/constraints || -0.27% spectral/hartel/ida || -0.82% spectral/mate || -20.34% spectral/para || +0.46% spectral/rewrite || +1.30% spectral/sphere || -0.14% ==========================++========== geom mean || -0.59% real/smallpt has a huge nest of local definitions, and I could not pin down a reason for a regression. But there are three big wins! Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12707 T13386 T13536a T14766 T15703 T16577 T17516 T18223 T18282 T18923 T21839c T20049 T5321Fun T5030 T6048 T8095 T9630 T783 Metric Increase: MultiLayerModulesTH_OneShot T13253-spj T18304 T18698a T9961 T3294 - - - - - 27db3c5e by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Testsuite message changes from simplifier improvements - - - - - 271a7812 by Simon Peyton Jones at 2024-04-03T01:27:55-04:00 Account for bottoming functions in OccurAnal This fixes #24582, a small but long-standing bug - - - - - 0fde229f by Ben Gamari at 2024-04-04T07:04:58-04:00 testsuite: Introduce template-haskell-exports test - - - - - 0c4a9686 by Luite Stegeman at 2024-04-04T07:05:39-04:00 Update correct counter in bumpTickyAllocd - - - - - 5f085d3a by Fendor at 2024-04-04T14:47:33-04:00 Replace `SizedSeq` with `FlatBag` for flattened structure LinkedLists are notoriously memory ineffiecient when all we do is traversing a structure. As 'UnlinkedBCO' has been identified as a data structure that impacts the overall memory usage of GHCi sessions, we avoid linked lists and prefer flattened structure for storing. We introduce a new memory efficient representation of sequential elements that has special support for the cases: * Empty * Singleton * Tuple Elements This improves sharing in the 'Empty' case and avoids the overhead of 'Array' until its constant overhead is justified. - - - - - 82cfe10c by Fendor at 2024-04-04T14:47:33-04:00 Compact FlatBag array representation `Array` contains three additional `Word`'s we do not need in `FlatBag`. Move `FlatBag` to `SmallArray`. Expand the API of SmallArray by `sizeofSmallArray` and add common traversal functions, such as `mapSmallArray` and `foldMapSmallArray`. Additionally, allow users to force the elements of a `SmallArray` via `rnfSmallArray`. - - - - - 36a75b80 by Andrei Borzenkov at 2024-04-04T14:48:10-04:00 Change how invisible patterns represented in haskell syntax and TH AST (#24557) Before this patch: data ArgPat p = InvisPat (LHsType p) | VisPat (LPat p) With this patch: data Pat p = ... | InvisPat (LHsType p) ... And the same transformation in the TH land. The rest of the changes is just updating code to handle new AST and writing tests to check if it is possible to create invalid states using TH. Metric Increase: MultiLayerModulesTH_OneShot - - - - - 28009fbc by Matthew Pickering at 2024-04-04T14:48:46-04:00 Fix off by one error in seekBinNoExpand and seekBin - - - - - 9b9e031b by Ben Gamari at 2024-04-04T21:30:08-04:00 compiler: Allow more types in GHCForeignImportPrim For many, many years `GHCForeignImportPrim` has suffered from the rather restrictive limitation of not allowing any non-trivial types in arguments or results. This limitation was justified by the code generator allegely barfing in the presence of such types. However, this restriction appears to originate well before the NCG rewrite and the new NCG does not appear to have any trouble with such types (see the added `T24598` test). Lift this restriction. Fixes #24598. - - - - - 1324b862 by Alan Zimmerman at 2024-04-04T21:30:44-04:00 EPA: Use EpaLocation not SrcSpan in ForeignDecls This allows us to update them for makeDeltaAst in ghc-exactprint - - - - - 19883a23 by Alan Zimmerman at 2024-04-05T16:58:17-04:00 EPA: Use EpaLocation for RecFieldsDotDot So we can update it to a delta position in makeDeltaAst if needed. - - - - - e8724327 by Matthew Pickering at 2024-04-05T16:58:53-04:00 Remove accidentally committed test.hs - - - - - 88cb3e10 by Fendor at 2024-04-08T09:03:34-04:00 Avoid UArray when indexing is not required `UnlinkedBCO`'s can occur many times in the heap. Each `UnlinkedBCO` references two `UArray`'s but never indexes them. They are only needed to encode the elements into a `ByteArray#`. The three words for the lower bound, upper bound and number of elements are essentially unused, thus we replace `UArray` with a wrapper around `ByteArray#`. This saves us up to three words for each `UnlinkedBCO`. Further, to avoid re-allocating these words for `ResolvedBCO`, we repeat the procedure for `ResolvedBCO` and add custom `Binary` and `Show` instances. For example, agda's repl session has around 360_000 UnlinkedBCO's, so avoiding these three words is already saving us around 8MB residency. - - - - - f2cc1107 by Fendor at 2024-04-08T09:04:11-04:00 Never UNPACK `FastMutInt` for counting z-encoded `FastString`s In `FastStringTable`, we count the number of z-encoded FastStrings that exist in a GHC session. We used to UNPACK the counters to not waste memory, but live retainer analysis showed that we allocate a lot of `FastMutInt`s, retained by `mkFastZString`. We lazily compute the `FastZString`, only incrementing the counter when the `FastZString` is forced. The function `mkFastStringWith` calls `mkZFastString` and boxes the `FastMutInt`, leading to the following core: mkFastStringWith = \ mk_fs _ -> = case stringTable of { FastStringTable _ n_zencs segments# _ -> ... case ((mk_fs (I# ...) (FastMutInt n_zencs)) `cast` <Co:2> :: ...) ... Marking this field as `NOUNPACK` avoids this reboxing, eliminating the allocation of a fresh `FastMutInt` on every `FastString` allocation. - - - - - c6def949 by Matthew Pickering at 2024-04-08T16:06:51-04:00 Force in_multi to avoid retaining entire hsc_env - - - - - fbb91a63 by Fendor at 2024-04-08T16:06:51-04:00 Eliminate name thunk in declaration fingerprinting Thunk analysis showed that we have about 100_000 thunks (in agda and `-fwrite-simplified-core`) pointing to the name of the name decl. Forcing this thunk fixes this issue. The thunk created here is retained by the thunk created by forkM, it is better to eagerly force this because the result (a `Name`) is already retained indirectly via the `IfaceDecl`. - - - - - 3b7b0c1c by Alan Zimmerman at 2024-04-08T16:07:27-04:00 EPA: Use EpaLocation in WarningTxt This allows us to use an EpDelta if needed when using makeDeltaAst. - - - - - 12b997df by Alan Zimmerman at 2024-04-08T16:07:27-04:00 EPA: Move DeltaPos and EpaLocation' into GHC.Types.SrcLoc This allows us to use a NoCommentsLocation for the possibly trailing comma location in a StringLiteral. This in turn allows us to correctly roundtrip via makeDeltaAst. - - - - - 868c8a78 by Fendor at 2024-04-09T08:51:50-04:00 Prefer packed representation for CompiledByteCode As there are many 'CompiledByteCode' objects alive during a GHCi session, representing its element in a more packed manner improves space behaviour at a minimal cost. When running GHCi on the agda codebase, we find around 380 live 'CompiledByteCode' objects. Packing their respective 'UnlinkedByteCode' can save quite some pointers. - - - - - be3bddde by Alan Zimmerman at 2024-04-09T08:52:26-04:00 EPA: Capture all comments in a ClassDecl Hopefully the final fix needed for #24533 - - - - - 3d0806fc by Jade at 2024-04-10T05:39:53-04:00 Validate -main-is flag using parseIdentifier Fixes #24368 - - - - - dd530bb7 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: free error message before returning Fixes a memory leak in rts/linker/PEi386.c - - - - - e008a19a by Alexis King at 2024-04-10T05:40:29-04:00 linker: Avoid linear search when looking up Haskell symbols via dlsym See the primary Note [Looking up symbols in the relevant objects] for a more in-depth explanation. When dynamically loading a Haskell symbol (typical when running a splice or GHCi expression), before this commit we would search for the symbol in all dynamic libraries that were loaded. However, this could be very inefficient when too many packages are loaded (which can happen if there are many package dependencies) because the time to lookup the would be linear in the number of packages loaded. This commit drastically improves symbol loading performance by introducing a mapping from units to the handles of corresponding loaded dlls. These handles are returned by dlopen when we load a dll, and can then be used to look up in a specific dynamic library. Looking up a given Name is now much more precise because we can get lookup its unit in the mapping and lookup the symbol solely in the handles of the dynamic libraries loaded for that unit. In one measurement, the wait time before the expression was executed went from +-38 seconds down to +-2s. This commit also includes Note [Symbols may not be found in pkgs_loaded], explaining the fallback to the old behaviour in case no dll can be found in the unit mapping for a given Name. Fixes #23415 Co-authored-by: Rodrigo Mesquita (@alt-romes) - - - - - dcfaa190 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 rts: Make addDLL a wrapper around loadNativeObj Rewrite the implementation of `addDLL` as a wrapper around the more principled `loadNativeObj` rts linker function. The latter should be preferred while the former is preserved for backwards compatibility. `loadNativeObj` was previously only available on ELF platforms, so this commit further refactors the rts linker to transform loadNativeObj_ELF into loadNativeObj_POSIX, which is available in ELF and MachO platforms. The refactor made it possible to remove the `dl_mutex` mutex in favour of always using `linker_mutex` (rather than a combination of both). Lastly, we implement `loadNativeObj` for Windows too. - - - - - 12931698 by Rodrigo Mesquita at 2024-04-10T05:40:29-04:00 Use symbol cache in internal interpreter too This commit makes the symbol cache that was used by the external interpreter available for the internal interpreter too. This follows from the analysis in #23415 that suggests the internal interpreter could benefit from this cache too, and that there is no good reason not to have the cache for it too. It also makes it a bit more uniform to have the symbol cache range over both the internal and external interpreter. This commit also refactors the cache into a function which is used by both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the caching logic to `lookupSymbolInDLL` too. - - - - - dccd3ea1 by Ben Gamari at 2024-04-10T05:40:29-04:00 testsuite: Add test for lookupSymbolInNativeObj - - - - - 1b1a92bd by Alan Zimmerman at 2024-04-10T05:41:05-04:00 EPA: Remove unnecessary XRec in CompleteMatchSig The XRec for [LIdP pass] is not needed for exact printing, remove it. - - - - - 6e18ce2b by Ben Gamari at 2024-04-12T08:16:09-04:00 users-guide: Clarify language extension documentation Over the years the users guide's language extension documentation has gone through quite a few refactorings. In the process some of the descriptions have been rendered non-sensical. For instance, the description of `NoImplicitPrelude` actually describes the semantics of `ImplicitPrelude`. To fix this we: * ensure that all extensions are named in their "positive" sense (e.g. `ImplicitPrelude` rather than `NoImplicitPrelude`). * rework the documentation to avoid flag-oriented wording like "enable" and "disable" * ensure that the polarity of the documentation is consistent with reality. Fixes #23895. - - - - - a933aff3 by Zubin Duggal at 2024-04-12T08:16:45-04:00 driver: Make `checkHomeUnitsClosed` faster The implementation of `checkHomeUnitsClosed` was traversing every single path in the unit dependency graph - this grows exponentially and quickly grows to be infeasible on larger unit dependency graphs. Instead we replace this with a faster implementation which follows from the specificiation of the closure property - there is a closure error if there are units which are both are both (transitively) depended upon by home units and (transitively) depend on home units, but are not themselves home units. To compute the set of units required for closure, we first compute the closure of the unit dependency graph, then the transpose of this closure, and find all units that are reachable from the home units in the transpose of the closure. - - - - - 23c3e624 by Andreas Klebinger at 2024-04-12T08:17:21-04:00 RTS: Emit warning when -M < -H Fixes #24487 - - - - - d23afb8c by Ben Gamari at 2024-04-12T08:17:56-04:00 testsuite: Add broken test for CApiFFI with -fprefer-bytecode See #24634. - - - - - a4bb3a51 by Ben Gamari at 2024-04-12T08:18:32-04:00 base: Deprecate GHC.Pack As proposed in #21461. Closes #21540. - - - - - 55eb8c98 by Ben Gamari at 2024-04-12T08:19:08-04:00 ghc-internal: Fix mentions of ghc-internal in deprecation warnings Closes #24609. - - - - - b0fbd181 by Ben Gamari at 2024-04-12T08:19:44-04:00 rts: Implement set_initial_registers for AArch64 Fixes #23680. - - - - - 14c9ec62 by Ben Gamari at 2024-04-12T08:20:20-04:00 ghcup-metadata: Use Debian 9 binaries on Ubuntu 16, 17 Closes #24646. - - - - - 35a1621e by Ben Gamari at 2024-04-12T08:20:55-04:00 Bump unix submodule to 2.8.5.1 Closes #24640. - - - - - a1c24df0 by Finley McIlwaine at 2024-04-12T08:21:31-04:00 Correct default -funfolding-use-threshold in docs - - - - - 0255d03c by Oleg Grenrus at 2024-04-12T08:22:07-04:00 FastString is a __Modified__ UTF-8 - - - - - c3489547 by Matthew Pickering at 2024-04-12T13:13:44-04:00 rts: Improve tracing message when nursery is resized It is sometimes more useful to know how much bigger or smaller the nursery got when it is resized. In particular I am trying to investigate situations where we end up with fragmentation due to the nursery (#24577) - - - - - 5e4f4ba8 by Simon Peyton Jones at 2024-04-12T13:14:20-04:00 Don't generate wrappers for `type data` constructors with StrictData Previously, the logic for checking if a data constructor needs a wrapper or not would take into account whether the constructor's fields have explicit strictness (e.g., `data T = MkT !Int`), but the logic would _not_ take into account whether `StrictData` was enabled. This meant that something like `type data T = MkT Int` would incorrectly generate a wrapper for `MkT` if `StrictData` was enabled, leading to the horrible errors seen in #24620. To fix this, we disable generating wrappers for `type data` constructors altogether. Fixes #24620. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - dbdf1995 by Alex Mason at 2024-04-15T15:28:26+10:00 Implements MO_S_Mul2 and MO_U_Mul2 using the UMULH, UMULL and SMULH instructions for AArch64 Also adds a test for MO_S_Mul2 - - - - - 42bd0407 by Teo Camarasu at 2024-04-16T20:06:39-04:00 Make template-haskell a stage1 package Promoting template-haskell from a stage0 to a stage1 package means that we can much more easily refactor template-haskell. We implement this by duplicating the in-tree `template-haskell`. A new `template-haskell-next` library is autogenerated to mirror `template-haskell` `stage1:ghc` to depend on the new interface of the library including the `Binary` instances without adding an explicit dependency on `template-haskell`. This is controlled by the `bootstrap-th` cabal flag When building `template-haskell` modules as part of this vendoring we do not have access to quote syntax, so we cannot use variable quote notation (`'Just`). So we either replace these with hand-written `Name`s or hide the code behind CPP. We can remove the `th_hack` from hadrian, which was required when building stage0 packages using the in-tree `template-haskell` library. For more details see Note [Bootstrapping Template Haskell]. Resolves #23536 Co-Authored-By: Sebastian Graf <sgraf1337 at gmail.com> Co-Authored-By: Matthew Craven <5086-clyring at users.noreply.gitlab.haskell.org> - - - - - 3d973e47 by Ben Gamari at 2024-04-16T20:07:15-04:00 Bump parsec submodule to 3.1.17.0 - - - - - 9d38bfa0 by Simon Peyton Jones at 2024-04-16T20:07:51-04:00 Clone CoVars in CorePrep This MR addresses #24463. It's all explained in the new Note [Cloning CoVars and TyVars] - - - - - 0fe2b410 by Andreas Klebinger at 2024-04-16T20:08:27-04:00 NCG: Fix a bug where we errounously removed a required jump instruction. Add a new method to the Instruction class to check if we can eliminate a jump in favour of fallthrough control flow. Fixes #24507 - - - - - 9f99126a by Teo Camarasu at 2024-04-16T20:09:04-04:00 Fix documentation preview from doc-tarball job - Include all the .html files and assets in the job artefacts - Include all the .pdf files in the job artefacts - Mark the artefact as an "exposed" artefact meaning it turns up in the UI. Resolves #24651 - - - - - 3a0642ea by Ben Gamari at 2024-04-16T20:09:39-04:00 rts: Ignore EINTR while polling in timerfd itimer implementation While the RTS does attempt to mask signals, it may be that a foreign library unmasks them. This previously caused benign warnings which we now ignore. See #24610. - - - - - 9a53cd3f by Alan Zimmerman at 2024-04-16T20:10:15-04:00 EPA: Add additional comments field to AnnsModule This is used in exact printing to store comments coming after the `where` keyword but before any comments allocated to imports or decls. It is used in ghc-exactprint, see https://github.com/alanz/ghc-exactprint/commit/44bbed311fd8f0d053053fef195bf47c17d34fa7 - - - - - e5c43259 by Bryan Richter at 2024-04-16T20:10:51-04:00 Remove unrunnable FreeBSD CI jobs FreeBSD runner supply is inelastic. Currently there is only one, and it's unavailable because of a hardware issue. - - - - - 914eb49a by Ben Gamari at 2024-04-16T20:11:27-04:00 rel-eng: Fix mktemp usage in recompress-all We need a temporary directory, not a file. - - - - - f30e4984 by Teo Camarasu at 2024-04-16T20:12:03-04:00 Fix ghc API link in docs/index.html This was missing part of the unit ID meaning it would 404. Resolves #24674 - - - - - d7a3d6b5 by Ben Gamari at 2024-04-16T20:12:39-04:00 template-haskell: Declare TH.Lib.Internal as not-home Rather than `hide`. Closes #24659. - - - - - 5eaa46e7 by Matthew Pickering at 2024-04-19T02:14:55-04:00 testsuite: Rename isCross() predicate to needsTargetWrapper() isCross() was a misnamed because it assumed that all cross targets would provide a target wrapper, but the two most common cross targets (javascript, wasm) don't need a target wrapper. Therefore we rename this predicate to `needsTargetWrapper()` so situations in the testsuite where we can check whether running executables requires a target wrapper or not. - - - - - 55a9d699 by Simon Peyton Jones at 2024-04-19T02:15:32-04:00 Do not float HNFs out of lambdas This MR adjusts SetLevels so that it is less eager to float a HNF (lambda or constructor application) out of a lambda, unless it gets to top level. Data suggests that this change is a small net win: * nofib bytes-allocated falls by -0.09% (but a couple go up) * perf/should_compile bytes-allocated falls by -0.5% * perf/should_run bytes-allocated falls by -0.1% See !12410 for more detail. When fiddling elsewhere, I also found that this patch had a huge positive effect on the (very delicate) test perf/should_run/T21839r But that improvement doesn't show up in this MR by itself. Metric Decrease: MultiLayerModulesRecomp T15703 parsing001 - - - - - f0701585 by Alan Zimmerman at 2024-04-19T02:16:08-04:00 EPA: Fix comments in mkListSyntaxTy0 Also extend the test to confirm. Addresses #24669, 1 of 4 - - - - - b01c01d4 by Serge S. Gulin at 2024-04-19T02:16:51-04:00 JS: set image `x86_64-linux-deb11-emsdk-closure` for build - - - - - c90c6039 by Alan Zimmerman at 2024-04-19T02:17:27-04:00 EPA: Provide correct span for PatBind And remove unused parameter in checkPatBind Contributes to #24669 - - - - - 26036f96 by Alan Zimmerman at 2024-04-19T13:11:08-04:00 EPA: Fix span for PatBuilderAppType Include the location of the prefix @ in the span for InVisPat. Also removes unnecessary annotations from HsTP. Contributes to #24669 - - - - - dba03aab by Matthew Craven at 2024-04-19T13:11:44-04:00 testsuite: Give the pre_cmd for mhu-perf more time - - - - - d31fbf6c by Krzysztof Gogolewski at 2024-04-19T21:04:09-04:00 Fix quantification order for a `op` b and a %m -> b Fixes #23764 Implements https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0640-tyop-quantification-order.rst Updates haddock submodule. - - - - - 385cd1c4 by Sebastian Graf at 2024-04-19T21:04:45-04:00 Make `seq#` a magic Id and inline it in CorePrep (#24124) We can save much code and explanation in Tag Inference and StgToCmm by making `seq#` a known-key Magic Id in `GHC.Internal.IO` and inline this definition in CorePrep. See the updated `Note [seq# magic]`. I also implemented a new `Note [Flatten case-bind]` to get better code for otherwise nested case scrutinees. I renamed the contructors of `ArgInfo` to use an `AI` prefix in order to resolve the clash between `type CpeApp = CoreExpr` and the data constructor of `ArgInfo`, as well as fixed typos in `Note [CorePrep invariants]`. Fixes #24252 and #24124. - - - - - 275e41a9 by Jade at 2024-04-20T11:10:40-04:00 Put the newline after errors instead of before them This mainly has consequences for GHCi but also slightly alters how the output of GHC on the commandline looks. Fixes: #22499 - - - - - dd339c7a by Teo Camarasu at 2024-04-20T11:11:16-04:00 Remove unecessary stage0 packages Historically quite a few packages had to be stage0 as they depended on `template-haskell` and that was stage0. In #23536 we made it so that was no longer the case. This allows us to remove a bunch of packages from this list. A few still remain. A new version of `Win32` is required by `semaphore-compat`. Including `Win32` in the stage0 set requires also including `filepath` because otherwise Hadrian's dependency logic gets confused. Once our boot compiler has a newer version of `Win32` all of these will be able to be dropped. Resolves #24652 - - - - - 2f8e3a25 by Alan Zimmerman at 2024-04-20T11:11:52-04:00 EPA: Avoid duplicated comments in splice decls Contributes to #24669 - - - - - c70b9ddb by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fix typos and namings (fixes #24602) You may noted that I've also changed term of ``` , global "h$vt_double" ||= toJExpr IntV ``` See "IntV" and ``` WaitReadOp -> \[] [fd] -> pure $ PRPrimCall $ returnS (app "h$waidRead" [fd]) ``` See "h$waidRead" - - - - - 3db54f9b by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: trivial checks for variable presence (fixes #24602) - - - - - 777f108f by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: fs module imported twice (by emscripten and by ghc-internal). ghc-internal import wrapped in a closure to prevent conflict with emscripten (fixes #24602) Better solution is to use some JavaScript module system like AMD, CommonJS or even UMD. It will be investigated at other issues. At first glance we should try UMD (See https://github.com/umdjs/umd) - - - - - a45a5712 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: thread.js requires h$fds and h$fdReady to be declared for static code analysis, minimal code copied from GHCJS (fixes #24602) I've just copied some old pieces of GHCJS from publicly available sources (See https://github.com/Taneb/shims/blob/a6dd0202dcdb86ad63201495b8b5d9763483eb35/src/io.js#L607). Also I didn't put details to h$fds. I took minimal and left only its object initialization: `var h$fds = {};` - - - - - ad90bf12 by Serge S. Gulin at 2024-04-21T16:33:43+03:00 JS: heap and stack overflows reporting defined as js hard failure (fixes #24602) These errors were treated as a hard failure for browser application. The fix is trivial: just throw error. - - - - - 5962fa52 by Serge S. Gulin at 2024-04-21T16:33:44+03:00 JS: Stubs for code without actual implementation detected by Google Closure Compiler (fixes #24602) These errors were fixed just by introducing stubbed functions with throw for further implementation. - - - - - a0694298 by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add externs to linker (fixes #24602) After enabling jsdoc and built-in google closure compiler types I was needed to deal with the following: 1. Define NodeJS-environment types. I've just copied minimal set of externs from semi-official repo (see https://github.com/externs/nodejs/blob/6c6882c73efcdceecf42e7ba11f1e3e5c9c041f0/v8/nodejs.js#L8). 2. Define Emscripten-environment types: `HEAP8`. Emscripten already provides some externs in our code but it supposed to be run in some module system. And its definitions do not work well in plain bundle. 3. We have some functions which purpose is to add to functions some contextual information via function properties. These functions should be marked as `modifies` to let google closure compiler remove calls if these functions are not used actually by call graph. Such functions are: `h$o`, `h$sti`, `h$init_closure`, `h$setObjInfo`. 4. STG primitives such as registries and stuff from `GHC.StgToJS`. `dXX` properties were already present at externs generator function but they are started from `7`, not from `1`. This message is related: `// fixme does closure compiler bite us here?` - - - - - e58bb29f by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: added both tests: for size and for correctness (fixes #24602) By some reason MacOS builds add to stderr messages like: Ignoring unexpected archive entry: __.SYMDEF ... However I left stderr to `/dev/null` for compatibility with linux CI builds. - - - - - 909f3a9c by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Disable js linker warning for empty symbol table to make js tests running consistent across environments - - - - - 83eb10da by Serge S. Gulin at 2024-04-21T16:34:07+03:00 JS: Add special preprocessor for js files due of needing to keep jsdoc comments (fixes #24602) Our js files have defined google closure compiler types at jsdoc entries but these jsdoc entries are removed by cpp preprocessor. I considered that reusing them in javascript-backend would be a nice thing. Right now haskell processor uses `-traditional` option to deal with comments and `//` operators. But now there are following compiler options: `-C` and `-CC`. You can read about them at GCC (see https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#index-CC) and CLang (see https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-CC). It seems that `-CC` works better for javascript jsdoc than `-traditional`. At least it leaves `/* ... */` comments w/o changes. - - - - - e1cf8dc2 by brandon s allbery kf8nh at 2024-04-22T03:48:26-04:00 fix link in CODEOWNERS It seems that our local Gitlab no longer has documentation for the `CODEOWNERS` file, but the master documentation still does. Use that instead. - - - - - 593f4e04 by Fendor at 2024-04-23T10:19:14-04:00 Add performance regression test for '-fwrite-simplified-core' - - - - - 1ba39b05 by Fendor at 2024-04-23T10:19:14-04:00 Typecheck corebindings lazily during bytecode generation This delays typechecking the corebindings until the bytecode generation happens. We also avoid allocating a thunk that is retained by `unsafeInterleaveIO`. In general, we shouldn't retain values of the hydrated `Type`, as not evaluating the bytecode object keeps it alive. It is better if we retain the unhydrated `IfaceType`. See Note [Hydrating Modules] - - - - - e916fc92 by Alan Zimmerman at 2024-04-23T10:19:50-04:00 EPA: Keep comments in a CaseAlt match The comments now live in the surrounding location, not inside the Match. Make sure we keep them. Closes #24707 - - - - - d2b17f32 by Cheng Shao at 2024-04-23T15:01:22-04:00 driver: force merge objects when building dynamic objects This patch forces the driver to always merge objects when building dynamic objects even when ar -L is supported. It is an oversight of !8887: original rationale of that patch is favoring the relatively cheap ar -L operation over object merging when ar -L is supported, which makes sense but only if we are building static objects! Omitting check for whether we are building dynamic objects will result in broken .so files with undefined reference errors at executable link time when building GHC with llvm-ar. Fixes #22210. - - - - - 209d09f5 by Julian Ospald at 2024-04-23T15:02:03-04:00 Allow non-absolute values for bootstrap GHC variable Fixes #24682 - - - - - 3fff0977 by Matthew Pickering at 2024-04-23T15:02:38-04:00 Don't depend on registerPackage function in Cabal More recent versions of Cabal modify the behaviour of libAbiHash which breaks our usage of registerPackage. It is simpler to inline the part of registerPackage that we need and avoid any additional dependency and complication using the higher-level function introduces. - - - - - c62dc317 by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: remove obsolete ln script This commit removes an obsolete ln script in ghc-bignum/gmp. See 060251c24ad160264ae8553efecbb8bed2f06360 for its original intention, but it's been obsolete for a long time, especially since the removal of the make build system. Hence the house cleaning. - - - - - 6399d52b by Cheng Shao at 2024-04-25T01:32:02-04:00 ghc-bignum: update gmp to 6.3.0 This patch bumps the gmp-tarballs submodule and updates gmp to 6.3.0. The tarball format is now xz, and gmpsrc.patch has been patched into the tarball so hadrian no longer needs to deal with patching logic when building in-tree GMP. - - - - - 65b4b92f by Cheng Shao at 2024-04-25T01:32:02-04:00 hadrian: remove obsolete Patch logic This commit removes obsolete Patch logic from hadrian, given we no longer need to patch the gmp tarball when building in-tree GMP. - - - - - 71f28958 by Cheng Shao at 2024-04-25T01:32:02-04:00 autoconf: remove obsolete patch detection This commit removes obsolete deletection logic of the patch command from autoconf scripts, given we no longer need to patch anything in the GHC build process. - - - - - daeda834 by Sylvain Henry at 2024-04-25T01:32:43-04:00 JS: correctly handle RUBBISH literals (#24664) - - - - - 8a06ddf6 by Matthew Pickering at 2024-04-25T11:16:16-04:00 Linearise ghc-internal and base build This is achieved by requesting the final package database for ghc-internal, which mandates it is fully built as a dependency of configuring the `base` package. This is at the expense of cross-package parrallelism between ghc-internal and the base package. Fixes #24436 - - - - - 94da9365 by Andrei Borzenkov at 2024-04-25T11:16:54-04:00 Fix tuple puns renaming (24702) Move tuple renaming short cutter from `isBuiltInOcc_maybe` to `isPunOcc_maybe`, so we consider incoming module. I also fixed some hidden bugs that raised after the change was done. - - - - - fa03b1fb by Fendor at 2024-04-26T18:03:13-04:00 Refactor the Binary serialisation interface The goal is simplifiy adding deduplication tables to `ModIface` interface serialisation. We identify two main points of interest that make this difficult: 1. UserData hardcodes what `Binary` instances can have deduplication tables. Moreover, it heavily uses partial functions. 2. GHC.Iface.Binary hardcodes the deduplication tables for 'Name' and 'FastString', making it difficult to add more deduplication. Instead of having a single `UserData` record with fields for all the types that can have deduplication tables, we allow to provide custom serialisers for any `Typeable`. These are wrapped in existentials and stored in a `Map` indexed by their respective `TypeRep`. The `Binary` instance of the type to deduplicate still needs to explicitly look up the decoder via `findUserDataReader` and `findUserDataWriter`, which is no worse than the status-quo. `Map` was chosen as microbenchmarks indicate it is the fastest for a small number of keys (< 10). To generalise the deduplication table serialisation mechanism, we introduce the types `ReaderTable` and `WriterTable` which provide a simple interface that is sufficient to implement a general purpose deduplication mechanism for `writeBinIface` and `readBinIface`. This allows us to provide a list of deduplication tables for serialisation that can be extended more easily, for example for `IfaceTyCon`, see the issue https://gitlab.haskell.org/ghc/ghc/-/issues/24540 for more motivation. In addition to this refactoring, we split `UserData` into `ReaderUserData` and `WriterUserData`, to avoid partial functions and reduce overall memory usage, as we need fewer mutable variables. Bump haddock submodule to accomodate for `UserData` split. ------------------------- Metric Increase: MultiLayerModulesTH_Make MultiLayerModulesRecomp T21839c ------------------------- - - - - - bac57298 by Fendor at 2024-04-26T18:03:13-04:00 Split `BinHandle` into `ReadBinHandle` and `WriteBinHandle` A `BinHandle` contains too much information for reading data. For example, it needs to keep a `FastMutInt` and a `IORef BinData`, when the non-mutable variants would suffice. Additionally, this change has the benefit that anyone can immediately tell whether the `BinHandle` is used for reading or writing. Bump haddock submodule BinHandle split. - - - - - 4d6394dd by Simon Peyton Jones at 2024-04-26T18:03:49-04:00 Fix missing escaping-kind check in tcPatSynSig Note [Escaping kind in type signatures] explains how we deal with escaping kinds in type signatures, e.g. f :: forall r (a :: TYPE r). a where the kind of the body is (TYPE r), but `r` is not in scope outside the forall-type. I had missed this subtlety in tcPatSynSig, leading to #24686. This MR fixes it; and a similar bug in tc_top_lhs_type. (The latter is tested by T24686a.) - - - - - 981c2c2c by Alan Zimmerman at 2024-04-26T18:04:25-04:00 EPA: check-exact: check that the roundtrip reproduces the source Closes #24670 - - - - - a8616747 by Andrew Lelechenko at 2024-04-26T18:05:01-04:00 Document that setEnv is not thread-safe - - - - - 1e41de83 by Bryan Richter at 2024-04-26T18:05:37-04:00 CI: Work around frequent Signal 9 errors - - - - - a6d5f9da by Naïm Favier at 2024-04-27T17:52:40-04:00 ghc-internal: add MonadFix instance for (,) Closes https://gitlab.haskell.org/ghc/ghc/-/issues/24288, implements CLC proposal https://github.com/haskell/core-libraries-committee/issues/238. Adds a MonadFix instance for tuples, permitting value recursion in the "native" writer monad and bringing consistency with the existing instance for transformers's WriterT (and, to a lesser extent, for Solo). - - - - - 64feadcd by Rodrigo Mesquita at 2024-04-27T17:53:16-04:00 bindist: Fix xattr cleaning The original fix (725343aa) was incorrect because it used the shell bracket syntax which is the quoting syntax in autoconf, making the test for existence be incorrect and therefore `xattr` was never run. Fixes #24554 - - - - - e2094df3 by damhiya at 2024-04-28T23:52:00+09:00 Make read accepts binary integer formats CLC proposal : https://github.com/haskell/core-libraries-committee/issues/177 - - - - - 1c2fd963 by Alan Zimmerman at 2024-04-29T23:17:00-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 - - - - - 4189d17e by Sylvain Henry at 2024-04-29T23:17:42-04:00 LLVM: better unreachable default destination in Switch (#24717) See added note. Co-authored-by: Siddharth Bhat <siddu.druid at gmail.com> - - - - - a3725c88 by Cheng Shao at 2024-04-29T23:18:20-04:00 ci: enable wasm jobs for MRs with wasm label This patch enables wasm jobs for MRs with wasm label. Previously the wasm label didn't actually have any effect on the CI pipeline, and full-ci needed to be applied to run wasm jobs which was a waste of runners when working on the wasm backend, hence the fix here. - - - - - 702f7964 by Matthew Pickering at 2024-04-29T23:18:56-04:00 Make interface files and object files depend on inplace .conf file A potential fix for #24737 - - - - - 728af21e by Cheng Shao at 2024-04-30T05:30:23-04:00 utils: remove obsolete vagrant scripts Vagrantfile has long been removed in !5288. This commit further removes the obsolete vagrant scripts in the tree. - - - - - 36f2c342 by Cheng Shao at 2024-04-30T05:31:00-04:00 Update autoconf scripts Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 - - - - - ecbf22a6 by Ben Gamari at 2024-04-30T05:31:36-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00 testsuite: Handle exceptions in framework_fail when testdir is not initialised When `framework_fail` is called before initialising testdir, it would fail with an exception reporting the testdir not being initialised instead of the actual failure. Ensure we report the actual reason for the failure instead of failing in this way. One way this can manifest is when trying to run a test that doesn't exist using `--only` - - - - - d5bea4d6 by Alan Zimmerman at 2024-04-30T22:45:45-04:00 EPA: Fix range for GADT decl with sig only Closes #24714 - - - - - 4d78c53c by Sylvain Henry at 2024-05-01T17:23:06-04:00 Fix TH dependencies (#22229) Add a dependency between Syntax and Internal (via module reexport). - - - - - 37e38db4 by Sylvain Henry at 2024-05-01T17:23:06-04:00 Bump haddock submodule - - - - - ca13075c by Sylvain Henry at 2024-05-01T17:23:47-04:00 JS: cleanup to prepare for #24743 - - - - - 40026ac3 by Alan Zimmerman at 2024-05-01T22:45:07-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 - - - - - 92134789 by Hécate Moonlight at 2024-05-01T22:45:42-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 - - - - - a580722e by Cheng Shao at 2024-05-02T08:18:45-04:00 testsuite: fix req_target_smp predicate - - - - - ac9c5f84 by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Remove (unused)coarse grained locking. The STM code had a coarse grained locking mode guarded by #defines that was unused. This commit removes the code. - - - - - 917ef81b by Andreas Klebinger at 2024-05-02T08:18:45-04:00 STM: Be more optimistic when validating in-flight transactions. * Don't lock tvars when performing non-committal validation. * If we encounter a locked tvar don't consider it a failure. This means in-flight validation will only fail if committing at the moment of validation is *guaranteed* to fail. This prevents in-flight validation from failing spuriously if it happens in parallel on multiple threads or parallel to thread comitting. - - - - - 167a56a0 by Alan Zimmerman at 2024-05-02T08:19:22-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 - - - - - 9bae34d8 by doyougnu at 2024-05-02T15:41:08-04:00 testsuite: expand size testing infrastructure - closes #24191 - adds windows_skip, wasm_skip, wasm_arch, find_so, _find_so - path_from_ghcPkg, collect_size_ghc_pkg, collect_object_size, find_non_inplace functions to testsuite - adds on_windows and req_dynamic_ghc predicate to testsuite The design is to not make the testsuite too smart and simply offload to ghc-pkg for locations of object files and directories. - - - - - b85b1199 by Sylvain Henry at 2024-05-02T15:41:49-04:00 GHCi: support inlining breakpoints (#24712) When a breakpoint is inlined, its context may change (e.g. tyvars in scope). We must take this into account and not used the breakpoint tick index as its sole identifier. Each instance of a breakpoint (even with the same tick index) now gets a different "info" index. We also need to distinguish modules: - tick module: module with the break array (tick counters, status, etc.) - info module: module having the CgBreakInfo (info at occurrence site) - - - - - 649c24b9 by Oleg Grenrus at 2024-05-03T20:45:42-04:00 Expose constructors of SNat, SChar and SSymbol in ghc-internal - - - - - d603f199 by Mikolaj Konarski at 2024-05-03T20:46:19-04:00 Add DCoVarSet to PluginProv (!12037) - - - - - ba480026 by Serge S. Gulin at 2024-05-03T20:47:01-04:00 JS: Enable more efficient packing of string data (fixes #24706) - - - - - be1e60ee by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! - - - - - 58408c77 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add a couple more HasCallStack constraints in SimpleOpt Just for debugging, no effect on normal code - - - - - 70e245e8 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Add comments to Prep.hs This documentation patch fixes a TODO left over from !12364 - - - - - e5687186 by Simon Peyton Jones at 2024-05-03T20:47:37-04:00 Use HasDebugCallStack, rather than HasCallStack - - - - - 631cefec by Cheng Shao at 2024-05-03T20:48:17-04:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ - - - - - 1dacb506 by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump time submodule to 1.14 As requested in #24528. ------------------------- Metric Decrease: ghc_bignum_so rts_so Metric Increase: cabal_syntax_dir rts_so time_dir time_so ------------------------- - - - - - 4941b90e by Ben Gamari at 2024-05-03T20:48:53-04:00 Bump terminfo submodule to current master - - - - - 43d48b44 by Cheng Shao at 2024-05-03T20:49:30-04:00 wasm: use scheduler.postTask() for context switch when available This patch makes use of scheduler.postTask() for JSFFI context switch when it's available. It's a more principled approach than our MessageChannel based setImmediate() implementation, and it's available in latest version of Chromium based browsers. - - - - - 08207501 by Cheng Shao at 2024-05-03T20:50:08-04:00 testsuite: give pre_cmd for mhu-perf 5x time - - - - - bf3d4db0 by Alan Zimmerman at 2024-05-03T20:50:43-04:00 EPA: Preserve comments for pattern synonym sig Closes #24749 - - - - - c49493f2 by Matthew Pickering at 2024-05-04T06:02:57-04:00 tests: Widen acceptance window for dir and so size tests These are testing things which are sometimes out the control of a GHC developer. Therefore we shouldn't fail CI if something about these dependencies change because we can't do anything about it. It is still useful to have these statistics for visualisation in grafana though. Ticket #24759 - - - - - 9562808d by Matthew Pickering at 2024-05-04T06:02:57-04:00 Disable rts_so test It has already manifested large fluctuations and destabilising CI Fixes #24762 - - - - - fc24c5cf by Ryan Scott at 2024-05-04T06:03:33-04:00 unboxedSum{Type,Data}Name: Use GHC.Types as the module Unboxed sum constructors are now defined in the `GHC.Types` module, so if you manually quote an unboxed sum (e.g., `''Sum2#`), you will get a `Name` like: ```hs GHC.Types.Sum2# ``` The `unboxedSumTypeName` function in `template-haskell`, however, mistakenly believes that unboxed sum constructors are defined in `GHC.Prim`, so `unboxedSumTypeName 2` would return an entirely different `Name`: ```hs GHC.Prim.(#|#) ``` This is a problem for Template Haskell users, as it means that they can't be sure which `Name` is the correct one. (Similarly for `unboxedSumDataName`.) This patch fixes the implementations of `unboxedSum{Type,Data}Name` to use `GHC.Types` as the module. For consistency with `unboxedTupleTypeName`, the `unboxedSumTypeName` function now uses the non-punned syntax for unboxed sums (`Sum<N>#`) as the `OccName`. Fixes #24750. - - - - - 7eab4e01 by Alan Zimmerman at 2024-05-04T16:14:55+01:00 EPA: Widen stmtslist to include last semicolon Closes #24754 - - - - - 06f7db40 by Teo Camarasu at 2024-05-05T00:19:38-04:00 doc: Fix type error in hs_try_putmvar example - - - - - af000532 by Moritz Schuler at 2024-05-05T06:30:58-04:00 Fix parsing of module names in CLI arguments closes issue #24732 - - - - - da74e9c9 by Ben Gamari at 2024-05-05T06:31:34-04:00 ghc-platform: Add Setup.hs The Hadrian bootstrapping script relies upon `Setup.hs` to drive its build. Addresses #24761. - - - - - 35d34fde by Alan Zimmerman at 2024-05-05T12:52:40-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 - - - - - 03c5dfbf by Simon Peyton Jones at 2024-05-05T12:53:15-04:00 Fix a float-out error Ticket #24768 showed that the Simplifier was accidentally destroying a join point. It turned out to be that we were sending a bottoming join point to the top, accidentally abstracting over /other/ join points. Easily fixed. - - - - - adba68e7 by John Ericson at 2024-05-05T19:35:56-04:00 Substitute bindist files with Hadrian not configure The `ghc-toolchain` overhaul will eventually replace all this stuff with something much more cleaned up, but I think it is still worth making this sort of cleanup in the meantime so other untanglings and dead code cleaning can procede. I was able to delete a fair amount of dead code doing this too. `LLVMTarget_CPP` is renamed to / merged with `LLVMTarget` because it wasn't actually turned into a valid CPP identifier. (Original to 1345c7cc42c45e63ab1726a8fd24a7e4d4222467, actually.) Progress on #23966 Co-Authored-By: Sylvain Henry <hsyl20 at gmail.com> - - - - - 18f4ff84 by Alan Zimmerman at 2024-05-05T19:36:32-04:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 - - - - - a19201d4 by Matthew Craven at 2024-05-06T19:54:29-04:00 Add test cases for #24664 ...since none are present in the original MR !12463 fixing this issue. - - - - - 46328a49 by Alan Zimmerman at 2024-05-06T19:55:05-04:00 EPA: preserve comments in data decls Closes #24771 - - - - - 3b51995c by Andrei Borzenkov at 2024-05-07T14:39:40-04:00 Rename Solo# data constructor to MkSolo# (#24673) - data Solo# a = (# a #) + data Solo# a = MkSolo# a And `(# foo #)` syntax now becomes just a syntactic sugar for `MkSolo# a`. - - - - - 4d59abf2 by Arsen Arsenović at 2024-05-07T14:40:24-04:00 Add the cmm_cpp_is_gcc predicate to the testsuite A future C-- test called T24474-cmm-override-g0 relies on the GCC-specific behaviour of -g3 implying -dD, which, in turn, leads to it emitting #defines past the preprocessing stage. Clang, at least, does not do this, so the test would fail if ran on Clang. As the behaviour here being tested is ``-optCmmP-g3'' undoing effects of the workaround we apply as a fix for bug #24474, and the workaround was for GCC-specific behaviour, the test needs to be marked as fragile on other compilers. - - - - - 25b0b404 by Arsen Arsenović at 2024-05-07T14:40:24-04:00 Split out the C-- preprocessor, and make it pass -g0 Previously, C-- was processed with the C preprocessor program. This means that it inherited flags passed via -optc. A flag that is somewhat often passed through -optc is -g. At certain -g levels (>=2), GCC starts emitting defines *after* preprocessing, for the purposes of debug info generation. This is not useful for the C-- compiler, and, in fact, causes lexer errors. We can suppress this effect (safely, if supported) via -g0. As a workaround, in older versions of GCC (<=10), GCC only emitted defines if a certain set of -g*3 flags was passed. Newer versions check the debug level. For the former, we filter out those -g*3 flags and, for the latter, we specify -g0 on top of that. As a compatible and effective solution, this change adds a C-- preprocessor distinct from the C compiler and preprocessor, but that keeps its flags. The command line produced for C-- preprocessing now looks like: $pgmCmmP $optCs_without_g3 $g0_if_supported $optCmmP Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/24474 - - - - - d3c36cc9 by Zubin Duggal at 2024-05-08T15:47:15+01:00 Don't store a GlobalRdrEnv in `mi_globals` for GHCi. GHCi only needs the `mi_globals` field for modules imported with :module +*SomeModule. It uses this field to make the top level environment in `SomeModule` available to the repl. By default, only the first target in the command line parameters is "star" loaded into GHCi. Other modules have to be manually "star" loaded into the repl. Storing the top level GlobalRdrEnv for each module is very wasteful, especially given that we will most likely never need most of these environments. Instead we store only the information needed to reconstruct the top level environment in a module, which is the `IfaceTopEnv` data structure, consisting of all import statements as well as all top level symbols defined in the module (not taking export lists into account) When a particular module is "star-loaded" into GHCi (as the first commandline target, or via an explicit `:module +*SomeModule`, we reconstruct the top level environment on demand using the `IfaceTopEnv`. - - - - - ceb0bf3c by Fendor at 2024-05-08T15:47:15+01:00 Fix tests - - - - - 62e680a0 by Matthew Pickering at 2024-05-08T15:47:15+01:00 Store GlobalRdrElt directly rather than AvailInfo - - - - - 30 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/default.nix - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/mk-ghcup-metadata/README.mkd - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - + .gitlab/rel_eng/recompress-all - .gitlab/rel_eng/upload.sh - CODEOWNERS - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/PrimOps.hs-boot - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0bdac55166d607fb99b7835e0864d5f070c42c18...62e680a0fc7def96887641e95b5e3f9ce4479349 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0bdac55166d607fb99b7835e0864d5f070c42c18...62e680a0fc7def96887641e95b5e3f9ce4479349 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 14:50:26 2024 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 08 May 2024 10:50:26 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/prof-dyn Message-ID: <663b913236ff0_6129d2de1b901481ad@gitlab.mail> Matthew Pickering pushed new branch wip/prof-dyn at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/prof-dyn You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 15:15:31 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 08 May 2024 11:15:31 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/fix-ghcup-metadata Message-ID: <663b97138797f_6129d323e9181638ad@gitlab.mail> Ben Gamari pushed new branch wip/fix-ghcup-metadata at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/fix-ghcup-metadata You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 15:17:49 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 08 May 2024 11:17:49 -0400 Subject: [Git][ghc/ghc][wip/fix-ghcup-metadata] 2 commits: Revert "ghcup-metadata: Drop output_name field" Message-ID: <663b979db8951_6129d32f9f1016562a@gitlab.mail> Ben Gamari pushed to branch wip/fix-ghcup-metadata at Glasgow Haskell Compiler / GHC Commits: a219b856 by Ben Gamari at 2024-05-08T11:17:43-04:00 Revert "ghcup-metadata: Drop output_name field" This reverts commit ecbf22a6ac397a791204590f94c0afa82e29e79f. - - - - - c44a0176 by Ben Gamari at 2024-05-08T11:17:43-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - 1 changed file: - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py Changes: ===================================== .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py ===================================== @@ -170,7 +170,6 @@ def mk_from_platform(pipeline_type, platform): info = job_mapping[platform.name][pipeline_type] eprint(f"From {platform.name} / {pipeline_type} selecting {info['name']}") return Artifact(info['name'] - , f"{info['jobInfo']['bindistName']}.tar.xz" , "ghc-{version}-{pn}.tar.xz".format(version="{version}", pn=platform.name) , platform.subdir) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/28ef470d8b6582584c31f5675daadf148bf260c4...c44a01760bde507921af824ad8e6ccad142a156d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/28ef470d8b6582584c31f5675daadf148bf260c4...c44a01760bde507921af824ad8e6ccad142a156d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 15:21:11 2024 From: gitlab at gitlab.haskell.org (Serge S. Gulin (@gulin.serge)) Date: Wed, 08 May 2024 11:21:11 -0400 Subject: [Git][ghc/ghc][wip/T24504] Apply 1 suggestion(s) to 1 file(s) Message-ID: <663b986764248_6129d342cc981660e4@gitlab.mail> Serge S. Gulin pushed to branch wip/T24504 at Glasgow Haskell Compiler / GHC Commits: 205f4f1a by Matthew Pickering at 2024-05-08T15:21:09+00:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 1 changed file: - rts/include/rts/Constants.h Changes: ===================================== rts/include/rts/Constants.h ===================================== @@ -351,6 +351,6 @@ /* * closure_desc of InfoProv is now uint32_t at all platforms, but * we have to keep its stringified representation. - * It is known that maximum lenght of uint32_t in string is 10 chars (4294967295) + 1 NULL. + * It is known that maximum length of uint32_t in string is 10 chars (4294967295) + 1 NULL. */ #define CLOSURE_DESC_BUFFER_SIZE 11 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/205f4f1a75f5b3121b42ca1b4a224234601d4415 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/205f4f1a75f5b3121b42ca1b4a224234601d4415 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 15:22:48 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Wed, 08 May 2024 11:22:48 -0400 Subject: [Git][ghc/ghc][wip/reinstallable-th] 18 commits: Rename Solo# data constructor to MkSolo# (#24673) Message-ID: <663b98c8b17ee_6129d350c53c167056@gitlab.mail> Teo Camarasu pushed to branch wip/reinstallable-th at Glasgow Haskell Compiler / GHC Commits: 3b51995c by Andrei Borzenkov at 2024-05-07T14:39:40-04:00 Rename Solo# data constructor to MkSolo# (#24673) - data Solo# a = (# a #) + data Solo# a = MkSolo# a And `(# foo #)` syntax now becomes just a syntactic sugar for `MkSolo# a`. - - - - - 4d59abf2 by Arsen Arsenović at 2024-05-07T14:40:24-04:00 Add the cmm_cpp_is_gcc predicate to the testsuite A future C-- test called T24474-cmm-override-g0 relies on the GCC-specific behaviour of -g3 implying -dD, which, in turn, leads to it emitting #defines past the preprocessing stage. Clang, at least, does not do this, so the test would fail if ran on Clang. As the behaviour here being tested is ``-optCmmP-g3'' undoing effects of the workaround we apply as a fix for bug #24474, and the workaround was for GCC-specific behaviour, the test needs to be marked as fragile on other compilers. - - - - - 25b0b404 by Arsen Arsenović at 2024-05-07T14:40:24-04:00 Split out the C-- preprocessor, and make it pass -g0 Previously, C-- was processed with the C preprocessor program. This means that it inherited flags passed via -optc. A flag that is somewhat often passed through -optc is -g. At certain -g levels (>=2), GCC starts emitting defines *after* preprocessing, for the purposes of debug info generation. This is not useful for the C-- compiler, and, in fact, causes lexer errors. We can suppress this effect (safely, if supported) via -g0. As a workaround, in older versions of GCC (<=10), GCC only emitted defines if a certain set of -g*3 flags was passed. Newer versions check the debug level. For the former, we filter out those -g*3 flags and, for the latter, we specify -g0 on top of that. As a compatible and effective solution, this change adds a C-- preprocessor distinct from the C compiler and preprocessor, but that keeps its flags. The command line produced for C-- preprocessing now looks like: $pgmCmmP $optCs_without_g3 $g0_if_supported $optCmmP Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/24474 - - - - - ac0719cd by Teo Camarasu at 2024-05-08T09:53:53+01:00 Make template-haskell reinstallable - - - - - 71864274 by Teo Camarasu at 2024-05-08T09:53:53+01:00 Split out GHC.Internal.TH.Lift - - - - - 7917ef33 by Teo Camarasu at 2024-05-08T09:53:53+01:00 Move MonadIO to ghc-internal - - - - - 952d0761 by Teo Camarasu at 2024-05-08T09:53:54+01:00 Move GHC.Internal.Syntax into ghc-internal - - - - - 44e13ad9 by Teo Camarasu at 2024-05-08T09:53:54+01:00 Move GHC.Lexeme into ghc-internal - - - - - ed988768 by Teo Camarasu at 2024-05-08T09:53:54+01:00 Move GHC.Internal.TH.Lib to ghc-internal - - - - - e71231e4 by Teo Camarasu at 2024-05-08T09:53:54+01:00 Move GHC.Internal.TH.Lift to ghc-internal - - - - - 4712894b by Teo Camarasu at 2024-05-08T09:53:55+01:00 Move GHC.Internal.TH.Quote to ghc-internal - - - - - abb384f1 by Teo Camarasu at 2024-05-08T09:53:55+01:00 Drop thUnit/thUnitId - - - - - abae26ea by Teo Camarasu at 2024-05-08T14:33:41+01:00 Update Safe/trustworthy annotations - - - - - 9d5edbc9 by Teo Camarasu at 2024-05-08T14:36:36+01:00 Update test outputs - - - - - 48b97f3c by Teo Camarasu at 2024-05-08T14:41:09+01:00 Stop vendoring filepath in template-haskell There is no need now that it is reinstallable - - - - - b8c98874 by Teo Camarasu at 2024-05-08T16:09:41+01:00 Rename modules moved to ghc-internal to start with GHC.Internal We re-expose the old names from ghc-boot-th for backcompat - - - - - 15d852d4 by Teo Camarasu at 2024-05-08T16:18:47+01:00 Update docs - - - - - 4d007d7f by Teo Camarasu at 2024-05-08T16:22:35+01:00 mark as safe - - - - - 30 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Recomp/Flags.hs - compiler/GHC/Plugins.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Runtime/Interpreter/JS.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools/Cpp.hs - compiler/GHC/SysTools/Tasks.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Gen/Splice.hs-boot - compiler/GHC/Tc/Types/TH.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Unit/State.hs - compiler/GHC/Unit/Types.hs - compiler/ghc.cabal.in - configure.ac - distrib/configure.ac.in - docs/users_guide/phases.rst - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bbb27ec859c36dcb889dd9ed62cca1cb1deb4b00...4d007d7f99289b1d451647bb01070c1a557a77c8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bbb27ec859c36dcb889dd9ed62cca1cb1deb4b00...4d007d7f99289b1d451647bb01070c1a557a77c8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 15:53:39 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Wed, 08 May 2024 11:53:39 -0400 Subject: [Git][ghc/ghc][wip/reinstallable-th] 3 commits: Rename modules moved to ghc-internal to start with GHC.Internal Message-ID: <663ba00329ffc_6129d39bf9e4169540@gitlab.mail> Teo Camarasu pushed to branch wip/reinstallable-th at Glasgow Haskell Compiler / GHC Commits: cc9d45e9 by Teo Camarasu at 2024-05-08T16:50:29+01:00 Rename modules moved to ghc-internal to start with GHC.Internal We re-expose the old names from ghc-boot-th for backcompat - - - - - cebad7d2 by Teo Camarasu at 2024-05-08T16:52:58+01:00 Update docs - - - - - 35fa7bba by Teo Camarasu at 2024-05-08T16:53:13+01:00 mark as safe - - - - - 19 changed files: - compiler/GHC/Rename/Splice.hs - libraries/base/src/Data/Fixed.hs - + libraries/ghc-boot-th/GHC/ForeignSrcLang/Type.hs - + libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs - + libraries/ghc-boot-th/GHC/Lexeme.hs - libraries/ghc-boot-th/ghc-boot-th.cabal.in - libraries/ghc-internal/ghc-internal.cabal - libraries/ghc-internal/src/GHC/ForeignSrcLang/Type.hs → libraries/ghc-internal/src/GHC/Internal/ForeignSrcLang.hs - libraries/ghc-internal/src/GHC/LanguageExtensions/Type.hs → libraries/ghc-internal/src/GHC/Internal/LanguageExtensions.hs - libraries/ghc-internal/src/GHC/Lexeme.hs → libraries/ghc-internal/src/GHC/Internal/Lexeme.hs - libraries/ghc-internal/src/GHC/Internal/TH/Lib.hs - libraries/ghc-internal/src/GHC/Internal/TH/Lift.hs - libraries/ghc-internal/src/GHC/Internal/TH/Quote.hs - libraries/ghc-internal/src/GHC/Internal/TH/Syntax.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs - libraries/template-haskell/Language/Haskell/TH/Ppr.hs - libraries/template-haskell/Language/Haskell/TH/PprLib.hs - libraries/template-haskell/Language/Haskell/TH/Quote.hs - libraries/template-haskell/Language/Haskell/TH/Syntax.hs Changes: ===================================== compiler/GHC/Rename/Splice.hs ===================================== @@ -590,7 +590,7 @@ problems. Consider the following code: module X where import Prelude ( Monad(..), Bool(..), print, ($) ) - import GHC.Internal.TH.Syntax + import Language.Haskell.TH.Syntax $( do stuff <- [| if True then 10 else 15 |] runIO $ print stuff @@ -620,7 +620,7 @@ following code is expected to be rejected (because of the lack of suitable module X where import Prelude ( Monad(..), Bool(..), print, ($) ) - import GHC.Internal.TH.Syntax + import Language.Haskell.TH.Syntax $$( do stuff <- [|| if True then 10 else 15 ||] runIO $ print stuff ===================================== libraries/base/src/Data/Fixed.hs ===================================== @@ -140,6 +140,7 @@ instance (Typeable k,Typeable a) => Data (Fixed (a :: k)) where dataTypeOf _ = tyFixed toConstr _ = conMkFixed +-- @since 2.19.0.0 instance TH.Lift (Fixed a) where liftTyped x = TH.unsafeCodeCoerce (TH.lift x) lift (MkFixed x) = [| MkFixed x |] ===================================== libraries/ghc-boot-th/GHC/ForeignSrcLang/Type.hs ===================================== @@ -0,0 +1,5 @@ +module GHC.ForeignSrcLang.Type + ( ForeignSrcLang(..) + ) where + +import GHC.Internal.ForeignSrcLang ===================================== libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs ===================================== @@ -0,0 +1,14 @@ +----------------------------------------------------------------------------- +-- | +-- Module : GHC.LanguageExtensions.Type +-- Copyright : (c) The GHC Team +-- +-- Maintainer : ghc-devs at haskell.org +-- Portability : portable +-- +-- A data type defining the language extensions supported by GHC. +-- +{-# LANGUAGE Safe #-} +module GHC.LanguageExtensions.Type ( Extension(..) ) where + +import GHC.Internal.LanguageExtensions ===================================== libraries/ghc-boot-th/GHC/Lexeme.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE CPP #-} +----------------------------------------------------------------------------- +-- | +-- Module : GHC.Lexeme +-- Copyright : (c) The GHC Team +-- +-- Maintainer : ghc-devs at haskell.org +-- Portability : portable +-- +-- Functions to evaluate whether or not a string is a valid identifier. +-- +module GHC.Lexeme ( + -- * Lexical characteristics of Haskell names + startsVarSym, startsVarId, startsConSym, startsConId, + startsVarSymASCII, isVarSymChar, okSymChar + ) where + +import GHC.Internal.Lexeme ===================================== libraries/ghc-boot-th/ghc-boot-th.cabal.in ===================================== @@ -44,6 +44,9 @@ Library GHC.Internal.TH.Lib.Map GHC.Internal.TH.Ppr GHC.Internal.TH.PprLib + GHC.LanguageExtensions.Type + GHC.ForeignSrcLang.Type + GHC.Lexeme build-depends: base >= 4.7 && < 4.21, @@ -54,20 +57,17 @@ Library cpp-options: -DBOOTSTRAP_TH hs-source-dirs: @SourceRoot@ ../ghc-internal/src exposed-modules: - GHC.Lexeme - GHC.LanguageExtensions.Type - GHC.ForeignSrcLang.Type GHC.Internal.TH.Syntax GHC.Internal.TH.Lib + GHC.Internal.LanguageExtensions + GHC.Internal.ForeignSrcLang + GHC.Internal.Lexeme else hs-source-dirs: @SourceRoot@ build-depends: ghc-internal reexported-modules: GHC.Internal.TH.Lib, - GHC.LanguageExtensions.Type, - GHC.ForeignSrcLang.Type, GHC.Internal.TH.Syntax, - GHC.Lexeme, GHC.Internal.TH.Lift, GHC.Internal.TH.Quote ===================================== libraries/ghc-internal/ghc-internal.cabal ===================================== @@ -161,6 +161,7 @@ Library GHC.Internal.Foreign.Ptr GHC.Internal.Foreign.StablePtr GHC.Internal.Foreign.Storable + GHC.Internal.ForeignSrcLang GHC.Internal.Arr GHC.Internal.ArrayArray GHC.Internal.Base @@ -230,6 +231,8 @@ Library GHC.Internal.Integer.Logarithms GHC.Internal.IsList GHC.Internal.Ix + GHC.Internal.LanguageExtensions + GHC.Internal.Lexeme GHC.Internal.List GHC.Internal.Maybe GHC.Internal.MVar @@ -291,9 +294,6 @@ Library GHC.Internal.Unsafe.Coerce -- TODO: remove GHC.Internal.IOPort - GHC.ForeignSrcLang.Type - GHC.LanguageExtensions.Type - GHC.Lexeme reexported-modules: GHC.Num.Integer ===================================== libraries/ghc-internal/src/GHC/ForeignSrcLang/Type.hs → libraries/ghc-internal/src/GHC/Internal/ForeignSrcLang.hs ===================================== @@ -1,6 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveGeneric #-} -module GHC.ForeignSrcLang.Type +module GHC.Internal.ForeignSrcLang ( ForeignSrcLang(..) ) where ===================================== libraries/ghc-internal/src/GHC/LanguageExtensions/Type.hs → libraries/ghc-internal/src/GHC/Internal/LanguageExtensions.hs ===================================== @@ -1,6 +1,6 @@ ----------------------------------------------------------------------------- -- | --- Module : GHC.LanguageExtensions.Type +-- Module : GHC.Internal.LanguageExtensions -- Copyright : (c) The GHC Team -- -- Maintainer : ghc-devs at haskell.org @@ -9,7 +9,7 @@ -- A data type defining the language extensions supported by GHC. -- {-# LANGUAGE DeriveGeneric, CPP, Trustworthy #-} -module GHC.LanguageExtensions.Type ( Extension(..) ) where +module GHC.Internal.LanguageExtensions ( Extension(..) ) where #ifdef BOOTSTRAP_TH import Prelude -- See note [Why do we import Prelude here?] ===================================== libraries/ghc-internal/src/GHC/Lexeme.hs → libraries/ghc-internal/src/GHC/Internal/Lexeme.hs ===================================== @@ -1,7 +1,7 @@ {-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- -- | --- Module : GHC.Lexeme +-- Module : GHC.Internal.Lexeme -- Copyright : (c) The GHC Team -- -- Maintainer : ghc-devs at haskell.org @@ -9,7 +9,7 @@ -- -- Functions to evaluate whether or not a string is a valid identifier. -- -module GHC.Lexeme ( +module GHC.Internal.Lexeme ( -- * Lexical characteristics of Haskell names startsVarSym, startsVarId, startsConSym, startsConId, startsVarSymASCII, isVarSymChar, okSymChar ===================================== libraries/ghc-internal/src/GHC/Internal/TH/Lib.hs ===================================== @@ -5,12 +5,12 @@ {-# LANGUAGE Trustworthy #-} -- | --- Language.Haskell.TH.Lib.Internal exposes some additional functionality that +-- GHC.Internal.TH.Lib exposes some additional functionality that -- is used internally in GHC's integration with Template Haskell. This is not a -- part of the public API, and as such, there are no API guarantees for this -- module from version to version. --- Why do we have both Language.Haskell.TH.Lib.Internal and +-- Why do we have both GHC.Internal.TH.Lib and -- Language.Haskell.TH.Lib? Ultimately, it's because the functions in the -- former (which are tailored for GHC's use) need different type signatures -- than the ones in the latter. Syncing up the Internal type signatures would ===================================== libraries/ghc-internal/src/GHC/Internal/TH/Lift.hs ===================================== @@ -14,10 +14,32 @@ {-# LANGUAGE UnboxedTuples #-} {-# OPTIONS_GHC -fno-warn-inline-rule-shadowing #-} -module GHC.Internal.TH.Lift where +-- | This module gives the definition of the 'Lift' class. +-- +-- This is an internal module. +-- Please import "Language.Haskell.TH" or "Language.Haskell.TH.Syntax" instead! + +module GHC.Internal.TH.Lift + ( Lift(..) + , liftString + -- * Wired-in names + , trueName + , falseName + , nothingName + , justName + , leftName + , rightName + , nonemptyName + -- * Generic Lift implementations + , dataToQa + , dataToExpQ + , liftData + , dataToPatQ + ) + where import GHC.Internal.TH.Syntax -import GHC.Lexeme ( startsVarSym, startsVarId ) +import GHC.Internal.Lexeme ( startsVarSym, startsVarId ) import GHC.Internal.Data.Either import GHC.Internal.Type.Reflection @@ -32,14 +54,6 @@ import GHC.Internal.Int import GHC.Internal.Data.Data import GHC.Internal.Natural --- See Note [Bootstrapping Template Haskell] - ------------------------------------------------------ --- --- The Lift class --- ------------------------------------------------------ - -- | A 'Lift' instance can have any of its values turned into a Template -- Haskell expression. This is needed when a value used within a Template -- Haskell quotation is bound outside the Oxford brackets (@[| ... |]@ or @@ -186,10 +200,6 @@ instance Lift Addr# where lift x = return (LitE (StringPrimL (map (fromIntegral . ord) (unpackCString# x)))) --- TODO: move this somewhere else --- | --- @since 2.19.0.0 - instance Lift a => Lift (Maybe a) where liftTyped x = unsafeCodeCoerce (lift x) ===================================== libraries/ghc-internal/src/GHC/Internal/TH/Quote.hs ===================================== @@ -12,6 +12,8 @@ quasiquoter @q@ which can be invoked using the syntax extension is enabled, and some utility functions for manipulating quasiquoters. Nota bene: this package does not define any parsers, that is up to you. + +This is an internal module. Please import 'Language.Haskell.TH.Quote' instead. -} module GHC.Internal.TH.Quote( QuasiQuoter(..), ===================================== libraries/ghc-internal/src/GHC/Internal/TH/Syntax.hs ===================================== @@ -20,7 +20,7 @@ module GHC.Internal.TH.Syntax ( module GHC.Internal.TH.Syntax -- * Language extensions - , module GHC.LanguageExtensions.Type + , module GHC.Internal.LanguageExtensions , ForeignSrcLang(..) -- * Notes -- ** Unresolved Infix @@ -78,8 +78,8 @@ import GHC.Internal.IO.Exception import GHC.Internal.Unicode import qualified GHC.Types as Kind (Type) #endif -import GHC.ForeignSrcLang.Type -import GHC.LanguageExtensions.Type +import GHC.Internal.ForeignSrcLang +import GHC.Internal.LanguageExtensions ----------------------------------------------------- -- ===================================== libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs ===================================== @@ -1,4 +1,18 @@ -{-# LANGUAGE Trustworthy #-} +{-# LANGUAGE Safe #-} +-- | +-- Language.Haskell.TH.Lib.Internal exposes some additional functionality that +-- is used internally in GHC's integration with Template Haskell. This is not a +-- part of the public API, and as such, there are no API guarantees for this +-- module from version to version. + +-- Why do we have both GHC.Internal.TH.Lib and +-- Language.Haskell.TH.Lib? Ultimately, it's because the functions in the +-- former (which are tailored for GHC's use) need different type signatures +-- than the ones in the latter. Syncing up the Internal type signatures would +-- involve a massive amount of breaking changes, so for the time being, we +-- relegate as many changes as we can to just the Internal module, where it +-- is safe to break things. + module Language.Haskell.TH.Lib.Internal ( module GHC.Internal.TH.Lib ) where ===================================== libraries/template-haskell/Language/Haskell/TH/Ppr.hs ===================================== @@ -1,4 +1,7 @@ {-# LANGUAGE Safe #-} + +-- | contains a prettyprinter for the +-- Template Haskell datatypes module Language.Haskell.TH.Ppr ( module GHC.Internal.TH.Ppr ) where ===================================== libraries/template-haskell/Language/Haskell/TH/PprLib.hs ===================================== @@ -1,4 +1,6 @@ {-# LANGUAGE Safe #-} + +-- | Monadic front-end to Text.PrettyPrint module Language.Haskell.TH.PprLib ( module GHC.Internal.TH.PprLib ) where ===================================== libraries/template-haskell/Language/Haskell/TH/Quote.hs ===================================== @@ -1,4 +1,18 @@ {-# LANGUAGE Safe #-} +{- | +Module : Language.Haskell.TH.Quote +Description : Quasi-quoting support for Template Haskell + +Template Haskell supports quasiquoting, which permits users to construct +program fragments by directly writing concrete syntax. A quasiquoter is +essentially a function with takes a string to a Template Haskell AST. +This module defines the 'QuasiQuoter' datatype, which specifies a +quasiquoter @q@ which can be invoked using the syntax +@[q| ... string to parse ... |]@ when the @QuasiQuotes@ language +extension is enabled, and some utility functions for manipulating +quasiquoters. Nota bene: this package does not define any parsers, +that is up to you. +-} module Language.Haskell.TH.Quote (module GHC.Internal.TH.Quote) where ===================================== libraries/template-haskell/Language/Haskell/TH/Syntax.hs ===================================== @@ -9,16 +9,16 @@ import GHC.Internal.TH.Syntax import GHC.Internal.TH.Lift import System.FilePath --- The only difference between this module and GHC.Internal.TH.Syntax --- (which it reexports fully) is that this module depends on the --- Internal.TH.Lib module. +-- This module completely re-exports 'GHC.Internal.TH.Syntax', and exports +-- functions that depend on filepath. -- +-- Additionally it re-exports 'GHC.Internal.TH.Lift', which depends on +-- 'GHC.Internal.TH.Lib'. -- We did this to fix #22229: a module importing the Syntax module to use -- DeriveLift (Lift is defined there) would lead GHC to load the -- interface file for the Internal module (where wired-in TH things live), -- but the Internal module might not be built yet at this point. Adding an --- explicit dependency from Syntax to Internal fixes this. We do this with a --- module reexport because Internal actually depends on Syntax. +-- explicit dependency from Syntax to Lift fixes this. -- -- See Note [Tracking dependencies on primitives] in GHC.Internal.Base, wrinkle W4. import GHC.Internal.TH.Lib () View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4d007d7f99289b1d451647bb01070c1a557a77c8...35fa7bba8b2e9bed1e51bc2e40940463d1dcfb67 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4d007d7f99289b1d451647bb01070c1a557a77c8...35fa7bba8b2e9bed1e51bc2e40940463d1dcfb67 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 15:56:16 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Wed, 08 May 2024 11:56:16 -0400 Subject: [Git][ghc/ghc][wip/reinstallable-th] Update bootstrapping flag doc Message-ID: <663ba0a0b0223_6129d3adc804170149@gitlab.mail> Teo Camarasu pushed to branch wip/reinstallable-th at Glasgow Haskell Compiler / GHC Commits: 2309e23a by Teo Camarasu at 2024-05-08T16:56:04+01:00 Update bootstrapping flag doc - - - - - 1 changed file: - libraries/ghc-boot-th/ghc-boot-th.cabal.in Changes: ===================================== libraries/ghc-boot-th/ghc-boot-th.cabal.in ===================================== @@ -29,8 +29,8 @@ source-repository head Flag bootstrap Description: Enabled when building the stage1 compiler in order to vendor the in-tree - `template-haskell` library (including its dependency `ghc-boot-th`), while - allowing dependencies to depend on the boot `template-haskell` library. + `ghc-boot-th` library (dependency of `template-haskell`), while allowing + dependencies to depend on the boot `template-haskell` library. See Note [Bootstrapping Template Haskell] Default: False Manual: True View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2309e23a5be9ba35bf77c92acda2173c19d383d3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2309e23a5be9ba35bf77c92acda2173c19d383d3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 16:02:21 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Wed, 08 May 2024 12:02:21 -0400 Subject: [Git][ghc/ghc][wip/reinstallable-th] remove accidentally committed file Message-ID: <663ba20daf8c8_6129d3c63fb01759bf@gitlab.mail> Teo Camarasu pushed to branch wip/reinstallable-th at Glasgow Haskell Compiler / GHC Commits: a67a130b by Teo Camarasu at 2024-05-08T17:02:14+01:00 remove accidentally committed file - - - - - 1 changed file: - − libraries/ghc-boot-th/GHC/Internal/TH/Lift.hs Changes: ===================================== libraries/ghc-boot-th/GHC/Internal/TH/Lift.hs deleted ===================================== @@ -1,3 +0,0 @@ --- | - -module GHC.Internal.TH.Lift where View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a67a130be13202ce4015029a05a1ddf2baabfd73 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a67a130be13202ce4015029a05a1ddf2baabfd73 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 17:01:25 2024 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Wed, 08 May 2024 13:01:25 -0400 Subject: [Git][ghc/ghc][wip/reinstallable-th] 7 commits: Update test outputs Message-ID: <663bafe57e0d7_6129d43b57a0182862@gitlab.mail> Teo Camarasu pushed to branch wip/reinstallable-th at Glasgow Haskell Compiler / GHC Commits: f7240155 by Teo Camarasu at 2024-05-08T17:31:52+01:00 Update test outputs - - - - - 958af060 by Teo Camarasu at 2024-05-08T17:31:52+01:00 Rename modules moved to ghc-internal to start with GHC.Internal We re-expose the old names from ghc-boot-th for backcompat - - - - - baf55f19 by Teo Camarasu at 2024-05-08T17:31:52+01:00 Update docs - - - - - 4e9c0190 by Teo Camarasu at 2024-05-08T17:31:52+01:00 mark as safe - - - - - 53f8be29 by Teo Camarasu at 2024-05-08T17:31:53+01:00 Update bootstrapping flag doc - - - - - 90c4a5b9 by Teo Camarasu at 2024-05-08T17:31:53+01:00 remove accidentally committed file - - - - - 061d7c18 by Teo Camarasu at 2024-05-08T17:31:53+01:00 Fix formatting - - - - - 30 changed files: - compiler/GHC/Rename/Splice.hs - libraries/base/src/Data/Array/Byte.hs - libraries/base/src/Data/Fixed.hs - + libraries/ghc-boot-th/GHC/ForeignSrcLang/Type.hs - − libraries/ghc-boot-th/GHC/Internal/TH/Lift.hs - + libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs - + libraries/ghc-boot-th/GHC/Lexeme.hs - libraries/ghc-boot-th/ghc-boot-th.cabal.in - libraries/ghc-internal/ghc-internal.cabal - libraries/ghc-internal/src/GHC/ForeignSrcLang/Type.hs → libraries/ghc-internal/src/GHC/Internal/ForeignSrcLang.hs - libraries/ghc-internal/src/GHC/LanguageExtensions/Type.hs → libraries/ghc-internal/src/GHC/Internal/LanguageExtensions.hs - libraries/ghc-internal/src/GHC/Lexeme.hs → libraries/ghc-internal/src/GHC/Internal/Lexeme.hs - libraries/ghc-internal/src/GHC/Internal/TH/Lib.hs - libraries/ghc-internal/src/GHC/Internal/TH/Lift.hs - libraries/ghc-internal/src/GHC/Internal/TH/Quote.hs - libraries/ghc-internal/src/GHC/Internal/TH/Syntax.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs - libraries/template-haskell/Language/Haskell/TH/Ppr.hs - libraries/template-haskell/Language/Haskell/TH/PprLib.hs - libraries/template-haskell/Language/Haskell/TH/Quote.hs - libraries/template-haskell/Language/Haskell/TH/Syntax.hs - testsuite/tests/deriving/should_compile/T14682.stderr - testsuite/tests/deriving/should_compile/drv-empty-data.stderr - testsuite/tests/driver/T20604/T20604.stdout - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/template-haskell-exports.stdout - testsuite/tests/plugins/plugins10.stdout - testsuite/tests/quotes/TH_localname.stderr - testsuite/tests/th/T10796b.stderr - testsuite/tests/th/T11452.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a67a130be13202ce4015029a05a1ddf2baabfd73...061d7c18e0506f350bd03393c012b79968b2814d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a67a130be13202ce4015029a05a1ddf2baabfd73...061d7c18e0506f350bd03393c012b79968b2814d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 17:24:55 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 08 May 2024 13:24:55 -0400 Subject: [Git][ghc/ghc][master] -fprof-late: Only insert cost centres on functions/non-workfree cafs. Message-ID: <663bb566e878e_6129d48272d41877c3@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9b4129a5 by Andreas Klebinger at 2024-05-08T13:24:20-04:00 -fprof-late: Only insert cost centres on functions/non-workfree cafs. They are usually useless and doing so for data values comes with a large compile time/code size overhead. Fixes #24103 - - - - - 8 changed files: - compiler/GHC/Core/LateCC.hs - compiler/GHC/Core/LateCC/TopLevelBinds.hs - compiler/GHC/Core/LateCC/Types.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Types/RepType.hs - docs/users_guide/9.12.1-notes.rst - docs/users_guide/profiling.rst Changes: ===================================== compiler/GHC/Core/LateCC.hs ===================================== @@ -21,6 +21,7 @@ import GHC.Types.SrcLoc import GHC.Utils.Error import GHC.Utils.Logger import GHC.Utils.Outputable +import GHC.Types.RepType (mightBeFunTy) -- | Late cost center insertion logic used by the driver addLateCostCenters :: @@ -78,8 +79,11 @@ addLateCostCenters logger LateCCConfig{..} core_binds = do top_level_cc_pred :: CoreExpr -> Bool top_level_cc_pred = case lateCCConfig_whichBinds of - LateCCAllBinds -> - const True + LateCCBinds -> \rhs -> + -- Make sure we record any functions. Even if it's something like `f = g`. + mightBeFunTy (exprType rhs) || + -- If the RHS is a CAF doing work also insert a CC. + not (exprIsWorkFree rhs) LateCCOverloadedBinds -> isOverloadedTy . exprType LateCCNone -> ===================================== compiler/GHC/Core/LateCC/TopLevelBinds.hs ===================================== @@ -3,16 +3,18 @@ module GHC.Core.LateCC.TopLevelBinds where import GHC.Prelude -import GHC.Core --- import GHC.Core.LateCC import GHC.Core.LateCC.Types import GHC.Core.LateCC.Utils + +import GHC.Core import GHC.Core.Opt.Monad import GHC.Driver.DynFlags import GHC.Types.Id import GHC.Types.Name import GHC.Unit.Module.ModGuts +import Data.Maybe + {- Note [Collecting late cost centres] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Usually cost centres defined by a module are collected @@ -26,7 +28,7 @@ us from collecting them here when we run this pass before tidy. Note [Adding late cost centres to top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The basic idea is very simple. For every top level binder +The basic idea is very simple. For a top level binder `f = rhs` we compile it as if the user had written `f = {-# SCC f #-} rhs`. @@ -37,6 +39,21 @@ might inhibit optimizations at the call site. For this reason we provide flags for both approaches as they have different tradeoffs. +To reduce overhead we ignore workfree bindings because they don't contribute +meaningfully to a performance profile. This reduces code size massively as it +allows us to allocate definitions like `val = Just 32` at compile time instead +of turning them into a CAF of the form `val = let x = Just 32 in x` which +would be the alternative. + +We make an exception for rhss with function types. This allows us to get +cost centres on eta-reduced definitions like `f = g`. By putting a tick onto +`f`s rhs we end up with + + f = \eta1 eta2 ... etan -> + g eta1 ... etan + +Which can make it easier to understand call graphs of an application. + We also don't add a cost centre for any binder that is a constructor worker or wrapper. These will never meaningfully enrich the resulting profile so we improve efficiency by omitting those. @@ -89,15 +106,20 @@ topLevelBindsCC pred core_bind = doBndr :: Id -> CoreExpr -> LateCCM s CoreExpr doBndr bndr rhs - -- Cost centres on constructor workers are pretty much useless - -- so we don't emit them if we are looking at the rhs of a constructor - -- binding. - | Just _ <- isDataConId_maybe bndr = pure rhs - | otherwise = if pred rhs then addCC bndr rhs else pure rhs + -- Not a constructor worker. + -- Cost centres on constructor workers are pretty much useless so we don't emit them + -- if we are looking at the rhs of a constructor binding. + | isNothing (isDataConId_maybe bndr) + , pred rhs + = addCC bndr rhs + | otherwise = pure rhs -- We want to put the cost centre below the lambda as we only care about - -- executions of the RHS. + -- executions of the RHS. Note that the lambdas might be hidden under ticks + -- or casts. So look through these as well. addCC :: Id -> CoreExpr -> LateCCM s CoreExpr + addCC bndr (Cast rhs co) = pure Cast <*> addCC bndr rhs <*> pure co + addCC bndr (Tick t rhs) = (Tick t) <$> addCC bndr rhs addCC bndr (Lam b rhs) = Lam b <$> addCC bndr rhs addCC bndr rhs = do let name = idName bndr ===================================== compiler/GHC/Core/LateCC/Types.hs ===================================== @@ -34,7 +34,7 @@ data LateCCConfig = -- | The types of top-level bindings we support adding cost centers to. data LateCCBindSpec = LateCCNone - | LateCCAllBinds + | LateCCBinds | LateCCOverloadedBinds -- | Late cost centre insertion environment ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -1978,6 +1978,8 @@ isPiTy ty = case coreFullView ty of _ -> False -- | Is this a function? +-- Note: `forall {b}. Show b => b -> IO b` will not be considered a function by this function. +-- It would merely be a forall wrapping a function type. isFunTy :: Type -> Bool isFunTy ty | FunTy {} <- coreFullView ty = True ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -1805,7 +1805,7 @@ hscGenHardCode hsc_env cgguts location output_filename = do if gopt Opt_ProfLateInlineCcs dflags then LateCCNone else if gopt Opt_ProfLateCcs dflags then - LateCCAllBinds + LateCCBinds else if gopt Opt_ProfLateOverloadedCcs dflags then LateCCOverloadedBinds else ===================================== compiler/GHC/Types/RepType.hs ===================================== @@ -693,6 +693,9 @@ mightBeFunTy :: Type -> Bool -- AK: It would be nice to figure out and document the difference -- between this and isFunTy at some point. mightBeFunTy ty + -- Currently ghc has no unlifted functions. + | definitelyUnliftedType ty + = False | [BoxedRep _] <- typePrimRep ty , Just tc <- tyConAppTyCon_maybe (unwrapType ty) , isDataTyCon tc ===================================== docs/users_guide/9.12.1-notes.rst ===================================== @@ -34,6 +34,16 @@ See ``Note [The importance of tracking free coercion variables]`` in ``GHC.Core.TyCo.Rep``, :ref:`constraint-solving-with-plugins` and the migration guide. +- The flag `-fprof-late` will no longer prevent top level constructors from being statically allocated. + + It used to be the case that we would add a cost centre for bindings like `foo = Just bar`. + This turned the binding into a caf that would allocate the constructor on first evaluation. + + However without the cost centre `foo` can be allocated at compile time. This reduces code-bloat and + reduces overhead for short-running applications. + + The tradeoff is that calling `whoCreated` on top level value definitions like `foo` will be less informative. + GHCi ~~~~ ===================================== docs/users_guide/profiling.rst ===================================== @@ -483,10 +483,12 @@ of your profiled program will be different to that of the unprofiled one. :since: 9.4.1 - Adds an automatic ``SCC`` annotation to all top level bindings late in the compilation pipeline after - the optimizer has run and unfoldings have been created. This means these cost centres will not interfere with core-level optimizations + Adds an automatic ``SCC`` annotation to all top level bindings which might perform work. + This is done late in the compilation pipeline after the optimizer has run and unfoldings have been created. + This means these cost centres will not interfere with core-level optimizations and the resulting profile will be closer to the performance profile of an optimized non-profiled executable. + While the results of this are generally informative, some of the compiler internal names will leak into the profile. Further if a function is inlined into a use site it's costs will be counted against the caller's cost center. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9b4129a580e6c1d18197ef2ed3a8b89d52a2b133 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9b4129a580e6c1d18197ef2ed3a8b89d52a2b133 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 17:26:07 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 08 May 2024 13:26:07 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Simplifier: Preserve OccInfo on DataAlt fields when case binder is dead (#24770) Message-ID: <663bb5af18f1d_6129d4a099d01922ec@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 259b63d3 by Sebastian Graf at 2024-05-08T13:24:57-04:00 Simplifier: Preserve OccInfo on DataAlt fields when case binder is dead (#24770) See the adjusted `Note [DataAlt occ info]`. This change also has a positive repercussion on `Note [Combine case alts: awkward corner]`. Fixes #24770. We now try not to call `dataConRepStrictness` in `adjustFieldsIdInfo` when all fields are lazy anyway, leading to a 2% ghc/alloc decrease in T9675. Metric Decrease: T9675 - - - - - 31b28cdb by Sebastian Graf at 2024-05-08T13:24:57-04:00 Kill seqRule, discard dead seq# in Prep (#24334) Discarding seq#s in Core land via `seqRule` was problematic; see #24334. So instead we discard certain dead, discardable seq#s in Prep now. See the updated `Note [seq# magic]`. This fixes the symptoms of #24334. - - - - - 15 changed files: - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Types/Id/Make.hs - testsuite/tests/codeGen/should_compile/T24264.hs - + testsuite/tests/core-to-stg/T24334.hs - + testsuite/tests/core-to-stg/T24334.stdout - testsuite/tests/core-to-stg/all.T - testsuite/tests/simplCore/should_compile/T21851.stderr - + testsuite/tests/simplCore/should_compile/T24770.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/CSE.hs ===================================== @@ -9,12 +9,8 @@ module GHC.Core.Opt.CSE (cseProgram, cseOneExpr) where import GHC.Prelude import GHC.Core.Subst -import GHC.Types.Var ( Var ) import GHC.Types.Var.Env ( mkInScopeSet ) -import GHC.Types.Id ( Id, idType, idHasRules, zapStableUnfolding - , idInlineActivation, setInlineActivation - , zapIdOccInfo, zapIdUsageInfo, idInlinePragma - , isJoinId, idJoinPointHood, idUnfolding ) +import GHC.Types.Id import GHC.Core.Utils ( mkAltExpr , exprIsTickedString , stripTicksE, stripTicksT, mkTicks ) @@ -754,7 +750,7 @@ combineAlts alts , Alt _ bndrs1 rhs1 <- alt1 , let filtered_alts = filterOut (identical_alt rhs1) rest_alts , not (equalLength rest_alts filtered_alts) - = assertPpr (null bndrs1) (ppr alts) $ + = assertPpr (all isDeadBinder bndrs1) (ppr alts) $ Alt DEFAULT [] rhs1 : filtered_alts | otherwise @@ -762,14 +758,13 @@ combineAlts alts where find_bndr_free_alt :: [CoreAlt] -> (Maybe CoreAlt, [CoreAlt]) - -- The (Just alt) is a binder-free alt - -- See Note [Combine case alts: awkward corner] + -- The (Just alt) is an alt where all fields are dead find_bndr_free_alt [] = (Nothing, []) find_bndr_free_alt (alt@(Alt _ bndrs _) : alts) - | null bndrs = (Just alt, alts) - | otherwise = case find_bndr_free_alt alts of - (mb_bf, alts) -> (mb_bf, alt:alts) + | all isDeadBinder bndrs = (Just alt, alts) + | otherwise = case find_bndr_free_alt alts of + (mb_bf, alts) -> (mb_bf, alt:alts) identical_alt rhs1 (Alt _ _ rhs) = eqCoreExpr rhs1 rhs -- Even if this alt has binders, they will have been cloned @@ -823,9 +818,9 @@ big for cheapEqExpr to catch it. Note [Combine case alts: awkward corner] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We would really like to check isDeadBinder on the binders in the -alternative. But alas, the simplifer zaps occ-info on binders in case -alternatives; see Note [Case alternative occ info] in GHC.Core.Opt.Simplify. +We check isDeadBinder on field binders in order to collapse into a DEFAULT alt. +But alas, the simplifer often zaps occ-info on field binders in DataAlts when +the case binder is alive; see Note [DataAlt occ info] in GHC.Core.Opt.Simplify. * One alternative (perhaps a good one) would be to do OccAnal just before CSE. Then perhaps we could get rid of combineIdenticalAlts @@ -833,14 +828,12 @@ alternatives; see Note [Case alternative occ info] in GHC.Core.Opt.Simplify. * Another would be for CSE to return free vars as it goes. -* But the current solution is to find a nullary alternative (including - the DEFAULT alt, if any). This will not catch - case x of - A y -> blah - B z p -> blah - where no alternative is nullary or DEFAULT. But the current - solution is at least cheap. - +* But the current solution is to accept that we do not catch cases such as + case x of c + A _ -> blah[c] + B _ _ -> blah[c] + where the case binder c is alive and no alternative is DEFAULT. + But the current solution is at least cheap. ************************************************************************ * * ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -2067,21 +2067,18 @@ unsafeEqualityProofRule {- ********************************************************************* * * - Rules for seq# and spark# + Rules for spark# * * ********************************************************************* -} -seqRule :: RuleM CoreExpr -seqRule = do +-- spark# :: forall a s . a -> State# s -> (# State# s, a #) +sparkRule :: RuleM CoreExpr +sparkRule = do -- reduce on HNF [Type _ty_a, Type _ty_s, a, s] <- getArgs guard $ exprIsHNF a return $ mkCoreUnboxedTuple [s, a] - --- spark# :: forall a s . a -> State# s -> (# State# s, a #) -sparkRule :: RuleM CoreExpr -sparkRule = seqRule -- reduce on HNF, just the same - -- XXX perhaps we shouldn't do this, because a spark eliminated by - -- this rule won't be counted as a dud at runtime? + -- XXX perhaps we shouldn't do this, because a spark eliminated by + -- this rule won't be counted as a dud at runtime? {- ************************************************************************ @@ -2158,9 +2155,7 @@ builtinRules platform <- getPlatform return $ Var (primOpId IntAndOp) `App` arg `App` mkIntVal platform (d - 1) - ], - - mkBasicRule seqHashName 4 seqRule + ] ] ++ builtinBignumRules {-# NOINLINE builtinRules #-} ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -26,7 +26,7 @@ core expression with (hopefully) improved usage information. module GHC.Core.Opt.OccurAnal ( occurAnalysePgm, occurAnalyseExpr, - zapLambdaBndrs, scrutBinderSwap_maybe + zapLambdaBndrs, BinderSwapDecision(..), scrutOkForBinderSwap ) where import GHC.Prelude hiding ( head, init, last, tail ) @@ -3262,7 +3262,7 @@ inline x, cancel the casts, and away we go. Note [Care with binder-swap on dictionaries] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -This Note explains why we need isDictId in scrutBinderSwap_maybe. +This Note explains why we need isDictId in scrutOkForBinderSwap. Consider this tricky example (#21229, #21470): class Sing (b :: Bool) where sing :: Bool @@ -3306,7 +3306,7 @@ Conclusion: for a /dictionary variable/ do not perform the clever cast version of the binder-swap -Hence the subtle isDictId in scrutBinderSwap_maybe. +Hence the subtle isDictId in scrutOkForBinderSwap. Note [Zap case binders in proxy bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -3328,7 +3328,7 @@ addBndrSwap :: OutExpr -> Id -> OccEnv -> OccEnv -- See Note [The binder-swap substitution] addBndrSwap scrut case_bndr env@(OccEnv { occ_bs_env = swap_env, occ_bs_rng = rng_vars }) - | Just (scrut_var, mco) <- scrutBinderSwap_maybe scrut + | DoBinderSwap scrut_var mco <- scrutOkForBinderSwap scrut , scrut_var /= case_bndr -- Consider: case x of x { ... } -- Do not add [x :-> x] to occ_bs_env, else lookupBndrSwap will loop @@ -3342,25 +3342,30 @@ addBndrSwap scrut case_bndr case_bndr' = zapIdOccInfo case_bndr -- See Note [Zap case binders in proxy bindings] -scrutBinderSwap_maybe :: OutExpr -> Maybe (OutVar, MCoercion) --- If (scrutBinderSwap_maybe e = Just (v, mco), then +-- | See bBinderSwaOk. +data BinderSwapDecision + = NoBinderSwap + | DoBinderSwap OutVar MCoercion + +scrutOkForBinderSwap :: OutExpr -> BinderSwapDecision +-- If (scrutOkForBinderSwap e = DoBinderSwap v mco, then -- v = e |> mco -- See Note [Case of cast] -- See Note [Care with binder-swap on dictionaries] -- -- We use this same function in SpecConstr, and Simplify.Iteration, -- when something binder-swap-like is happening -scrutBinderSwap_maybe (Var v) = Just (v, MRefl) -scrutBinderSwap_maybe (Cast (Var v) co) - | not (isDictId v) = Just (v, MCo (mkSymCo co)) +scrutOkForBinderSwap (Var v) = DoBinderSwap v MRefl +scrutOkForBinderSwap (Cast (Var v) co) + | not (isDictId v) = DoBinderSwap v (MCo (mkSymCo co)) -- Cast: see Note [Case of cast] -- isDictId: see Note [Care with binder-swap on dictionaries] -- The isDictId rejects a Constraint/Constraint binder-swap, perhaps -- over-conservatively. But I have never seen one, so I'm leaving -- the code as simple as possible. Losing the binder-swap in a -- rare case probably has very low impact. -scrutBinderSwap_maybe (Tick _ e) = scrutBinderSwap_maybe e -- Drop ticks -scrutBinderSwap_maybe _ = Nothing +scrutOkForBinderSwap (Tick _ e) = scrutOkForBinderSwap e -- Drop ticks +scrutOkForBinderSwap _ = NoBinderSwap lookupBndrSwap :: OccEnv -> Id -> (CoreExpr, Id) -- See Note [The binder-swap substitution] ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -1719,7 +1719,7 @@ extendCaseBndrEnv :: LevelEnv -> LevelEnv extendCaseBndrEnv le@(LE { le_subst = subst, le_env = id_env }) case_bndr (Var scrut_var) - -- We could use OccurAnal. scrutBinderSwap_maybe here, and perhaps + -- We could use OccurAnal. scrutOkForBinderSwap here, and perhaps -- get a bit more floating. But we didn't in the past and it's -- an unforced change, so I'm leaving it. = le { le_subst = extendSubstWithVar subst case_bndr scrut_var ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -23,7 +23,7 @@ import GHC.Core.TyCo.Compare( eqType ) import GHC.Core.Opt.Simplify.Env import GHC.Core.Opt.Simplify.Inline import GHC.Core.Opt.Simplify.Utils -import GHC.Core.Opt.OccurAnal ( occurAnalyseExpr, zapLambdaBndrs, scrutBinderSwap_maybe ) +import GHC.Core.Opt.OccurAnal ( occurAnalyseExpr, zapLambdaBndrs, scrutOkForBinderSwap, BinderSwapDecision (..) ) import GHC.Core.Make ( FloatBind, mkImpossibleExpr, castBottomExpr ) import qualified GHC.Core.Make import GHC.Core.Coercion hiding ( substCo, substCoVar ) @@ -33,7 +33,7 @@ import GHC.Core.FamInstEnv ( FamInstEnv, topNormaliseType_maybe ) import GHC.Core.DataCon ( DataCon, dataConWorkId, dataConRepStrictness , dataConRepArgTys, isUnboxedTupleDataCon - , StrictnessMark (..) ) + , StrictnessMark (..), dataConWrapId_maybe ) import GHC.Core.Opt.Stats ( Tick(..) ) import GHC.Core.Ppr ( pprCoreExpr ) import GHC.Core.Unfold @@ -3234,16 +3234,36 @@ The point is that we bring into the envt a binding after the outer case, and that makes (a,b) alive. At least we do unless the case binder is guaranteed dead. -Note [Case alternative occ info] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -When we are simply reconstructing a case (the common case), we always -zap the occurrence info on the binders in the alternatives. Even -if the case binder is dead, the scrutinee is usually a variable, and *that* -can bring the case-alternative binders back to life. -See Note [Add unfolding for scrutinee] +Note [DataAlt occ info] +~~~~~~~~~~~~~~~~~~~~~~~ +Our general goal is to preserve dead-ness occ-info on the field binders of a +case alternative. Why? It's generally a good idea, but one specific reason is to +support (SEQ4) of Note [seq# magic]. + +But we have to be careful: even if the field binder is not mentioned in the case +alternative and thus annotated IAmDead by OccurAnal, it might "come back to +life" in one of two ways: + + 1. If the case binder is alive, its unfolding might bring back the field + binder, as in Note [knownCon occ info]: + case blah of y { I# _ -> $wf (case y of I# v -> v) } + ==> + case blah of y { I# v -> $wf v } + 2. Even if the case binder appears to be dead, there is the scenario in + Note [Add unfolding for scrutinee], in which the fields come back to live + through the unfolding of variable scrutinee, as follows: + join j = case x of Just v -> blah v; Nothing -> ... in + case x of Just _ -> jump j; Nothing -> ... + ==> { inline j, unfold x to Just v, simplify } + join j = case x of Just v -> blah v; Nothing -> ... in + case x of Just v -> blah v; Nothing -> ... + +Thus, when we are simply reconstructing a case (the common case), and the +case binder is not dead, or the scrutinee is a variable, we zap the +occurrence info on DataAlt field binders. See `adjustFieldOccInfo`. Note [Improving seq] -~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~ Consider type family F :: * -> * type instance F Int = Int @@ -3349,7 +3369,9 @@ simplAlts env0 scrut case_bndr alts cont' -- NB: pass case_bndr::InId, not case_bndr' :: OutId, to prepareAlts -- See Note [Shadowing in prepareAlts] in GHC.Core.Opt.Simplify.Utils - ; alts' <- mapM (simplAlt alt_env' (Just scrut') imposs_deflt_cons case_bndr' cont') in_alts + ; alts' <- forM in_alts $ + simplAlt alt_env' (Just scrut') imposs_deflt_cons + case_bndr' (scrutOkForBinderSwap scrut) cont' ; let alts_ty' = contResultType cont' -- See Note [Avoiding space leaks in OutType] @@ -3375,36 +3397,42 @@ improveSeq _ env scrut _ case_bndr1 _ ------------------------------------ simplAlt :: SimplEnv - -> Maybe OutExpr -- The scrutinee - -> [AltCon] -- These constructors can't be present when - -- matching the DEFAULT alternative - -> OutId -- The case binder + -> Maybe OutExpr -- The scrutinee + -> [AltCon] -- These constructors can't be present when + -- matching the DEFAULT alternative + -> OutId -- The case binder `bndr` + -> BinderSwapDecision -- DoBinderSwap v co <==> scrut = Just (v |> co), + -- add unfolding `v :-> bndr |> sym co` -> SimplCont -> InAlt -> SimplM OutAlt -simplAlt env scrut' imposs_deflt_cons case_bndr' cont' (Alt DEFAULT bndrs rhs) +simplAlt env _scrut' imposs_deflt_cons case_bndr' bndr_swap' cont' (Alt DEFAULT bndrs rhs) = assert (null bndrs) $ - do { let env' = addDefaultUnfoldings env scrut' case_bndr' imposs_deflt_cons + do { let env' = addDefaultUnfoldings env case_bndr' bndr_swap' imposs_deflt_cons ; rhs' <- simplExprC env' rhs cont' ; return (Alt DEFAULT [] rhs') } -simplAlt env scrut' _ case_bndr' cont' (Alt (LitAlt lit) bndrs rhs) +simplAlt env _scrut' _ case_bndr' bndr_swap' cont' (Alt (LitAlt lit) bndrs rhs) = assert (null bndrs) $ - do { let env' = addAltUnfoldings env scrut' case_bndr' (Lit lit) + do { let env' = addAltUnfoldings env case_bndr' bndr_swap' (Lit lit) ; rhs' <- simplExprC env' rhs cont' ; return (Alt (LitAlt lit) [] rhs') } -simplAlt env scrut' _ case_bndr' cont' (Alt (DataAlt con) vs rhs) +simplAlt env scrut' _ case_bndr' bndr_swap' cont' (Alt (DataAlt con) vs rhs) = do { -- See Note [Adding evaluatedness info to pattern-bound variables] - let vs_with_evals = addEvals scrut' con vs - ; (env', vs') <- simplBinders env vs_with_evals + -- and Note [DataAlt occ info] + ; let vs_with_info = adjustFieldsIdInfo scrut' case_bndr' bndr_swap' con vs + -- Adjust evaluated-ness and occ-info flags before `simplBinders` + -- because the latter extends the in-scope set, which propagates this + -- adjusted info to use sites. + ; (env', vs') <- simplBinders env vs_with_info -- Bind the case-binder to (con args) ; let inst_tys' = tyConAppArgs (idType case_bndr') con_app :: OutExpr con_app = mkConApp2 con inst_tys' vs' - env'' = addAltUnfoldings env' scrut' case_bndr' con_app + env'' = addAltUnfoldings env' case_bndr' bndr_swap' con_app ; rhs' <- simplExprC env'' rhs cont' ; return (Alt (DataAlt con) vs' rhs') } @@ -3438,9 +3466,10 @@ do it here). The right thing is to do some kind of binder-swap; see #15226 for discussion. -} -addEvals :: Maybe OutExpr -> DataCon -> [Id] -> [Id] +adjustFieldsIdInfo :: Maybe OutExpr -> OutId -> BinderSwapDecision -> DataCon -> [Id] -> [Id] -- See Note [Adding evaluatedness info to pattern-bound variables] -addEvals scrut con vs +-- and Note [DataAlt occ info] +adjustFieldsIdInfo scrut case_bndr bndr_swap con vs -- Deal with seq# applications | Just scr <- scrut , isUnboxedTupleDataCon con @@ -3449,59 +3478,75 @@ addEvals scrut con vs -- a list of arguments only to throw it away immediately. , Just (Var f) <- stripNArgs 4 scr , f `hasKey` seqHashKey - , let x' = zapIdOccInfoAndSetEvald MarkedStrict x - = [s, x'] + , let x' = setCaseBndrEvald MarkedStrict x + = map (adjustFieldOccInfo case_bndr bndr_swap) [s, x'] -- Deal with banged datacon fields -addEvals _scrut con vs = go vs the_strs - where - the_strs = dataConRepStrictness con - - go [] [] = [] - go (v:vs') strs | isTyVar v = v : go vs' strs - go (v:vs') (str:strs) = zapIdOccInfoAndSetEvald str v : go vs' strs - go _ _ = pprPanic "Simplify.addEvals" - (ppr con $$ - ppr vs $$ - ppr_with_length (map strdisp the_strs) $$ - ppr_with_length (dataConRepArgTys con) $$ - ppr_with_length (dataConRepStrictness con)) - where - ppr_with_length list - = ppr list <+> parens (text "length =" <+> ppr (length list)) - strdisp :: StrictnessMark -> SDoc - strdisp MarkedStrict = text "MarkedStrict" - strdisp NotMarkedStrict = text "NotMarkedStrict" - -zapIdOccInfoAndSetEvald :: StrictnessMark -> Id -> Id -zapIdOccInfoAndSetEvald str v = - setCaseBndrEvald str $ -- Add eval'dness info - zapIdOccInfo v -- And kill occ info; - -- see Note [Case alternative occ info] - -addDefaultUnfoldings :: SimplEnv -> Maybe OutExpr -> OutId -> [AltCon] -> SimplEnv -addDefaultUnfoldings env mb_scrut case_bndr imposs_deflt_cons + -- This case is quite allocation sensitive to T9233 which has a large record + -- with strict fields. Hence we try not to update vs twice! +adjustFieldsIdInfo _scrut case_bndr bndr_swap con vs + | Nothing <- dataConWrapId_maybe con + -- A common fast path; no need to allocate the_strs when they are all lazy + -- anyway! It shaves off 2% in T9675 + = map (adjustFieldOccInfo case_bndr bndr_swap) vs + | otherwise + = go vs the_strs + where + the_strs = dataConRepStrictness con + + go [] [] = [] + go (v:vs') strs | isTyVar v = v : go vs' strs + go (v:vs') (str:strs) = adjustFieldOccInfo case_bndr bndr_swap (setCaseBndrEvald str v) : go vs' strs + go _ _ = pprPanic "Simplify.adjustFieldsIdInfo" + (ppr con $$ + ppr vs $$ + ppr_with_length (map strdisp the_strs) $$ + ppr_with_length (dataConRepArgTys con) $$ + ppr_with_length (dataConRepStrictness con)) + where + ppr_with_length list + = ppr list <+> parens (text "length =" <+> ppr (length list)) + strdisp :: StrictnessMark -> SDoc + strdisp MarkedStrict = text "MarkedStrict" + strdisp NotMarkedStrict = text "NotMarkedStrict" + +adjustFieldOccInfo :: OutId -> BinderSwapDecision -> CoreBndr -> CoreBndr +-- Kill occ info if we do binder swap and the case binder is alive; +-- see Note [DataAlt occ info] +adjustFieldOccInfo case_bndr bndr_swap field_bndr + | isTyVar field_bndr + = field_bndr + + | not (isDeadBinder case_bndr) -- (1) in the Note: If the case binder is alive, + = zapIdOccInfo field_bndr -- the field binders might come back alive + + | DoBinderSwap{} <- bndr_swap -- (2) in the Note: If binder swap might take place, + = zapIdOccInfo field_bndr -- the case binder might come back alive + + | otherwise + = field_bndr -- otherwise the field binders stay dead + +addDefaultUnfoldings :: SimplEnv -> OutId -> BinderSwapDecision -> [AltCon] -> SimplEnv +addDefaultUnfoldings env case_bndr bndr_swap imposs_deflt_cons = env2 where unf = mkOtherCon imposs_deflt_cons -- Record the constructors that the case-binder *can't* be. env1 = addBinderUnfolding env case_bndr unf - env2 | Just scrut <- mb_scrut - , Just (v,_mco) <- scrutBinderSwap_maybe scrut + env2 | DoBinderSwap v _mco <- bndr_swap = addBinderUnfolding env1 v unf | otherwise = env1 -addAltUnfoldings :: SimplEnv -> Maybe OutExpr -> OutId -> OutExpr -> SimplEnv -addAltUnfoldings env mb_scrut case_bndr con_app +addAltUnfoldings :: SimplEnv -> OutId -> BinderSwapDecision -> OutExpr -> SimplEnv +addAltUnfoldings env case_bndr bndr_swap con_app = env2 where con_app_unf = mk_simple_unf con_app env1 = addBinderUnfolding env case_bndr con_app_unf -- See Note [Add unfolding for scrutinee] - env2 | Just scrut <- mb_scrut - , Just (v,mco) <- scrutBinderSwap_maybe scrut + env2 | DoBinderSwap v mco <- bndr_swap = addBinderUnfolding env1 v $ if isReflMCo mco -- isReflMCo: avoid calling mk_simple_unf then con_app_unf -- twice in the common case @@ -3580,7 +3625,7 @@ So instead we add the unfolding x -> Just a, and x -> Nothing in the respective RHSs. Since this transformation is tantamount to a binder swap, we use -GHC.Core.Opt.OccurAnal.scrutBinderSwap_maybe to do the check. +GHC.Core.Opt.OccurAnal.scrutOkForBinderSwap to do the check. Exactly the same issue arises in GHC.Core.Opt.SpecConstr; see Note [Add scrutinee to ValueEnv too] in GHC.Core.Opt.SpecConstr @@ -3884,8 +3929,9 @@ mkDupableContWithDmds env _ ; let cont_scaling = contHoleScaling cont -- See Note [Scaling in case-of-case] ; (alt_env', case_bndr') <- simplBinder alt_env (scaleIdBy cont_scaling case_bndr) - ; alts' <- mapM (simplAlt alt_env' Nothing [] case_bndr' alt_cont) (scaleAltsBy cont_scaling alts) - -- Safe to say that there are no handled-cons for the DEFAULT case + ; alts' <- forM (scaleAltsBy cont_scaling alts) $ + simplAlt alt_env' Nothing [] case_bndr' NoBinderSwap alt_cont + -- Safe to say that there are no handled-cons for the DEFAULT case -- NB: simplBinder does not zap deadness occ-info, so -- a dead case_bndr' will still advertise its deadness -- This is really important because in ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -36,7 +36,7 @@ import GHC.Core.Opt.Simplify.Inline import GHC.Core.FVs ( exprsFreeVarsList, exprFreeVars ) import GHC.Core.Opt.Monad import GHC.Core.Opt.WorkWrap.Utils -import GHC.Core.Opt.OccurAnal( scrutBinderSwap_maybe ) +import GHC.Core.Opt.OccurAnal( BinderSwapDecision(..), scrutOkForBinderSwap ) import GHC.Core.DataCon import GHC.Core.Class( classTyVars ) import GHC.Core.Coercion hiding( substCo ) @@ -1104,7 +1104,7 @@ extendCaseBndrs env scrut case_bndr con alt_bndrs = (env2, alt_bndrs') where live_case_bndr = not (isDeadBinder case_bndr) - env1 | Just (v, mco) <- scrutBinderSwap_maybe scrut + env1 | DoBinderSwap v mco <- scrutOkForBinderSwap scrut , isReflMCo mco = extendValEnv env v cval | otherwise = env -- See Note [Add scrutinee to ValueEnv too] env2 | live_case_bndr = extendValEnv env1 case_bndr cval @@ -1198,7 +1198,7 @@ though the simplifier has systematically replaced uses of 'x' with 'y' and 'b' with 'c' in the code. The use of 'b' in the ValueEnv came from outside the case. See #4908 for the live example. -It's very like the binder-swap story, so we use scrutBinderSwap_maybe +It's very like the binder-swap story, so we use scrutOkForBinderSwap to identify suitable scrutinees -- but only if there is no cast (isReflMCo) because that's all that the ValueEnv allows. ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -890,6 +890,29 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con [covar] _]) floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } +cpeRhsE env (Case scrut bndr _ [Alt (DataAlt dc) [token_out, res] rhs]) + -- See item (SEQ4) of Note [seq# magic]. We want to match + -- case seq# @a @RealWorld s of (# s', _ #) -> rhs[s'] + -- and simplify to rhs[s]. Triggers in T15226. + | isUnboxedTupleDataCon dc + , (Var f,[_ty1, _ty2, arg, Var token_in]) <- collectArgs scrut + , f `hasKey` seqHashKey + , exprOkToDiscard arg + -- ok-to-discard, because we want to discard the evaluation of `arg`. + -- ok-to-discard includes ok-for-spec, but *also* CanFail primops such as + -- `quotInt# 1# 0#`, but not ThrowsException primops. + -- See Note [Classifying primop effects] + -- and Note [Transformations affected by primop effects] for why this is + -- the correct choice. + , Var token_in' <- lookupCorePrepEnv env token_in + , isDeadBinder res, isDeadBinder bndr + -- Check that bndr and res are dead + -- We can rely on `isDeadBinder res`, despite the fact that the Simplifier + -- often zaps the OccInfo on case-alternative binders (see Note [DataAlt occ info] + -- in GHC.Core.Opt.Simplify.Iteration) because the scrutinee is not a + -- variable, and in that case the zapping doesn't happen; see that Note. + = cpeRhsE (extendCorePrepEnv env token_out token_in') rhs + cpeRhsE env (Case scrut bndr ty alts) = do { (floats, scrut') <- cpeBody env scrut ; (env', bndr2) <- cpCloneBndr env bndr ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -2295,9 +2295,16 @@ Things to note also we can attach an evaldUnfolding to x' to discard any subsequent evals such as the `case x' of __DEFAULT`. +(SEQ4) + T15226 demonstrates that we want to discard ok-for-discard seq#s. That is, + simplify `case seq# s of (# s', _ #) -> rhs[s']` to `rhs[s]`. + You might wonder whether the Simplifier could do this. But see the excellent + example in #24334 (immortalised as test T24334) for why it should be done in + CorePrep. + Implementing seq#. The compiler has magic for `seq#` in -- GHC.Core.Opt.ConstantFold.seqRule: eliminate (seq# s) +- GHC.CoreToStg.Prep.cpeRhsE: Implement (SEQ4). - Simplify.addEvals records evaluated-ness for the result (cf. (SEQ3)); see Note [Adding evaluatedness info to pattern-bound variables] ===================================== testsuite/tests/codeGen/should_compile/T24264.hs ===================================== @@ -24,12 +24,8 @@ fun3 :: a -> IO a {-# OPAQUE fun3 #-} fun3 x = do pure () - -- "evaluate $! x" - case x of !x' -> IO (noinline seq# x') - -- noinline to work around the bogus seqRule - -- This ideally also should not push a continuation to the stack - -- before entering 'x'. It currently does, but let's wait for - -- !11515 to land before worrying about that. + evaluate $! x + -- This should not push a continuation to the stack before entering 'x' funPair :: a -> IO (a, a) {-# OPAQUE funPair #-} ===================================== testsuite/tests/core-to-stg/T24334.hs ===================================== @@ -0,0 +1,20 @@ +import Control.Exception +import Data.IORef + +strictPrint :: Show a => a -> IO () +{-# OPAQUE strictPrint #-} +strictPrint x = print $! x + +f :: Show a => a -> IORef a -> IO () +{-# OPAQUE f #-} +f x r = do + x' <- evaluate $! x + writeIORef r x' + strictPrint x' + +main :: IO () +main = do + r <- newIORef (42 :: Int) + f (error "foo") r `catch` \(e :: SomeException) -> return () + n <- readIORef r + print n ===================================== testsuite/tests/core-to-stg/T24334.stdout ===================================== @@ -0,0 +1 @@ +42 ===================================== testsuite/tests/core-to-stg/all.T ===================================== @@ -5,4 +5,5 @@ test('T23270', [grep_errmsg(r'patError')], compile, ['-O0 -dsuppress-uniques -dd test('T23914', normal, compile, ['-O']) test('T14895', normal, compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-uniques']) test('T24124', normal, compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-uniques']) +test('T24334', normal, compile_and_run, ['-O']) test('T24463', normal, compile, ['-O']) ===================================== testsuite/tests/simplCore/should_compile/T21851.stderr ===================================== @@ -10,8 +10,12 @@ g' :: Int -> Int [GblId, Arity=1, Str=, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 30 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [0] 30 0}] g' - = \ (x :: Int) -> case T21851a.$w$sf x of { (# ww, ww1 #) -> ww } + = \ (x :: Int) -> + case T21851a.$w$sf x of { (# ww, _ [Occ=Dead] #) -> ww } + + ===================================== testsuite/tests/simplCore/should_compile/T24770.hs ===================================== @@ -0,0 +1,3 @@ +module T24770 where + +foo = getLine >> getLine ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -516,3 +516,4 @@ test('T24370', normal, compile, ['-O']) test('T24551', normal, compile, ['-O -dcore-lint']) test('T24726', normal, compile, ['-dcore-lint -dsuppress-uniques']) test('T24768', normal, compile, ['-O']) +test('T24770', [ grep_errmsg(r'Dead') ], compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9b4129a580e6c1d18197ef2ed3a8b89d52a2b133...31b28cdb4adde2ab14adb153afa817ef9197830f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9b4129a580e6c1d18197ef2ed3a8b89d52a2b133...31b28cdb4adde2ab14adb153afa817ef9197830f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 17:56:24 2024 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 08 May 2024 13:56:24 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: -fprof-late: Only insert cost centres on functions/non-workfree cafs. Message-ID: <663bbcc898985_6129d4de525c193651@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 9b4129a5 by Andreas Klebinger at 2024-05-08T13:24:20-04:00 -fprof-late: Only insert cost centres on functions/non-workfree cafs. They are usually useless and doing so for data values comes with a large compile time/code size overhead. Fixes #24103 - - - - - 259b63d3 by Sebastian Graf at 2024-05-08T13:24:57-04:00 Simplifier: Preserve OccInfo on DataAlt fields when case binder is dead (#24770) See the adjusted `Note [DataAlt occ info]`. This change also has a positive repercussion on `Note [Combine case alts: awkward corner]`. Fixes #24770. We now try not to call `dataConRepStrictness` in `adjustFieldsIdInfo` when all fields are lazy anyway, leading to a 2% ghc/alloc decrease in T9675. Metric Decrease: T9675 - - - - - 31b28cdb by Sebastian Graf at 2024-05-08T13:24:57-04:00 Kill seqRule, discard dead seq# in Prep (#24334) Discarding seq#s in Core land via `seqRule` was problematic; see #24334. So instead we discard certain dead, discardable seq#s in Prep now. See the updated `Note [seq# magic]`. This fixes the symptoms of #24334. - - - - - a94ca7db by Rodrigo Mesquita at 2024-05-08T13:56:13-04:00 Document NcgImpl methods Fixes #19914 - - - - - c0b61888 by Zejun Wu at 2024-05-08T13:56:17-04:00 Make renamer to be more flexible with parens in the LHS of the rules We used to reject LHS like `(f a) b` in RULES and requires it to be written as `f a b`. It will be handy to allow both as the expression may be more readable with extra parens in some cases when infix operator is involved. Espceially when TemplateHaskell is used, extra parens may be added out of user's control and result in "valid" rules being rejected and there are not always ways to workaround it. Fixes #24621 - - - - - bf203e4d by Rodrigo Mesquita at 2024-05-08T13:56:17-04:00 Rename pre-processor invocation args Small clean up. Uses proper names for the various groups of arguments that make up the pre-processor invocation. - - - - - 11a23306 by Cheng Shao at 2024-05-08T13:56:18-04:00 ghc-heap: fix typo in ghc-heap cbits - - - - - 30 changed files: - compiler/GHC/Cmm.hs - compiler/GHC/CmmToAsm/AArch64/RegInfo.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Core/LateCC.hs - compiler/GHC/Core/LateCC/TopLevelBinds.hs - compiler/GHC/Core/LateCC/Types.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/SysTools/Tasks.hs - compiler/GHC/Types/Id/Make.hs - compiler/GHC/Types/RepType.hs - docs/users_guide/9.12.1-notes.rst - docs/users_guide/profiling.rst - libraries/ghc-heap/cbits/Stack.cmm - testsuite/tests/codeGen/should_compile/T24264.hs - + testsuite/tests/core-to-stg/T24334.hs - + testsuite/tests/core-to-stg/T24334.stdout - testsuite/tests/core-to-stg/all.T - + testsuite/tests/rename/should_compile/T24621_normal.hs - + testsuite/tests/rename/should_compile/T24621_th.hs - testsuite/tests/rename/should_compile/all.T The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/413985ad937ec77a40c7a59ae12eb9ff6f6c98df...11a233063497a42a981c4692963937b0952e0b25 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/413985ad937ec77a40c7a59ae12eb9ff6f6c98df...11a233063497a42a981c4692963937b0952e0b25 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 18:25:18 2024 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Wed, 08 May 2024 14:25:18 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/ubuntu24_04 Message-ID: <663bc38e9162b_6129d52ae50420368b@gitlab.mail> Cheng Shao pushed new branch wip/ubuntu24_04 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ubuntu24_04 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 18:25:26 2024 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 08 May 2024 14:25:26 -0400 Subject: [Git][ghc/ghc][wip/T24466] Wibble Message-ID: <663bc3965af42_6129d52cda9420384c@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24466 at Glasgow Haskell Compiler / GHC Commits: bf9e9ff2 by Simon Peyton Jones at 2024-05-08T19:25:13+01:00 Wibble - - - - - 1 changed file: - compiler/GHC/Core/Opt/Simplify/Utils.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1608,10 +1608,11 @@ postInlineUnconditionally env bind_cxt old_bndr bndr rhs -- in GHC.Core.Opt.Simplify.Iteration | otherwise = case occ_info of - OneOcc { occ_in_lam = in_lam, occ_int_cxt = int_cxt, occ_n_br = n_br } + OneOcc { occ_in_lam = in_lam, occ_n_br = n_br } | n_br == 1, NotInsideLam <- in_lam -- One syntactic occurrence -> True -- See Note [Post-inline for single-use things] {- + OneOcc { occ_in_lam = in_lam, occ_int_cxt = int_cxt, occ_n_br = n_br } -- See Note [Inline small things to avoid creating a thunk] | n_br >= 100 -> False -- See #23627 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bf9e9ff282cbae740bab6807d1014004fa05b7f0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bf9e9ff282cbae740bab6807d1014004fa05b7f0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 18:30:01 2024 From: gitlab at gitlab.haskell.org (Serge S. Gulin (@gulin.serge)) Date: Wed, 08 May 2024 14:30:01 -0400 Subject: [Git][ghc/ghc][wip/T24504] 4 commits: -fprof-late: Only insert cost centres on functions/non-workfree cafs. Message-ID: <663bc4a951fed_6129d54677c42102f4@gitlab.mail> Serge S. Gulin pushed to branch wip/T24504 at Glasgow Haskell Compiler / GHC Commits: 9b4129a5 by Andreas Klebinger at 2024-05-08T13:24:20-04:00 -fprof-late: Only insert cost centres on functions/non-workfree cafs. They are usually useless and doing so for data values comes with a large compile time/code size overhead. Fixes #24103 - - - - - 259b63d3 by Sebastian Graf at 2024-05-08T13:24:57-04:00 Simplifier: Preserve OccInfo on DataAlt fields when case binder is dead (#24770) See the adjusted `Note [DataAlt occ info]`. This change also has a positive repercussion on `Note [Combine case alts: awkward corner]`. Fixes #24770. We now try not to call `dataConRepStrictness` in `adjustFieldsIdInfo` when all fields are lazy anyway, leading to a 2% ghc/alloc decrease in T9675. Metric Decrease: T9675 - - - - - 31b28cdb by Sebastian Graf at 2024-05-08T13:24:57-04:00 Kill seqRule, discard dead seq# in Prep (#24334) Discarding seq#s in Core land via `seqRule` was problematic; see #24334. So instead we discard certain dead, discardable seq#s in Prep now. See the updated `Note [seq# magic]`. This fixes the symptoms of #24334. - - - - - 188631bb by Ben Gamari at 2024-05-08T21:27:57+03:00 IPE: Eliminate dependency on Read Instead of encoding the closure type as decimal string we now simply represent it as an integer, eliminating the need for `Read` in `GHC.Internal.InfoProv.Types.peekInfoProv`. Closes #24504. ------------------------- Metric Decrease: T24602_perf_size size_hello_artifact ------------------------- - - - - - 30 changed files: - compiler/GHC/Core/LateCC.hs - compiler/GHC/Core/LateCC/TopLevelBinds.hs - compiler/GHC/Core/LateCC/Types.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/StgToCmm/InfoTableProv.hs - compiler/GHC/Types/Id/Make.hs - compiler/GHC/Types/RepType.hs - docs/users_guide/9.12.1-notes.rst - docs/users_guide/profiling.rst - libraries/ghc-internal/src/GHC/Internal/InfoProv/Types.hsc - rts/IPE.c - rts/Trace.c - rts/eventlog/EventLog.c - rts/include/rts/Constants.h - rts/include/rts/IPE.h - testsuite/tests/codeGen/should_compile/T24264.hs - + testsuite/tests/core-to-stg/T24334.hs - + testsuite/tests/core-to-stg/T24334.stdout - testsuite/tests/core-to-stg/all.T - testsuite/tests/rts/ipe/ipeEventLog.stderr - testsuite/tests/rts/ipe/ipeEventLog_fromMap.stderr - testsuite/tests/rts/ipe/ipeMap.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/205f4f1a75f5b3121b42ca1b4a224234601d4415...188631bbc1ca2277032e9f59ee22aed68b0702e9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/205f4f1a75f5b3121b42ca1b4a224234601d4415...188631bbc1ca2277032e9f59ee22aed68b0702e9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 20:35:50 2024 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Wed, 08 May 2024 16:35:50 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/az/ghc-9.10-epa-additional-backports Message-ID: <663be22691202_6129d64c7024227863@gitlab.mail> Alan Zimmerman pushed new branch wip/az/ghc-9.10-epa-additional-backports at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/ghc-9.10-epa-additional-backports You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 22:03:45 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 08 May 2024 18:03:45 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/ghc-9.10 Message-ID: <663bf6c187601_9f9652218fc851aa@gitlab.mail> Ben Gamari deleted branch wip/ghc-9.10 at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed May 8 22:03:59 2024 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 08 May 2024 18:03:59 -0400 Subject: [Git][ghc/ghc][ghc-9.10] 15 commits: bindist: Fix xattr cleaning Message-ID: <663bf6cf8463_9f9651311b8853bc@gitlab.mail> Ben Gamari pushed to branch ghc-9.10 at Glasgow Haskell Compiler / GHC Commits: b8c66bf3 by Rodrigo Mesquita at 2024-05-08T02:08:37-04:00 bindist: Fix xattr cleaning The original fix (725343aa) was incorrect because it used the shell bracket syntax which is the quoting syntax in autoconf, making the test for existence be incorrect and therefore `xattr` was never run. Fixes #24554 (cherry picked from commit e03760db6713068ad8ba953d2252ec12b3278c9b) - - - - - 250c5df7 by Ben Gamari at 2024-05-08T02:08:37-04:00 ghcup-metadata: Drop output_name field This is entirely redundant to the filename of the URL. There is no compelling reason to name the downloaded file differently from its source. - - - - - 7b327164 by Alan Zimmerman at 2024-05-08T02:08:37-04:00 EPA: check-exact: check that the roundtrip reproduces the source Closes #24670 (cherry picked from commit 981c2c2c5017cb7ae47babff4d2163324d7cbde6) - - - - - a8c27c7c by Alan Zimmerman at 2024-05-08T02:09:14-04:00 EPA: Preserve comments in Match Pats Closes #24708 Closes #24715 Closes #24734 (cherry picked from commit 1c2fd963d6fd78d1c752a21348c7db85f5d64df2) - - - - - e8603c75 by Alan Zimmerman at 2024-05-08T02:09:27-04:00 EPA: Preserve comments for PrefixCon Preserve comments in fun (Con {- c1 -} a b) = undefined Closes #24736 (cherry picked from commit 40026ac30fcdbe84a551f445f5e20691c0527ded) - - - - - 015a0430 by Alan Zimmerman at 2024-05-08T02:09:27-04:00 EPA: fix span for empty \case(s) In instance SDecide Nat where SZero %~ (SSucc _) = Disproved (\case) Ensure the span for the HsLam covers the full construct. Closes #24748 (cherry picked from commit 167a56a003106ed84742e3970cc2189ffb98b0c7) - - - - - c5a65a7f by Alan Zimmerman at 2024-05-08T02:09:27-04:00 EPA: preserve comments in class and data decls Fix checkTyClHdr which was discarding comments. Closes #24755 (cherry picked from commit 35d34fde62cd9e0002ac42f10bf705552f5c654e) - - - - - 43a7dc68 by Alan Zimmerman at 2024-05-08T02:09:27-04:00 EPA: fix mkHsOpTyPV duplicating comments Closes #24753 (cherry picked from commit 18f4ff84b323236f6dfd07f3bbc2842308a01e91) - - - - - 01eeecec by Alan Zimmerman at 2024-05-08T02:09:27-04:00 EPA: preserve comments in data decls Closes #24771 (cherry picked from commit 46328a49d988143111ab530d7907b9426b58311a) - - - - - 2c7a0cf7 by Simon Peyton Jones at 2024-05-08T02:09:27-04:00 Track in-scope variables in ruleCheckProgram This small patch fixes #24726, by tracking in-scope variables properly in -drule-check. Not hard to do! (cherry picked from commit be1e60eec0ec37da41643af17d78c698ab2a7083) - - - - - 4896c50b by Andrew Lelechenko at 2024-05-08T02:09:27-04:00 Document that setEnv is not thread-safe (cherry picked from commit a86167471a7a471fb75ae9ba6c641bd1e74bc16d) - - - - - 843f95b1 by Matthew Pickering at 2024-05-08T02:09:27-04:00 Don't depend on registerPackage function in Cabal More recent versions of Cabal modify the behaviour of libAbiHash which breaks our usage of registerPackage. It is simpler to inline the part of registerPackage that we need and avoid any additional dependency and complication using the higher-level function introduces. (cherry picked from commit 3fff09779d5830549ae455a15907b7bb9fe7859a) - - - - - 720ff1f9 by Hécate Moonlight at 2024-05-08T02:09:27-04:00 Correct `@since` metadata in HpcFlags It was introduced in base-4.20, not 4.22. Fix #24721 (cherry picked from commit 9213478931b18402998c18f5c4e6f0ee09054b18) - - - - - 7f9b05a8 by Teo Camarasu at 2024-05-08T02:09:27-04:00 doc: Fix type error in hs_try_putmvar example (cherry picked from commit 06f7db4001e4eee0f3076d949876f8f4af0eb6fb) - - - - - d5f45368 by Cheng Shao at 2024-05-08T09:39:29+01:00 driver: always merge objects when possible This patch makes the driver always merge objects with `ld -r` when possible, and only fall back to calling `ar -L` when merge objects command is unavailable. This completely reverts !8887 and !12313, given more fixes in Cabal seems to be needed to avoid breaking certain configurations and the maintainence cost is exceeding the behefits in this case :/ (cherry picked from commit 631cefec222e2db951c58db0b15a8d80ef5549cb) - - - - - 26 changed files: - .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py - compiler/GHC/Core/Rules.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - distrib/configure.ac.in - docs/users_guide/exts/ffi.rst - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc - libraries/ghc-internal/src/GHC/Internal/System/Environment.hs - libraries/ghc-internal/src/GHC/Internal/System/Environment/Blank.hsc - testsuite/tests/parser/should_compile/T20846.stderr - testsuite/tests/printer/Makefile - + testsuite/tests/printer/MatchPatComments.hs - testsuite/tests/printer/PprExportWarn.hs - + testsuite/tests/printer/PrefixConComment.hs - + testsuite/tests/printer/Test24748.hs - + testsuite/tests/printer/Test24753.hs - + testsuite/tests/printer/Test24755.hs - + testsuite/tests/printer/Test24771.hs - testsuite/tests/printer/all.T - + testsuite/tests/simplCore/should_compile/T24726.hs - + testsuite/tests/simplCore/should_compile/T24726.stderr - testsuite/tests/simplCore/should_compile/all.T - utils/check-exact/Main.hs Changes: ===================================== .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py ===================================== @@ -65,7 +65,6 @@ eprint(f"Supported platforms: {job_mapping.keys()}") class Artifact(NamedTuple): job_name: str download_name: str - output_name: str subdir: str # Platform spec provides a specification which is agnostic to Job @@ -75,11 +74,9 @@ class PlatformSpec(NamedTuple): subdir: str source_artifact = Artifact('source-tarball' - , 'ghc-{version}-src.tar.xz' , 'ghc-{version}-src.tar.xz' , 'ghc-{version}' ) test_artifact = Artifact('source-tarball' - , 'ghc-{version}-testsuite.tar.xz' , 'ghc-{version}-testsuite.tar.xz' , 'ghc-{version}/testsuite' ) @@ -164,11 +161,6 @@ def mk_one_metadata(release_mode, version, job_map, artifact): , "dlSubdir": artifact.subdir.format(version=version) , "dlHash" : h } - # Only add dlOutput if it is inconsistent with the filename inferred from the URL - output = artifact.output_name.format(version=version) - if Path(urlparse(final_url).path).name != output: - res["dlOutput"] = output - eprint(res) return res ===================================== compiler/GHC/Core/Rules.hs ===================================== @@ -47,7 +47,7 @@ import GHC.Driver.Ppr( showSDoc ) import GHC.Core -- All of it import GHC.Core.Subst import GHC.Core.SimpleOpt ( exprIsLambda_maybe ) -import GHC.Core.FVs ( exprFreeVars, exprsFreeVars, bindFreeVars +import GHC.Core.FVs ( exprFreeVars, bindFreeVars , rulesFreeVarsDSet, exprsOrphNames ) import GHC.Core.Utils ( exprType, mkTick, mkTicks , stripTicksTopT, stripTicksTopE @@ -1887,41 +1887,59 @@ ruleCheckProgram ropts phase rule_pat rules binds vcat [ p $$ line | p <- bagToList results ] ] where + line = text (replicate 20 '-') env = RuleCheckEnv { rc_is_active = isActive phase , rc_id_unf = idUnfolding -- Not quite right -- Should use activeUnfolding , rc_pattern = rule_pat , rc_rules = rules , rc_ropts = ropts - } - results = unionManyBags (map (ruleCheckBind env) binds) - line = text (replicate 20 '-') + , rc_in_scope = emptyInScopeSet } + + results = go env binds + + go _ [] = emptyBag + go env (bind:binds) = let (env', ds) = ruleCheckBind env bind + in ds `unionBags` go env' binds + +data RuleCheckEnv = RuleCheckEnv + { rc_is_active :: Activation -> Bool + , rc_id_unf :: IdUnfoldingFun + , rc_pattern :: String + , rc_rules :: Id -> [CoreRule] + , rc_ropts :: RuleOpts + , rc_in_scope :: InScopeSet } + +extendInScopeRC :: RuleCheckEnv -> Var -> RuleCheckEnv +extendInScopeRC env@(RuleCheckEnv { rc_in_scope = in_scope }) v + = env { rc_in_scope = in_scope `extendInScopeSet` v } -data RuleCheckEnv = RuleCheckEnv { - rc_is_active :: Activation -> Bool, - rc_id_unf :: IdUnfoldingFun, - rc_pattern :: String, - rc_rules :: Id -> [CoreRule], - rc_ropts :: RuleOpts -} +extendInScopeListRC :: RuleCheckEnv -> [Var] -> RuleCheckEnv +extendInScopeListRC env@(RuleCheckEnv { rc_in_scope = in_scope }) vs + = env { rc_in_scope = in_scope `extendInScopeSetList` vs } -ruleCheckBind :: RuleCheckEnv -> CoreBind -> Bag SDoc +ruleCheckBind :: RuleCheckEnv -> CoreBind -> (RuleCheckEnv, Bag SDoc) -- The Bag returned has one SDoc for each call site found -ruleCheckBind env (NonRec _ r) = ruleCheck env r -ruleCheckBind env (Rec prs) = unionManyBags [ruleCheck env r | (_,r) <- prs] +ruleCheckBind env (NonRec b r) = (env `extendInScopeRC` b, ruleCheck env r) +ruleCheckBind env (Rec prs) = (env', unionManyBags (map (ruleCheck env') rhss)) + where + (bs, rhss) = unzip prs + env' = env `extendInScopeListRC` bs ruleCheck :: RuleCheckEnv -> CoreExpr -> Bag SDoc -ruleCheck _ (Var _) = emptyBag -ruleCheck _ (Lit _) = emptyBag -ruleCheck _ (Type _) = emptyBag -ruleCheck _ (Coercion _) = emptyBag -ruleCheck env (App f a) = ruleCheckApp env (App f a) [] -ruleCheck env (Tick _ e) = ruleCheck env e -ruleCheck env (Cast e _) = ruleCheck env e -ruleCheck env (Let bd e) = ruleCheckBind env bd `unionBags` ruleCheck env e -ruleCheck env (Lam _ e) = ruleCheck env e -ruleCheck env (Case e _ _ as) = ruleCheck env e `unionBags` - unionManyBags [ruleCheck env r | Alt _ _ r <- as] +ruleCheck _ (Var _) = emptyBag +ruleCheck _ (Lit _) = emptyBag +ruleCheck _ (Type _) = emptyBag +ruleCheck _ (Coercion _) = emptyBag +ruleCheck env (App f a) = ruleCheckApp env (App f a) [] +ruleCheck env (Tick _ e) = ruleCheck env e +ruleCheck env (Cast e _) = ruleCheck env e +ruleCheck env (Let bd e) = let (env', ds) = ruleCheckBind env bd + in ds `unionBags` ruleCheck env' e +ruleCheck env (Lam b e) = ruleCheck (env `extendInScopeRC` b) e +ruleCheck env (Case e b _ as) = ruleCheck env e `unionBags` + unionManyBags [ruleCheck (env `extendInScopeListRC` (b:bs)) r + | Alt _ bs r <- as] ruleCheckApp :: RuleCheckEnv -> Expr CoreBndr -> [Arg CoreBndr] -> Bag SDoc ruleCheckApp env (App f a) as = ruleCheck env a `unionBags` ruleCheckApp env f (a:as) @@ -1945,8 +1963,9 @@ ruleAppCheck_help env fn args rules vcat [text "Expression:" <+> ppr (mkApps (Var fn) args), vcat (map check_rule rules)] where - n_args = length args - i_args = args `zip` [1::Int ..] + in_scope = rc_in_scope env + n_args = length args + i_args = args `zip` [1::Int ..] rough_args = map roughTopName args check_rule rule = rule_herald rule <> colon <+> rule_info (rc_ropts env) rule @@ -1976,10 +1995,8 @@ ruleAppCheck_help env fn args rules mismatches = [i | (rule_arg, (arg,i)) <- rule_args `zip` i_args, not (isJust (match_fn rule_arg arg))] - lhs_fvs = exprsFreeVars rule_args -- Includes template tyvars match_fn rule_arg arg = match renv emptyRuleSubst rule_arg arg MRefl where - in_scope = mkInScopeSet (lhs_fvs `unionVarSet` exprFreeVars arg) renv = RV { rv_lcl = mkRnEnv2 in_scope , rv_tmpls = mkVarSet rule_bndrs , rv_fltR = mkEmptySubst in_scope ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -1040,13 +1040,17 @@ this is accomplished with the `ld -r` command. We rely on this for two ends: The command used for object linking is set using the -pgmlm and -optlm command-line options. -Sadly, the LLD linker that we use on Windows does not support the `-r` flag -needed to support object merging (see #21068). For this reason on Windows we do -not support GHCi objects. To deal with foreign stubs we build a static archive -of all of a module's object files instead merging them. Consequently, we can -end up producing `.o` files which are in fact static archives. However, -toolchains generally don't have a problem with this as they use file headers, -not the filename, to determine the nature of inputs. +However, `ld -r` is broken in some cases: + + * The LLD linker that we use on Windows does not support the `-r` + flag needed to support object merging (see #21068). For this reason + on Windows we do not support GHCi objects. + +In these cases, we bundle a module's own object file with its foreign +stub's object file, instead of merging them. Consequently, we can end +up producing `.o` files which are in fact static archives. This can +only work if `ar -L` is supported, so the archive `.o` files can be +properly added to the final static library. Note that this has somewhat non-obvious consequences when producing initializers and finalizers. See Note [Initializers and finalizers in Cmm] @@ -1072,7 +1076,7 @@ via gcc. -- | See Note [Object merging]. joinObjectFiles :: HscEnv -> [FilePath] -> FilePath -> IO () joinObjectFiles hsc_env o_files output_fn - | can_merge_objs && not dashLSupported = do + | can_merge_objs = do let toolSettings' = toolSettings dflags ldIsGnuLd = toolSettings_ldIsGnuLd toolSettings' ld_r args = GHC.SysTools.runMergeObjects (hsc_logger hsc_env) (hsc_tmpfs hsc_env) (hsc_dflags hsc_env) ( ===================================== compiler/GHC/Parser.y ===================================== @@ -2486,9 +2486,8 @@ forall :: { Located ([AddEpAnn], Maybe [LHsTyVarBndr Specificity GhcPs]) } | {- empty -} { noLoc ([], Nothing) } constr_stuff :: { Located (LocatedN RdrName, HsConDeclH98Details GhcPs) } - : infixtype {% fmap (reLoc. (fmap (\b -> (dataConBuilderCon b, - dataConBuilderDetails b)))) - (runPV $1) } + : infixtype {% do { b <- runPV $1 + ; return (sL1 b (dataConBuilderCon b, dataConBuilderDetails b)) }} | '(#' usum_constr '#)' {% let (t, tag, arity) = $2 in pure (sLL $1 $3 $ mkUnboxedSumCon t tag arity)} usum_constr :: { (LHsType GhcPs, Int, Int) } -- constructor for the data decls SumN# @@ -2900,10 +2899,10 @@ aexp :: { ECP } [mj AnnLam $1] } | '\\' 'lcase' altslist(pats1) { ECP $ $3 >>= \ $3 -> - mkHsLamPV (comb2 $1 $>) LamCase $3 [mj AnnLam $1,mj AnnCase $2] } + mkHsLamPV (comb3 $1 $2 $>) LamCase $3 [mj AnnLam $1,mj AnnCase $2] } | '\\' 'lcases' altslist(argpats) { ECP $ $3 >>= \ $3 -> - mkHsLamPV (comb2 $1 $>) LamCases $3 [mj AnnLam $1,mj AnnCases $2] } + mkHsLamPV (comb3 $1 $2 $>) LamCases $3 [mj AnnLam $1,mj AnnCases $2] } | 'if' exp optSemi 'then' exp optSemi 'else' exp {% runPV (unECP $2) >>= \ ($2 :: LHsExpr GhcPs) -> return $ ECP $ ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -1244,7 +1244,7 @@ transferAnnsOnlyA (EpAnn a an cs) (EpAnn a' an' cs') -- | Transfer comments from the annotations in the -- first 'SrcSpanAnnA' argument to those in the second. -transferCommentsOnlyA :: SrcSpanAnnA -> SrcSpanAnnA -> (SrcSpanAnnA, SrcSpanAnnA) +transferCommentsOnlyA :: EpAnn a -> EpAnn b -> (EpAnn a, EpAnn b) transferCommentsOnlyA (EpAnn a an cs) (EpAnn a' an' cs') = (EpAnn a an emptyComments, EpAnn a' an' (cs <> cs')) ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -205,11 +205,11 @@ mkClassDecl :: SrcSpan -> P (LTyClDecl GhcPs) mkClassDecl loc' (L _ (mcxt, tycl_hdr)) fds where_cls layout annsIn - = do { let loc = noAnnSrcSpan loc' - ; (binds, sigs, ats, at_defs, _, docs) <- cvBindsAndSigs where_cls - ; (cls, tparams, fixity, ann) <- checkTyClHdr True tycl_hdr + = do { (binds, sigs, ats, at_defs, _, docs) <- cvBindsAndSigs where_cls + ; (cls, tparams, fixity, ann, cs) <- checkTyClHdr True tycl_hdr ; tyvars <- checkTyVars (text "class") whereDots cls tparams ; let anns' = annsIn Semi.<> ann + ; let loc = EpAnn (spanAsAnchor loc') noAnn cs ; return (L loc (ClassDecl { tcdCExt = (anns', layout, NoAnnSortKey) , tcdCtxt = mcxt , tcdLName = cls, tcdTyVars = tyvars @@ -232,12 +232,13 @@ mkTyData :: SrcSpan -> P (LTyClDecl GhcPs) mkTyData loc' is_type_data new_or_data cType (L _ (mcxt, tycl_hdr)) ksig data_cons (L _ maybe_deriv) annsIn - = do { let loc = noAnnSrcSpan loc' - ; (tc, tparams, fixity, ann) <- checkTyClHdr False tycl_hdr + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False tycl_hdr ; tyvars <- checkTyVars (ppr new_or_data) equalsDots tc tparams ; let anns' = annsIn Semi.<> ann - ; data_cons <- checkNewOrData (locA loc) (unLoc tc) is_type_data new_or_data data_cons + ; data_cons <- checkNewOrData loc' (unLoc tc) is_type_data new_or_data data_cons ; defn <- mkDataDefn cType mcxt ksig data_cons maybe_deriv + ; !cs' <- getCommentsFor loc' + ; let loc = EpAnn (spanAsAnchor loc') noAnn (cs' Semi.<> cs) ; return (L loc (DataDecl { tcdDExt = anns', tcdLName = tc, tcdTyVars = tyvars, tcdFixity = fixity, @@ -264,14 +265,14 @@ mkTySynonym :: SrcSpan -> [AddEpAnn] -> P (LTyClDecl GhcPs) mkTySynonym loc lhs rhs annsIn - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs ; tyvars <- checkTyVars (text "type") equalsDots tc tparams ; let anns' = annsIn Semi.<> ann - ; return (L (noAnnSrcSpan loc) (SynDecl - { tcdSExt = anns' - , tcdLName = tc, tcdTyVars = tyvars - , tcdFixity = fixity - , tcdRhs = rhs })) } + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (SynDecl { tcdSExt = anns' + , tcdLName = tc, tcdTyVars = tyvars + , tcdFixity = fixity + , tcdRhs = rhs })) } mkStandaloneKindSig :: SrcSpan @@ -304,8 +305,9 @@ mkTyFamInstEqn :: SrcSpan -> [AddEpAnn] -> P (LTyFamInstEqn GhcPs) mkTyFamInstEqn loc bndrs lhs rhs anns - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs - ; return (L (noAnnSrcSpan loc) $ FamEqn + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' $ FamEqn { feqn_ext = anns `mappend` ann , feqn_tycon = tc , feqn_bndrs = bndrs @@ -325,10 +327,11 @@ mkDataFamInst :: SrcSpan -> P (LInstDecl GhcPs) mkDataFamInst loc new_or_data cType (mcxt, bndrs, tycl_hdr) ksig data_cons (L _ maybe_deriv) anns - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False tycl_hdr + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False tycl_hdr ; data_cons <- checkNewOrData loc (unLoc tc) False new_or_data data_cons ; defn <- mkDataDefn cType mcxt ksig data_cons maybe_deriv - ; return (L (noAnnSrcSpan loc) (DataFamInstD noExtField (DataFamInstDecl + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (DataFamInstD noExtField (DataFamInstDecl (FamEqn { feqn_ext = ann Semi.<> anns , feqn_tycon = tc , feqn_bndrs = bndrs @@ -369,10 +372,10 @@ mkFamDecl :: SrcSpan -> [AddEpAnn] -> P (LTyClDecl GhcPs) mkFamDecl loc info topLevel lhs ksig injAnn annsIn - = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs + = do { (tc, tparams, fixity, ann, cs) <- checkTyClHdr False lhs ; tyvars <- checkTyVars (ppr info) equals_or_where tc tparams - ; return (L (noAnnSrcSpan loc) (FamDecl noExtField - (FamilyDecl + ; let loc' = EpAnn (spanAsAnchor loc) noAnn cs + ; return (L loc' (FamDecl noExtField (FamilyDecl { fdExt = annsIn Semi.<> ann , fdTopLevel = topLevel , fdInfo = info, fdLName = tc @@ -1041,45 +1044,46 @@ checkTyClHdr :: Bool -- True <=> class header -> P (LocatedN RdrName, -- the head symbol (type or class name) [LHsTypeArg GhcPs], -- parameters of head symbol LexicalFixity, -- the declaration is in infix format - [AddEpAnn]) -- API Annotation for HsParTy + [AddEpAnn], -- API Annotation for HsParTy -- when stripping parens + EpAnnComments) -- Accumulated comments from re-arranging -- Well-formedness check and decomposition of type and class heads. -- Decomposes T ty1 .. tyn into (T, [ty1, ..., tyn]) -- Int :*: Bool into (:*:, [Int, Bool]) -- returning the pieces checkTyClHdr is_cls ty - = goL ty [] [] [] Prefix + = goL emptyComments ty [] [] [] Prefix where - goL (L l ty) acc ops cps fix = go l ty acc ops cps fix + goL cs (L l ty) acc ops cps fix = go cs l ty acc ops cps fix -- workaround to define '*' despite StarIsType - go ll (HsParTy an (L l (HsStarTy _ isUni))) acc ops' cps' fix + go cs ll (HsParTy an (L l (HsStarTy _ isUni))) acc ops' cps' fix = do { addPsMessage (locA l) PsWarnStarBinder ; let name = mkOccNameFS tcClsName (starSym isUni) ; let a' = newAnns ll l an ; return (L a' (Unqual name), acc, fix - , (reverse ops') ++ cps') } + , (reverse ops') ++ cps', cs) } - go _ (HsTyVar _ _ ltc@(L _ tc)) acc ops cps fix - | isRdrTc tc = return (ltc, acc, fix, (reverse ops) ++ cps) - go _ (HsOpTy _ _ t1 ltc@(L _ tc) t2) acc ops cps _fix - | isRdrTc tc = return (ltc, lhs:rhs:acc, Infix, (reverse ops) ++ cps) + go cs l (HsTyVar _ _ ltc@(L _ tc)) acc ops cps fix + | isRdrTc tc = return (ltc, acc, fix, (reverse ops) ++ cps, cs Semi.<> comments l) + go cs l (HsOpTy _ _ t1 ltc@(L _ tc) t2) acc ops cps _fix + | isRdrTc tc = return (ltc, lhs:rhs:acc, Infix, (reverse ops) ++ cps, cs Semi.<> comments l) where lhs = HsValArg noExtField t1 rhs = HsValArg noExtField t2 - go l (HsParTy _ ty) acc ops cps fix = goL ty acc (o:ops) (c:cps) fix + go cs l (HsParTy _ ty) acc ops cps fix = goL (cs Semi.<> comments l) ty acc (o:ops) (c:cps) fix where (o,c) = mkParensEpAnn (realSrcSpan (locA l)) - go _ (HsAppTy _ t1 t2) acc ops cps fix = goL t1 (HsValArg noExtField t2:acc) ops cps fix - go _ (HsAppKindTy at ty ki) acc ops cps fix = goL ty (HsTypeArg at ki:acc) ops cps fix - go l (HsTupleTy _ HsBoxedOrConstraintTuple ts) [] ops cps fix + go cs l (HsAppTy _ t1 t2) acc ops cps fix = goL (cs Semi.<> comments l) t1 (HsValArg noExtField t2:acc) ops cps fix + go cs l (HsAppKindTy at ty ki) acc ops cps fix = goL (cs Semi.<> comments l) ty (HsTypeArg at ki:acc) ops cps fix + go cs l (HsTupleTy _ HsBoxedOrConstraintTuple ts) [] ops cps fix = return (L (l2l l) (nameRdrName tup_name) - , map (HsValArg noExtField) ts, fix, (reverse ops)++cps) + , map (HsValArg noExtField) ts, fix, (reverse ops)++cps, cs Semi.<> comments l) where arity = length ts tup_name | is_cls = cTupleTyConName arity | otherwise = getName (tupleTyCon Boxed arity) -- See Note [Unit tuples] in GHC.Hs.Type (TODO: is this still relevant?) - go l _ _ _ _ _ + go _ l _ _ _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope (locA l) $ (PsErrMalformedTyOrClDecl ty) @@ -1211,33 +1215,34 @@ checkPattern_details :: ParseContext -> PV (LocatedA (PatBuilder GhcPs)) -> P (L checkPattern_details extraDetails pp = runPV_details extraDetails (pp >>= checkLPat) checkLArgPat :: LocatedA (ArgPatBuilder GhcPs) -> PV (LPat GhcPs) -checkLArgPat (L l (ArgPatBuilderVisPat p)) - = checkPat l (L l p) [] [] +checkLArgPat (L l (ArgPatBuilderVisPat p)) = checkLPat (L l p) checkLArgPat (L l (ArgPatBuilderArgPat p)) = return (L l p) checkLPat :: LocatedA (PatBuilder GhcPs) -> PV (LPat GhcPs) -checkLPat e@(L l _) = checkPat l e [] [] - -checkPat :: SrcSpanAnnA -> LocatedA (PatBuilder GhcPs) -> [HsConPatTyArg GhcPs] -> [LPat GhcPs] - -> PV (LPat GhcPs) -checkPat loc (L l e@(PatBuilderVar (L ln c))) tyargs args - | isRdrDataCon c = return . L loc $ ConPat +checkLPat (L l@(EpAnn anc an _) p) = do + (L l' p', cs) <- checkPat (EpAnn anc an emptyComments) emptyComments (L l p) [] [] + return (L (addCommentsToEpAnn l' cs) p') + +checkPat :: SrcSpanAnnA -> EpAnnComments -> LocatedA (PatBuilder GhcPs) -> [HsConPatTyArg GhcPs] -> [LPat GhcPs] + -> PV (LPat GhcPs, EpAnnComments) +checkPat loc cs (L l e@(PatBuilderVar (L ln c))) tyargs args + | isRdrDataCon c = return (L loc $ ConPat { pat_con_ext = noAnn -- AZ: where should this come from? , pat_con = L ln c , pat_args = PrefixCon tyargs args - } + }, comments l Semi.<> cs) | (not (null args) && patIsRec c) = do ctx <- askParseContext patFail (locA l) . PsErrInPat e $ PEIP_RecPattern args YesPatIsRecursive ctx -checkPat loc (L _ (PatBuilderAppType f at t)) tyargs args = - checkPat loc f (HsConPatTyArg at t : tyargs) args -checkPat loc (L _ (PatBuilderApp f e)) [] args = do +checkPat loc cs (L la (PatBuilderAppType f at t)) tyargs args = + checkPat loc (cs Semi.<> comments la) f (HsConPatTyArg at t : tyargs) args +checkPat loc cs (L la (PatBuilderApp f e)) [] args = do p <- checkLPat e - checkPat loc f [] (p : args) -checkPat loc (L l e) [] [] = do + checkPat loc (cs Semi.<> comments la) f [] (p : args) +checkPat loc cs (L l e) [] [] = do p <- checkAPat loc e - return (L l p) -checkPat loc e _ _ = do + return (L l p, cs) +checkPat loc _ e _ _ = do details <- fromParseContext <$> askParseContext patFail (locA loc) (PsErrInPat (unLoc e) details) @@ -1346,13 +1351,13 @@ checkFunBind :: SrcStrictness -> [LocatedA (ArgPatBuilder GhcPs)] -> Located (GRHSs GhcPs (LHsExpr GhcPs)) -> P (HsBind GhcPs) -checkFunBind strictness locF ann fun is_infix pats (L _ grhss) +checkFunBind strictness locF ann (L lf fun) is_infix pats (L _ grhss) = do ps <- runPV_details extraDetails (mapM checkLArgPat pats) let match_span = noAnnSrcSpan $ locF - return (makeFunBind fun (L (noAnnSrcSpan $ locA match_span) + return (makeFunBind (L (l2l lf) fun) (L (noAnnSrcSpan $ locA match_span) [L match_span (Match { m_ext = ann , m_ctxt = FunRhs - { mc_fun = fun + { mc_fun = L lf fun , mc_fixity = is_infix , mc_strictness = strictness } , m_pats = ps @@ -1361,7 +1366,7 @@ checkFunBind strictness locF ann fun is_infix pats (L _ grhss) -- That isn't quite right, but it'll do for now. where extraDetails - | Infix <- is_infix = ParseContext (Just $ unLoc fun) NoIncompleteDoBlock + | Infix <- is_infix = ParseContext (Just fun) NoIncompleteDoBlock | otherwise = noParseContext makeFunBind :: LocatedN RdrName -> LocatedL [LMatch GhcPs (LHsExpr GhcPs)] @@ -1433,20 +1438,27 @@ isFunLhs e = go e [] [] [] where mk = fmap ArgPatBuilderVisPat - go (L _ (PatBuilderVar (L loc f))) es ops cps - | not (isRdrDataCon f) = return (Just (L loc f, Prefix, es, (reverse ops) ++ cps)) - go (L _ (PatBuilderApp f e)) es ops cps = go f (mk e:es) ops cps - go (L l (PatBuilderPar _ e _)) es@(_:_) ops cps = go e es (o:ops) (c:cps) + go (L l (PatBuilderVar (L loc f))) es ops cps + | not (isRdrDataCon f) = do + let (_l, loc') = transferCommentsOnlyA l loc + return (Just (L loc' f, Prefix, es, (reverse ops) ++ cps)) + go (L l (PatBuilderApp (L lf f) e)) es ops cps = do + let (_l, lf') = transferCommentsOnlyA l lf + go (L lf' f) (mk e:es) ops cps + go (L l (PatBuilderPar _ (L le e) _)) es@(_:_) ops cps = go (L le' e) es (o:ops) (c:cps) -- NB: es@(_:_) means that there must be an arg after the parens for the -- LHS to be a function LHS. This corresponds to the Haskell Report's definition -- of funlhs. where + (_l, le') = transferCommentsOnlyA l le (o,c) = mkParensEpAnn (realSrcSpan $ locA l) - go (L loc (PatBuilderOpApp l (L loc' op) r anns)) es ops cps + go (L loc (PatBuilderOpApp (L ll l) (L loc' op) r anns)) es ops cps | not (isRdrDataCon op) -- We have found the function! - = return (Just (L loc' op, Infix, (mk l:mk r:es), (anns ++ reverse ops ++ cps))) + = do { let (_l, ll') = transferCommentsOnlyA loc ll + ; return (Just (L loc' op, Infix, (mk (L ll' l):mk r:es), (anns ++ reverse ops ++ cps))) } | otherwise -- Infix data con; keep going - = do { mb_l <- go l es ops cps + = do { let (_l, ll') = transferCommentsOnlyA loc ll + ; mb_l <- go (L ll' l) es ops cps ; return (reassociate =<< mb_l) } where reassociate (op', Infix, j : L k_loc (ArgPatBuilderVisPat k) : es', anns') @@ -1455,12 +1467,13 @@ isFunLhs e = go e [] [] [] op_app = mk $ L loc (PatBuilderOpApp (L k_loc k) (L loc' op) r (reverse ops ++ cps)) reassociate _other = Nothing - go (L _ (PatBuilderAppType pat tok ty_pat@(HsTP _ (L (EpAnn anc ann cs) _)))) es ops cps - = go pat (L (EpAnn anc' ann cs) (ArgPatBuilderArgPat invis_pat) : es) ops cps + go (L l (PatBuilderAppType (L lp pat) tok ty_pat@(HsTP _ (L (EpAnn anc ann cs) _)))) es ops cps + = go (L lp' pat) (L (EpAnn anc' ann cs) (ArgPatBuilderArgPat invis_pat) : es) ops cps where invis_pat = InvisPat tok ty_pat anc' = case tok of NoEpTok -> anc EpTok l -> widenAnchor anc [AddEpAnn AnnAnyclass l] + (_l, lp') = transferCommentsOnlyA l lp go _ _ _ _ = return Nothing data ArgPatBuilder p @@ -2048,28 +2061,32 @@ instance DisambTD (HsType GhcPs) where mkHsAppTyHeadPV = return mkHsAppTyPV t1 t2 = return (mkHsAppTy t1 t2) mkHsAppKindTyPV t at ki = return (mkHsAppKindTy at t ki) - mkHsOpTyPV prom t1 op t2 = return (mkLHsOpTy prom t1 op t2) + mkHsOpTyPV prom t1 op t2 = do + let (L l ty) = mkLHsOpTy prom t1 op t2 + !cs <- getCommentsFor (locA l) + return (L (addCommentsToEpAnn l cs) ty) mkUnpackednessPV = addUnpackednessP -dataConBuilderCon :: DataConBuilder -> LocatedN RdrName -dataConBuilderCon (PrefixDataConBuilder _ dc) = dc -dataConBuilderCon (InfixDataConBuilder _ dc _) = dc +dataConBuilderCon :: LocatedA DataConBuilder -> LocatedN RdrName +dataConBuilderCon (L _ (PrefixDataConBuilder _ dc)) = dc +dataConBuilderCon (L _ (InfixDataConBuilder _ dc _)) = dc -dataConBuilderDetails :: DataConBuilder -> HsConDeclH98Details GhcPs +dataConBuilderDetails :: LocatedA DataConBuilder -> HsConDeclH98Details GhcPs -- Detect when the record syntax is used: -- data T = MkT { ... } -dataConBuilderDetails (PrefixDataConBuilder flds _) +dataConBuilderDetails (L _ (PrefixDataConBuilder flds _)) | [L (EpAnn anc _ cs) (HsRecTy an fields)] <- toList flds = RecCon (L (EpAnn anc an cs) fields) -- Normal prefix constructor, e.g. data T = MkT A B C -dataConBuilderDetails (PrefixDataConBuilder flds _) +dataConBuilderDetails (L _ (PrefixDataConBuilder flds _)) = PrefixCon noTypeArgs (map hsLinear (toList flds)) -- Infix constructor, e.g. data T = Int :! Bool -dataConBuilderDetails (InfixDataConBuilder lhs _ rhs) - = InfixCon (hsLinear lhs) (hsLinear rhs) +dataConBuilderDetails (L (EpAnn _ _ csl) (InfixDataConBuilder (L (EpAnn anc ann csll) lhs) _ rhs)) + = InfixCon (hsLinear (L (EpAnn anc ann (csl Semi.<> csll)) lhs)) (hsLinear rhs) + instance DisambTD DataConBuilder where mkHsAppTyHeadPV = tyToDataConBuilder @@ -2090,8 +2107,9 @@ instance DisambTD DataConBuilder where mkHsOpTyPV prom lhs tc rhs = do check_no_ops (unLoc rhs) -- check the RHS because parsing type operators is right-associative data_con <- eitherToP $ tyConToDataCon tc + !cs <- getCommentsFor (locA l) checkNotPromotedDataCon prom data_con - return $ L l (InfixDataConBuilder lhs data_con rhs) + return $ L (addCommentsToEpAnn l cs) (InfixDataConBuilder lhs data_con rhs) where l = combineLocsA lhs rhs check_no_ops (HsBangTy _ _ t) = check_no_ops (unLoc t) @@ -3212,8 +3230,8 @@ mkSumOrTuplePat l Boxed a at Sum{} _ = mkLHsOpTy :: PromotionFlag -> LHsType GhcPs -> LocatedN RdrName -> LHsType GhcPs -> LHsType GhcPs mkLHsOpTy prom x op y = - let loc = getLoc x `combineSrcSpansA` (noAnnSrcSpan $ getLocA op) `combineSrcSpansA` getLoc y - in L loc (mkHsOpTy prom x op y) + let loc = locA x `combineSrcSpans` locA op `combineSrcSpans` locA y + in L (noAnnSrcSpan loc) (mkHsOpTy prom x op y) mkMultTy :: EpToken "%" -> LHsType GhcPs -> EpUniToken "->" "→" -> HsArrow GhcPs mkMultTy pct t@(L _ (HsTyLit _ (HsNumTy (SourceText (unpackFS -> "1")) 1))) arr ===================================== distrib/configure.ac.in ===================================== @@ -114,16 +114,16 @@ if test "$HostOS" = "darwin"; then # The following is the work around suggested by @carter in #17418 during # install time. This should help us with code signing issues by removing # extended attributes from all files. - XATTR=${XATTR:-/usr/bin/xattr} + XATTR="${XATTR:-/usr/bin/xattr}" - if [ -e "${XATTR}" ]; then + if test -e "${XATTR}"; then # Instead of cleaning the attributes of the ghc-toolchain binary only, # we clean them from all files in the bin/ and lib/ directories, as it additionally future # proofs running executables from the bindist besides ghc-toolchain at configure time, and # we can avoid figuring out the path to the ghc-toolchain dynlib specifically. - /usr/bin/xattr -rc bin/ - /usr/bin/xattr -rc lib/ + "$XATTR" -rc bin/ + "$XATTR" -rc lib/ fi fi ===================================== docs/users_guide/exts/ffi.rst ===================================== @@ -998,7 +998,7 @@ the data. We can do it like this: sp <- newStablePtrPrimMVar mvar fp <- mallocForeignPtr withForeignPtr fp $ \presult -> do - cap <- threadCapability =<< myThreadId + (cap, _) <- threadCapability =<< myThreadId scheduleCallback sp cap presult takeMVar mvar `onException` forkIO (do takeMVar mvar; touchForeignPtr fp) ===================================== hadrian/src/Hadrian/Haskell/Cabal/Parse.hs ===================================== @@ -31,6 +31,7 @@ import qualified Distribution.PackageDescription.Parsec as C import qualified Distribution.Simple.Compiler as C import qualified Distribution.Simple.Program.Db as C import qualified Distribution.Simple as C +import qualified Distribution.Simple.GHC as GHC import qualified Distribution.Simple.Program.Builtin as C import qualified Distribution.Simple.Utils as C import qualified Distribution.Simple.Program.Types as C @@ -363,12 +364,11 @@ registerPackage rs context = do need [setupConfig] -- This triggers 'configurePackage' pd <- packageDescription <$> readContextData context db_path <- packageDbPath (PackageDbLoc (stage context) (iplace context)) - dist_dir <- Context.buildPath context pid <- pkgUnitId (stage context) (package context) -- Note: the @cPath@ is ignored. The path that's used is the 'buildDir' path -- from the local build info @lbi at . lbi <- liftIO $ C.getPersistBuildConfig cPath - liftIO $ register db_path pid dist_dir pd lbi + liftIO $ register db_path pid pd lbi -- Then after the register, which just writes the .conf file, do the recache step. buildWithResources rs $ target context (GhcPkg Recache (stage context)) [] [] @@ -377,25 +377,23 @@ registerPackage rs context = do -- into a different package database to the one it was configured against. register :: FilePath -> String -- ^ Package Identifier - -> FilePath -> C.PackageDescription -> LocalBuildInfo -> IO () -register pkg_db pid build_dir pd lbi +register pkg_db pid pd lbi = withLibLBI pd lbi $ \lib clbi -> do - absPackageDBs <- C.absolutePackageDBPaths packageDbs - installedPkgInfo <- C.generateRegistrationInfo - C.silent pd lib lbi clbi False reloc build_dir - (C.registrationPackageDB absPackageDBs) - + when reloc $ error "register does not support reloc" + installedPkgInfo <- generateRegistrationInfo pd lbi lib clbi writeRegistrationFile installedPkgInfo where regFile = pkg_db pid <.> "conf" reloc = relocatable lbi - -- Using a specific package db here is why we have to copy the function from Cabal. - packageDbs = [C.SpecificPackageDB pkg_db] + + generateRegistrationInfo pkg lbi lib clbi = do + abi_hash <- C.mkAbiHash <$> GHC.libAbiHash C.silent pkg lbi lib clbi + return (C.absoluteInstalledPackageInfo pkg abi_hash lib lbi clbi) writeRegistrationFile installedPkgInfo = do writeUTF8File regFile (CP.showInstalledPackageInfo installedPkgInfo) ===================================== libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc ===================================== @@ -399,14 +399,14 @@ data ParFlags = ParFlags -- | Parameters pertaining to Haskell program coverage (HPC) -- --- @since base-4.22.0.0 +-- @since base-4.20.0.0 data HpcFlags = HpcFlags { writeTixFile :: Bool -- ^ Controls whether the @.tix@ file should be -- written after the execution of the program. } - deriving (Show -- ^ @since base-4.22.0.0 - , Generic -- ^ @since base-4.22.0.0 + deriving (Show -- ^ @since base-4.20.0.0 + , Generic -- ^ @since base-4.20.0.0 ) -- | Parameters of the runtime system -- ===================================== libraries/ghc-internal/src/GHC/Internal/System/Environment.hs ===================================== @@ -225,6 +225,13 @@ ioe_missingEnvVar name = ioException (IOError Nothing NoSuchThing "getEnv" -- Throws `Control.Exception.IOException` if @name@ is the empty string or -- contains an equals sign. -- +-- Beware that this function must not be executed concurrently +-- with 'getEnv', 'lookupEnv', 'getEnvironment' and such. One thread +-- reading environment variables at the same time with another one modifying them +-- can result in a segfault, see +-- [Setenv is not Thread Safe](https://www.evanjones.ca/setenv-is-not-thread-safe.html) +-- for discussion. +-- -- @since base-4.7.0.0 setEnv :: String -> String -> IO () setEnv key_ value_ @@ -269,6 +276,13 @@ foreign import ccall unsafe "putenv" c_putenv :: CString -> IO CInt -- Throws `Control.Exception.IOException` if @name@ is the empty string or -- contains an equals sign. -- +-- Beware that this function must not be executed concurrently +-- with 'getEnv', 'lookupEnv', 'getEnvironment' and such. One thread +-- reading environment variables at the same time with another one modifying them +-- can result in a segfault, see +-- [Setenv is not Thread Safe](https://www.evanjones.ca/setenv-is-not-thread-safe.html) +-- for discussion. +-- -- @since base-4.7.0.0 unsetEnv :: String -> IO () #if defined(mingw32_HOST_OS) ===================================== libraries/ghc-internal/src/GHC/Internal/System/Environment/Blank.hsc ===================================== @@ -109,6 +109,13 @@ getEnvDefault name fallback = fromMaybe fallback <$> getEnv name -- | Like 'GHC.Internal.System.Environment.setEnv', but allows blank environment values -- and mimics the function signature of 'System.Posix.Env.setEnv' from the -- @unix@ package. +-- +-- Beware that this function must not be executed concurrently +-- with 'getEnv', 'lookupEnv', 'getEnvironment' and such. One thread +-- reading environment variables at the same time with another one modifying them +-- can result in a segfault, see +-- [Setenv is not Thread Safe](https://www.evanjones.ca/setenv-is-not-thread-safe.html) +-- for discussion. setEnv :: String {- ^ variable name -} -> String {- ^ variable value -} -> @@ -151,6 +158,13 @@ foreign import ccall unsafe "setenv" -- | Like 'GHC.Internal.System.Environment.unsetEnv', but allows for the removal of -- blank environment variables. May throw an exception if the underlying -- platform doesn't support unsetting of environment variables. +-- +-- Beware that this function must not be executed concurrently +-- with 'getEnv', 'lookupEnv', 'getEnvironment' and such. One thread +-- reading environment variables at the same time with another one modifying them +-- can result in a segfault, see +-- [Setenv is not Thread Safe](https://www.evanjones.ca/setenv-is-not-thread-safe.html) +-- for discussion. unsetEnv :: String -> IO () #if defined(mingw32_HOST_OS) unsetEnv key = withCWString key $ \k -> do ===================================== testsuite/tests/parser/should_compile/T20846.stderr ===================================== @@ -71,11 +71,7 @@ (L (EpAnn (EpaSpan { T20846.hs:4:1-6 }) - (NameAnn - (NameParens) - (EpaSpan { T20846.hs:4:1 }) - (EpaSpan { T20846.hs:4:2-5 }) - (EpaSpan { T20846.hs:4:6 }) + (NameAnnTrailing []) (EpaComments [])) ===================================== testsuite/tests/printer/Makefile ===================================== @@ -826,3 +826,33 @@ Test24533: PprLetIn: $(CHECK_PPR) $(LIBDIR) PprLetIn.hs $(CHECK_EXACT) $(LIBDIR) PprLetIn.hs + +.PHONY: CaseAltComments +CaseAltComments: + $(CHECK_PPR) $(LIBDIR) CaseAltComments.hs + $(CHECK_EXACT) $(LIBDIR) CaseAltComments.hs + +.PHONY: MatchPatComments +MatchPatComments: + $(CHECK_PPR) $(LIBDIR) MatchPatComments.hs + $(CHECK_EXACT) $(LIBDIR) MatchPatComments.hs + +.PHONY: Test24748 +Test24748: + $(CHECK_PPR) $(LIBDIR) Test24748.hs + $(CHECK_EXACT) $(LIBDIR) Test24748.hs + +.PHONY: Test24755 +Test24755: + $(CHECK_PPR) $(LIBDIR) Test24755.hs + $(CHECK_EXACT) $(LIBDIR) Test24755.hs + +.PHONY: Test24753 +Test24753: + $(CHECK_PPR) $(LIBDIR) Test24753.hs + $(CHECK_EXACT) $(LIBDIR) Test24753.hs + +.PHONY: Test24771 +Test24771: + $(CHECK_PPR) $(LIBDIR) Test24771.hs + $(CHECK_EXACT) $(LIBDIR) Test24771.hs ===================================== testsuite/tests/printer/MatchPatComments.hs ===================================== @@ -0,0 +1,16 @@ +module MatchPatComments where + +expandProcess + outCHAs -- c0 + locationDescr = + blah + +next + ( steps -- c1 + , ys -- c2 + ) x -- c3 + = (steps, x, ys) + +makeProjection + Function{funMutual = VV, -- c4 + funAbstr = ConcreteDef} = undefined ===================================== testsuite/tests/printer/PprExportWarn.hs ===================================== @@ -6,12 +6,12 @@ module PprExportWarning ( reallyreallyreallyreallyreallyreallyreallyreallylongname, {-# DEPRECATED "Just because" #-} Bar(Bar1, Bar2), {-# WARNING "Just because" #-} name, - {-# DEPRECATED ["Reason", - "Another reason"] #-} + {-# DEPRECATED ["Reason", + "Another reason"] #-} Baz, {-# DEPRECATED [ ] #-} module GHC, {-# WARNING "Dummy Pattern" #-} pattern Dummy, - Foo'(..), + Foo'(..), reallyreallyreallyreallyreallyreallyreallyreallylongname', Bar'(Bar1, Bar2), name', Baz', module Data.List, pattern Dummy' ) where ===================================== testsuite/tests/printer/PrefixConComment.hs ===================================== @@ -0,0 +1,4 @@ +module PrefixConComment where + +fun (Con {- c1 -} a {- c2 -} b {- c3 -}) + = undefined ===================================== testsuite/tests/printer/Test24748.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE LambdaCase #-} +module Test24748 where + +instance SDecide Nat where + SZero %~ (SSucc _) = Disproved (\case) + +foo = (\case) +bar = (\cases) ===================================== testsuite/tests/printer/Test24753.hs ===================================== @@ -0,0 +1,8 @@ +module Test24753 where + +type ErrorChoiceApi + = "path0" :> Get '[JSON] Int -- c0 + :<|> "path4" :> (ReqBody '[PlainText] Int :> Post '[PlainText] Int -- c4 + :<|> ReqBody '[PlainText] Int :> Post '[JSON] Int) -- c5 + :<|> "path5" :> (ReqBody '[JSON] Int :> Post '[PlainText] Int -- c6 + :<|> ReqBody '[PlainText] Int :> Post '[PlainText] Int) -- c7 ===================================== testsuite/tests/printer/Test24755.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeOperators #-} +module Test24755 where + +class + a -- c1 + :+ -- c2 + b -- c3 ===================================== testsuite/tests/printer/Test24771.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeOperators #-} +module Test24771 where + +data Foo + = Int -- c1 + :* -- c2 + String -- c3 ===================================== testsuite/tests/printer/all.T ===================================== @@ -198,3 +198,8 @@ test('ListTuplePuns', extra_files(['ListTuplePuns.hs']), ghci_script, ['ListTupl test('AnnotationNoListTuplePuns', [ignore_stderr, req_ppr_deps], makefile_test, ['AnnotationNoListTuplePuns']) test('Test24533', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24533']) test('PprLetIn', [ignore_stderr, req_ppr_deps], makefile_test, ['PprLetIn']) +test('MatchPatComments', [ignore_stderr, req_ppr_deps], makefile_test, ['MatchPatComments']) +test('Test24748', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24748']) +test('Test24755', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24755']) +test('Test24753', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24753']) +test('Test24771', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24771']) ===================================== testsuite/tests/simplCore/should_compile/T24726.hs ===================================== @@ -0,0 +1,26 @@ +{-# OPTIONS_GHC -drule-check concatMap #-} + -- This rule-check thing crashed #24726 + +module T24726 where + +data Stream a = forall s. Stream (s -> ()) s + +concatMapS :: (a -> Stream b) -> Stream a -> Stream b +concatMapS f (Stream next0 s0) = Stream undefined undefined +{-# INLINE [1] concatMapS #-} + +concatMapS' :: (s -> ()) -> (a -> s) -> Stream a -> Stream b +concatMapS' = undefined + +{-# RULES "concatMap" forall step f. concatMapS (\x -> Stream step (f x)) = concatMapS' step f #-} + +replicateStep :: a -> b +replicateStep _ = undefined +{-# INLINE replicateStep #-} + +replicateS :: Int -> a -> Stream a +replicateS n x0 = Stream replicateStep undefined +{-# INLINE replicateS #-} + +foo1 :: Stream Int -> Stream Int +foo1 = concatMapS (replicateS 2) ===================================== testsuite/tests/simplCore/should_compile/T24726.stderr ===================================== @@ -0,0 +1,36 @@ + +==================== Rule check ==================== +Rule check results: +-------------------- +Expression: concatMapS @(*) @Int @Int foo1 +Rule "concatMap": all arguments match (considered individually), but rule as a whole does not +-------------------- + + + +==================== Rule check ==================== +Rule check results: +-------------------- +Expression: concatMapS @(*) @Int @Int foo1 +Rule "concatMap": all arguments match (considered individually), but rule as a whole does not +-------------------- + + + +==================== Rule check ==================== +Rule check results: +-------------------- +Expression: concatMapS @(*) @Int @Int foo1 +Rule "concatMap": all arguments match (considered individually), but rule as a whole does not +-------------------- + + + +==================== Rule check ==================== +Rule check results: +-------------------- +Expression: concatMapS @(*) @Int @Int foo1 +Rule "concatMap": all arguments match (considered individually), but rule as a whole does not +-------------------- + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -515,3 +515,4 @@ test('T24229a', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typea test('T24229b', [ grep_errmsg(r'wfoo') ], compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques -dppr-cols=99999']) test('T24370', normal, compile, ['-O']) test('T24551', normal, compile, ['-O -dcore-lint']) +test('T24726', normal, compile, ['-dcore-lint -dsuppress-uniques']) ===================================== utils/check-exact/Main.hs ===================================== @@ -128,7 +128,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/ghc/_build/stage1/ -- "../../testsuite/tests/printer/Ppr034.hs" Nothing -- "../../testsuite/tests/printer/Ppr035.hs" Nothing -- "../../testsuite/tests/printer/Ppr036.hs" Nothing - "../../testsuite/tests/printer/Ppr037.hs" Nothing + "../../testsuite/tests/printer/MatchPatComments.hs" Nothing -- "../../testsuite/tests/printer/Ppr038.hs" Nothing -- "../../testsuite/tests/printer/Ppr039.hs" Nothing -- "../../testsuite/tests/printer/Ppr040.hs" Nothing @@ -319,8 +319,10 @@ testOneFile _ libdir fileName mchanger = do expectedSource <- readFile newFileExpected changedSource <- readFile newFileChanged return (expectedSource == changedSource, expectedSource, changedSource) - Nothing -> return (True, "", "") - + Nothing -> do + expectedSource <- readFile fileName + changedSource <- readFile newFile + return (expectedSource == changedSource, expectedSource, changedSource) (p