[Git][ghc/ghc][wip/ghc-debug] 55 commits: Allow unsaturated runRW# applications
Sven Tennie
gitlab at gitlab.haskell.org
Fri Aug 28 06:53:31 UTC 2020
Sven Tennie pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC
Commits:
f4cc57fa by Ben Gamari at 2020-08-18T15:38:55-04:00
Allow unsaturated runRW# applications
Previously we had a very aggressive Core Lint check which caught
unsaturated applications of runRW#. However, there is nothing
wrong with such applications and they may naturally arise in desugared
Core. For instance, the desugared Core of Data.Primitive.Array.runArray#
from the `primitive` package contains:
case ($) (runRW# @_ @_) (\s -> ...) of ...
In this case it's almost certain that ($) will be inlined, turning the
application into a saturated application. However, even if this weren't
the case there isn't a problem: CorePrep (after deleting an unnecessary
case) can simply generate code in its usual way, resulting in a call to
the Haskell definition of runRW#.
Fixes #18291.
- - - - -
3ac6ae7c by Ben Gamari at 2020-08-18T15:38:55-04:00
testsuite: Add test for #18291
- - - - -
a87a0b49 by Eli Schwartz at 2020-08-18T15:39:30-04:00
install: do not install sphinx doctrees
These files are 100% not needed at install time, and they contain
unreproducible info. See https://reproducible-builds.org/ for why this
matters.
- - - - -
194b25ee by Ben Gamari at 2020-08-18T15:40:05-04:00
testsuite: Allow baseline commit to be set explicitly
- - - - -
fdcf7645 by Ben Gamari at 2020-08-18T15:40:05-04:00
gitlab-ci: Use MR base commit as performance baseline
- - - - -
9ad5cab3 by Fendor at 2020-08-18T15:40:42-04:00
Expose UnitInfoMap as it is part of the public API
- - - - -
aa4b744d by Ben Gamari at 2020-08-18T22:11:36-04:00
testsuite: Only run llvm ways if llc is available
As noted in #18560, we previously would always run the LLVM ways since
`configure` would set `SettingsLlcCommand` to something non-null when
it otherwise couldn't find the `llc` executable. Now we rather probe for
the existence of the `llc` executable in the testsuite driver.
Fixes #18560.
- - - - -
0c5ed5c7 by Sylvain Henry at 2020-08-18T22:12:13-04:00
DynFlags: refactor GHC.CmmToAsm (#17957, #10143)
This patch removes the use of `sdocWithDynFlags` from GHC.CmmToAsm.*.Ppr
To do that I've had to make some refactoring:
* X86' and PPC's `Instr` are no longer `Outputable` as they require a
`Platform` argument
* `Instruction` class now exposes `pprInstr :: Platform -> instr -> SDoc`
* as a consequence, I've refactored some modules to avoid .hs-boot files
* added (derived) functor instances for some datatypes parametric in the
instruction type. It's useful for pretty-printing as we just have to
map `pprInstr` before pretty-printing the container datatype.
- - - - -
731c8d3b by nineonine at 2020-08-19T18:47:39-04:00
Implement -Wredundant-bang-patterns (#17340)
Add new flag '-Wredundant-bang-patterns' that enables checks for "dead" bangs.
Dead bangs are the ones that under no circumstances can force a thunk that
wasn't already forced. Dead bangs are a form of redundant bangs. The new check
is performed in Pattern-Match Coverage Checker along with other checks (namely,
redundant and inaccessible RHSs). Given
f :: Bool -> Int
f True = 1
f !x = 2
we can detect dead bang patterns by checking whether @x ~ ⊥@ is satisfiable
where the PmBang appears in 'checkGrdTree'. If not, then clearly the bang is
dead. Such a dead bang is then indicated in the annotated pattern-match tree by
a 'RedundantSrcBang' wrapping. In 'redundantAndInaccessibles', we collect
all dead bangs to warn about.
Note that we don't want to warn for a dead bang that appears on a redundant
clause. That is because in that case, we recommend to delete the clause wholly,
including its leading pattern match.
Dead bang patterns are redundant. But there are bang patterns which are
redundant that aren't dead, for example
f !() = 0
the bang still forces the match variable, before we attempt to match on (). But
it is redundant with the forcing done by the () match. We currently don't
detect redundant bangs that aren't dead.
- - - - -
eb9bdaef by Simon Peyton Jones at 2020-08-19T18:48:14-04:00
Add right-to-left rule for pattern bindings
Fix #18323 by adding a few lines of code to handle non-recursive
pattern bindings. see GHC.Tc.Gen.Bind
Note [Special case for non-recursive pattern bindings]
Alas, this confused the pattern-match overlap checker; see #18323.
Note that this patch only affects pattern bindings like that
for (x,y) in this program
combine :: (forall a . [a] -> a) -> [forall a. a -> a]
-> ((forall a . [a] -> a), [forall a. a -> a])
breaks = let (x,y) = combine head ids
in x y True
We need ImpredicativeTypes for those [forall a. a->a] types to be
valid. And with ImpredicativeTypes the old, unprincipled "allow
unification variables to unify with a polytype" story actually
works quite well. So this test compiles fine (if delicatedly) with
old GHCs; but not with QuickLook unless we add this patch
- - - - -
293c7fba by Sylvain Henry at 2020-08-21T09:36:38-04:00
Put CFG weights into their own module (#17957)
It avoids having to query DynFlags to get them
- - - - -
50eb4460 by Sylvain Henry at 2020-08-21T09:36:38-04:00
Don't use DynFlags in CmmToAsm.BlockLayout (#17957)
- - - - -
659eb31b by Sylvain Henry at 2020-08-21T09:36:38-04:00
NCG: Dwarf configuration
* remove references to DynFlags in GHC.CmmToAsm.Dwarf
* add specific Dwarf options in NCGConfig instead of directly querying
the debug level
- - - - -
2d8ca917 by Sylvain Henry at 2020-08-21T09:37:15-04:00
Fix -ddump-stg flag
-ddump-stg was dumping the initial STG (just after Core-to-STG pass)
which was misleading because we want the final STG to know if a function
allocates or not. Now we have a new flag -ddump-stg-from-core for this and
-ddump-stg is deprecated.
- - - - -
fddddbf4 by Vladislav Zavialov at 2020-08-21T09:37:49-04:00
Import qualified Prelude in Cmm/Parser.y
In preparation for the next version of 'happy', c95920 added a qualified
import to GHC/Parser.y but for some reason neglected GHC/Cmm/Parser.y
This patch adds the missing qualified import to GHC/Cmm/Parser.y and
also adds a clarifying comment to explain why this import is needed.
- - - - -
989c1c27 by Ben Gamari at 2020-08-21T11:27:53-04:00
gitlab-ci: Test master branch as well
While these builds are strictly speaking redundant (since every commit
is tested by @marge-bot before making it into `master`), they are nevertheless
useful as they are displayed in the branch's commit list in GitLab's web interface.
Fixes #18595.
- - - - -
e67ae884 by Aditya Gupta at 2020-08-22T03:29:00-04:00
mkUnique refactoring (#18362)
Move uniqFromMask from Unique.Supply to Unique.
Move the the functions that call mkUnique from Unique to Builtin.Uniques
- - - - -
03cfcfd4 by Wander Hillen at 2020-08-22T03:29:36-04:00
Add ubuntu 20.04 jobs for nightly and release
- - - - -
3f501545 by Craig Ferguson at 2020-08-22T03:30:13-04:00
Utils: clarify docs slightly
The previous comment implies `nTimes n f` is either `f^{n+1}` or
`f^{2^n}` (when in fact it's `f^n`).
- - - - -
8b865092 by Krzysztof Gogolewski at 2020-08-23T14:12:53+02:00
Do not print synonyms in :i (->), :i Type (#18594)
This adds a new printing flag `sdocPrintTypeAbbreviations` that is used
specifically to avoid ghci printing 'type (->) = (->)' and 'type Type = Type'.
- - - - -
d8f61182 by Krzysztof Gogolewski at 2020-08-23T14:12:56+02:00
Move pprTyTcApp' inside pprTyTcApp
No semantic change
- - - - -
364258e0 by Krzysztof Gogolewski at 2020-08-24T00:32:31-04:00
Fix types in silly shifts (#18589)
Patch written by Simon. I have only added a testcase.
- - - - -
b1eb38a0 by Sylvain Henry at 2020-08-24T00:33:13-04:00
Perf: make SDoc monad one-shot (#18202)
With validate-x86_64-linux-deb9-hadrian:
T1969 -3.4% (threshold: +/-1%)
T3294 -3.3% (threshold: +/-1%)
T12707 -1.4% (threshold: +/-1%)
Additionally with validate-x86_64-linux-deb9-unreg-hadrian:
T4801 -2.4% (threshold: +/-2%)
T13035 -1.4% (threshold: +/-1%)
T13379 -2.4% (threshold: +/-2%)
ManyAlternatives -2.5% (threshold: +/-2%)
ManyConstructors -3.0% (threshold: +/-2%)
Metric Decrease:
T12707
T1969
T3294
ManyAlternatives
ManyConstructors
T13035
T13379
T4801
- - - - -
a77b9ec2 by Krzysztof Gogolewski at 2020-08-24T10:04:20-04:00
Add a test for #18397
The bug was fixed by !3421.
- - - - -
05550a5a by Sylvain Henry at 2020-08-24T10:04:59-04:00
Avoid roundtrip through SDoc
As found by @monoidal on https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3885#note_295126
- - - - -
0a1ecc5f by Ben Gamari at 2020-08-25T07:37:05-04:00
SysTools.Process: Handle exceptions in readCreateProcessWithExitCode'
In #18069 we are observing MVar deadlocks from somewhere in ghc.exe.
This use of MVar stood out as being one of the more likely culprits.
Here we make sure that it is exception-safe.
- - - - -
db8793ad by Richard Eisenberg at 2020-08-25T07:37:40-04:00
Use tcView, not coreView, in the pure unifier.
Addresses a lingering point within #11715.
- - - - -
fb77207a by Simon Peyton Jones at 2020-08-25T07:38:16-04:00
Use LIdP rather than (XRec p (IdP p))
This patch mainly just replaces use of
XRec p (IdP p)
with
LIdP p
One slightly more significant change is to parameterise
HsPatSynDetails over the pass rather than the argument type,
so that it's uniform with HsConDeclDetails and HsConPatDetails.
I also got rid of the dead code GHC.Hs.type.conDetailsArgs
But this is all just minor refactoring. No change in functionality.
- - - - -
8426a136 by Krzysztof Gogolewski at 2020-08-25T07:38:54-04:00
Add a test for #18585
- - - - -
2d635a50 by Takenobu Tani at 2020-08-26T04:50:21-04:00
linters: Make CPP linter skip image files
This patch adds an exclusion rule for `docs/users_guide/images`,
to avoid lint errors of PDF files.
- - - - -
b7d98cb2 by Takenobu Tani at 2020-08-26T04:50:21-04:00
users-guide: Color the logo on the front page of the PDF
This patch updates the logo with a recent color scheme.
This affects only the PDF version of the user's guide.
See also:
* https://mail.haskell.org/pipermail/ghc-devs/2020-August/019139.html
* https://gitlab.haskell.org/ghc/ghc/-/wikis/logo
- - - - -
0b17fa18 by Sylvain Henry at 2020-08-26T04:50:58-04:00
Refactor UnitId pretty-printing
When we pretty-print a UnitId for the user, we try to map it back to its
origin package name, version and component to print
"package-version:component" instead of some hash.
The UnitId type doesn't carry these information, so we have to look into
a UnitState to find them. This is why the Outputable instance of
UnitId used `sdocWithDynFlags` in order to access the `unitState` field
of DynFlags.
This is wrong for several reasons:
1. The DynFlags are accessed when the message is printed, not when it is
generated. So we could imagine that the unitState may have changed
in-between. Especially if we want to allow unit unloading.
2. We want GHC to support several independent sessions at once, hence
several UnitState. The current approach supposes there is a unique
UnitState as a UnitId doesn't indicate which UnitState to use.
See the Note [Pretty-printing UnitId] in GHC.Unit for the new approach
implemented by this patch.
One step closer to remove `sdocDynFlags` field from `SDocContext`
(#10143).
Fix #18124.
Also fix some Backpack code to use SDoc instead of String.
- - - - -
dc476a50 by Sylvain Henry at 2020-08-26T04:51:35-04:00
Bignum: fix BigNat subtraction (#18604)
There was a confusion between the boolean expected by
withNewWordArrayTrimedMaybe and the boolean returned by subtracting
functions.
- - - - -
fcb10b6c by Peter Trommler at 2020-08-26T10:42:30-04:00
PPC and X86: Portable printing of IEEE floats
GNU as and the AIX assembler support floating point literals.
SPARC seems to have support too but I cannot test on SPARC.
Curiously, `doubleToBytes` is also used in the LLVM backend.
To avoid endianness issues when cross-compiling float and double literals
are printed as C-style floating point values. The assembler then takes
care of memory layout and endianness.
This was brought up in #18431 by @hsyl20.
- - - - -
770100e0 by Krzysztof Gogolewski at 2020-08-26T10:43:13-04:00
primops: Remove Monadic and Dyadic categories
There were four categories of primops: Monadic, Dyadic, Compare, GenPrimOp.
The compiler does not treat Monadic and Dyadic in any special way,
we can just replace them with GenPrimOp.
Compare is still used in isComparisonPrimOp.
- - - - -
01ff8c89 by Aditya Gupta at 2020-08-27T14:19:26-04:00
Consolidate imports in getMinimalImports (#18264)
- - - - -
bacccb73 by Ryan Scott at 2020-08-27T14:20:01-04:00
Make {hsExpr,hsType,pat}NeedsParens aware of boxed 1-tuples
`hsExprNeedsParens`, `hsTypeNeedsParens`, and `patNeedsParens`
previously assumed that all uses of explicit tuples in the source
syntax never need to be parenthesized. This is true save for one
exception: boxed one-tuples, which use the `Solo` data type from
`GHC.Tuple` instead of special tuple syntax. This patch adds the
necessary logic to the three `*NeedsParens` functions to handle
`Solo` correctly.
Fixes #18612.
- - - - -
909efbc8 by Matthew Pickering at 2020-08-28T08:23:39+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>
- - - - -
f1f1de64 by Sven Tennie at 2020-08-28T08:23:39+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.
- - - - -
c3cea59f by Sven Tennie at 2020-08-28T08:23:39+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.
- - - - -
6cb3485b by Sven Tennie at 2020-08-28T08:23:39+02:00
Add documentation to ghc-debug functions (#18405)
- - - - -
574560d8 by Sven Tennie at 2020-08-28T08:23:39+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
| ^^^^^^^^^^^
)
- - - - -
29550137 by Sven Tennie at 2020-08-28T08:23:39+02:00
Add test for rts_pause and rts_unpause (#18405)
- - - - -
91367faf by Sven Tennie at 2020-08-28T08:23:39+02:00
Add test list_threads_and_misc_roots (#18405)
It uses rts_listThreads() and rts_listMiscRoots().
- - - - -
574b953a by Sven Tennie at 2020-08-28T08:23:39+02:00
Introduce rts_isPaused() (#18405)
Some operations are only save when the RTS is paused. This predicate
helps to make such checks.
- - - - -
00bda91a by Sven Tennie at 2020-08-28T08:23:39+02:00
Decode CostCentreStacks, CostCentres and InfoTables (#18405)
These are the data structures used by profiling, i.e. they are only
available when the RTS is used with `-prof`. Otherwise fetching them
results into `Nothing`.
To reduce unnecessary decoding, a state monad transformer is used to
provide caching for CostCentres.
Because the three types form a circular data structure, loop-breakers
are applied to prevent endless decoding loops.
- - - - -
e5711e5a by Sven Tennie at 2020-08-28T08:23:39+02:00
Use more precise types in tests (#18405)
Use `Ptr ()` instead of `Word` to communicate that addresses/pointers
are meant.
- - - - -
120289fb by Sven Tennie at 2020-08-28T08:23:39+02:00
Introduce LiftedClosure (#18405)
This is a representation for closures that do not have a representation
in the Haskell language. I.e. things like StgTSOs.
- - - - -
42559bcd by Sven Tennie at 2020-08-28T08:23:39+02:00
Expect stack_marking starting from GHC 8.10 (#18405)
This field was introduced with GHC 8.10.
- - - - -
51befcb1 by Sven Tennie at 2020-08-28T08:23:39+02:00
Add WhatNext, WhyBlocked and TsoFlags to TSO closure (#18405)
These constants can easily be decoded to sum types.
Additionally extract TestUtils with common test functions.
- - - - -
a2a388f4 by Sven Tennie at 2020-08-28T08:23:39+02:00
END_TSO_QUEUE is not a closure type on it's own (#18405)
Indeed it's a CONSTR_NOCAF.
- - - - -
9af8a921 by Sven Tennie at 2020-08-28T08:23:39+02:00
Rename boundTaskExiting and getTask (#18405)
Both are directly related to myTask, which the new names now reflect.
- - - - -
801a46d8 by Sven Tennie at 2020-08-28T08:23:39+02:00
Mark unsafe accesses (#18405)
StgTSO and StgStack are very dynamic by nature. Accesses to outdated
pointers lead to segmentation faults or absolutely wrong results.
So, make sure (by naming) that the users nows about these facts.
The safe way to access these fields it to stop the RTS via RTS API.
- - - - -
9ed2a47e by Sven Tennie at 2020-08-28T08:23:39+02:00
Check pointers with pattern matching (#18405)
This is nicer than to check the length of the pointer's list and index
on it.
- - - - -
3c805925 by Sven Tennie at 2020-08-28T08:23:39+02:00
Remove unsave function (#18405)
heap_view_closurePtrsAsWords is currently only used by ghc-debug, so
it can be defined there.
- - - - -
30 changed files:
- .gitlab-ci.yml
- .gitlab/ci.sh
- .gitlab/linters/check-cpp.py
- 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/Types.hs-boot
- compiler/GHC/Builtin/Types/Prim.hs
- compiler/GHC/Builtin/Uniques.hs
- compiler/GHC/Builtin/Uniques.hs-boot
- compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/ByteCode/Types.hs
- compiler/GHC/Cmm.hs
- compiler/GHC/Cmm/Info/Build.hs
- compiler/GHC/Cmm/Parser.y
- compiler/GHC/CmmToAsm.hs
- compiler/GHC/CmmToAsm/BlockLayout.hs
- compiler/GHC/CmmToAsm/CFG.hs
- + compiler/GHC/CmmToAsm/CFG/Weight.hs
- compiler/GHC/CmmToAsm/Config.hs
- compiler/GHC/CmmToAsm/Dwarf.hs
- compiler/GHC/CmmToAsm/Instr.hs
- compiler/GHC/CmmToAsm/Monad.hs
- compiler/GHC/CmmToAsm/PIC.hs
- + compiler/GHC/CmmToAsm/PPC.hs
- compiler/GHC/CmmToAsm/PPC/CodeGen.hs
- compiler/GHC/CmmToAsm/PPC/Instr.hs
- compiler/GHC/CmmToAsm/PPC/Ppr.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/335cd21124f7c3ace718b16ab046b20a077ad44f...3c805925c1d9345ae1ed7a7a7db00294a5685ed4
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/335cd21124f7c3ace718b16ab046b20a077ad44f...3c805925c1d9345ae1ed7a7a7db00294a5685ed4
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/20200828/860af1d5/attachment-0001.html>
More information about the ghc-commits
mailing list