[Git][ghc/ghc][wip/fendor/remove-stg_stackDecode] 9 commits: Kill IOPort#

Hannes Siebenhandl pushed to branch wip/fendor/remove-stg_stackDecode at Glasgow Haskell Compiler / GHC Commits: 34fc50c1 by Ben Gamari at 2025-08-11T13:36:25-04:00 Kill IOPort# This type is unnecessary, having been superceded by `MVar` and a rework of WinIO's blocking logic. See #20947. See https://github.com/haskell/core-libraries-committee/issues/213. - - - - - 56b32c5a by sheaf at 2025-08-12T10:00:19-04:00 Improve deep subsumption This commit improves the DeepSubsumption sub-typing implementation in GHC.Tc.Utils.Unify.tc_sub_type_deep by being less eager to fall back to unification. For example, we now are properly able to prove the subtyping relationship ((∀ a. a->a) -> Int) -> Bool <= β[tau] Bool for an unfilled metavariable β. In this case (with an AppTy on the right), we used to fall back to unification. No longer: now, given that the LHS is a FunTy and that the RHS is a deep rho type (does not need any instantiation), we try to make the RHS into a FunTy, viz. β := (->) γ We can then continue using covariance & contravariance of the function arrow, which allows us to prove the subtyping relationship, instead of trying to unify which would cause us to error out with: Couldn't match expected type ‘β’ with actual type ‘(->) ((∀ a. a -> a) -> Int) See Note [FunTy vs non-FunTy case in tc_sub_type_deep] in GHC.Tc.Utils.Unify. The other main improvement in this patch concerns type inference. The main subsumption logic happens (before & after this patch) in GHC.Tc.Gen.App.checkResultTy. However, before this patch, all of the DeepSubsumption logic only kicked in in 'check' mode, not in 'infer' mode. This patch adds deep instantiation in the 'infer' mode of checkResultTy when we are doing deep subsumption, which allows us to accept programs such as: f :: Int -> (forall a. a->a) g :: Int -> Bool -> Bool test1 b = case b of True -> f False -> g test2 b = case b of True -> g False -> f See Note [Deeply instantiate in checkResultTy when inferring]. Finally, we add representation-polymorphism checks to ensure that the lambda abstractions we introduce when doing subsumption obey the representation polymorphism invariants of Note [Representation polymorphism invariants] in GHC.Core. See Note [FunTy vs FunTy case in tc_sub_type_deep]. This is accompanied by a courtesy change to `(<.>) :: HsWrapper -> HsWrapper -> HsWrapper`, adding the equation: WpCast c1 <.> WpCast c2 = WpCast (c1 `mkTransCo` c2) This is useful because mkWpFun does not introduce an eta-expansion when both of the argument & result wrappers are casts; so this change allows us to avoid introducing lambda abstractions when casts suffice. Fixes #26225 - - - - - d175aff8 by Sylvain Henry at 2025-08-12T10:01:31-04:00 Add regression test for #18619 - - - - - a3983a26 by Sylvain Henry at 2025-08-12T10:02:20-04:00 RTS: remove some TSAN annotations (#20464) Use RELAXED_LOAD_ALWAYS macro instead. - - - - - 0434af81 by Ben Gamari at 2025-08-12T10:03:02-04:00 Bump time submodule to 1.15 Also required bumps of Cabal, directory, and hpc. - - - - - f589c50c by fendor at 2025-08-13T10:33:58+02:00 Move stack decoding logic from ghc-heap to ghc-internal The stack decoding logic in `ghc-heap` is more sophisticated than the one currently employed in `CloneStack`. We want to use the stack decoding implementation from `ghc-heap` in `base`. We cannot simply depend on `ghc-heap` in `base` due do bootstrapping issues. Thus, we move the code that is necessary to implement stack decoding to `ghc-internal`. This is the right location, as we don't want to add a new API to `base`. Moving the stack decoding logic and re-exposing it in ghc-heap is insufficient, though, as we have a dependency cycle between. * ghc-heap depends on stage1:ghc-internal * stage0:ghc depends on stage0:ghc-heap To fix this, we remove ghc-heap from the set of `stage0` dependencies. This is not entirely straight-forward, as a couple of boot dependencies, such as `ghci` depend on `ghc-heap`. Luckily, the boot compiler of GHC is now >=9.10, so we can migrate `ghci` to use `ghc-internal` instead of `ghc-heap`, which already exports the relevant modules. However, we cannot 100% remove ghc's dependency on `ghc-heap`, since when we compile `stage0:ghc`, `stage1:ghc-internal` is not yet available. Thus, when we compile with the boot-compiler, we still depend on an older version of `ghc-heap`, and only use the modules from `ghc-internal`, if the `ghc-internal` version is recent enough. ------------------------- Metric Increase: size_hello_artifact size_hello_artifact_gzip size_hello_unicode size_hello_unicode_gzip ------------------------- These metric increases are unfortunate, they are most likely caused by the larger (literally in terms of lines of code) stack decoder implementation that are now linked into hello-word binaries. On linux, it is almost a 10% increase, which is considerable. - - - - - 7a3ee095 by fendor at 2025-08-13T10:33:59+02:00 Implement `decode` in terms of `decodeStackWithIpe` Uses the more efficient stack decoder implementation. - - - - - 812a1527 by fendor at 2025-08-13T10:33:59+02:00 Remove stg_decodeStackzh - - - - - e908a899 by fendor at 2025-08-13T10:33:59+02:00 Remove ghcHeap from list of toolTargets - - - - - 110 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps/Ids.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Types.hs - compiler/GHC/HsToCore.hs - compiler/GHC/Runtime/Heap/Inspect.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/StgToJS/Prim.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/Tc/Utils/Concrete.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/GHC/Types/Id/Make.hs - compiler/ghc.cabal.in - ghc/ghc-bin.cabal.in - hadrian/src/Rules/ToolArgs.hs - hadrian/src/Settings/Default.hs - libraries/Cabal - libraries/base/base.cabal.in - libraries/base/changelog.md - libraries/base/src/GHC/Exts.hs - − libraries/base/src/GHC/IOPort.hs - libraries/base/src/GHC/Stack/CloneStack.hs - libraries/directory - libraries/ghc-heap/GHC/Exts/Heap/ClosureTypes.hs - libraries/ghc-heap/GHC/Exts/Heap/Closures.hs - libraries/ghc-heap/GHC/Exts/Heap/Constants.hsc - libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc - libraries/ghc-heap/GHC/Exts/Heap/InfoTable/Types.hsc - libraries/ghc-heap/GHC/Exts/Heap/InfoTableProf.hsc - libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/Types.hs - libraries/ghc-heap/GHC/Exts/Stack/Constants.hsc - libraries/ghc-heap/GHC/Exts/Stack/Decode.hs - libraries/ghc-heap/ghc-heap.cabal.in - libraries/ghc-heap/cbits/HeapPrim.cmm → libraries/ghc-internal/cbits/HeapPrim.cmm - libraries/ghc-heap/cbits/Stack.cmm → libraries/ghc-internal/cbits/Stack.cmm - libraries/ghc-internal/cbits/StackCloningDecoding.cmm - libraries/ghc-heap/cbits/Stack_c.c → libraries/ghc-internal/cbits/Stack_c.c - libraries/ghc-internal/ghc-internal.cabal.in - libraries/ghc-internal/jsbits/base.js - libraries/ghc-internal/src/GHC/Internal/Event/Windows.hsc - libraries/ghc-internal/src/GHC/Internal/Event/Windows/Thread.hs - libraries/ghc-internal/src/GHC/Internal/Exception/Backtrace.hs - libraries/ghc-internal/src/GHC/Internal/Exts.hs - + libraries/ghc-internal/src/GHC/Internal/Heap/Closures.hs - + libraries/ghc-internal/src/GHC/Internal/Heap/Constants.hsc - + libraries/ghc-internal/src/GHC/Internal/Heap/InfoTable.hsc - + libraries/ghc-internal/src/GHC/Internal/Heap/InfoTable/Types.hsc - + libraries/ghc-internal/src/GHC/Internal/Heap/InfoTableProf.hsc - + libraries/ghc-internal/src/GHC/Internal/Heap/ProfInfo/Types.hs - libraries/ghc-internal/src/GHC/Internal/IO/Buffer.hs - libraries/ghc-internal/src/GHC/Internal/IO/Windows/Handle.hsc - − libraries/ghc-internal/src/GHC/Internal/IOPort.hs - libraries/ghc-internal/src/GHC/Internal/Prim/PtrEq.hs - libraries/ghc-internal/src/GHC/Internal/Stack/CloneStack.hs - + libraries/ghc-internal/src/GHC/Internal/Stack/Constants.hsc - + libraries/ghc-internal/src/GHC/Internal/Stack/Decode.hs - libraries/ghc-prim/changelog.md - libraries/ghci/GHCi/Message.hs - libraries/ghci/ghci.cabal.in - libraries/hpc - libraries/time - libraries/unix - rts/CloneStack.c - rts/CloneStack.h - rts/Prelude.h - rts/PrimOps.cmm - rts/RtsSymbols.c - rts/external-symbols.list.in - rts/include/stg/MiscClosures.h - rts/include/stg/SMP.h - rts/posix/ticker/Pthread.c - rts/posix/ticker/TimerFd.c - rts/win32/AsyncWinIO.c - rts/win32/libHSghc-internal.def - testsuite/tests/corelint/LintEtaExpand.stderr - testsuite/tests/indexed-types/should_fail/T5439.stderr - 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 - testsuite/tests/interface-stability/ghc-experimental-exports.stdout - testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32 - testsuite/tests/interface-stability/ghc-prim-exports.stdout - testsuite/tests/interface-stability/ghc-prim-exports.stdout-mingw32 - + testsuite/tests/numeric/should_run/T18619.hs - + testsuite/tests/numeric/should_run/T18619.stderr - testsuite/tests/numeric/should_run/all.T - testsuite/tests/partial-sigs/should_compile/T10403.stderr - testsuite/tests/partial-sigs/should_fail/T10615.stderr - testsuite/tests/primops/should_run/UnliftedIOPort.hs - testsuite/tests/primops/should_run/all.T - + testsuite/tests/rep-poly/NoEtaRequired.hs - testsuite/tests/rep-poly/T21906.stderr - testsuite/tests/rep-poly/all.T - + testsuite/tests/typecheck/should_compile/T26225.hs - + testsuite/tests/typecheck/should_compile/T26225b.hs - testsuite/tests/typecheck/should_compile/all.T - − testsuite/tests/typecheck/should_fail/T12563.stderr - testsuite/tests/typecheck/should_fail/T14618.stderr - testsuite/tests/typecheck/should_fail/T6022.stderr - testsuite/tests/typecheck/should_fail/T8883.stderr - testsuite/tests/typecheck/should_fail/all.T - testsuite/tests/typecheck/should_fail/tcfail140.stderr - utils/genprimopcode/Main.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/77e8e7607710425d8bf309159351558... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/77e8e7607710425d8bf309159351558... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Hannes Siebenhandl (@fendor)