ghc.git
3 weeks agoNonmoving: Ensure write barrier vanishes in non-threaded RTS wip/gc/optimize
Ben Gamari [Sun, 19 May 2019 17:29:42 +0000 (13:29 -0400)] 
Nonmoving: Ensure write barrier vanishes in non-threaded RTS

3 weeks agoNonMoving: Don't do major GC if one is already running
Ben Gamari [Fri, 17 May 2019 23:18:42 +0000 (19:18 -0400)] 
NonMoving: Don't do major GC if one is already running

Previously we would perform a preparatory moving collection, resulting
in many things being added to the mark queue. When we finished with this
we would realize in nonmovingCollect that there was already a collection
running, in which case we would simply not run the nonmoving collector.

However, it was very easy to end up in a "treadmilling" situation: all
subsequent GC following the first failed major GC would be scheduled as
major GCs. Consequently we would continuously feed the concurrent
collector with more mark queue entries and it would never finish.

This patch aborts the major collection far earlier, meaning that we
avoid adding nonmoving objects to the mark queue and allowing the
concurrent collector to finish.

3 weeks agoNonMovingMark: Eliminate redundant check_in_nonmoving_heaps
Ben Gamari [Sat, 4 May 2019 00:06:47 +0000 (20:06 -0400)] 
NonMovingMark: Eliminate redundant check_in_nonmoving_heaps

3 weeks agoNonMoving: Optimise allocator cache behavior
Ben Gamari [Sun, 12 May 2019 03:04:54 +0000 (23:04 -0400)] 
NonMoving: Optimise allocator cache behavior

Previously we would look at the segment header to determine the block
size despite the fact that we already had the block size at hand.

3 weeks agoNonMoving: Prefetch segment header
Ben Gamari [Thu, 16 May 2019 21:14:38 +0000 (17:14 -0400)] 
NonMoving: Prefetch segment header

3 weeks agoNonMoving: Pre-fetch during mark
Ben Gamari [Wed, 15 May 2019 20:49:40 +0000 (16:49 -0400)] 
NonMoving: Pre-fetch during mark

This improved overall runtime on nofib's constraints test by nearly 10%.

3 weeks agoNonMoving: Fuse sweep preparation into mark prep
Ben Gamari [Sat, 11 May 2019 23:53:46 +0000 (19:53 -0400)] 
NonMoving: Fuse sweep preparation into mark prep

3 weeks agoNonMoving: Inline nonmovingClearAllBitmaps
Ben Gamari [Sat, 11 May 2019 23:32:17 +0000 (19:32 -0400)] 
NonMoving: Inline nonmovingClearAllBitmaps

3 weeks agoNonMoving: Prefetch when clearing bitmaps
Ben Gamari [Sat, 11 May 2019 23:14:43 +0000 (19:14 -0400)] 
NonMoving: Prefetch when clearing bitmaps

Ensure that the bitmap of the segmentt that we will clear next is in
cache by the time we reach it.

3 weeks agorts: Add prefetch macros
Ben Gamari [Sat, 18 May 2019 15:02:03 +0000 (11:02 -0400)] 
rts: Add prefetch macros

3 weeks agoNonMoving: Optimize bitmap search during allocation
Ben Gamari [Sat, 11 May 2019 15:55:42 +0000 (11:55 -0400)] 
NonMoving: Optimize bitmap search during allocation

Use memchr instead of a open-coded loop. This is nearly twice as fast in
a synthetic benchmark.

3 weeks agoNonMovingMark: Optimize representation of mark queue
Ben Gamari [Fri, 3 May 2019 23:44:54 +0000 (19:44 -0400)] 
NonMovingMark: Optimize representation of mark queue

This shortens MarkQueueEntry by 30% (one word)

3 weeks agoAllocate mark queues in larger block groups
Ben Gamari [Sun, 14 Apr 2019 16:26:57 +0000 (12:26 -0400)] 
Allocate mark queues in larger block groups

3 weeks agoNonMoving: Eliminate integer division in nonmovingBlockCount
Ben Gamari [Tue, 16 Apr 2019 18:32:40 +0000 (14:32 -0400)] 
NonMoving: Eliminate integer division in nonmovingBlockCount

Perf showed that the this single div was capturing up to 10% of samples
in nonmovingMark. However, the overwhelming majority of cases is looking
at small block sizes. These cases we can easily compute explicitly,
allowing the compiler to turn the division into a significantly more
efficient division-by-constant.

While the increase in source code looks scary, this all optimises down
to very nice looking assembler. At this point the only remaining
hotspots in nonmovingBlockCount are due to memory access.

3 weeks agoMore comments for aging wip/gc/aging
Ben Gamari [Tue, 18 Jun 2019 21:22:06 +0000 (17:22 -0400)] 
More comments for aging

3 weeks agoDisable aging when doing deadlock detection GC
Ben Gamari [Sun, 16 Jun 2019 16:22:56 +0000 (12:22 -0400)] 
Disable aging when doing deadlock detection GC

3 weeks agoNonmoving: Allow aging and refactor static objects logic
Ben Gamari [Thu, 18 Apr 2019 18:08:32 +0000 (14:08 -0400)] 
Nonmoving: Allow aging and refactor static objects logic

This commit does two things:

 * Allow aging of objects during the preparatory minor GC
 * Refactor handling of static objects to avoid the use of a hashtable

3 weeks agoNonmoving: Disable memory inventory with concurrent collection wip/gc/nonmoving-concurrent
Ben Gamari [Fri, 17 May 2019 02:13:02 +0000 (22:13 -0400)] 
Nonmoving: Disable memory inventory with concurrent collection

3 weeks agorts: Implement concurrent collection in the nonmoving collector
Ben Gamari [Tue, 5 Feb 2019 16:51:14 +0000 (11:51 -0500)] 
rts: Implement concurrent collection in the nonmoving collector

This extends the non-moving collector to allow concurrent collection.

The full design of the collector implemented here is described in detail
in a technical note

    B. Gamari. "A Concurrent Garbage Collector For the Glasgow Haskell
    Compiler" (2018)

This extension involves the introduction of a capability-local
remembered set, known as the /update remembered set/, which tracks
objects which may no longer be visible to the collector due to mutation.
To maintain this remembered set we introduce a write barrier on
mutations which is enabled while a concurrent mark is underway.

The update remembered set representation is similar to that of the
nonmoving mark queue, being a chunked array of `MarkEntry`s. Each
`Capability` maintains a single accumulator chunk, which it flushed
when it (a) is filled, or (b) when the nonmoving collector enters its
post-mark synchronization phase.

While the write barrier touches a significant amount of code it is
conceptually straightforward: the mutator must ensure that the referee
of any pointer it overwrites is added to the update remembered set.
However, there are a few details:

 * In the case of objects with a dirty flag (e.g. `MVar`s) we can
   exploit the fact that only the *first* mutation requires a write
   barrier.

 * Weak references, as usual, complicate things. In particular, we must
   ensure that the referee of a weak object is marked if dereferenced by
   the mutator. For this we (unfortunately) must introduce a read
   barrier, as described in Note [Concurrent read barrier on deRefWeak#]
   (in `NonMovingMark.c`).

 * Stable names are also a bit tricky as described in Note [Sweeping
   stable names in the concurrent collector] (`NonMovingSweep.c`).

We take quite some pains to ensure that the high thread count often seen
in parallel Haskell applications doesn't affect pause times. To this end
we allow thread stacks to be marked either by the thread itself (when it
is executed or stack-underflows) or the concurrent mark thread (if the
thread owning the stack is never scheduled). There is a non-trivial
handshake to ensure that this happens without racing which is described
in Note [StgStack dirtiness flags and concurrent marking].

Co-Authored-by: Ömer Sinan Ağacan <omer@well-typed.com>
4 weeks agotestsuite: Add nonmoving WAY wip/gc/nonmoving-nonconcurrent
Ben Gamari [Tue, 5 Feb 2019 19:39:52 +0000 (14:39 -0500)] 
testsuite: Add nonmoving WAY

This simply runs the compile_and_run tests with `-xn`, enabling the
nonmoving oldest generation.

4 weeks agorts: Non-concurrent mark and sweep
Ömer Sinan Ağacan [Tue, 5 Feb 2019 05:18:44 +0000 (00:18 -0500)] 
rts: Non-concurrent mark and sweep

This implements the core heap structure and a serial mark/sweep
collector which can be used to manage the oldest-generation heap.
This is the first step towards a concurrent mark-and-sweep collector
aimed at low-latency applications.

The full design of the collector implemented here is described in detail
in a technical note

    B. Gamari. "A Concurrent Garbage Collector For the Glasgow Haskell
    Compiler" (2018)

The basic heap structure used in this design is heavily inspired by

    K. Ueno & A. Ohori. "A fully concurrent garbage collector for
    functional programs on multicore processors." /ACM SIGPLAN Notices/
    Vol. 51. No. 9 (presented by ICFP 2016)

This design is intended to allow both marking and sweeping
concurrent to execution of a multi-core mutator. Unlike the Ueno design,
which requires no global synchronization pauses, the collector
introduced here requires a stop-the-world pause at the beginning and end
of the mark phase.

To avoid heap fragmentation, the allocator consists of a number of
fixed-size /sub-allocators/. Each of these sub-allocators allocators into
its own set of /segments/, themselves allocated from the block
allocator. Each segment is broken into a set of fixed-size allocation
blocks (which back allocations) in addition to a bitmap (used to track
the liveness of blocks) and some additional metadata (used also used
to track liveness).

This heap structure enables collection via mark-and-sweep, which can be
performed concurrently via a snapshot-at-the-beginning scheme (although
concurrent collection is not implemented in this patch).

The mark queue is a fairly straightforward chunked-array structure.
The representation is a bit more verbose than a typical mark queue to
accomodate a combination of two features:

 * a mark FIFO, which improves the locality of marking, reducing one of
   the major overheads seen in mark/sweep allocators (see [1] for
   details)

 * the selector optimization and indirection shortcutting, which
   requires that we track where we found each reference to an object
   in case we need to update the reference at a later point (e.g. when
   we find that it is an indirection). See Note [Origin references in
   the nonmoving collector] (in `NonMovingMark.h`) for details.

Beyond this the mark/sweep is fairly run-of-the-mill.

[1] R. Garner, S.M. Blackburn, D. Frampton. "Effective Prefetch for
    Mark-Sweep Garbage Collection." ISMM 2007.

Co-Authored-By: Ben Gamari <ben@well-typed.com>
4 weeks agorts: Introduce debug flag for non-moving GC
Ben Gamari [Sat, 7 Jul 2018 01:02:22 +0000 (21:02 -0400)] 
rts: Introduce debug flag for non-moving GC

4 weeks agorts: Introduce flag to enable the nonmoving old generation
Ben Gamari [Tue, 5 Feb 2019 05:10:43 +0000 (00:10 -0500)] 
rts: Introduce flag to enable the nonmoving old generation

This flag will enable the use of a non-moving oldest generation.

4 weeks agorts/Scav: Expose scavenging functions
Ömer Sinan Ağacan [Tue, 5 Feb 2019 16:46:25 +0000 (11:46 -0500)] 
rts/Scav: Expose scavenging functions

To keep the non-moving collector nicely separated from the moving
collector its scavenging phase will live in another file,
`NonMovingScav.c`. However, it will need to use these functions so
let's expose them.

4 weeks agorts: Disable aggregate-return warnings from gcc
Ben Gamari [Tue, 5 Feb 2019 17:48:29 +0000 (12:48 -0500)] 
rts: Disable aggregate-return warnings from gcc

This warning is a bit of a relic; there is little reason to avoid
aggregate return values in 2019.

4 weeks agorts/StableName: Expose FOR_EACH_STABLE_NAME, freeSnEntry, SNT_size
Ömer Sinan Ağacan [Tue, 5 Feb 2019 05:40:27 +0000 (00:40 -0500)] 
rts/StableName: Expose FOR_EACH_STABLE_NAME, freeSnEntry, SNT_size

These will be needed when we implement sweeping in the nonmoving
collector.

4 weeks agoMerge branches 'wip/gc/misc-rts' and 'wip/gc/aligned-block-allocation' into wip/gc... wip/gc/preparation
Ben Gamari [Wed, 19 Jun 2019 18:20:36 +0000 (14:20 -0400)] 
Merge branches 'wip/gc/misc-rts' and 'wip/gc/aligned-block-allocation' into wip/gc/preparation

4 weeks agoComments
Ömer Sinan Ağacan [Wed, 19 Jun 2019 06:54:27 +0000 (09:54 +0300)] 
Comments

4 weeks agoDisallow allocating megablocks, again
Ömer Sinan Ağacan [Wed, 19 Jun 2019 06:41:14 +0000 (09:41 +0300)] 
Disallow allocating megablocks, again

4 weeks agorts: Fix CPP linter issues wip/gc/misc-rts
Ben Gamari [Tue, 18 Jun 2019 23:19:42 +0000 (19:19 -0400)] 
rts: Fix CPP linter issues

4 weeks agorts: Fix macro parenthesisation
Ben Gamari [Wed, 8 May 2019 22:35:26 +0000 (18:35 -0400)] 
rts: Fix macro parenthesisation

4 weeks agorts/GC: Refactor gcCAFs
Ben Gamari [Wed, 6 Feb 2019 02:17:36 +0000 (21:17 -0500)] 
rts/GC: Refactor gcCAFs

4 weeks agorts: Give stack flags proper macros
Ben Gamari [Tue, 5 Feb 2019 16:01:10 +0000 (11:01 -0500)] 
rts: Give stack flags proper macros

This were previously quite unclear and will change a bit under the
non-moving collector so let's clear this up now.

4 weeks agorts/Capability: A few documentation comments
Ben Gamari [Tue, 5 Feb 2019 15:43:56 +0000 (10:43 -0500)] 
rts/Capability: A few documentation comments

4 weeks agorts: Add Note explaining applicability of selector optimisation depth limit
Ben Gamari [Tue, 3 Jul 2018 23:58:37 +0000 (19:58 -0400)] 
rts: Add Note explaining applicability of selector optimisation depth limit

This was slightly non-obvious so a note seems deserved.

4 weeks agorts/GC: Add an obvious assertion during block initialization
Ömer Sinan Ağacan [Tue, 5 Feb 2019 15:40:29 +0000 (10:40 -0500)] 
rts/GC: Add an obvious assertion during block initialization

Namely ensure that block descriptors are initialized with valid
generation numbers.

Co-Authored-By: Ben Gamari <ben@well-typed.com>
4 weeks agoUse allocLargeChunkOnNode to reduce splitting
Ömer Sinan Ağacan [Wed, 17 Apr 2019 13:44:56 +0000 (16:44 +0300)] 
Use allocLargeChunkOnNode to reduce splitting

4 weeks agoFix lint errors
Ömer Sinan Ağacan [Wed, 10 Apr 2019 12:12:32 +0000 (15:12 +0300)] 
Fix lint errors

4 weeks agoDisallow allocating megablocks, update tests
Ömer Sinan Ağacan [Wed, 10 Apr 2019 06:05:18 +0000 (09:05 +0300)] 
Disallow allocating megablocks, update tests

4 weeks agorts/BlockAlloc: Use allocLargeChunk in aligned block allocation
Ben Gamari [Mon, 4 Mar 2019 22:20:39 +0000 (17:20 -0500)] 
rts/BlockAlloc: Use allocLargeChunk in aligned block allocation

4 weeks agorts/BlockAlloc: Wibbles
Ben Gamari [Mon, 4 Mar 2019 22:20:33 +0000 (17:20 -0500)] 
rts/BlockAlloc: Wibbles

4 weeks agotestsuite/testblockalloc: Test aligned block group allocation
Ben Gamari [Mon, 4 Mar 2019 22:12:14 +0000 (17:12 -0500)] 
testsuite/testblockalloc: Test aligned block group allocation

4 weeks agotestsuite/testblockalloc: A bit of refactoring
Ben Gamari [Mon, 4 Mar 2019 22:07:20 +0000 (17:07 -0500)] 
testsuite/testblockalloc: A bit of refactoring

4 weeks agorts/BlockAlloc: Allow aligned allocation requests
Ömer Sinan Ağacan [Mon, 5 Mar 2018 12:57:47 +0000 (15:57 +0300)] 
rts/BlockAlloc: Allow aligned allocation requests

This implements support for block group allocations which are aligned to
an integral number of blocks.

This will be used by the nonmoving garbage collector, which uses the
block allocator to allocate the segments which back its heap. These
segments are a fixed number of blocks in size, with each segment being
aligned to the segment size boundary. This allows us to easily find the
segment metadata stored at the beginning of the segment.

4 weeks agorts/Schedule: Allow synchronization without holding a capability wip/gc/sync-without-capability
Ben Gamari [Fri, 20 Jul 2018 01:57:14 +0000 (21:57 -0400)] 
rts/Schedule: Allow synchronization without holding a capability

The concurrent mark-and-sweep will be performed by a GHC task which will
not hold a capability. This is necessary to avoid a concurrent mark from
interfering with minor generation collections.

However, the major collector must synchronize with the mutators at the
end of marking to flush their update remembered sets. This patch extends
the `requestSync` mechanism used to synchronize garbage collectors to
allow synchronization without holding a capability.

This change is fairly straightforward as the capability was previously
only required for two reasons:

 1. to ensure that we don't try to re-acquire a capability that we
    the sync requestor already holds.

 2. to provide a way to suspend and later resume the sync request if
    there is already a sync pending.

When synchronizing without holding a capability we needn't worry about
consideration (1) at all.

(2) is slightly trickier and may happen, for instance, when a capability
requests a minor collection and shortly thereafter the non-moving mark
thread requests a post-mark synchronization. In this case we need to
ensure that the non-moving mark thread suspends his request until after
the minor GC has concluded to avoid dead-locking. For this we introduce
a condition variable, `sync_finished_cond`, which a
non-capability-bearing requestor will wait on and which is signalled
after a synchronization or GC has finished.

4 weeks agoAdd link to mfix.github.io/ghc in HACKING.md wip/gc/base wip/gc/factor-out-bitmap-walking wip/gc/printer-improvements wip/gc/unglobalize-gc-state
Siddharth Bhat [Sun, 16 Jun 2019 12:36:24 +0000 (14:36 +0200)] 
Add link to mfix.github.io/ghc in HACKING.md

4 weeks agomake: Clean includes/settings file
Ben Gamari [Fri, 14 Jun 2019 21:23:20 +0000 (17:23 -0400)] 
make: Clean includes/settings file

Now since this is generated by the build system we should ensure that it
is properly cleaned.

[skip ci]

4 weeks agoUse TupleSections in CmmParse.y, simplify a few exprs
Ömer Sinan Ağacan [Sun, 16 Jun 2019 07:09:49 +0000 (10:09 +0300)] 
Use TupleSections in CmmParse.y, simplify a few exprs

4 weeks agogitlab-ci: Don't allow failure of deb9-dwarf job
Ben Gamari [Fri, 14 Jun 2019 02:53:37 +0000 (22:53 -0400)] 
gitlab-ci: Don't allow failure of deb9-dwarf job

This #16741 out of the way this should now pass.

4 weeks agotestsuite: Really fix #16741
Ben Gamari [Fri, 14 Jun 2019 02:51:53 +0000 (22:51 -0400)] 
testsuite: Really fix #16741

The previous fix, !1095, didn't work as `--show-iface` ignores
`-dsuppress-ticks`. Rework the test instead.

4 weeks agofix runghc's GHC detection logic to cover the "in-tree Hadrian build" scenario
Alp Mestanogullari [Fri, 14 Jun 2019 19:28:31 +0000 (21:28 +0200)] 
fix runghc's GHC detection logic to cover the "in-tree Hadrian build" scenario

Before this patch, runghc would only run the GHC detection logic on Windows and
assume that it was invoked through a wrapper script on all other platforms.
This patch lifts this limitation and makes that logic work for the scenario
where someone is calling the runghc executable directly, without passing an
explicit path to GHC.

4 weeks agogitlab-ci: Build alpine release bindists
Ben Gamari [Tue, 11 Jun 2019 01:00:57 +0000 (21:00 -0400)] 
gitlab-ci: Build alpine release bindists

4 weeks agotestsuite: Ensure that ffi005 output order is predictable
Ben Gamari [Tue, 11 Jun 2019 17:09:55 +0000 (13:09 -0400)] 
testsuite: Ensure that ffi005 output order is predictable

The libc output buffer wasn't being flushed, making the order
system-depedent.

4 weeks agotestsuite: Flush conc059's printf buffer
Ben Gamari [Tue, 11 Jun 2019 17:04:05 +0000 (13:04 -0400)] 
testsuite: Flush conc059's printf buffer

Otherwise it the order out the Haskell and C output will be
system-dependent.

4 weeks agotestsuite: Ensure T5423 flushes C output buffer
Ben Gamari [Tue, 11 Jun 2019 16:48:32 +0000 (12:48 -0400)] 
testsuite: Ensure T5423 flushes C output buffer

Previously T5423 would fail to flush the printf output buffer.
Consequently it was platform-dependent whether the C or Haskell print
output would be emitted first.

4 weeks agotestsuite: Fix T8602 on musl
Ben Gamari [Tue, 11 Jun 2019 16:45:24 +0000 (12:45 -0400)] 
testsuite: Fix T8602 on musl

Musl wants hash-bangs on all executables.

4 weeks agobase/Event/Poll: Drop POLLRDHUP enum item
Ben Gamari [Tue, 11 Jun 2019 04:51:53 +0000 (00:51 -0400)] 
base/Event/Poll: Drop POLLRDHUP enum item

Previously the Event enumeration produced by hsc2hs would sometimes
include a currently-unused POLLRDHUP item. This unused binding would
result in a build failure. Drop it.

4 weeks agoRemove dead code
Krzysztof Gogolewski [Wed, 26 Dec 2018 11:28:43 +0000 (12:28 +0100)] 
Remove dead code

4 weeks agoSynchronize ClsInst.doTyConApp with TcTypeable validity checks (#15862)
Ryan Scott [Fri, 14 Jun 2019 15:07:46 +0000 (11:07 -0400)] 
Synchronize ClsInst.doTyConApp with TcTypeable validity checks (#15862)

Issue #15862 demonstrated examples of type constructors on which
`TcTypeable.tyConIsTypeable` would return `False`, but the `Typeable`
constraint solver in `ClsInst` (in particular, `doTyConApp`) would
try to generate `Typeable` evidence for anyway, resulting in
disaster. This incongruity was caused by the fact that `doTyConApp`
was using a weaker validity check than `tyConIsTypeable` to determine
if a type constructor warrants `Typeable` evidence or not. The
solution, perhaps unsurprisingly, is to use `tyConIsTypeable` in
`doTyConApp` instead.

To avoid import cycles between `ClsInst` and `TcTypeable`, I factored
out `tyConIsTypeable` into its own module, `TcTypeableValidity`.

Fixes #15862.

4 weeks agotestsuite: Add assertions that way lists are in fact lists
Ben Gamari [Fri, 14 Jun 2019 00:21:03 +0000 (20:21 -0400)] 
testsuite: Add assertions that way lists are in fact lists

Previously there were a few cases where operations like `omit_ways`
were incorrectly passed a single way (e.g. `omit_ways('threaded2')`).
This won't work as the author expected.

4 weeks agoFix typo in error message
Aiken Cairncross [Fri, 14 Jun 2019 13:21:37 +0000 (14:21 +0100)] 
Fix typo in error message

4 weeks agotestsuite: Skip hDuplicateTo001 in concurrent ways
Ben Gamari [Fri, 14 Jun 2019 00:20:09 +0000 (20:20 -0400)] 
testsuite: Skip hDuplicateTo001 in concurrent ways

As noted in #16819, this operation is racy under concurrent execution.

4 weeks agotestsuite: Introduce concurrent_ways set
Ben Gamari [Fri, 14 Jun 2019 00:17:20 +0000 (20:17 -0400)] 
testsuite: Introduce concurrent_ways set

Previously we just tested for the threaded2 when determining whether to
skip tests which are fragile under concurrent execution. However, this
isn't the only way which is concurrent.

4 weeks agoDisable optimisation when building Cabal in development flavours
Ben Gamari [Thu, 13 Jun 2019 20:24:10 +0000 (16:24 -0400)] 
Disable optimisation when building Cabal in development flavours

This updates the make and Hadrian build flavours targetting developers
to disable optimisation when building the Cabal library. Cabal tends to
tickle some very bad compiler performance cases (e.g. #16577) so
disabling optimisation here makes a sizeable impact on overall build
time.

See #16817.

4 weeks agoDisable optimisation when building Cabal lib for stage0
Ben Gamari [Thu, 13 Jun 2019 20:22:31 +0000 (16:22 -0400)] 
Disable optimisation when building Cabal lib for stage0

This disables optimisation when building Cabal for Hadrian and
stage0 `ghc-cabal`. Cabal is performance critical in neither case nor
will any performance difference here be visible to the end-user.

See #16817.

4 weeks agoBump unix submodule
Ben Gamari [Fri, 14 Jun 2019 20:04:13 +0000 (16:04 -0400)] 
Bump unix submodule

Skips `executeFile001` test in `threaded2` way. Fixes #16814.

4 weeks agoRemove duplicates from 'ghc --info' output
Alp Mestanogullari [Fri, 14 Jun 2019 09:57:38 +0000 (11:57 +0200)] 
Remove duplicates from 'ghc --info' output

4 weeks agogitlab-ci: Lint the linters
Ben Gamari [Wed, 12 Jun 2019 15:11:31 +0000 (11:11 -0400)] 
gitlab-ci: Lint the linters

4 weeks agolint: Only apply --interactive lint to testsuite .T files
Ben Gamari [Wed, 12 Jun 2019 14:54:48 +0000 (10:54 -0400)] 
lint: Only apply --interactive lint to testsuite .T files

4 weeks agogitlab-ci: Lint testsuite for framework failures
Ben Gamari [Wed, 12 Jun 2019 13:37:13 +0000 (09:37 -0400)] 
gitlab-ci: Lint testsuite for framework failures

This introduces a new lint job checking for framework failures and
listing broken tests.

5 weeks agoPrelRules: Don't break let/app invariant in shiftRule
Ben Gamari [Mon, 10 Jun 2019 13:25:57 +0000 (09:25 -0400)] 
PrelRules: Don't break let/app invariant in shiftRule

Previously shiftRule would rewrite as invalid shift like
```
let x = I# (uncheckedIShiftL# n 80)
in ...
```
to
```
let x = I# (error "invalid shift")
in ...
```
However, this breaks the let/app invariant as `error` is not
okay-for-speculation. There isn't an easy way to avoid this so let's not
try. Instead we just take advantage of the undefined nature of invalid
shifts and return zero.

Fixes #16742.

5 weeks agoImplement the -XUnliftedNewtypes extension.
Andrew Martin [Sun, 12 May 2019 13:23:25 +0000 (09:23 -0400)] 
Implement the -XUnliftedNewtypes extension.

GHC Proposal: 0013-unlifted-newtypes.rst
Discussion: https://github.com/ghc-proposals/ghc-proposals/pull/98
Issues: #15219, #1311, #13595, #15883
Implementation Details:
  Note [Implementation of UnliftedNewtypes]
  Note [Unifying data family kinds]
  Note [Compulsory newtype unfolding]

This patch introduces the -XUnliftedNewtypes extension. When this
extension is enabled, GHC drops the restriction that the field in
a newtype must be of kind (TYPE 'LiftedRep). This allows types
like Int# and ByteArray# to be used in a newtype. Additionally,
coerce is made levity-polymorphic so that it can be used with
newtypes over unlifted types.

The bulk of the changes are in TcTyClsDecls.hs. With -XUnliftedNewtypes,
getInitialKind is more liberal, introducing a unification variable to
return the kind (TYPE r0) rather than just returning (TYPE 'LiftedRep).
When kind-checking a data constructor with kcConDecl, we attempt to
unify the kind of a newtype with the kind of its field's type. When
typechecking a data declaration with tcTyClDecl, we again perform a
unification. See the implementation note for more on this.

Co-authored-by: Richard Eisenberg <rae@richarde.dev>
5 weeks agoAdd Outputable instances for Float, Double.
Andreas Klebinger [Thu, 13 Jun 2019 15:07:45 +0000 (17:07 +0200)] 
Add Outputable instances for Float, Double.

5 weeks agoHadrian: remove superfluous dependencies in Rules.Compile
Alp Mestanogullari [Tue, 11 Jun 2019 12:27:17 +0000 (14:27 +0200)] 
Hadrian: remove superfluous dependencies in Rules.Compile

Each package's object files were 'need'ing the library files of all transitive
dependencies of the current package, whichi is pointless since the said
libraries are not needed until we link those object files together.

This fixes #16759.

5 weeks agoRemove unused Unique field from StgFCallOp
Ömer Sinan Ağacan [Mon, 10 Jun 2019 09:40:37 +0000 (12:40 +0300)] 
Remove unused Unique field from StgFCallOp

Fixes #16696

5 weeks agoMaintain separate flags for C++ compiler invocations
Ben Gamari [Mon, 3 Jun 2019 22:51:17 +0000 (18:51 -0400)] 
Maintain separate flags for C++ compiler invocations

Previously we would pass flags intended for the C compiler to the C++
compiler (see #16738). This would cause, for instance, `-std=gnu99` to
be passed to the C++ compiler, causing spurious test failures. Fix this
by maintaining a separate set of flags for C++ compilation invocations.

5 weeks agogitlab-ci: Disable validate-x86_64-linux-deb9 job to reduce load
Ben Gamari [Wed, 12 Jun 2019 05:36:33 +0000 (01:36 -0400)] 
gitlab-ci: Disable validate-x86_64-linux-deb9 job to reduce load

Enable artifacts on to ensure we have bindist coverage.

5 weeks agogitlab-ci: Disable deb9-llvm job, introduce nightly LLVM job
Ben Gamari [Wed, 12 Jun 2019 05:14:32 +0000 (01:14 -0400)] 
gitlab-ci: Disable deb9-llvm job, introduce nightly LLVM job

This should help alleviate queue times as the LLVM job is one of the
longest that we have.

5 weeks agotestsuite: A more portable solution to #9399
Ben Gamari [Tue, 11 Jun 2019 13:54:55 +0000 (09:54 -0400)] 
testsuite: A more portable solution to #9399

Previously we used an awful hybrid batch script/Bourne shell script to
allow this test to run both on Windows and Linux (fixing #9399).
However, this breaks on some libc implementations (e.g. musl). Fix this.

Fixes #16798.

5 weeks agoClean up .circleci
Ben Gamari [Tue, 11 Jun 2019 03:47:47 +0000 (23:47 -0400)] 
Clean up .circleci

Move prepare-system.sh to .gitlab and remove everything else.

5 weeks agogitlab-ci: Don't build PDF user's guide on AArch64
Ben Gamari [Tue, 11 Jun 2019 23:48:56 +0000 (19:48 -0400)] 
gitlab-ci: Don't build PDF user's guide on AArch64

For reasons I don't understand sphinx seems to fail to produce a .idx
file for makeindex.

5 weeks agousers-guide: Fix a few markup issues
Ben Gamari [Tue, 11 Jun 2019 02:51:58 +0000 (22:51 -0400)] 
users-guide: Fix a few markup issues

Strangely these were only causing the build to fail in the aarch64-linux
job, despite Sphinx throwing errors in all jobs I checked.

Also changes some `#ifdef`s to `#if defined` to satisfy the linter.

5 weeks agoHadrian: Do not allow the Linux jobs to fail anymore
Alp Mestanogullari [Mon, 10 Jun 2019 18:55:12 +0000 (20:55 +0200)] 
Hadrian: Do not allow the Linux jobs to fail anymore

MR !1151 makes the Hadrian/Linux job pass by fixing the last two test failures,
so we can now be stricter and not allow those jobs to fail anymore, easily
letting us see when patches introduce test failures.

5 weeks agoHadrian: Track RTS library symlink targets
David Eichmann [Tue, 4 Jun 2019 18:01:19 +0000 (19:01 +0100)] 
Hadrian: Track RTS library symlink targets

This requires creating RTS library symlinks when registering, outside
of the rule for the registered library file.

5 weeks agoPrelRules: Ensure that string unpack/append rule fires with source notes
Ben Gamari [Tue, 4 Jun 2019 04:42:10 +0000 (00:42 -0400)] 
PrelRules: Ensure that string unpack/append rule fires with source notes

Previously the presence of source notes could hide nested applications
of `unpackFoldrCString#` from our constant folding logic. For instance,
consider the expression:

```haskell
unpackFoldrCString# "foo" c (unpackFoldrCString# "baz" c n)
```

Specifically, ticks appearing in two places can defeat the rule:

  a. Surrounding the inner application of `unpackFoldrCString#`
  b. Surrounding the fold function, `c`

The latter caused the `str_rules` testcase to fail when `base` was built
with `-g3`.

Fixes #16740.

5 weeks agoFix #16525: ObjectCode freed wrongly because of lack of info header check
Phuong Trinh [Thu, 25 Apr 2019 17:44:02 +0000 (18:44 +0100)] 
Fix #16525: ObjectCode freed wrongly because of lack of info header check

`checkUnload` currently doesn't check the info header of static objects.
Thus, it may free an `ObjectCode` struct wrongly even if there's still a
live static object whose info header lies in a mapped section of that
`ObjectCode`. This fixes the issue by adding an appropriate check.

5 weeks agoAdd a few missing llvm-targets
Ben Gamari [Wed, 12 Jun 2019 18:24:23 +0000 (14:24 -0400)] 
Add a few missing llvm-targets

This should finally fix #14261.

[skip ci]

5 weeks agogitlab-ci: Bump Docker image
Ben Gamari [Wed, 12 Jun 2019 21:52:35 +0000 (17:52 -0400)] 
gitlab-ci: Bump Docker image

Fixes linters.

5 weeks agotestsuite: Don't run tests requiring TH in profasm way when GhcDynamic
Ben Gamari [Tue, 11 Jun 2019 19:56:07 +0000 (15:56 -0400)] 
testsuite: Don't run tests requiring TH in profasm way when GhcDynamic

Since we can't load profiled objects when GhcDynamic==YES. Affects:

* T16737
* T16384
* T16718
* T16619
* T16190

5 weeks agotestsuite: Unbreak galois_raytrace on i386
Ben Gamari [Tue, 11 Jun 2019 17:24:35 +0000 (13:24 -0400)] 
testsuite: Unbreak galois_raytrace on i386

galois_raytrace was previously broken on i386 due to use of x87
arithmethic on that platform. However,
42504f4a575395a35eec5c3fd7c9ef6e2b54e68e removes x87 support; this
resulted in an unexpected pass. Unmark this test as broken.

5 weeks agotestsuite: Skip cgrun078 in ghci way
Ben Gamari [Tue, 11 Jun 2019 05:09:17 +0000 (01:09 -0400)] 
testsuite: Skip cgrun078 in ghci way

This test requires FFI usage.

5 weeks agoprocess: Bump submodule
Ben Gamari [Mon, 10 Jun 2019 13:52:08 +0000 (09:52 -0400)] 
process: Bump submodule

 * Skip process005 in ghci way
 * Mark process002 as fragile in threaded2

5 weeks agoBump unix submodule
Ben Gamari [Sat, 6 Apr 2019 18:45:52 +0000 (14:45 -0400)] 
Bump unix submodule

Marks posix002 as fragile in threaded2 way due to #16550.

5 weeks agoFix uses of #ifdef/#ifndef
Ben Gamari [Sun, 9 Jun 2019 13:50:41 +0000 (09:50 -0400)] 
Fix uses of #ifdef/#ifndef

The linter now enforces our preference for `#if defined()` and
`#if !defined()`.

5 weeks agogitlab-ci: Fetch submodules before running submodule linter
Ben Gamari [Sun, 9 Jun 2019 16:31:32 +0000 (12:31 -0400)] 
gitlab-ci: Fetch submodules before running submodule linter

5 weeks agolinters/check-makefiles: Limit lint to Makefiles
Ben Gamari [Sun, 9 Jun 2019 14:36:58 +0000 (10:36 -0400)] 
linters/check-makefiles: Limit lint to Makefiles

Previously we would apply this rule, which is only intended for
testsuite Makefiles, to all files. This lead to a number of
false-positives in all.T files.

5 weeks agotestsuite: Note intentional typo in T7130
Ben Gamari [Tue, 11 Jun 2019 05:11:58 +0000 (01:11 -0400)] 
testsuite: Note intentional typo in T7130

I earlier accidentally corrected it breaking the test.

5 weeks agotestsuite: Mark T16737 as broken in ghci way due to #16541
Ben Gamari [Sun, 9 Jun 2019 13:32:55 +0000 (09:32 -0400)] 
testsuite: Mark T16737 as broken in ghci way due to #16541

5 weeks agotestsuite: Mark T16449_2 as broken due to #16742
Ben Gamari [Tue, 4 Jun 2019 04:56:47 +0000 (00:56 -0400)] 
testsuite: Mark T16449_2 as broken due to #16742

5 weeks agotestsuite: Skip T493 in ghci way.
Ben Gamari [Tue, 4 Jun 2019 04:53:09 +0000 (00:53 -0400)] 
testsuite: Skip T493 in ghci way.

T493 tests #493, which is an FFI test. FFI tests should be skipped
in ghci way.