[Git][ghc/ghc][wip/ttg/types/basic] 37 commits: Interpreter: Add locking for communication with external interpreter

Hassan Al-Awwadi (@hassan.awwadi) gitlab at gitlab.haskell.org
Sun Oct 27 12:36:33 UTC 2024



Hassan Al-Awwadi pushed to branch wip/ttg/types/basic at Glasgow Haskell Compiler / GHC


Commits:
d5f42045 by Luite Stegeman at 2024-10-20T16:34:47-04:00
Interpreter: Add locking for communication with external interpreter

This adds locking to communication with the external interpreter
to prevent concurrent tasks interfering with each other. This
fixes Template Haskell with the external interpreter in parallel (-j)
builds.

Fixes #25083

- - - - -
d6bfea76 by Matthew James Kraai at 2024-10-20T16:35:29-04:00
Use monospace font for "Either a b" in fmap docs

The documentation for fmap shows "`Either a b`" in the default font
instead of showing "Either a b" in a monospace font.

- - - - -
4bc7f9c8 by Luite Stegeman at 2024-10-20T16:36:15-04:00
Parser: remove non-ASCII characters from Parser.y

Non-ASCII characters in the source causes a problem with the default
Haskell Language Server setup in VSCode. Two characters seems to have
been left in by accident.

Workaround for #25396

- - - - -
7f61ed4e by Alan Zimmerman at 2024-10-21T06:39:45-04:00
EPA: Remove [AddEpAnn] Commit 5

EPA: Remove [AddEpAnn] from AnnPragma

EPA: Remove [AddEpAnn] From ForeignDecl

EPA: Remove [AddEpAnn] from RoleAnnotDecl

EPA: Remove [AddEpAnn] from StandaloneKindSig

EPA: Remove [AddEpAnn] From HsDeriving

EPA: Remove [AddEpAnn] from ConDeclField

EPA: Remove [AddEpAnn] from ConDeclGADT

EPA: Remove [AddEpAnn] from ConDeclH98

EPA: Remove [AddEpAnn] from ClsInstDecl

- - - - -
f8694fe7 by Cheng Shao at 2024-10-21T06:40:21-04:00
wasm: bump dyld v8 heap size limit

This patch adds `--max-old-space-size=8192` to wasm dyld shebang
arguments to bump V8 heap size limit. The default limit
(`heap_size_limit` returned by `v8.getHeapStatistics()`) is
dynamically determined and a bit too low under certain workloads, and
V8 would waste too much CPU time to garbage collect old generation
heap more aggressively. Bumping the limit to 8G doesn't imply dyld
would really take that much memory at run-time, but it lessens V8 heap
stress significantly.

- - - - -
d328d173 by Luite Stegeman at 2024-10-21T12:39:18+00:00
Add requestTickyCounterSamples to GHC.Internal.Profiling

This allows the user to request ticky counters to be written to
the eventlog at specific times.

See #24645

- - - - -
71765b1d by Simon Peyton Jones at 2024-10-21T20:55:00-04:00
Move defaulting code into a new module

GHC.Tc.Solver had reached 4,000 lines -- although quite a lot of them
are comments.

This MR

* Adds the new module GHC.Tc.Solver.Default, which has all the
  complex, but well modularised, defaulting code

* Moves a bit of code from GHC.Tc.Solver into the existing
  GHC.Tc.Solver.Solve. Notably solveWanteds and simplifyWantedsTcM,
  which are called from GHC.Tc.Solver.Default

It's a pure refactor.  No code changes.

- - - - -
a398227b by Simon Peyton Jones at 2024-10-21T20:55:00-04:00
Improve the generalisation code in Solver.simplifyInfer

The code in `decideQuantification` has become quite complicated.
This MR straightens it out, adds a new Note, and on the way
fixes #25266.

See especially Note [decideAndPromoteTyVars] which is is where
all the action happens in this MR.

- - - - -
148059fe by Andrzej Rybczak at 2024-10-21T20:55:40-04:00
Adjust catches to properly rethrow exceptions

https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13302 implemented exception
rethrowing proposal, but it didn't adjust `catches`. This fixes it.

- - - - -
25121dbc by doyougnu at 2024-10-22T09:38:18-04:00
linker: add --optimistic-linking flag

This patch adds:

- the --optimistic-linking flag which binds unknown symbols in the
runtime linker to 0xDEADBEEF instead of exiting with failure

- The test T25240 which tests these flags using dead code in the FFI system.

- closes #25240

This patch is part of the upstreaming haskell.nix patches project.

- - - - -
f19e076d by doyougnu at 2024-10-22T09:38:18-04:00
ghc-internal: hide linkerOptimistic in MiscFlags

- - - - -
edc02197 by Cheng Shao at 2024-10-22T09:38:54-04:00
hadrian: fix bindist executable wrapper logic for cross targets

This commit fixes an oversight of hadrian wrapper generation logic:
when doing cross compilation, `wrapper` is called on executable names
with cross prefix, therefore we must use `isSuffixOf` when matching to
take the cross prefix into account. Also add missing cross prefix to
ghci wrapper content and fix hsc2hs wrapper logic.

- - - - -
edf3bdf5 by Andreas Klebinger at 2024-10-22T16:30:42-04:00
mkTick: Push ticks through unsafeCoerce#.

unsafeCoerce# doesn't exist at runtime so we should treat it like a Cast
for the purpose of mkTick.

This means if we have `{-# SCC foo #-} (unsafeCoerce# trivial_expr))` we
now push the scope part of the cost centre up to `trivial_expr` at which
point we can discard it completely if the expression is trivial enough.

This fixes #25212.

- - - - -
1bdb1317 by Cheng Shao at 2024-10-22T16:31:17-04:00
hadrian: enable late-CCS for perf flavour as well

This patch enables late-CCS for perf flavour so that the testsuite can
pass for perf as well. Fixes #25308.

- - - - -
fde12aba by Cheng Shao at 2024-10-22T16:31:54-04:00
hadrian: make sure ghc-bin internal-interpreter is disabled for stage0 when not cross compiling

This patch disables internal-interpreter flag for stage0 ghc-bin when
not cross compiling, see added comment for explanation. Fixes #25406.

- - - - -
6ab8d751 by ignatiusm at 2024-10-24T01:23:35-04:00
Improve heap overflow exception message (#25198)

Catch heap overflow exceptions and suggest using `+RTS -M<size>`.

Fix #25198

- - - - -
b3f7fb80 by Rodrigo Mesquita at 2024-10-24T01:24:12-04:00
determinism: Interface re-export list det

In 'DocStructureItem' we want to make sure the 'Avails' are sorted, for
interface file determinism. This commit introduces 'DetOrdAvails', a
newtype that should only be constructed by sorting Avails with
'sortAvails' unless the avails are known to be deterministically
ordered. This newtype is used by 'DocStructureItem' where 'Avails' was
previously used to ensure the list of avails is deterministically sorted
by construction.

Note: Even though we order the constructors and avails in the interface
file, the order of constructors in the haddock output is still
determined from the order of declaration in the source. This was also
true before, when the list of constructors in the interface file <docs>
section was non-deterministic. Some haddock tests such as
"ConstructorArgs" observe this (check the order of constructors in
out/ConstructorArgs.html vs src/ConstructorArgs.hs vs its interface file)

The updated tests are caused by haddock corners where the order in the
source is not preserved (and was non-deterministic before this PR):
    * Module header in the latex backend
    * Re-export of pattern synonyms associated to a datatype (#25342)

Fixes #25304

- - - - -
e39c8c99 by Rodrigo Mesquita at 2024-10-24T01:24:12-04:00
Revert "ci: Allow abi-test to fail."

After #25304, the abi-test with interface and object determinism
succeeds.

This reverts commit 7b37afc9f3e79559055488998ee73187886a0e00.

- - - - -
7b1b0c6d by Alan Zimmerman at 2024-10-24T13:07:02-04:00
EPA: reduce [AddEpann] in AnnList

Remove it from the `al_rest` field, and make `AnnList` parameterized
on a type to be used in `al_rest`, for the various use cases.

- - - - -
4a00731e by Rodrigo Mesquita at 2024-10-24T13:07:38-04:00
Fix -fobject-determinism flag definition

The flag should be defined as an fflag to make sure the
-fno-object-determinism flag is also an available option.

Fixes #25397

- - - - -
55e4b9f2 by Sebastian Graf at 2024-10-25T07:01:54-04:00
CorePrep: Attach evaldUnfolding to floats to detect more values

See `Note [Pin evaluatedness on floats]`.

- - - - -
9f57c96d by Sebastian Graf at 2024-10-25T07:01:54-04:00
Make DataCon workers strict in strict fields (#20749)

This patch tweaks `exprIsConApp_maybe`, `exprIsHNF` and friends, and Demand
Analysis so that they exploit and maintain strictness of DataCon workers. See
`Note [Strict fields in Core]` for details.

Very little needed to change, and it puts field seq insertion done by Tag
Inference into a new perspective: That of *implementing* strict field semantics.
Before Tag Inference, DataCon workers are strict. Afterwards they are
effectively lazy and field seqs happen around use sites. History has shown
that there is no other way to guarantee taggedness and thus the STG Strict Field
Invariant.

Knock-on changes:

  * I reworked the whole narrative around "Tag inference".
    It's now called "EPT enforcement" and I recycyled the different overview
    Notes into `Note [EPT enforcement]`.

  * `exprIsHNF` previously used `exprOkForSpeculation` on unlifted arguments
    instead of recursing into `exprIsHNF`. That regressed the termination
    analysis in CPR analysis (which simply calls out to `exprIsHNF`), so I made
    it call `exprOkForSpeculation`, too.

  * There's a small regression in Demand Analysis, visible in the changed test
    output of T16859: Previously, a field seq on a variable would give that
    variable a "used exactly once" demand, now it's "used at least once",
    because `dmdTransformDataConSig` accounts for future uses of the field
    that actually all go through the case binder (and hence won't re-enter the
    potential thunk). The difference should hardly be observable.

  * The Simplifier's fast path for data constructors only applies to lazy
    data constructors now. I observed regressions involving Data.Binary.Put's
    `Pair` data type.

  * Unfortunately, T21392 does no longer reproduce after this patch, so I marked
    it as "not broken" in order to track whether we regress again in the future.

Fixes #20749, the satisfying conclusion of an annoying saga (cf. the ideas
in #21497 and #22475).

Compiler perf generally improves, sometimes drastically:

                                                     Baseline
                                 Test    Metric          value      New value Change
--------------------------------------------------------------------------------
             ManyConstructors(normal) ghc/alloc  3,629,760,116  3,711,852,800  +2.3%  BAD
  MultiLayerModulesTH_OneShot(normal) ghc/alloc  2,502,735,440  2,565,282,888  +2.5%  BAD
                       T12707(normal) ghc/alloc    804,399,798    791,807,320  -1.6% GOOD
                       T17516(normal) ghc/alloc    964,987,744  1,008,383,520  +4.5%
                       T18140(normal) ghc/alloc     75,381,152     49,860,560 -33.9% GOOD
                      T18698b(normal) ghc/alloc    232,614,457    184,262,736 -20.8% GOOD
                       T18923(normal) ghc/alloc     62,002,368     58,301,408  -6.0% GOOD
                       T20049(normal) ghc/alloc     75,719,168     70,494,368  -6.9% GOOD
                        T3294(normal) ghc/alloc  1,237,925,833  1,157,638,992  -6.5% GOOD
                        T9233(normal) ghc/alloc    686,490,105    635,166,688  -7.5% GOOD

                            geo. mean                                          -0.7%
                            minimum                                           -33.9%
                            maximum                                            +4.5%

I looked at T17516. It seems we do a few more simplifier iterations and end up
with a larger program. It seems that some things inline more, while other things
inline less. I don't see low-hanging fruit.

I also looked at MultiLayerModulesTH_OneShot. It appears we generate a strange
join point in the `getUnique` method of `Uniquable GHC.Unit.Types.Module` that
should better call-site inline, but does not. Perhaps with !11492.

NoFib does not seem affected much either:

+-------------------------------++--+------------+-----------+---------------+-----------+
|                               ||  |      base/ | std. err. | T20749/ (rel) | std. err. |
+===============================++==+============+===========+===============+===========+
|           spectral/last-piece ||  |    7.263e8 |      0.0% |        +0.62% |      0.0% |
+===============================++==+============+===========+===============+===========+
|                     geom mean ||  |     +0.00% |           |               |           |
+-------------------------------++--+------------+-----------+---------------+-----------+

I had a look at last-piece. Nothing changes in stg-final, but there is a bit
of ... movement around Data.Map.insert's use of GHC.Exts.lazy that is gone in
stg-final.

Co-Authored-By: Jaro Reinders <jaro.reinders at gmail.com>

Metric Decrease:
    T12707
    T18140
    T18698b
    T18923
    T19695
    T20049
    T3294
    T9233
    T21839c
Metric Increase:
    ManyConstructors
    MultiLayerModulesTH_OneShot

- - - - -
0225249a by Simon Peyton Jones at 2024-10-25T07:02:32-04:00
Some renaming

This is a pure refactor, tidying up some inconsistent naming:

   isEqPred          -->  isEqClassPred
   isEqPrimPred      -->  isEqPred
   isReprEqPrimPred  -->  isReprEqPred
   mkPrimEqPred      -->  mkNomEqPred
   mkReprPrimEqPred  -->  mkReprEqPred
   mkPrimEqPredRold  -->  mkEqPredRole

Plus I moved mkNomEqPred, mkReprEqPred, mkEqPredRolek
  from GHC.Core.Coercion to GHC.Core.Predicate
where they belong.  That means that Coercion imports Predicate
rather than vice versa -- better.

- - - - -
15a3456b by Ryan Hendrickson at 2024-10-25T07:02:32-04:00
compiler: Fix deriving with method constraints

See Note [Inferred contexts from method constraints]

Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com>

- - - - -
dbc77ce8 by Alan Zimmerman at 2024-10-25T18:20:13+01:00
EPA: Remove AddEpann commit 7

EPA: Remove [AddEpAnn] from HYPHEN in Parser.y

The return value is never used, as it is part of the backpack
configuration parsing.

EPA: Remove last [AddEpAnn] usages

Remove residual usage in GHC. It is still used
- In haddock TTG extension point definitions (to be removed)
- Some check-exact residual, to be removed
- Comments around DisambECP in PostProcess

EPA: Clean up [AddEpAnn] from check-exact

There is one left, to be cleaned up when we remove AddEpann itself

EPA: Remove [AddEpAnn] from haddock

The TTG extension points need a value, it is not critical what that
value is, in most cases.

EPA: Remove AddEpAnn from HsRuleAnn

EPA: Remove AddEpAnn from HsCmdArrApp

- - - - -
23ddcc01 by Simon Peyton Jones at 2024-10-26T12:44:34-04:00
Fix optimisation of InstCo

It turned out (#25387) that the fix to #15725 was not quite right:

  commit 48efbc04bd45d806c52376641e1a7ed7278d1ec7
  Date:   Mon Oct 15 10:25:02 2018 +0200

    Fix #15725 with an extra Sym

Optimising InstCo is quite subtle, and the invariants surrounding
the LiftingContext in the coercion optimiser were not stated explicitly.

This patch refactors the InstCo optimisation, and documents these
invariants.  See
  * Note [Optimising InstCo]
  * Note [The LiftingContext in optCoercion]

I also did some refactoring of course:

* Instead of a Bool swap-flag, I am not using GHC.Types.Basic.SwapFlag

* I added some invariant-checking the coercion-construction functions
  in GHC.Core.Coercion.Opt.  (Sadly these invariants don't hold during
  typechecking, becuase the types are un-zonked, so I can't put these
  checks in GHC.Core.Coercion.)

- - - - -
589fea7f by Cheng Shao at 2024-10-27T05:36:38-04:00
ghcid: use multi repl for ghcid

- - - - -
d52a0475 by Andrew Lelechenko at 2024-10-27T05:37:13-04:00
documentation: add motivating section to Control.Monad.Fix

- - - - -
301c3b54 by Cheng Shao at 2024-10-27T05:37:49-04:00
wasm: fix safari console error message related to import("node:timers")

This patch fixes the wasm backend JSFFI prelude script to avoid
calling `import("node:timers")` on non-deno hosts. Safari doesn't like
it and would print an error message to the console. Fixes
https://gitlab.haskell.org/ghc/ghc-wasm-meta/-/issues/13.

- - - - -
6b60906e by Hassan Al-Awwadi at 2024-10-27T13:36:11+01:00
Moved TyConFlavour to L.H.S, moved TopLevelFlag to extension field

side note is that I don't think Haddoc makes use of the fdTopLevel field so it doesn't get TopLeveLFlag in its extension field

- - - - -
3bf08128 by Hassan Al-Awwadi at 2024-10-27T13:36:11+01:00
Moved InlinePragma to L.H.S and parameterized it over the pass

Because its no longer "Basic", I figured I would define the GHC specific
stuff in GHC.Hs.InlinePragma, and would add it as an import. Little did I
know that InlinePragma is very prolific and this would cause *so much churn*.

Also the linter claims it can't find some notes, yet I can see them with
my own eyes...

- - - - -
bba8d00d by Hassan Al-Awwadi at 2024-10-27T13:36:12+01:00
whitespace

- - - - -
641e506e by Hassan Al-Awwadi at 2024-10-27T13:36:12+01:00
Moved OverlapMode from GHC.Types.Basic to L.H.S.OverlapPragma

Parameterized it over the pass too. The rest is churn.

- - - - -
1ff040be by Hassan Al-Awwadi at 2024-10-27T13:36:12+01:00
move RuleName to L.H.S.Basic

- - - - -
197862eb by Hassan Al-Awwadi at 2024-10-27T13:36:12+01:00
cleanup

- - - - -
9b513053 by Hassan Al-Awwadi at 2024-10-27T13:36:12+01:00
review suggestions

- - - - -
da8bebdf by Hassan Al-Awwadi at 2024-10-27T13:36:12+01:00
unused import

- - - - -


30 changed files:

- .ghcid
- .gitlab-ci.yml
- .gitlab/ci.sh
- compiler/GHC.hs
- compiler/GHC/Builtin/PrimOps/Ids.hs
- compiler/GHC/Builtin/Types.hs
- compiler/GHC/Builtin/Types/Prim.hs
- compiler/GHC/Core.hs
- compiler/GHC/Core/Coercion.hs
- compiler/GHC/Core/Coercion.hs-boot
- compiler/GHC/Core/Coercion/Opt.hs
- compiler/GHC/Core/DataCon.hs
- compiler/GHC/Core/InstEnv.hs
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Opt/Arity.hs
- compiler/GHC/Core/Opt/CSE.hs
- compiler/GHC/Core/Opt/CprAnal.hs
- compiler/GHC/Core/Opt/DmdAnal.hs
- compiler/GHC/Core/Opt/OccurAnal.hs
- compiler/GHC/Core/Opt/Pipeline.hs
- compiler/GHC/Core/Opt/Pipeline/Types.hs
- compiler/GHC/Core/Opt/Simplify.hs
- compiler/GHC/Core/Opt/Simplify/Env.hs
- compiler/GHC/Core/Opt/Simplify/Inline.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Core/Opt/SpecConstr.hs
- compiler/GHC/Core/Opt/Specialise.hs
- compiler/GHC/Core/Opt/WorkWrap.hs
- compiler/GHC/Core/Opt/WorkWrap/Utils.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d22b13c530b029cb75b92c67b87e6fba7d141261...da8bebdfe6b86064f5add40010d0cdcaa425d915

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d22b13c530b029cb75b92c67b87e6fba7d141261...da8bebdfe6b86064f5add40010d0cdcaa425d915
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20241027/243cbe80/attachment-0001.html>


More information about the ghc-commits mailing list