| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When -XStrict is enabled the rules for irrefutability are slightly modified.
Specifically, the pattern in a program like
do ~(Just hi) <- expr
cannot be considered irrefutable. The ~ here merely disables the bang that
-XStrict would usually apply, rendering the program equivalent to the following
without -XStrict
do Just hi <- expr
To achieve make this pattern irrefutable with -XStrict the user would rather
need to write
do ~(~(Just hi)) <- expr
Failing to account for this resulted in #19027. To fix this isIrrefutableHsPat
takes care to check for two the irrefutability of the inner pattern when it
encounters a LazyPat and -XStrict is enabled.
|
|
|
|
|
|
|
|
|
| |
They are not part of the IOManager interface used within the rest of the
RTS. They are the part of the interface of specific I/O manager
implementations.
They are no longer called directly elsewhere in the RTS, and are now
only called by the dispatch functions in IOManager.c
|
|
|
|
|
|
|
| |
Use in the scheduler in threaded mode.
Replaces the direct call to ioManagerWakeup which are part of specific
I/O manager implementations.
|
|
|
|
|
| |
The latter is the proper hook defined in IOManager.h. The former is part
of a specific I/O manager implementation (the threaded unix one).
|
|
|
|
|
|
|
|
|
|
| |
Replace a direct call to ioManagerStartCap in the forkProcess in
Schedule.c with a new hook initIOManagerAfterFork in IOManager.
This replaces a direct hook in the scheduler from the a single I/O
manager impl (the threaded unix one) with a generic hook.
Add some commentrary on opportunities for future rationalisation.
|
| |
|
|
|
|
|
|
|
|
| |
Move them from the external IOInterface.h to the internal IOManager.h.
The functions are all in fact internal. They are not used from the base
library at all.
Remove ioManagerWakeup as an exported symbol. It is not used elsewhere.
|
|
|
|
|
| |
This is a better home for it. It is not really an aspect of
capabilities. It is specific to one of the I/O manager impls.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It is currently rather difficult to understand or work with the various
I/O manager implementations. This is for a few reasons:
1. They do not have a clear or common API. There are some common
function names, but a lot of things just get called directly.
2. They have hooks into many other parts of the RTS where they get
called from.
3. There is a _lot_ of CPP involved, both THREADED_RTS vs !THREADED_RTS
and also mingw32_HOST_OS vs !mingw32_HOST_OS. This doesn't really
identify the I/O manager implementation.
4. They have data structures with unclear ownership, or that are
co-owned with other components like the scheduler. Some data
structures are used by multiple I/O managers.
One thing that would help is if the interface between the I/O managers
and the rest of the RTS was clearer, even if it was not completely
uniform. Centralising it would make it easier to see how to reduce any
unnecessary diversity in the interfaces.
This patch makes a start by creating a new IOManager.{h,c} module. It is
initially empty, but we will move things into it in subsequent patches.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Naming is hard. Where we want to get to is to have a clear internal and
external API for the IO manager within the RTS. What we have right now
is just the external API (used in base for the Haskell side of the
threaded IO manager impls) living in includes/rts/IOManager.h.
We want to add a clear RTS internal API, which really ought to live in
rts/IOManager.h. Several people think it's too confusing to have both:
* includes/rts/IOManager.h for the external API
* rts/IOManager.h for the internal API
So the plan is to add rts/IOManager.{h,c} as the internal parts, and
rename the external part to be includes/rts/IOInterface.h.
It is admittidly not great to have .h files in includes/rts/ called
"interface" since by definition, every .h fle under includes/ is an
interface!
Alternative naming scheme suggestions welcome!
|
|
|
|
|
| |
It is only for MIO, and we want to use the generic name IOManager for
the name of the common parts of the interface and dispatch.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
From `Note [Speculative evaluation]`:
Since call-by-value is much cheaper than call-by-need, we case-bind
arguments that are either
1. Strictly evaluated anyway, according to the StrictSig of the
callee, or
2. ok-for-spec, according to 'exprOkForSpeculation'
While (1) is a no-brainer and always beneficial, (2) is a bit
more subtle, as the careful haddock for 'exprOkForSpeculation'
points out. Still, by case-binding the argument we don't need
to allocate a thunk for it, whose closure must be retained as
long as the callee might evaluate it. And if it is evaluated on
most code paths anyway, we get to turn the unknown eval in the
callee into a known call at the call site.
NoFib Results:
```
--------------------------------------------------------------------------------
Program Allocs Instrs
--------------------------------------------------------------------------------
ansi -9.4% -10.4%
maillist -0.1% -0.1%
paraffins -0.7% -0.5%
scc -0.0% +0.1%
treejoin -0.0% -0.1%
--------------------------------------------------------------------------------
Min -9.4% -10.4%
Max 0.0% +0.1%
Geometric Mean -0.1% -0.1%
```
Fixes #19224.
|
|
|
|
|
|
| |
Thery is still, in my view, far too numerous, but I believe this won't
be too hard to improve upon. At the very lease, we can always add more
extension points!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
----------------
What:
There are two splits.
The first spit is:
- `Language.Haskell.Syntax.Extension`
- `GHC.Hs.Extension`
where the former now just contains helpers like `NoExtCon` and all the
families, and the latter is everything having to do with `GhcPass`.
The second split is:
- `Language.Haskell.Syntax.<mod>`
- `GHC.Hs.<mod>`
Where the former contains all the data definitions, and the few helpers
that don't use `GhcPass`, and the latter contains everything else. The
second modules also reexport the former.
----------------
Why:
See the issue for more details, but in short answer is we're trying to
grasp at the modularity TTG is supposed to offer, after a long time of
mainly just getting the safety benefits of more complete pattern
matching on the AST.
Now, we have an AST datatype which, without `GhcPass` is decently
stripped of GHC-specific concerns. Whereas before, not was it
GHC-specific, it was aware of all the GHC phases despite the
parameterization, with the instances and parametric data structure
side-by-side.
For what it's worth there are also some smaller, imminent benefits:
- The latter change also splits a strongly connected component in two,
since none of the `Language.Haskell.Syntax.*` modules import the older
ones.
- A few TTG violations (Using GhcPass directly in the AST) in `Expr` are
now more explicitly accounted for with new type families to provide the
necessary indirection.
-----------------
Future work:
- I don't see why all the type families should live in
`Language.Haskell.Syntax.Extension`. That seems anti-modular for
little benefit. All the ones used just once can be moved next to the
AST type they serve as an extension point for.
- Decide what to do with the `Outputable` instances. Some of these are
no orphans because they referred to `GhcPass`, and had to be moved. I
think the types could be generalized so they don't refer to `GhcPass`
and therefore can be moved back, but having gotten flak for increasing
the size and complexity types when generalizing before, I did *not*
want to do this.
- We should triage the remaining contents of `GHC.Hs.<mod>`. The
renaming helpers are somewhat odd for needing `GhcPass`. We might
consider if they are a) in fact only needed by one phase b) can be
generalized to be non-GhcPass-specific (e.g. take a callback rather
than GADT-match with `IsPass`) and then they can live in
`Language.Haskell.Syntax.<mod>`.
For more details, see
https://gitlab.haskell.org/ghc/ghc/-/wikis/implementing-trees-that-grow
Bumps Haddock submodule
|
|
|
|
| |
[ci skip]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Implement constant folding rules for Natural (similar to Integer ones)
* Add mkCoreUbxSum helper in GHC.Core.Make
* Remove naturalTo/FromInt
We now only provide `naturalTo/FromWord` as
the semantics is clear (truncate/zero-extend). For Int we have to deal
with negative numbers (throw an exception? convert to Word
beforehand?) so we leave the decision about what to do to the caller.
Moreover, now that we have sized types (Int8#, Int16#, ..., Word8#,
etc.) there is no reason to bless `Int#` more than `Int8#` or `Word8#`
(for example).
* Replaced a few `()` with `(# #)`
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This has two fixes:
1. Take TyVarTvs into account in matchableGivens. This
fixes #19106.
2. Don't allow unifying alpha ~ Maybe alpha. This fixes
#19107.
This patch also removes a redundant Note and redirects
references to a better replacement.
Also some refactoring/improvements around the BindFun
in the pure unifier, which now can take the RHS type
into account.
Close #19106.
Close #19107.
Test case: partial-sigs/should_compile/T19106,
typecheck/should_compile/T19107
|
|
|
|
|
| |
The validate flavour is already defined and used in hadrian, so this
legacy comment should be removed.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Nested TransCo were printed with a lot of indentation, e.g.:
`cast` (Sub (Sym (Foo.D:R:Index[0] <Bool>_N <'[]>_N)) ; ((Index
(Sym (SubDef (<1>_N,
<1>_N)))
<'[Bool]>_N)_R ; ...
With this patch we print them as follows:
`cast` (Sub (Sym (Foo.D:R:Index[0] <Bool>_N <'[]>_N))
; (Index (Sym (SubDef (<1>_N, <1>_N))) <'[Bool]>_N)_R
; Sub (Sym (Foo.D:R:Index[1] <1>_N <Int>_N <'[Bool]>_N))
; (Index (Sym (SubDef (<2>_N, <1>_N))) <'[Int, Bool]>_N)_R
|
|
|
|
|
|
|
|
|
| |
- All rts_mk functions return the tagged closure address
- rts_mkChar/rts_mkInt avoid allocation when the argument is within the
CHARLIKE/INTLIKE range
- rts_getBool avoids a memory load by checking the closure tag
- In rts_mkInt64/rts_mkWord64, allocated closure payload size is either
1 or 2 words depending on target architecture word size
|
|
|
|
|
| |
For big-endian machines remove the byte swap in the non-recursive call
of goSubWord since the integer is already in proper format.
|
| |
|
|
|
|
|
|
| |
Previously we would inexplicably append the key to id_rsa.
Fixes #19225.
|
|
|
|
|
| |
Ensure that shift amount parameter has the same type as the parameter to
shift.
|
|
|
|
|
|
| |
Alt, AnnAlt and IfaceAlt were using triples. This patch makes them use
dedicated types so that we can try to make some fields strict (for
example) in the future.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Use `mkConstrTag` to explicitly pass the constructor tag instead of
using `mkConstr` which queries the tag at runtime by querying the index
of the constructor name (a string) in the list of constructor names.
Perf improvement:
T16577(normal) ghc/alloc 11325573876.0 9249786992.0 -18.3% GOOD
Thanks to @sgraf812 for suggesting an additional list fusion fix during
reviews.
Metric Decrease:
T16577
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- `inversePrimOp` is renamed to `semiInversePrimOp` to indicate the
given primop is only a right inverse, not left inverse (and
contra-wise for the primop which we are giving rules for). This
explains why are new usage is not incorrect.
- The removed `subsumedByPrimOp` calls were actually dead as the match
on ill-typed code. @hsyl20 pointed this out in
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4390#note_311912,
Metric Decrease:
T13701
|
|
|
|
|
|
|
|
| |
- `leftZero`, `rightZero` and `zeroElem` could all be written using `isZeroLit`
- "modulo 1" rules could be written with `nonOneLit 1 $> Lit zero<type>`
All are due to @hsyl20; thanks!
|
|
|
|
|
| |
This isn't a bug yet, because we only shift native-sized types, but I
hope to change that.
|
| |
|
|
|
|
|
|
|
|
| |
This commit fixes 19 tests which were failing due to the use of
`consBag` / `snocBag`, which have been now replaced by `addMessage`.
This means that now GHC would output things in different order but
only for /diagnostics on the same line/, so this is just reflecting
that. The "normal" order of messages is still guaranteed.
|
|
|
|
|
|
|
|
|
| |
This commit paves the way to a richer and more structured representation
of GHC error messages, as per GHC proposal #306. More specifically
'Messages' from 'GHC.Types.Error' now gains an extra type parameter,
that we instantiate to 'ErrDoc' for now. Later, this will allow us to
replace ErrDoc with something more structure (for example messages
coming from the parser, the typechecker etc).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As #19142 showed, with -fdefer-type-errors we were allowing
compilation to proceed despite a fatal kind error. This patch
fixes it, as described in the new note in GHC.Tc.Solver,
Note [Wrapping failing kind equalities]
Also fixes #19158
Also when checking
default( ty1, ty2, ... )
only consider a possible default (C ty2) if ty2 is kind-compatible
with C. Previously we could form kind-incompatible constraints, with
who knows what kind of chaos resulting. (Actually, no chaos results,
but that's only by accident. It's plain wrong to form the constraint
(Num Either) for example.) I just happened to notice
this during fixing #19142.
|
|
|
|
|
|
|
|
| |
We have to be careful not to decode too much, too eagerly, as in
ghc-debug this will lead to references to memory locations outside of
the currently copied closure.
Fixes #19038
|
|
|
|
|
|
|
|
|
| |
Parameterize collect*Binders functions with a flag indicating if
evidence binders should be collected.
The related note in GHC.Hs.Utils has been updated.
Bump haddock submodule
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Evidence binders were not collected by
GHC.HsToCore.Arrows.collectStmtBinders, hence bindings for dictionaries
were not taken into account while computing local variables in
statements. As a consequence we had a transformation similar to this:
data Point a where Point :: RealFloat a => a -> Point a
do
p -< ...
returnA -< ... (Point 0)
===> { Type-checking }
do
let $dRealFloat_xyz = GHC.Float.$fRealFloatFloat
p -< ...
returnA -< ... (Point $dRealFloat_xyz 0)
===> { Arrows HsToCore }
first ...
>>> arr (\(p, ()) -> case p of ... ->
let $dRealFloat_xyz = GHC.Float.$fRealFloatFloat
in case .. of () -> ())
>>> \((),()) -> ... (Point $dRealFloat_xyz 0) -- dictionary not in scope
Now evidences are passed in the environment if necessary and we get:
===> { Arrows HsToCore }
first ...
>>> arr (\(p, ()) -> case p of ... ->
let $dRealFloat_xyz = GHC.Float.$fRealFloatFloat
in case .. of () -> $dRealFloat_xyz)
>>> \(ds,()) ->
let $dRealFloat_xyz = ds
in ... (Point $dRealFloat_xyz 0) -- dictionary in scope
Note that collectStmtBinders has been copy-pasted from GHC.Hs.Utils.
This ought to be factorized but Note [Dictionary binders in ConPatOut]
claims that:
Do *not* gather (a) dictionary and (b) dictionary bindings as
binders of a ConPatOut pattern. For most calls it doesn't matter,
because it's pre-typechecker and there are no ConPatOuts. But it
does matter more in the desugarer; for example,
GHC.HsToCore.Utils.mkSelectorBinds uses collectPatBinders. In a
lazy pattern, for example f ~(C x y) = ..., we want to generate
bindings for x,y but not for dictionaries bound by C. (The type
checker ensures they would not be used.)
Desugaring of arrow case expressions needs these bindings (see
GHC.HsToCore.Arrows and arrowcase1), but SPJ (Jan 2007) says it's
safer for it to use its own pat-binder-collector:
Accordingly to the last sentence, this patch doesn't make any attempt at
factorizing both codes.
Fix #18950
|
|
|
|
| |
When the pointer is already tagged we can avoid entering the closure.
|
|
|
|
|
|
|
|
|
| |
While looking at !2873 I noticed that dataToTag# previously didn't look
at a pointer's tag to determine its constructor. To be fair, there is a
bit of a trade-off here: using the pointer tag requires a bit more code
and another branch. On the other hand, it allows us to eliminate looking
at the info table in many cases (especially now since we tag large
constructor families; see #14373).
|
|
|
|
|
|
|
| |
Instead of producing auxiliary con2tag bindings we now rely on
dataToTag#, eliminating a fair bit of generated code.
Co-Authored-By: Ben Gamari <ben@well-typed.com>
|
|
|
|
| |
[CI skip]
|
|
|
|
|
|
| |
[ci skip] Since #13167 is closed, exceptions thrown in finalizers are
ignored and doesn't affect other finalizers in the same batch. This MR
updates the documentation in System.Mem.Weak to reflect that.
|
| |
|
| |
|