ghc.git
2 months agoNonMoving: Add summarizing Note
Ben Gamari [Fri, 17 May 2019 15:42:11 +0000 (11:42 -0400)] 
NonMoving: Add summarizing Note

2 months agoMerge branches 'wip/gc/optimize' and 'wip/gc/test' into wip/gc/everything
Ben Gamari [Wed, 19 Jun 2019 01:42:18 +0000 (21:42 -0400)] 
Merge branches 'wip/gc/optimize' and 'wip/gc/test' into wip/gc/everything

2 months agoNonmoving: Ensure write barrier vanishes in non-threaded RTS
Ben Gamari [Sun, 19 May 2019 17:29:42 +0000 (13:29 -0400)] 
Nonmoving: Ensure write barrier vanishes in non-threaded RTS

2 months 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.

2 months 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

2 months 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.

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

2 months 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%.

2 months 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

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

2 months 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.

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

2 months 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.

2 months 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)

2 months 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

2 months 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.

2 months agoSkip ghc_heap_all test in nonmoving ways
Ben Gamari [Wed, 3 Apr 2019 00:50:56 +0000 (20:50 -0400)] 
Skip ghc_heap_all test in nonmoving ways

2 months agoghc-heap: Skip heap_all test with debugged RTS
Ben Gamari [Tue, 5 Mar 2019 00:45:36 +0000 (19:45 -0500)] 
ghc-heap: Skip heap_all test with debugged RTS

The debugged RTS initializes the heap with 0xaa, which breaks the
(admittedly rather fragile) assumption that uninitialized fields are set
to 0x00:
```
Wrong exit code for heap_all(nonmoving)(expected 0 , actual 1 )
Stderr ( heap_all ):
heap_all: user error (assertClosuresEq: Closures do not match
Expected: FunClosure {info = StgInfoTable {entry = Nothing, ptrs = 0, nptrs = 1, tipe = FUN_0_1, srtlen = 0, code = Nothing}, ptrArgs = [], dataArgs = [0]}
Actual:   FunClosure {info = StgInfoTable {entry = Nothing, ptrs = 0, nptrs = 1, tipe = FUN_0_1, srtlen = 1032832, code = Nothing}, ptrArgs = [], dataArgs = [12297829382473034410]}

CallStack (from HasCallStack):
  assertClosuresEq, called at heap_all.hs:230:9 in main:Main
)
```

2 months agotestsuite: Skip T15892 in nonmoving_thr_ghc
Ben Gamari [Wed, 13 Feb 2019 20:33:31 +0000 (15:33 -0500)] 
testsuite: Skip T15892 in nonmoving_thr_ghc

2 months agotestsuite: bug1010 requires -c, which isn't supported by nonmoving
Ben Gamari [Wed, 13 Feb 2019 19:05:37 +0000 (14:05 -0500)] 
testsuite: bug1010 requires -c, which isn't supported by nonmoving

2 months agotestsuite: Ensure that threaded tests are run in nonmoving_thr
Ben Gamari [Wed, 13 Feb 2019 18:49:04 +0000 (13:49 -0500)] 
testsuite: Ensure that threaded tests are run in nonmoving_thr

2 months agotestsuite: Nonmoving collector doesn't support -G1
Ben Gamari [Tue, 5 Feb 2019 22:15:57 +0000 (17:15 -0500)] 
testsuite: Nonmoving collector doesn't support -G1

2 months agotestsuite: Don't run T15892 in nonmoving ways
Ben Gamari [Tue, 5 Feb 2019 22:06:25 +0000 (17:06 -0500)] 
testsuite: Don't run T15892 in nonmoving ways

The nonmoving GC doesn't support `+RTS -G1`, which this test insists on.

2 months agotestsuite: Add nonmoving_thr_ghc way
Ben Gamari [Tue, 12 Feb 2019 03:03:33 +0000 (22:03 -0500)] 
testsuite: Add nonmoving_thr_ghc way

This uses the nonmoving collector when compiling the testcases.

2 months agotestsuite: Add nonmoving_thr way
Ben Gamari [Tue, 12 Feb 2019 03:03:33 +0000 (22:03 -0500)] 
testsuite: Add nonmoving_thr way

2 months agoMore comments for aging
Ben Gamari [Tue, 18 Jun 2019 21:22:06 +0000 (17:22 -0400)] 
More comments for aging

2 months 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

2 months 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

2 months agorts/Stats: Track time usage of nonmoving collector
Ben Gamari [Fri, 3 May 2019 19:15:45 +0000 (15:15 -0400)] 
rts/Stats: Track time usage of nonmoving collector

2 months agorts: Add GetMyThreadCPUTime helper
Ben Gamari [Fri, 17 May 2019 19:40:26 +0000 (15:40 -0400)] 
rts: Add GetMyThreadCPUTime helper

2 months agoNonmovingCensus: Emit samples to eventlog
Ben Gamari [Mon, 15 Apr 2019 20:42:56 +0000 (16:42 -0400)] 
NonmovingCensus: Emit samples to eventlog

2 months agoAllow census without live word count
Ben Gamari [Sat, 16 Mar 2019 14:24:24 +0000 (10:24 -0400)] 
Allow census without live word count

Otherwise the census is unsafe when mutators are running due to
concurrent mutation.

2 months agorts/Eventlog: More descriptive error message
Ben Gamari [Mon, 15 Apr 2019 21:07:24 +0000 (17:07 -0400)] 
rts/Eventlog: More descriptive error message

2 months agorts: Introduce non-moving heap census
Ben Gamari [Tue, 5 Feb 2019 16:52:13 +0000 (11:52 -0500)] 
rts: Introduce non-moving heap census

This introduces a simple census of the non-moving heap (not to be
confused with the heap census used by the heap profiler). This
collects basic heap usage information (number of allocated and free
blocks) which is useful when characterising fragmentation of the
nonmoving heap.

2 months agorts: Tracing support for nonmoving collection events
Ben Gamari [Tue, 5 Feb 2019 16:51:52 +0000 (11:51 -0500)] 
rts: Tracing support for nonmoving collection events

This introduces a few events to mark key points in the nonmoving
garbage collection cycle. These include:

 * `EVENT_CONC_MARK_BEGIN`, denoting the beginning of a round of
   marking. This may happen more than once in a single major collection
   since we the major collector iterates until it hits a fixed point.

 * `EVENT_CONC_MARK_END`, denoting the end of a round of marking.

 * `EVENT_CONC_SYNC_BEGIN`, denoting the beginning of the post-mark
   synchronization phase

 * `EVENT_CONC_UPD_REM_SET_FLUSH`, indicating that a capability has
   flushed its update remembered set.

 * `EVENT_CONC_SYNC_END`, denoting that all mutators have flushed their
   update remembered sets.

 * `EVENT_CONC_SWEEP_BEGIN`, denoting the beginning of the sweep portion
   of the major collection.

 * `EVENT_CONC_SWEEP_END`, denoting the end of the sweep portion of the
   major collection.

2 months agoNonmoving: Disable memory inventory with concurrent collection
Ben Gamari [Fri, 17 May 2019 02:13:02 +0000 (22:13 -0400)] 
Nonmoving: Disable memory inventory with concurrent collection

2 months 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>
2 months agotestsuite: Add nonmoving WAY
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.

2 months 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>
2 months 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

2 months 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.

2 months 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.

2 months 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.

2 months 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.

2 months agoMerge branches 'wip/gc/misc-rts' and 'wip/gc/aligned-block-allocation' into wip/gc...
Ben Gamari [Wed, 19 Jun 2019 00:32:46 +0000 (20:32 -0400)] 
Merge branches 'wip/gc/misc-rts' and 'wip/gc/aligned-block-allocation' into wip/gc/preparation

2 months agoAllow allocating megablocks in allocAlignedGroupOnNode
Ömer Sinan Ağacan [Mon, 10 Jun 2019 07:42:41 +0000 (10:42 +0300)] 
Allow allocating megablocks in allocAlignedGroupOnNode

This is currently broken because freeGroup assumes integral number of
megablocks when freeing megablocks but we try to split the megablocks
returned by allocLargeChunkOnNode to smaller groups and free the rest.

2 months 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

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

2 months 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

2 months 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

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

2 months 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

2 months 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

2 months 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.

2 months agorts: Fix CPP linter issues
Ben Gamari [Tue, 18 Jun 2019 23:19:42 +0000 (19:19 -0400)] 
rts: Fix CPP linter issues

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

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

2 months 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.

2 months 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

2 months 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.

2 months 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.

2 months 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.

2 months 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

2 months 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]

2 months 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

2 months 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.

2 months 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.

2 months 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.

2 months 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

2 months 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.

2 months 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.

2 months 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.

2 months 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.

2 months 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.

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

2 months 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.

2 months 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.

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

2 months 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.

2 months 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.

2 months 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.

2 months 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.

2 months 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.

2 months 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

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

2 months 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

2 months 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.

2 months 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.

2 months 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>
2 months 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.

2 months 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.

2 months 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

2 months 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.

2 months 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.

2 months 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.

2 months 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.

2 months 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.

2 months 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.

2 months 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.

2 months 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.