[Git][ghc/ghc][wip/T16762-chunks-2-and-3] 25 commits: Refactor hole constraints.

Ryan Scott gitlab at gitlab.haskell.org
Sat May 9 11:35:13 UTC 2020



Ryan Scott pushed to branch wip/T16762-chunks-2-and-3 at Glasgow Haskell Compiler / GHC


Commits:
7ab6ab09 by Richard Eisenberg at 2020-05-06T04:39:32-04:00
Refactor hole constraints.

Previously, holes (both expression holes / out of scope variables and
partial-type-signature wildcards) were emitted as *constraints* via
the CHoleCan constructor. While this worked fine for error reporting,
there was a fair amount of faff in keeping these constraints in line.
In particular, and unlike other constraints, we could never change
a CHoleCan to become CNonCanonical. In addition:
 * the "predicate" of a CHoleCan constraint was really the type
   of the hole, which is not a predicate at all
 * type-level holes (partial type signature wildcards) carried
   evidence, which was never used
 * tcNormalise (used in the pattern-match checker) had to create
   a hole constraint just to extract it again; it was quite messy

The new approach is to record holes directly in WantedConstraints.
It flows much more nicely now.

Along the way, I did some cleaning up of commentary in
GHC.Tc.Errors.Hole, which I had a hard time understanding.

This was instigated by a future patch that will refactor
the way predicates are handled. The fact that CHoleCan's
"predicate" wasn't really a predicate is incompatible with
that future patch.

No test case, because this is meant to be purely internal.

It turns out that this change improves the performance of
the pattern-match checker, likely because fewer constraints
are sloshing about in tcNormalise. I have not investigated
deeply, but an improvement is not a surprise here:

-------------------------
Metric Decrease:
    PmSeriesG
-------------------------

- - - - -
420b957d by Ben Gamari at 2020-05-06T04:40:08-04:00
rts: Zero block flags with -DZ

Block flags are very useful for determining the state of a block.
However, some block allocator users don't touch them, leading to
misleading values. Ensure that we zero then when zero-on-gc is set. This
is safe and makes the flags more useful during debugging.

- - - - -
740b3b8d by Ben Gamari at 2020-05-06T04:40:08-04:00
nonmoving: Fix incorrect failed_to_evac value during deadlock gc

Previously we would incorrectly set the failed_to_evac flag if we
evacuated a value due to a deadlock GC. This would cause us to mark more
things as dirty than strictly necessary. It also turned up a nasty but
which I will fix next.

- - - - -
b2d72c75 by Ben Gamari at 2020-05-06T04:40:08-04:00
nonmoving: Fix handling of dirty objects

Previously we (incorrectly) relied on failed_to_evac to be "precise".
That is, we expected it to only be true if *all* of an object's fields
lived outside of the non-moving heap. However, does not match the
behavior of failed_to_evac, which is true if *any* of the object's
fields weren't promoted (meaning that some others *may* live in the
non-moving heap).

This is problematic as we skip the non-moving write barrier for dirty
objects (which we can only safely do if *all* fields point outside of
the non-moving heap).

Clearly this arises due to a fundamental difference in the behavior
expected of failed_to_evac in the moving and non-moving collector.
e.g., in the moving collector it is always safe to conservatively say
failed_to_evac=true whereas in the non-moving collector the safe value
is false.

This issue went unnoticed as I never wrote down the dirtiness
invariant enforced by the non-moving collector. We now define this
invariant as

    An object being marked as dirty implies that all of its fields are
    on the mark queue (or, equivalently, update remembered set).

To maintain this invariant we teach nonmovingScavengeOne to push the
fields of objects which we fail to evacuate to the update remembered
set. This is a simple and reasonably cheap solution and avoids the
complexity and fragility that other, more strict alternative invariants
would require.

All of this is described in a new Note, Note [Dirty flags in the
non-moving collector] in NonMoving.c.

- - - - -
9f3e6884 by Zubin Duggal at 2020-05-06T04:41:08-04:00
Allow atomic update of NameCache in readHieFile

The situation arises in ghcide where multiple different threads may need to
update the name cache, therefore with the older interface it could happen
that you start reading a hie file with name cache A and produce name cache
A + B, but another thread in the meantime updated the namecache to A +
C. Therefore if you write the new namecache you will lose the A' updates
from the second thread.

Updates haddock submodule

- - - - -
edec6a6c by Ryan Scott at 2020-05-06T04:41:57-04:00
Make isTauTy detect higher-rank contexts

Previously, `isTauTy` would only detect higher-rank `forall`s, not
higher-rank contexts, which led to some minor bugs observed
in #18127. Easily fixed by adding a case for
`(FunTy InvisArg _ _)`.

Fixes #18127.

- - - - -
a95e7fe0 by Ömer Sinan Ağacan at 2020-05-06T04:42:39-04:00
ELF linker: increment curSymbol after filling in fields of current entry

The bug was introduced in a8b7cef4d45 which added a field to the
`symbols` array elements and then updated this code incorrectly:

    - oc->symbols[curSymbol++] = nm;
    + oc->symbols[curSymbol++].name = nm;
    + oc->symbols[curSymbol].addr = symbol->addr;

- - - - -
cab1871a by Sylvain Henry at 2020-05-06T04:43:21-04:00
Move LeadingUnderscore into Platform (#17957)

Avoid direct use of DynFlags to know if symbols must be prefixed by an
underscore.

- - - - -
94e7c563 by Sylvain Henry at 2020-05-06T04:43:21-04:00
Don't use DynFlags in showLinkerState (#17957)

- - - - -
9afd9251 by Ryan Scott at 2020-05-06T04:43:58-04:00
Refactoring: Use bindSigTyVarsFV in rnMethodBinds

`rnMethodBinds` was explicitly using `xoptM` to determine if
`ScopedTypeVariables` is enabled before bringing type variables
bound by the class/instance header into scope. However, this `xoptM`
logic is already performed by the `bindSigTyVarsFV` function. This
patch uses `bindSigTyVarsFV` in `rnMethodBinds` to reduce the number
of places where we need to consult if `ScopedTypeVariables` is on.

This is purely refactoring, and there should be no user-visible
change in behavior.

- - - - -
6f6d72b2 by Brian Foley at 2020-05-08T15:29:25-04:00
Remove further dead code found by a simple Python script.

Avoid removing some functions that are part of an API even
though they're not used in-tree at the moment.

- - - - -
78bf8bf9 by Julien Debon at 2020-05-08T15:29:28-04:00
Add doc examples for Bifoldable

See #17929

- - - - -
66f0a847 by Julien Debon at 2020-05-08T15:29:29-04:00
doc (Bitraversable): Add examples to Bitraversable

* Add examples to Data.Bitraversable
* Fix formatting for (,) in Bitraversable and Bifoldable
* Fix mistake on bimapAccumR documentation

See #17929

- - - - -
9749fe12 by Baldur Blöndal at 2020-05-08T15:29:32-04:00
Specify kind variables for inferred kinds in base.

- - - - -
4e9aef9e by John Ericson at 2020-05-08T15:29:36-04:00
HsSigWcTypeScoping: Pull in documentation from stray location

- - - - -
f4d5c6df by John Ericson at 2020-05-08T15:29:36-04:00
Rename local `real_fvs` to `implicit_vs`

It doesn't make sense to call the "free" variables we are about to
implicitly bind the real ones.

- - - - -
20570b4b by John Ericson at 2020-05-08T15:29:36-04:00
A few tiny style nits with renaming

 - Use case rather than guards that repeatedly scrutenize same thing.

 - No need for view pattern when `L` is fine.

 - Use type synnonym to convey the intent like elsewhere.

- - - - -
09ac8de5 by John Ericson at 2020-05-08T15:29:36-04:00
Add `forAllOrNothing` function with note

- - - - -
bb35c0e5 by Joseph C. Sible at 2020-05-08T15:29:40-04:00
Document lawlessness of Ap's Num instance
- - - - -
cdd229ff by Joseph C. Sible at 2020-05-08T15:29:40-04:00
Apply suggestion to libraries/base/Data/Monoid.hs
- - - - -
926d2aab by Joseph C. Sible at 2020-05-08T15:29:40-04:00
Apply more suggestions from Simon Jakobi
- - - - -
7a763cff by Adam Gundry at 2020-05-08T15:29:41-04:00
Reject all duplicate declarations involving DuplicateRecordFields (fixes #17965)

This fixes a bug that resulted in some programs being accepted that used the same
identifier as a field label and another declaration, depending on the order they
appeared in the source code.

- - - - -
88e3c815 by Simon Peyton Jones at 2020-05-08T15:29:41-04:00
Fix specialisation for DFuns

When specialising a DFun we must take care to saturate the
unfolding.  See Note [Specialising DFuns] in Specialise.

Fixes #18120

- - - - -
86c77b36 by Greg Steuck at 2020-05-08T15:29:45-04:00
Remove unused SEGMENT_PROT_RWX

It's been unused for a year and is problematic on any OS which
requires W^X for security.

- - - - -
2c845e85 by Ryan Scott at 2020-05-09T07:34:53-04:00
WIP: Factor out HsPatSigType for pat sigs/RULE term sigs (#16762)

This implements chunks (2) and (3) of
https://gitlab.haskell.org/ghc/ghc/issues/16762#note_270170. Namely,
it introduces a dedicated `HsPatSigType` AST type, which represents
the types that can appear in pattern signatures and term-level `RULE`
binders. Previously, these were represented with `LHsSigWcType`.
Although `LHsSigWcType` is isomorphic to `HsPatSigType`, the intended
semantics of the two types are slightly different, as evidenced by
the fact that they have different code paths in the renamer and
typechecker.

See also the new `Note [Pattern signature binders and scoping]` in
`GHC.Hs.Types`.

- - - - -


30 changed files:

- compiler/GHC/Cmm/CLabel.hs
- compiler/GHC/Cmm/Utils.hs
- compiler/GHC/CmmToAsm/PPC/Cond.hs
- compiler/GHC/CmmToAsm/SPARC/Cond.hs
- compiler/GHC/CmmToAsm/X86/Cond.hs
- compiler/GHC/CmmToLlvm/Base.hs
- compiler/GHC/Core/Opt/Specialise.hs
- compiler/GHC/Core/Type.hs
- compiler/GHC/Core/Unfold.hs
- compiler/GHC/Driver/Main.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/Extension.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/Hs/Pat.hs
- compiler/GHC/Hs/Types.hs
- compiler/GHC/HsToCore/Binds.hs
- compiler/GHC/HsToCore/PmCheck/Oracle.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Ext/Binary.hs
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Plugins.hs
- compiler/GHC/Rename/Bind.hs
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/HsType.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Pat.hs
- compiler/GHC/Runtime/Linker.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/af9b43409fc2e65d6a7fdd9b95c484ab9cb0a9de...2c845e8579d22f4d6aed8a8eb8e22e4f1ed5ec28

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/af9b43409fc2e65d6a7fdd9b95c484ab9cb0a9de...2c845e8579d22f4d6aed8a8eb8e22e4f1ed5ec28
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/20200509/2bf87778/attachment-0001.html>


More information about the ghc-commits mailing list