[Git][ghc/ghc][wip/ghc-debug] 50 commits: ApiAnnotations; tweaks for ghc-exactprint update

Sven Tennie gitlab at gitlab.haskell.org
Fri Aug 14 13:16:16 UTC 2020



Sven Tennie pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC


Commits:
e4f1b73a by Alan Zimmerman at 2020-08-07T23:58:10-04:00
ApiAnnotations; tweaks for ghc-exactprint update

Remove unused ApiAnns, add one for linear arrow.

Include API Annotations for trailing comma in export list.

- - - - -
8a665db6 by Ben Gamari at 2020-08-07T23:58:45-04:00
configure: Fix double-negation in ld merge-objects check

We want to only run the check if ld is gold.

Fixes the fix to #17962.
- - - - -
a11c9678 by Adam Sandberg Ericsson at 2020-08-09T11:32:25+02:00
hadrian: depend on boot compiler version #18001

- - - - -
c8873b52 by Alan Zimmerman at 2020-08-09T21:17:54-04:00
Api Annotations : Adjust SrcSpans for prefix bang (!).

And prefix ~

(cherry picked from commit 8dbee2c578b1f642d45561be3f416119863e01eb)

- - - - -
77398b67 by Sylvain Henry at 2020-08-09T21:18:34-04:00
Avoid allocations in `splitAtList` (#18535)

As suspected by @simonpj in #18535, avoiding allocations in
`GHC.Utils.Misc.splitAtList` when there are no leftover arguments is
beneficial for performance:

   On CI validate-x86_64-linux-deb9-hadrian:
    T12227 -7%
    T12545 -12.3%
    T5030  -10%
    T9872a -2%
    T9872b -2.1%
    T9872c -2.5%

Metric Decrease:
    T12227
    T12545
    T5030
    T9872a
    T9872b
    T9872c

- - - - -
8ba41a0f by Felix Yan at 2020-08-10T20:23:29-04:00
Correct a typo in ghc.mk
- - - - -
1c469264 by Felix Yan at 2020-08-10T20:23:29-04:00
Add a closing parenthesis too

- - - - -
acf537f9 by Sylvain Henry at 2020-08-10T20:24:09-04:00
Make splitAtList strict in its arguments

Also fix its slightly wrong comment

Metric Decrease:
    T5030
    T12227
    T12545

- - - - -
ab4d1589 by Ben Gamari at 2020-08-11T22:18:03-04:00
typecheck: Drop SPECIALISE pragmas when there is no unfolding

Previously the desugarer would instead fall over when it realized that
there was no unfolding for an imported function with a SPECIALISE
pragma. We now rather drop the SPECIALISE pragma and throw a warning.

Fixes #18118.

- - - - -
0ac8c0a5 by Ben Gamari at 2020-08-11T22:18:03-04:00
testsuite: Add test for #18118

- - - - -
c43078d7 by Sven Tennie at 2020-08-11T22:18:38-04:00
Add hie.yaml to ghc-heap

This enables IDE support by haskell-language-server for ghc-heap.

- - - - -
f1088b3f by Ben Gamari at 2020-08-11T22:19:15-04:00
testsuite: Specify metrics collected by T17516

Previously it collected everything, including "max bytes used". This is
problematic since the test makes no attempt to control for deviations in
GC timing, resulting in high variability. Fix this by only collecting
"bytes allocated".

- - - - -
accbc242 by Sylvain Henry at 2020-08-12T03:50:12-04:00
DynFlags: disentangle Outputable

- put panic related functions into GHC.Utils.Panic
- put trace related functions using DynFlags in GHC.Driver.Ppr

One step closer making Outputable fully independent of DynFlags.

Bump haddock submodule

- - - - -
db6dd810 by Ben Gamari at 2020-08-12T03:50:48-04:00
testsuite: Increase tolerance of T16916

T16916 (testing #16916) has been slightly fragile in CI due to its
reliance on CPU times. While it's hard to see how to eliminate
the time-dependence entirely, we can nevertheless make it more tolerant.

Fixes #16966.

- - - - -
bee43aca by Sylvain Henry at 2020-08-12T20:52:50-04:00
Rewrite and move the monad-state hack note

The note has been rewritten by @simonpj in !3851

[skip ci]

- - - - -
25fdf25e by Alan Zimmerman at 2020-08-12T20:53:26-04:00
ApiAnnotations: Fix parser for new GHC 9.0 features

- - - - -
7831fe05 by Ben Gamari at 2020-08-13T03:44:17-04:00
parser: Suggest ImportQualifiedPost in prepositive import warning

As suggested in #18545.

- - - - -
55dec4dc by Sebastian Graf at 2020-08-13T03:44:52-04:00
PmCheck: Better long-distance info for where bindings (#18533)

Where bindings can see evidence from the pattern match of the `GRHSs`
they belong to, but not from anything in any of the guards (which belong
to one of possibly many RHSs).

Before this patch, we did *not* consider said evidence, causing #18533,
where the lack of considering type information from a case pattern match
leads to failure to resolve the vanilla COMPLETE set of a data type.

Making available that information required a medium amount of
refactoring so that `checkMatches` can return a
`[(Deltas, NonEmpty Deltas)]`; one `(Deltas, NonEmpty Deltas)` for each
`GRHSs` of the match group. The first component of the pair is the
covered set of the pattern, the second component is one covered set per
RHS.

Fixes #18533.
Regression test case: T18533

- - - - -
cf97889a by Hécate at 2020-08-13T03:45:29-04:00
Re-add BangPatterns to CodePage.hs

- - - - -
ffc0d578 by Sylvain Henry at 2020-08-13T09:49:56-04:00
Add HomeUnit type

Since Backpack the "home unit" is much more involved than what it was
before (just an identifier obtained with `-this-unit-id`). Now it is
used in conjunction with `-component-id` and `-instantiated-with` to
configure module instantiations and to detect if we are type-checking an
indefinite unit or compiling a definite one.

This patch introduces a new HomeUnit datatype which is much easier to
understand. Moreover to make GHC support several packages in the same
instances, we will need to handle several HomeUnits so having a
dedicated (documented) type is helpful.

Finally in #14335 we will also need to handle the case where we have no
HomeUnit at all because we are only loading existing interfaces for
plugins which live in a different space compared to units used to
produce target code. Several functions will have to be refactored to
accept "Maybe HomeUnit" parameters instead of implicitly querying the
HomeUnit fields in DynFlags. Having a dedicated type will make this
easier.

Bump haddock submodule

- - - - -
8a51b2ab by Sylvain Henry at 2020-08-13T21:09:15-04:00
Make IOEnv monad one-shot (#18202)

On CI (x86_64-linux-deb9-hadrian, compile_time/bytes_allocated):

    T10421     -1.8%    (threshold: +/- 1%)
    T10421a    -1.7%    (threshold: +/- 1%)
    T12150     -4.9%    (threshold: +/- 2%)
    T12227     -1.6     (threshold: +/- 1%)
    T12425     -1.5%    (threshold: +/- 1%)
    T12545     -3.8%    (threshold: +/- 1%)
    T12707     -3.0%    (threshold: +/- 1%)
    T13035     -3.0%    (threshold: +/- 1%)
    T14683     -10.3%   (threshold: +/- 2%)
    T3064      -6.9%    (threshold: +/- 2%)
    T4801      -4.3%    (threshold: +/- 2%)
    T5030      -2.6%    (threshold: +/- 2%)
    T5321FD    -3.6%    (threshold: +/- 2%)
    T5321Fun   -4.6%    (threshold: +/- 2%)
    T5631      -19.7%   (threshold: +/- 2%)
    T5642      -13.0%   (threshold: +/- 2%)
    T783       -2.7     (threshold: +/- 2%)
    T9020      -11.1    (threshold: +/- 2%)
    T9961      -3.4%    (threshold: +/- 2%)

    T1969 (compile_time/bytes_allocated)  -2.2%  (threshold: +/-1%)
    T1969 (compile_time/max_bytes_used)   +24.4% (threshold: +/-20%)

Additionally on other CIs:

    haddock.Cabal                  -10.0%   (threshold: +/- 5%)
    haddock.compiler               -9.5%    (threshold: +/- 5%)
    haddock.base (max bytes used)  +24.6%   (threshold: +/- 15%)
    T10370 (max bytes used, i386)  +18.4%   (threshold: +/- 15%)

Metric Decrease:
    T10421
    T10421a
    T12150
    T12227
    T12425
    T12545
    T12707
    T13035
    T14683
    T3064
    T4801
    T5030
    T5321FD
    T5321Fun
    T5631
    T5642
    T783
    T9020
    T9961
    haddock.Cabal
    haddock.compiler
Metric Decrease 'compile_time/bytes allocated':
    T1969
Metric Increase 'compile_time/max_bytes_used':
    T1969
    T10370
    haddock.base

- - - - -
10e5305c by Matthew Pickering at 2020-08-14T14:49:44+02:00
rts: Implement ghc-debug API (#18405)

There are four components to this patch which make it possible to
implement `ghc-debug`.

1. Add four new functions to the RtsAPI.
  * rts_pause and rts_unpause allow an external process to completely
  pause and unpause the RTS.
  * rts_listThreads and rts_listMiscRoots are used to find the current
  roots of the garbage collector.

These changes also mean that `Task.h` is exposed to the user.

2. Generalise the `ghc-heap` API so that raw `Word`s can be returned
rather than actual objects. This is necessary when trying to decode
closures on an external process because the pointers in such closures
are correct for the internal rather than external process. If you used
the previous API then you would get a segfault as the garbage collector
would try to traverse into these nonsensical branches.

```
-- before
getClosureData :: a -> IO Closure
-- after
getClosureDataX :: (forall c . c -> IO (Ptr StgInfoTable, [Word], [b]))
	                      -> a -> IO (GenClosure b)
```

For the normal case `b` is instantiated to `Box`, which contains a
pointer to a heap object.

```
data Box = Box a

-- GenClosure Box
```

For `ghc-debug` we instead just take the word of the address as we have
to explicitly interpret it on the external process.

```
GenClosure Word
```

3. Support for decoding `TSO` and `STACK` closures is partially
implemented. There is still quite a bit of work to do to finish both but
these at least allow us to make some more progress.

4. findPtr is generalised to take a callback argument. This means that
its result can be communicated to the debugger rather than just printing
out the result. The debugger has a function which invokes `findPtr` and
passes a callback which sends the result over a socket.

Co-authored-by: Ben Gamari <ben at smart-cactus.org>

- - - - -
9c7b81fd by Sven Tennie at 2020-08-14T14:49:44+02:00
Decode more StgTSO and StgStack fields (#18405)

Use hsc2hs to get an understandable and stable mapping from the C
structs to Haskell.

It's important to keep StgTSO and StgStack decoding downwards
compatible. This is especially needed for hadrian/ghci.

- - - - -
dfc95d97 by Sven Tennie at 2020-08-14T14:49:44+02:00
Add test for StgTSO decoding (#18405)

This makes sure ghc-heap decodes StgTSO and StgStack correctly.

To assert - otherwise dynamic - properties, a new, non-running TSO is
created in create_tso() (create_tso.c).

size is renamed to stack_size to use a dedicated type.

size was already defined as a HalfWord in GenClosure, which is
only equivalent to Word32 on 64bit architectures.

- - - - -
23af866a by Sven Tennie at 2020-08-14T14:49:44+02:00
Add documentation to ghc-debug functions (#18405)

- - - - -
a542b674 by Sven Tennie at 2020-08-14T14:49:44+02:00
Adjust type of getClosureX to type of getClosureDataX (#18405)

After a rebase the compiler complained:

libraries/ghc-heap/GHC/Exts/Heap.hs:89:23: error:
    • Couldn't match type: a -> IO (Ptr StgInfoTable, [Word], [b])
                     with: forall c. c -> IO (Ptr StgInfoTable, [Word], [b])
      Expected: (forall c. c -> IO (Ptr StgInfoTable, [Word], [b]))
                -> a -> IO (GenClosure b)
        Actual: (a -> IO (Ptr StgInfoTable, [Word], [b]))
                -> a -> IO (GenClosure b)
    • In the expression: getClosureX
      In an equation for ‘getClosureDataX’: getClosureDataX = getClosureX
      In the instance declaration for ‘HasHeapRep a’
    • Relevant bindings include
        getClosureDataX :: (forall c.
                            c -> IO (Ptr StgInfoTable, [Word], [b]))
                           -> a -> IO (GenClosure b)
          (bound at libraries/ghc-heap/GHC/Exts/Heap.hs:89:5)
   |
89 |     getClosureDataX = getClosureX
   |                       ^^^^^^^^^^^
)

- - - - -
0fa19e9f by Sven Tennie at 2020-08-14T14:49:44+02:00
Add test for rts_pause and rts_unpause (#18405)

- - - - -
180f96a3 by Sven Tennie at 2020-08-14T14:49:44+02:00
Add test list_threads_and_misc_roots (#18405)

It uses rts_listThreads() and rts_listMiscRoots().

- - - - -
225568db by Sven Tennie at 2020-08-14T14:49:44+02:00
Introduce rts_isPaused() (#18405)

Some operations are only save when the RTS is paused. This predicate
helps to make such checks.

- - - - -
d9c29efc by Sven Tennie at 2020-08-14T14:49:44+02:00
Decode CostCentreStacks, CostCentres and InfoTables (#18405)

- - - - -
06224b19 by Sven Tennie at 2020-08-14T14:49:44+02:00
Use cache and loop breakers for CostCentre, CostCentreStack and IndexTable decoding (#18405)

- - - - -
577b7c05 by Sven Tennie at 2020-08-14T14:49:44+02:00
Cleanup

- - - - -
af7737d1 by Sven Tennie at 2020-08-14T14:49:44+02:00
Query caches once, not twice

- - - - -
d1ecaae8 by Sven Tennie at 2020-08-14T14:49:44+02:00
Fix Haddock for EndTSOQueue

- - - - -
43f493de by Sven Tennie at 2020-08-14T14:49:44+02:00
Run prof_info test only in prof_ways (#18405)

That's the required way for collecting PROFILING data (e.g.
CostCentres).

- - - - -
4d136da2 by Sven Tennie at 2020-08-14T14:49:44+02:00
Skip WIP test

(Red on CI)

- - - - -
f02527ce by Sven Tennie at 2020-08-14T14:49:44+02:00
Add missing module to ghc-heap.cabal

- - - - -
ffe2690d by Sven Tennie at 2020-08-14T14:49:44+02:00
Rearrange #ifdef with GHC version

This prevents some "unused" warnings.

- - - - -
578d15be by Sven Tennie at 2020-08-14T14:49:44+02:00
Fix cpp redefinition warnings

With --Werror this made the build fail.

- - - - -
e453c951 by Sven Tennie at 2020-08-14T14:49:44+02:00
Add dummy import for PeekProfInfo_ProfilingEnabled for non-profiled builds

This circumvents #15197. Otherwise PeekProfInfo_ProfilingEnabled
wouldn't be available for make-based builds.

- - - - -
4cfa7bb7 by Sven Tennie at 2020-08-14T14:49:44+02:00
Add assertions to prof_info test (#18405)

- - - - -
ab52f87b by Sven Tennie at 2020-08-14T14:49:44+02:00
Fix types in tests

Use `Ptr ()` instead of `Word` to communicate that addresses/pointers
are meant.

- - - - -
a67ed8c7 by Sven Tennie at 2020-08-14T14:49:44+02:00
Cleanup

- - - - -
c94f2904 by Sven Tennie at 2020-08-14T14:49:44+02:00
Introduce LiftedClosure

This is a representation for closures that do not have a represantation
in the Haskell language. I.e. things like TSOs.

- - - - -
657c5bea by Sven Tennie at 2020-08-14T14:49:44+02:00
Fix prof_info test

Line number of self defined cost centre changed.

- - - - -
da30f660 by Sven Tennie at 2020-08-14T14:49:44+02:00
Expect stack_marking starting from GHC 8.10

This field was introduced with GHC 8.10.

- - - - -
a07ff7de by Sven Tennie at 2020-08-14T14:49:44+02:00
Add WhatNext, WhyBlocked and TsoFlags

Additionally extract TestUtils with common test functions.

- - - - -
2e90f9d9 by Sven Tennie at 2020-08-14T14:49:44+02:00
Parse TSO flags

- - - - -
125e4098 by Sven Tennie at 2020-08-14T14:49:44+02:00
Cache only CostCentres during ProfInfo decoding

Looks like caches for CostCentreStacks and IndexTables are not needed.

- - - - -
d5dba4a3 by Sven Tennie at 2020-08-14T14:49:44+02:00
Fix warning

- - - - -


30 changed files:

- aclocal.m4
- compiler/GHC.hs
- compiler/GHC/Builtin/Types.hs
- compiler/GHC/Builtin/Types/Prim.hs
- compiler/GHC/Builtin/Uniques.hs
- compiler/GHC/Builtin/Utils.hs
- compiler/GHC/ByteCode/Asm.hs
- compiler/GHC/ByteCode/Types.hs
- compiler/GHC/Cmm/CLabel.hs
- compiler/GHC/Cmm/CallConv.hs
- compiler/GHC/Cmm/CommonBlockElim.hs
- compiler/GHC/Cmm/DebugBlock.hs
- compiler/GHC/Cmm/Expr.hs
- compiler/GHC/Cmm/Info/Build.hs
- compiler/GHC/Cmm/LayoutStack.hs
- compiler/GHC/Cmm/Liveness.hs
- compiler/GHC/Cmm/Opt.hs
- compiler/GHC/Cmm/Parser.y
- compiler/GHC/Cmm/Ppr/Decl.hs
- compiler/GHC/Cmm/Ppr/Expr.hs
- compiler/GHC/Cmm/ProcPoint.hs
- compiler/GHC/Cmm/Switch.hs
- compiler/GHC/Cmm/Type.hs
- compiler/GHC/Cmm/Utils.hs
- compiler/GHC/CmmToAsm.hs
- compiler/GHC/CmmToAsm/BlockLayout.hs
- compiler/GHC/CmmToAsm/CFG.hs
- compiler/GHC/CmmToAsm/CPrim.hs
- compiler/GHC/CmmToAsm/Dwarf.hs
- compiler/GHC/CmmToAsm/Format.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/16dec2b634dcbe2254559a2f3e167ba5ac0acee8...d5dba4a3223f7a1aafaa9deb8cc0bea87172aa31

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/16dec2b634dcbe2254559a2f3e167ba5ac0acee8...d5dba4a3223f7a1aafaa9deb8cc0bea87172aa31
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/20200814/289d6dbd/attachment-0001.html>


More information about the ghc-commits mailing list