ghc.git
11 months agoAlways check the relocation value for x86_64
Zejun Wu [Mon, 1 Oct 2018 13:12:29 +0000 (15:12 +0200)] 
Always check the relocation value for x86_64

Summary:
Always check that no overflow happens during relocation for x86_64.
It's not safe to assume the result returned by `ocAllocateSymbolExtras` is
always valid if we allocate it neither in lower 2G nor in a contiguous range
with the image.

There are also some minor fixes in this diff:

* `off >= 0x7fffffffL` should be `>`
* use of unaligned pointer is undefined behavior, use `memcpy` instead, gcc
  will be able to optimize it to `mov %edx, (%rax)`.

Test Plan:
build ghci with:

```
DYNAMIC_GHC_PROGRAMS = NO
DYNAMIC_BY_DEFAULT = NO
```

and play with it.

  ./validate

Reviewers: simonmar, austin, bgamari, erikd

Reviewed By: simonmar

Subscribers: alpmestan, rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5168

11 months agoAdd -fkeep-cafs
Simon Marlow [Fri, 28 Sep 2018 12:27:22 +0000 (14:27 +0200)] 
Add -fkeep-cafs

Summary:
I noticed while playing around with
https://github.com/fbsamples/ghc-hotswap/ that the main binary needs to
have a custom main function to set `config.keep_cafs = true` when
initialising the runtime. This is pretty annoying, it means an extra
C file with some cryptic incantations in it, and a `-no-hs-main` flag.

So I've replaced this with a link-time flag to GHC, `-fkeep-cafs` that
does the same thing.

Test Plan:
New unit test that tests for the RTS's GC'd CAFs assertion, and also
the -keep-cafs flag.

Reviewers: bgamari, osa1, erikd, noamz

Reviewed By: osa1

Subscribers: rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5183

11 months agoExpose wopt_set/unset_fatal in DynFlags
Neil Mitchell [Wed, 26 Sep 2018 09:58:38 +0000 (10:58 +0100)] 
Expose wopt_set/unset_fatal in DynFlags

PR: https://github.com/ghc/ghc/pull/199/

11 months agoNormalise EmptyCase types using the constraint solver
Ryan Scott [Fri, 28 Sep 2018 12:22:48 +0000 (14:22 +0200)] 
Normalise EmptyCase types using the constraint solver

Summary:
Certain `EmptyCase` expressions were mistakently producing
warnings since their types did not have as many type families reduced
as they could have. The most direct way to fix this is to normalise
these types initially using the constraint solver to solve for any
local equalities that may be in scope.

Test Plan: make test TEST=T14813

Reviewers: simonpj, bgamari, goldfire

Reviewed By: simonpj

Subscribers: rwbarton, carter

GHC Trac Issues: #14813

Differential Revision: https://phabricator.haskell.org/D5094

11 months agoFix for recover with -fexternal-interpreter (#15418)
Simon Marlow [Wed, 26 Sep 2018 20:32:29 +0000 (15:32 -0500)] 
Fix for recover with -fexternal-interpreter (#15418)

Summary:
When using -fexternal-interpreter, recover was not treating a Q
compuation that simply registered an error with addErrTc as failing.

Test Plan:
New unit tests:
* T15418 is the repro from in the ticket
* TH_recover_warns is a new test to ensure that we're keeping warnings when
  the body of recover succeeds.

Reviewers: bgamari, RyanGlScott, angerman, goldfire, erikd

Subscribers: rwbarton, carter

GHC Trac Issues: #15418

Differential Revision: https://phabricator.haskell.org/D5185

11 months agousers' guide: document -freverse-errors
quasicomputational [Wed, 26 Sep 2018 09:57:38 +0000 (10:57 +0100)] 
users' guide: document -freverse-errors

11 months agoFix constant-folding for Integer shifts
Simon Peyton Jones [Wed, 26 Sep 2018 03:29:19 +0000 (04:29 +0100)] 
Fix constant-folding for Integer shifts

In this patch
    commit 869f69fd4a78371c221e6d9abd69a71440a4679a
    Author: Simon Peyton Jones <simonpj@microsoft.com>
    Date:   Wed Dec 11 18:19:34 2013 +0000

    Guarding against silly shifts

we deal with silly shifts like (Sll 1 9223372036854775807).  But
I only dealt with primops that Int# and Word#.

Alas, the same problem affects shifts of Integer, as Trac #15673
showed.  Fortunately, the problem is easy to fix.

11 months agoFix Lint of unsaturated type families
Simon Peyton Jones [Tue, 25 Sep 2018 14:19:22 +0000 (15:19 +0100)] 
Fix Lint of unsaturated type families

GHC allows types to have unsaturated type synonyms and type families,
provided they /are/ saturated if you expand all type synonyms.

TcValidity carefully checked this; see check_syn_tc_app.  But
Lint only did half the job, adn that led to Trac #15664.

This patch just teaches Core Lint to be as clever as TcValidity.

11 months agoExpand the Note on let-bound skolems
Simon Peyton Jones [Sun, 23 Sep 2018 14:23:09 +0000 (15:23 +0100)] 
Expand the Note on let-bound skolems

11 months agoAdd regression test for #15666
Ryan Scott [Tue, 25 Sep 2018 12:33:06 +0000 (08:33 -0400)] 
Add regression test for #15666

Commit 59f38587d44efd00b10a6d98f6a7a1b22e87f13a ended up
fixing #15666. Let's add a regression test to ensure that it stays
fixed.

11 months agoDon't show constraint tuples in errors (#14907)
Alec Theriault [Tue, 25 Sep 2018 09:58:12 +0000 (11:58 +0200)] 
Don't show constraint tuples in errors (#14907)

Summary:
This means that 'GHC.Classes.(%,%)' is no longer mentioned in
error messages for things like

   class (a,b,c)  -- outside of 'GHC.Classes'
   class (a,Bool)

Test Plan: make TEST=T14907a && make TEST=T14907b

Reviewers: RyanGlScott, bgamari

Reviewed By: RyanGlScott

Subscribers: rwbarton, carter

GHC Trac Issues: #14907

Differential Revision: https://phabricator.haskell.org/D5172

11 months agoaclocal.m4: fix shell comment syntax: '#', not '$'
Sergei Trofimovich [Tue, 25 Sep 2018 09:57:35 +0000 (11:57 +0200)] 
aclocal.m4: fix shell comment syntax: '#', not '$'

Summary:
Reported-by: Evan Laforge
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Reviewers: bgamari

Subscribers: rwbarton, erikd, carter

Differential Revision: https://phabricator.haskell.org/D5171

11 months agoFix a MSG_BLACKHOLE sanity check, add some comments
Ömer Sinan Ağacan [Mon, 24 Sep 2018 13:21:27 +0000 (16:21 +0300)] 
Fix a MSG_BLACKHOLE sanity check, add some comments

Reviewers: simonmar, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

GHC Trac Issues: #15508

Differential Revision: https://phabricator.haskell.org/D5178

11 months agoAdd a recursivity check in nonVoid
Ryan Scott [Sun, 23 Sep 2018 12:15:13 +0000 (08:15 -0400)] 
Add a recursivity check in nonVoid

Summary:
Previously `nonVoid` outright refused to call itself
recursively to avoid the risk of hitting infinite loops when
checking recurisve types. But this is too conservative—we //can//
call `nonVoid` recursively as long as we incorporate a way to detect
the presence of recursive types, and bail out if we do detect one.
Happily, such a mechanism already exists in the form of `checkRecTc`,
so let's use it.

Test Plan: make test TEST=T15584

Reviewers: simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, carter

GHC Trac Issues: #15584

Differential Revision: https://phabricator.haskell.org/D5116

11 months agoFix get getIdFromTrivialExpr
Simon Peyton Jones [Sat, 22 Sep 2018 23:44:14 +0000 (00:44 +0100)] 
Fix get getIdFromTrivialExpr

This bug, discovered by Trac #15325, has been lurking since

  commit 1c9fd3f1c5522372fcaf250c805b959e8090a62c
  Author: Simon Peyton Jones <simonpj@microsoft.com>
  Date:   Thu Dec 3 12:57:54 2015 +0000

    Case-of-empty-alts is trivial (Trac #11155)

I'd forgotttnen to modify getIdFromTrivialExpr when I
modified exprIsTrivial.   Easy to fix, though.

11 months agoComments only
Simon Peyton Jones [Thu, 20 Sep 2018 19:05:05 +0000 (20:05 +0100)] 
Comments only

11 months agoDon't look up unnecessary return in LastStmt
Simon Peyton Jones [Thu, 20 Sep 2018 19:02:39 +0000 (20:02 +0100)] 
Don't look up unnecessary return in LastStmt

This fixes Trac #15607. The general pattern is well
established (e.g. see the guard_op binding in rnStmt
of BodyStme), but we weren't using it for LastStmt.

11 months agoBuglet in reporting out of scope errors in rules
Simon Peyton Jones [Thu, 20 Sep 2018 18:53:56 +0000 (19:53 +0100)] 
Buglet in reporting out of scope errors in rules

Most out of scope errors get reported by the type checker these
days, but not all.  Example, the function on the LHS of a RULE.

Trace #15659 pointed out that this less-heavily-used code path
produce a "wacky" error message.  Indeed so.  Easily fixed.

11 months agotestsuite: Bump T9630 expected allocations
Ben Gamari [Sat, 22 Sep 2018 15:12:59 +0000 (11:12 -0400)] 
testsuite: Bump T9630 expected allocations

This failed on Darwin.

11 months agotestsuite: Bump expected allocations for T12707
Ben Gamari [Fri, 21 Sep 2018 22:51:38 +0000 (18:51 -0400)] 
testsuite: Bump expected allocations for T12707

11 months agotestsuite: Bump expected allocations of T9675
Ben Gamari [Fri, 21 Sep 2018 20:24:32 +0000 (16:24 -0400)] 
testsuite: Bump expected allocations of T9675

This inexplicably started with 989dca6cbd93, which appears to be a bump of the
`text` submodule. This is very fishy so I've opened #15663 to ensure we
investigate.

11 months agotestsuite: Fix readFail048 and readFail032 brokenness declarations
Ben Gamari [Fri, 21 Sep 2018 20:18:08 +0000 (16:18 -0400)] 
testsuite: Fix readFail048 and readFail032 brokenness declarations

Whoops.

11 months agotestsuite: Mark readFail032 and readFail048 as broken on Darwin
Ben Gamari [Fri, 21 Sep 2018 16:16:35 +0000 (12:16 -0400)] 
testsuite: Mark readFail032 and readFail048 as broken on Darwin

It looks like Clang's CPP implementation has an off-by-one error here.

11 months agotestsuite: Don't force run of llvm ways in T14251
Ben Gamari [Fri, 21 Sep 2018 15:44:35 +0000 (11:44 -0400)] 
testsuite: Don't force run of llvm ways in T14251

This breaks if LLVM is not available.

11 months agoRemove redundant slop zeroing
Ömer Sinan Ağacan [Fri, 21 Sep 2018 07:08:18 +0000 (10:08 +0300)] 
Remove redundant slop zeroing

OVERWRITE_INFO already does zero slopping by calling OVERWRITING_CLOSURE

11 months agoFix slop zeroing for AP_STACK eager blackholes in debug build
Ömer Sinan Ağacan [Fri, 21 Sep 2018 06:33:38 +0000 (09:33 +0300)] 
Fix slop zeroing for AP_STACK eager blackholes in debug build

As #15571 reports, eager blackholing breaks sanity checks as we can't
zero the payload when eagerly blackholing (because we'll be using the
payload after blackholing), but by the time we blackhole a previously
eagerly blackholed object (in `threadPaused()`) we don't have the
correct size information for the object (because the object's type
becomes BLACKHOLE when we eagerly blackhole it) so can't properly zero
the slop.

This problem can be solved for AP_STACK eager blackholing (which unlike
eager blackholing in general, is not optional) by zeroing the payload
after entering the stack. This patch implements this idea.

Fixes #15571.

Test Plan:
Previously concprog001 when compiled and run with sanity checks

    ghc-stage2 Mult.hs -debug -rtsopts
    ./Mult +RTS -DS

was failing with

    Mult: internal error: checkClosure: stack frame
        (GHC version 8.7.20180821 for x86_64_unknown_linux)
        Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

thic patch fixes this panic. The test still panics, but it runs for a while
before panicking (instead of directly panicking as before), and the new problem
seems unrelated:

    Mult: internal error: ASSERTION FAILED: file rts/sm/Sanity.c, line 296
        (GHC version 8.7.20180919 for x86_64_unknown_linux)
        Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

The new problem will be fixed in another diff.

I also tried slow validate (which requires D5164): this does not introduce any
new failures.

Reviewers: simonmar, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

GHC Trac Issues: #15571

Differential Revision: https://phabricator.haskell.org/D5165

11 months agouser-guide: Allow build with sphinx < 1.8
Ben Gamari [Thu, 20 Sep 2018 21:35:05 +0000 (17:35 -0400)] 
user-guide: Allow build with sphinx < 1.8

Apparently the override argument to add_directive_to_domain was added in sphinx
1.8.

11 months agousers_guide: fix sphinx error caused by non-explicit override
Zejun Wu [Thu, 20 Sep 2018 20:05:28 +0000 (16:05 -0400)] 
users_guide: fix sphinx error caused by non-explicit override

Encouter following error when `make`:

```
Extension error:
The 'ghc-flag' directive is already registered to domain std
```

as we register `ghc-flag` to `std` in `add_object_type` first and then
overtride it in `add_directive_to_domain`.

Test Plan:
  make -C utils/haddock/doc html SPHINX_BUILD=/usr/bin/sphinx-build

Reviewers: austin, bgamari, patrickdoc

Subscribers: rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5161

11 months agousers-guide: Fix build with sphinx 1.8
Ben Gamari [Thu, 20 Sep 2018 12:27:37 +0000 (08:27 -0400)] 
users-guide: Fix build with sphinx 1.8

It seems that both add_object_type and add_directive_to_domain both register a
directive. Previously sphinx didn't seem to mind this but as of Sphinx 1.8 it
crashes with an exception.

11 months agoRevert "adds -latomic to. ghc-prim"
Ben Gamari [Wed, 19 Sep 2018 19:23:27 +0000 (15:23 -0400)] 
Revert "adds -latomic to. ghc-prim"

This commit was never properly justified and relies on the existence of
libatomic, which doesn't appear to exist on Darwin.

This reverts commit ec9aacf3eb2975fd302609163aaef429962ecd87.

11 months agoAdd testcase for #14251
Ben Gamari [Wed, 19 Sep 2018 19:04:11 +0000 (15:04 -0400)] 
Add testcase for #14251

11 months agousers guide: Fix a few issues
Frank Steffahn [Tue, 21 Aug 2018 21:37:33 +0000 (23:37 +0200)] 
users guide: Fix a few issues

11 months agoRemove -Waggregate-return when building RTS
Ömer Sinan Ağacan [Thu, 20 Sep 2018 13:04:11 +0000 (16:04 +0300)] 
Remove -Waggregate-return when building RTS

This causes slow validate build to fail (in Profiling.c:countTickss), and
there's nothing wrong with struct returns.

Reviewers: simonmar, bgamari, erikd

Subscribers: rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5164

11 months agoUse predefined known-key names when possible
Chaitanya Koparkar [Wed, 19 Sep 2018 07:19:53 +0000 (09:19 +0200)] 
Use predefined known-key names when possible

Summary:
For certain entities in 'PrelNames', we were creating new 'Name's
instead of reusing the ones already defined. Easily fixed.

Test Plan: ./validate

Reviewers: dfeuer, RyanGlScott, bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, carter

GHC Trac Issues: #13279

Differential Revision: https://phabricator.haskell.org/D5160

11 months agodocs: fix example code
john [Mon, 17 Sep 2018 06:21:39 +0000 (06:21 +0000)] 
docs: fix example code

PR: https://github.com/ghc/ghc/pull/197/

11 months agoDon't shortcut SRTs for static functions (#15544)
Simon Marlow [Tue, 18 Sep 2018 15:47:56 +0000 (11:47 -0400)] 
Don't shortcut SRTs for static functions (#15544)

Shortcutting the SRT for a static function can lead to resurrecting a
static object at runtime, which violates assumptions in the GC. See
comments for details.

Test Plan:
- manual testing (in progress)
- validate

Reviewers: osa1, bgamari, erikd

Reviewed By: bgamari

Subscribers: rwbarton, carter

GHC Trac Issues: #15544

Differential Revision: https://phabricator.haskell.org/D5145

11 months agoBump deepseq submodule
Ben Gamari [Sun, 16 Sep 2018 20:56:16 +0000 (16:56 -0400)] 
Bump deepseq submodule

(cherry picked from commit c4209ba8a448b501a11d66640d280fe1e194f847)

11 months agoBump text submodule
Ben Gamari [Sun, 16 Sep 2018 20:55:21 +0000 (16:55 -0400)] 
Bump text submodule

(cherry picked from commit a512f1e32bd4d6079559e3172522591863321fe7)

11 months agoBump stm submodule
Ben Gamari [Sun, 16 Sep 2018 20:51:53 +0000 (16:51 -0400)] 
Bump stm submodule

(cherry picked from commit f458bca3a9667af95b8782747eab5b0e70cba4b4)

11 months agoInvert FP conditions to eliminate the explicit NaN check.
klebinger.andreas@gmx.at [Tue, 18 Sep 2018 15:46:38 +0000 (17:46 +0200)] 
Invert FP conditions to eliminate the explicit NaN check.

Summary:
Optimisation: we don't have to test the parity flag if we
know the test has already excluded the unordered case: eg >
and >= test for a zero carry flag, which can only occur for
ordered operands.

By reversing comparisons we can avoid testing the parity
for < and <= as well. This works since:
* If any of the arguments is an NaN CF gets set. Resulting in a false result.
* Since this allows us to rule out NaN we can exchange the arguments and invert the
  direction of the arrows.

Test Plan: ci/nofib

Reviewers: carter, bgamari, alpmestan

Reviewed By: alpmestan

Subscribers: alpmestan, simonpj, jmct, rwbarton, thomie

GHC Trac Issues: #15196

Differential Revision: https://phabricator.haskell.org/D4990

11 months agoFix check whether GCC supports __atomic_ builtins
Ilias Tsitsimpis [Tue, 18 Sep 2018 15:45:17 +0000 (17:45 +0200)] 
Fix check whether GCC supports __atomic_ builtins

Summary:
C11 atomics are never used because:

* The program used for checking whether GCC supports
__atomic_ builtins fails with the following error:

```
  error: size mismatch in argument 2 of `__atomic_load`
   int test(int *x) { int y; __atomic_load(&x, &y, __ATOMIC_SEQ_CST); return x; }
```

* There is a typo when checking if CONF_GCC_SUPPORTS__ATOMICS equals YES,
resulting in PRIM_CFLAGS and PRIM_EXTRA_LIBRARIES never being set.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, erikd, carter

Differential Revision: https://phabricator.haskell.org/D5154

11 months agoNoImplicitPrelude in ghc-boot-th, ghc-boot, ghc-heap, ghci
Shayne Fletcher [Tue, 21 Aug 2018 11:58:16 +0000 (07:58 -0400)] 
NoImplicitPrelude in ghc-boot-th, ghc-boot, ghc-heap, ghci

PR: https://github.com/ghc/ghc/pull/184

11 months agoUsers guide: EmptyDataDecls on by default
Chris Martin [Thu, 30 Aug 2018 17:23:59 +0000 (13:23 -0400)] 
Users guide: EmptyDataDecls on by default

12 months agoUpdated PE linker, section alignment and cleanup.
Tamar Christina [Mon, 17 Sep 2018 21:06:05 +0000 (22:06 +0100)] 
Updated PE linker, section alignment and cleanup.

Summary:
This patch is to address a couple of short comings of the PE linker.

The first thing it does is properly honor section alignments, so SSE code
will work reliably.

While doing this I've also changed how it reads and stores ObjectFile
information. Previously the entire object file was read in and treated
as one blob, including headers, symbol tables etc.

Now the ObjectFile is read in but stored in chunks, tables go into a temporary
info struct and code/data into a new private heap. This allows me to free all
meta data once we're done relocating. Which means we can reclaim this memory.

As I've mentioned above I've also moved from using VirtualAlloc to HeapAlloc.
The reason is VirtualAlloc is meant to be used for more low level memory
allocation, it's very fast because it can only allocate whole blocks,
(64k) by default, and the memory must be paged (4k) aligned.

So when you ask for e.g. 30k of memory, you're given a whole block where 34k
will be wasted memory. Nothing else can ever access that untill you free the 30k.

One downside of HeapAlloc is that you're not in control of how the heap grows,
and heap memory is always committed. So it's harder to tell how much we're
actually using now.

Another big upside of splitting off the ObjectCode tables to info structs
is that I can adjust them, so that later addressings can just use array
subscripts to index into them. This simplifies the code a lot and a lot of
complicated casts and indexing can be removed. Leaving less and more simple
code.

This patch doesn't fix the memprotection but it doesn't regress it either.
It does however make the next changes smaller and fixes the alignments.

Test Plan: ./validate , new test T13617

Reviewers: bgamari, erikd, simonmar, hvr, angerman

Reviewed By: angerman

Subscribers: nickkuk, carter, RyanGlScott, rwbarton, thomie

GHC Trac Issues: #13617

Differential Revision: https://phabricator.haskell.org/D3915

12 months agoMake sure forM_ and related functions fuse cleanly
Sebastian Graf [Mon, 17 Sep 2018 19:11:09 +0000 (21:11 +0200)] 
Make sure forM_ and related functions fuse cleanly

Summary:
It was revealed in #8763 that it's hard to come up with a list fusion
helper for `efdtIntFB` that doesn't duplicated occurrences of `c`,
which is crucial in guaranteeing that it is inlined.

Not inlining `c` led to spoiled join points, in turn leading to unnecessary
heap allocation. This patch tackles the problem from a different angle:
Fixing all consumers instead of the less often used producer
`efdtIntFB` by inserting an INLINE pragma in the appropriate places.
See https://ghc.haskell.org/trac/ghc/ticket/8763#comment:76 and the new
Note [List fusion and continuations in 'c'].

A quick run of NoFib revealed no regression or improvements whatsoever.

Reviewers: hvr, bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, carter

GHC Trac Issues: #8763

Differential Revision: https://phabricator.haskell.org/D5131

12 months agousers-guide: Fix code-block layout for QuantifiedConstraints
Takenobu Tani [Mon, 17 Sep 2018 14:47:02 +0000 (16:47 +0200)] 
users-guide: Fix code-block layout for QuantifiedConstraints

Summary:
Fix code-block layout for QuantifiedConstraints.

[ci skip]

Test Plan: build

Reviewers: bgamari, monoidal

Reviewed By: monoidal

Subscribers: rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5121

12 months agobase: Add bangs to GHC.IO.Handle.Text hGet* functions
Ben Gamari [Mon, 17 Sep 2018 14:46:26 +0000 (16:46 +0200)] 
base: Add bangs to GHC.IO.Handle.Text hGet* functions

Summary:
I believe that demand analysis doesn't notice that these are morally strict in
the pointer argument due to the `count == 0` special case. Fixes #15638.

Test Plan: Validate

Reviewers: andrewthad, hvr

Reviewed By: andrewthad

Subscribers: rwbarton, carter

GHC Trac Issues: #15638

Differential Revision: https://phabricator.haskell.org/D5149

12 months agoStable name comment wibbles
David Feuer [Mon, 17 Sep 2018 14:46:05 +0000 (16:46 +0200)] 
Stable name comment wibbles

Summary:
Some comments in the `StableName` code still referred to
stable pointer details. Fix that.

Reviewers: bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5152

12 months agoFix for #13862: Optional "-v" not allowed with :load in GHCi
roland [Sun, 16 Sep 2018 16:06:13 +0000 (19:06 +0300)] 
Fix for #13862: Optional "-v" not allowed with :load in GHCi

Replace the error message
    `Use -v to see a list of the files searched for.`
with
    `Use -v (or :set -v` in ghci) to see a list of the files searched for.`

Reviewers: bgamari, monoidal, thomie, osa1

Subscribers: rwbarton, carter

GHC Trac Issues: #13862

Differential Revision: https://phabricator.haskell.org/D5122

12 months agoCorrect submodule update for haddock
Richard Eisenberg [Sat, 15 Sep 2018 19:41:39 +0000 (15:41 -0400)] 
Correct submodule update for haddock

Previous commit (Coercion Quantification) was missing a
commit on the haddock submodule. This (hopefully) corrects it.

12 months agoCoercion Quantification
ningning [Sat, 15 Sep 2018 14:16:47 +0000 (10:16 -0400)] 
Coercion Quantification

This patch corresponds to #15497.

According to https://ghc.haskell.org/trac/ghc/wiki/DependentHaskell/Phase2,
 we would like to have coercion quantifications back. This will
allow us to migrate (~#) to be homogeneous, instead of its current
heterogeneous definition. This patch is (lots of) plumbing only. There
should be no user-visible effects.

An overview of changes:

- Both `ForAllTy` and `ForAllCo` can quantify over coercion variables,
but only in *Core*. All relevant functions are updated accordingly.
- Small changes that should be irrelevant to the main task:
    1. removed dead code `mkTransAppCo` in Coercion
    2. removed out-dated Note Computing a coercion kind and
       roles in Coercion
    3. Added `Eq4` in Note Respecting definitional equality in
       TyCoRep, and updated `mkCastTy` accordingly.
    4. Various updates and corrections of notes and typos.
- Haddock submodule needs to be changed too.

Acknowledgments:
This work was completed mostly during Ningning Xie's Google Summer
of Code, sponsored by Google. It was advised by Richard Eisenberg,
supported by NSF grant 1704041.

Test Plan: ./validate

Reviewers: goldfire, simonpj, bgamari, hvr, erikd, simonmar

Subscribers: RyanGlScott, monoidal, rwbarton, carter

GHC Trac Issues: #15497

Differential Revision: https://phabricator.haskell.org/D5054

12 months agoMark code related symbols as @function not @object
Sergei Azovskov [Fri, 14 Sep 2018 14:09:59 +0000 (15:09 +0100)] 
Mark code related symbols as @function not @object

Summary:
This diff is a part of the bigger project which goal is to improve
common profiling tools support (perf) for GHC binaries.

A similar job was already done and reverted in the past:
 * https://phabricator.haskell.org/rGHCb1f453e16f0ce11a2ab18cc4c350bdcbd36299a6
 * https://phabricator.haskell.org/rGHCf1f3c4f50650110ad0f700d6566a44c515b0548f

Reasoning:

`Perf` and similar tools build in memory symbol table from the .symtab
section of the ELF file to display human-readable function names instead
of the addresses in the output. `Perf` uses only two types of symbols:
`@function` and `@notype` but GHC is not capable to produce any
`@function` symbols so the `perf` output is pretty useless (All the
haskell symbols that you can see in `perf` now are `@notype` internal
symbols extracted by mistake/hack).

The changes:
 * mark code related symbols as @function
 * small hack to mark InfoTable symbols as code if TABLES_NEXT_TO_CODE is true

Limitations:
 * The perf symbolization support is not complete after this patch but
   I'm working on the second patch.
 * Constructor symbols are not supported. To fix that we can issue extra
   local symbols which mark code sections as code and will be only used
   for debug.

Test Plan:
tests
any additional ideas?

Perf output on stock ghc 8.4.1:
```
     9.78%  FibbSlow  FibbSlow            [.] ckY_info
     9.59%  FibbSlow  FibbSlow            [.] cjqd_info
     7.17%  FibbSlow  FibbSlow            [.] c3sg_info
     6.62%  FibbSlow  FibbSlow            [.] c1X_info
     5.32%  FibbSlow  FibbSlow            [.] cjsX_info
     4.18%  FibbSlow  FibbSlow            [.] s3rN_info
     3.82%  FibbSlow  FibbSlow            [.] c2m_info
     3.68%  FibbSlow  FibbSlow            [.] cjlJ_info
     3.26%  FibbSlow  FibbSlow            [.] c3sb_info
     3.19%  FibbSlow  FibbSlow            [.] cjPQ_info
     3.05%  FibbSlow  FibbSlow            [.] cjQd_info
     2.97%  FibbSlow  FibbSlow            [.] cjAB_info
     2.78%  FibbSlow  FibbSlow            [.] cjzP_info
     2.40%  FibbSlow  FibbSlow            [.] cjOS_info
     2.38%  FibbSlow  FibbSlow            [.] s3rK_info
     2.27%  FibbSlow  FibbSlow            [.] cjq0_info
     2.18%  FibbSlow  FibbSlow            [.] cKQ_info
     2.13%  FibbSlow  FibbSlow            [.] cjSl_info
     1.99%  FibbSlow  FibbSlow            [.] s3rL_info
     1.98%  FibbSlow  FibbSlow            [.] c2cC_info
     1.80%  FibbSlow  FibbSlow            [.] s3rO_info
     1.37%  FibbSlow  FibbSlow            [.] c2f2_info
...
```

Perf output on patched ghc:
```
     7.97%  FibbSlow  FibbSlow            [.] c3rM_info
     6.75%  FibbSlow  FibbSlow            [.] 0x000000000032cfa8
     6.63%  FibbSlow  FibbSlow            [.] cifA_info
     4.98%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqIntegerzh_info
     4.55%  FibbSlow  FibbSlow            [.] chXn_info
     4.52%  FibbSlow  FibbSlow            [.] c3rH_info
     4.45%  FibbSlow  FibbSlow            [.] chZB_info
     4.04%  FibbSlow  FibbSlow            [.] Main_fibbzuslow_info
     4.03%  FibbSlow  FibbSlow            [.] stg_ap_0_fast
     3.76%  FibbSlow  FibbSlow            [.] chXA_info
     3.67%  FibbSlow  FibbSlow            [.] cifu_info
     3.25%  FibbSlow  FibbSlow            [.] ci4r_info
     2.64%  FibbSlow  FibbSlow            [.] s3rf_info
     2.42%  FibbSlow  FibbSlow            [.] s3rg_info
     2.39%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqInteger_info
     2.25%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_minusInteger_info
     2.17%  FibbSlow  FibbSlow            [.] ghczmprim_GHCziClasses_zeze_info
     2.09%  FibbSlow  FibbSlow            [.] cicc_info
     2.03%  FibbSlow  FibbSlow            [.] 0x0000000000331e15
     2.02%  FibbSlow  FibbSlow            [.] s3ri_info
     1.91%  FibbSlow  FibbSlow            [.] 0x0000000000331bb8
     1.89%  FibbSlow  FibbSlow            [.] ci4N_info
...
```

Reviewers: simonmar, niteria, bgamari, goldfire

Reviewed By: simonmar, bgamari

Subscribers: lelf, rwbarton, thomie, carter

GHC Trac Issues: #15501

Differential Revision: https://phabricator.haskell.org/D4713

12 months agoMark system and internal symbols as private symbols in asm
Sergei Azovskov [Fri, 14 Sep 2018 13:56:37 +0000 (14:56 +0100)] 
Mark system and internal symbols as private symbols in asm

Summary:
This marks system and internal symbols as private in asm output so those
random generated sysmbols won't appear in .symtab

Reasoning:
 * internal symbols don't help to debug because names are just random
 * the symbols style breaks perf logic
 * internal symbols can take ~75% of the .symtab. In the same time
   .symtab can take about 20% of the binary file size

Notice:
This diff mostly makes sense on top of the D4713 (or similar)

Test Plan:
tests

Perf from D4713
```
     7.97%  FibbSlow  FibbSlow            [.] c3rM_info
     6.75%  FibbSlow  FibbSlow            [.] 0x000000000032cfa8
     6.63%  FibbSlow  FibbSlow            [.] cifA_info
     4.98%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqIntegerzh_info
     4.55%  FibbSlow  FibbSlow            [.] chXn_info
     4.52%  FibbSlow  FibbSlow            [.] c3rH_info
     4.45%  FibbSlow  FibbSlow            [.] chZB_info
     4.04%  FibbSlow  FibbSlow            [.] Main_fibbzuslow_info
     4.03%  FibbSlow  FibbSlow            [.] stg_ap_0_fast
     3.76%  FibbSlow  FibbSlow            [.] chXA_info
     3.67%  FibbSlow  FibbSlow            [.] cifu_info
     3.25%  FibbSlow  FibbSlow            [.] ci4r_info
     2.64%  FibbSlow  FibbSlow            [.] s3rf_info
     2.42%  FibbSlow  FibbSlow            [.] s3rg_info
     2.39%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqInteger_info
     2.25%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_minusInteger_info
     2.17%  FibbSlow  FibbSlow            [.] ghczmprim_GHCziClasses_zeze_info
     2.09%  FibbSlow  FibbSlow            [.] cicc_info
     2.03%  FibbSlow  FibbSlow            [.] 0x0000000000331e15
     2.02%  FibbSlow  FibbSlow            [.] s3ri_info
     1.91%  FibbSlow  FibbSlow            [.] 0x0000000000331bb8
     1.89%  FibbSlow  FibbSlow            [.] ci4N_info
...
```

Perf from this patch:
```
    15.37%  FibbSlow  FibbSlow            [.] Main_fibbzuslow_info
    15.33%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_minusInteger_info
    13.34%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqIntegerzh_info
     9.24%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_plusInteger_info
     9.08%  FibbSlow  FibbSlow            [.] frame_dummy
     8.25%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqInteger_info
     4.29%  FibbSlow  FibbSlow            [.] 0x0000000000321ab0
     3.84%  FibbSlow  FibbSlow            [.] stg_ap_0_fast
     3.07%  FibbSlow  FibbSlow            [.] ghczmprim_GHCziClasses_zeze_info
     2.39%  FibbSlow  FibbSlow            [.] 0x0000000000321ab7
     1.90%  FibbSlow  FibbSlow            [.] 0x00000000003266b8
     1.88%  FibbSlow  FibbSlow            [.] base_GHCziNum_zm_info
     1.83%  FibbSlow  FibbSlow            [.] 0x0000000000326915
     1.34%  FibbSlow  FibbSlow            [.] 0x00000000003248cc
     1.07%  FibbSlow  FibbSlow            [.] base_GHCziNum_zp_info
     0.98%  FibbSlow  FibbSlow            [.] 0x00000000003247c8
     0.80%  FibbSlow  FibbSlow            [.] 0x0000000000121498
     0.79%  FibbSlow  FibbSlow            [.] stg_gc_noregs
     0.75%  FibbSlow  FibbSlow            [.] 0x0000000000321ad6
     0.67%  FibbSlow  FibbSlow            [.] 0x0000000000321aca
     0.64%  FibbSlow  FibbSlow            [.] 0x0000000000321b4a
     0.61%  FibbSlow  FibbSlow            [.] 0x00000000002ff633
```

Reviewers: simonmar, niteria, bgamari

Reviewed By: simonmar

Subscribers: lelf, angerman, olsner, rwbarton, thomie, carter

Differential Revision: https://phabricator.haskell.org/D4722

12 months agoFix T15502 on 32-bit
Krzysztof Gogolewski [Fri, 14 Sep 2018 12:38:42 +0000 (14:38 +0200)] 
Fix T15502 on 32-bit

Summary:
The expected output uses a hardcoded value for
maxBound :: Int.

This should fix one of circleci failures on i386.

Test Plan: make test TEST=T15502

Reviewers: RyanGlScott, bgamari

Reviewed By: RyanGlScott

Subscribers: rwbarton, carter

GHC Trac Issues: #15502

Differential Revision: https://phabricator.haskell.org/D5151

12 months agotests: increase (compile) timeout multiplier for T13701 and MultiLayerModules
Alp Mestanogullari [Fri, 14 Sep 2018 12:01:09 +0000 (14:01 +0200)] 
tests: increase (compile) timeout multiplier for T13701 and MultiLayerModules

Summary:
Those tests are currently making our i386 validation fail on CircleCI:

  https://circleci.com/gh/ghc/ghc/8827

Test Plan: Using my Phab<->CircleCI bridge to run i386 validation for this diff.

Reviewers: bgamari, monoidal

Reviewed By: monoidal

Subscribers: rwbarton, carter

GHC Trac Issues: #15484, #15383

Differential Revision: https://phabricator.haskell.org/D5103

12 months agoAdd support for ImplicitParams and RecursiveDo in TH
Michael Sloan [Fri, 14 Sep 2018 10:17:13 +0000 (12:17 +0200)] 
Add support for ImplicitParams and RecursiveDo in TH

Summary:
This adds TH support for the ImplicitParams and RecursiveDo extensions.

I'm submitting this as one review because I cannot cleanly make
the two commits independent.

Initially, my goal was just to add ImplicitParams support, and
I found that reasonably straightforward, so figured I might
as well use my newfound knowledge to address some other TH omissions.

Test Plan: Validate

Reviewers: goldfire, austin, bgamari, RyanGlScott

Reviewed By: RyanGlScott

Subscribers: carter, RyanGlScott, thomie

GHC Trac Issues: #1262

Differential Revision: https://phabricator.haskell.org/D1979

12 months agoUpdate hsc2hs submodule
Chaitanya Koparkar [Thu, 13 Sep 2018 22:15:18 +0000 (18:15 -0400)] 
Update hsc2hs submodule

Test Plan: ./validate

Reviewers: bgamari, hvr, RyanGlScott

Reviewed By: RyanGlScott

Subscribers: monoidal, rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5114

12 months agobase: showEFloat: Handle negative precisions the same of zero precision
Ben Gamari [Thu, 13 Sep 2018 21:09:56 +0000 (17:09 -0400)] 
base: showEFloat: Handle negative precisions the same of zero precision

Test Plan: Validate

Reviewers: hvr, alpmestan

Reviewed By: alpmestan

Subscribers: rwbarton, carter

GHC Trac Issues: #15509

Differential Revision: https://phabricator.haskell.org/D5083

12 months agoeventlog: Factor out eventlog header generation into separate function
Ben Gamari [Thu, 13 Sep 2018 15:31:08 +0000 (11:31 -0400)] 
eventlog: Factor out eventlog header generation into separate function

12 months agoFix build
Krzysztof Gogolewski [Thu, 13 Sep 2018 20:52:05 +0000 (22:52 +0200)] 
Fix build

12 months agoRemove dead variable binding
Simon Peyton Jones [Thu, 13 Sep 2018 16:47:50 +0000 (17:47 +0100)] 
Remove dead variable binding

Fallout from earlier commit, sorry.

12 months agoMore info for Implication with -dppr-debug
Simon Peyton Jones [Thu, 13 Sep 2018 11:56:29 +0000 (12:56 +0100)] 
More info for Implication with -dppr-debug

12 months agoAdd regression test for Trac #15629
Simon Peyton Jones [Thu, 13 Sep 2018 11:56:09 +0000 (12:56 +0100)] 
Add regression test for Trac #15629

12 months agoAllow (~) in the head of a quantified constraints
Simon Peyton Jones [Thu, 13 Sep 2018 10:23:53 +0000 (11:23 +0100)] 
Allow (~) in the head of a quantified constraints

Since the introduction of quantified constraints, GHC has rejected
a quantified constraint with (~) in the head, thus
  f :: (forall a. blah => a ~ ty) => stuff

I am frankly dubious that this is ever useful.  But /is/ necessary for
Coercible (representation equality version of (~)) and it does no harm
to allow it for (~) as well.  Plus, our users are asking for it
(Trac #15359, #15625).

It was really only excluded by accident, so
this patch lifts the restriction. See TcCanonical
Note [Equality superclasses in quantified constraints]

There are a number of wrinkles:

* If the context of the quantified constraint is empty, we
  can get trouble when we get down to unboxed equality (a ~# b)
  or (a ~R# b), as Trac #15625 showed. This is even more of
  a corner case, but it produced an outright crash, so I elaborated
  the superclass machinery in TcCanonical.makeStrictSuperClasses
  to add a void argument in this case.  See
  Note [Equality superclasses in quantified constraints]

* The restriction on (~) was in TcValidity.checkValidInstHead.
  In lifting the restriction I discovered an old special case for
  (~), namely
      | clas_nm `elem` [ heqTyConName, eqTyConName]
      , nameModule clas_nm /= this_mod
  This was (solely) to support the strange instance
      instance a ~~ b => a ~ b
  in Data.Type.Equality. But happily that is no longer
  with us, since
     commit f265008fb6f70830e7e92ce563f6d83833cef071
     Refactor (~) to reduce the suerpclass stack
  So I removed the special case.

* I found that the Core invariants on when we could have
       co = <expr>
  were entirely not written down. (Getting this wrong ws
  the proximate source of the crash in Trac #15625.  So

  - Documented them better in CoreSyn
      Note [CoreSyn type and coercion invariant],
  - Modified CoreOpt and CoreLint to match
  - Modified CoreUtils.bindNonRec to match
  - Made MkCore.mkCoreLet use bindNonRec, rather
    than duplicate its logic
  - Made Simplify.rebuildCase case-to-let respect
      Note [CoreSyn type and coercion invariant],

12 months agoComments only (on IfDataInstance)
Simon Peyton Jones [Thu, 13 Sep 2018 08:18:25 +0000 (09:18 +0100)] 
Comments only (on IfDataInstance)

12 months agoDelete duplicated comment line
Simon Peyton Jones [Wed, 12 Sep 2018 12:21:19 +0000 (13:21 +0100)] 
Delete duplicated comment line

12 months agoComments about join-point return types
Simon Peyton Jones [Wed, 12 Sep 2018 12:21:02 +0000 (13:21 +0100)] 
Comments about join-point return types

12 months agoTypo in user guide wrongly claims DeriveLift was added in 7.2
Merijn Verstraaten [Mon, 10 Sep 2018 14:38:16 +0000 (16:38 +0200)] 
Typo in user guide wrongly claims DeriveLift was added in 7.2

12 months agoHonor INLINE on 0-arity bindings (#15578)
Tobias Dammers [Thu, 13 Sep 2018 08:21:49 +0000 (10:21 +0200)] 
Honor INLINE on 0-arity bindings (#15578)

Summary:
Fix test for #15578

By allowing 0-arity values to be inlined, we end up changing boringness
annotations, and this gets reflected in the Core output for this
particular test.

Add Notes for #15578

Test Plan: ./validate

Reviewers: simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, carter

GHC Trac Issues: #15578

Differential Revision: https://phabricator.haskell.org/D5137

12 months agorts/Printer.c: always define the findPtr symbol
Alp Mestanogullari [Wed, 12 Sep 2018 22:06:02 +0000 (18:06 -0400)] 
rts/Printer.c: always define the findPtr symbol

It was previously only defined (and therefore shipped) when DEBUG is
defined.  This patch defines it regardless of DEBUG. This will help fix
hadrian on OS X [1].

[1]: https://github.com/snowleopard/hadrian/issues/614

Test Plan: The error from hadrian#614 is gone

Reviewers: bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5138

12 months agotemplate-haskell: Fix typo in changelog
Ben Gamari [Mon, 10 Sep 2018 02:23:16 +0000 (22:23 -0400)] 
template-haskell: Fix typo in changelog

12 months agoRevert "ghc: Remove warning of StaticPointers not being supported by GHCi"
Ben Gamari [Fri, 7 Sep 2018 14:48:43 +0000 (10:48 -0400)] 
Revert "ghc: Remove warning of StaticPointers not being supported by GHCi"

While we now support use of StaticPointers in modules loaded via the
REPL (e.g. via `:load`), we currently do not support use of
StaticPointers on the REPL itself.

This reverts commit 9400a5c6b308fbb5b3a73690610736ca3b5eb0b3.

12 months agoBe a bit more aggressive about let-to-case
Simon Peyton Jones [Wed, 12 Sep 2018 12:06:53 +0000 (13:06 +0100)] 
Be a bit more aggressive about let-to-case

This patch takes up the missed opportunity described in
Trac #15631, by convering a case into a let slightly
more agressively. See Simplify.hs
Note [Case-to-let for strictly-used binders]

There is no measurable perf impact for good or ill. But
the code is simpler and easier to explain.

12 months agoRefactor info table entry error messages
Ömer Sinan Ağacan [Wed, 12 Sep 2018 06:11:18 +0000 (09:11 +0300)] 
Refactor info table entry error messages

We now show address of the entered object in error messages. Example:

    foo: internal error: Evaluated a CAF (0xe4c518) that was GC'd!
        (GHC version 8.6.0.20180907 for x86_64_unknown_linux)
        Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

Helpful when debugging.

Test Plan: This validates

Reviewers: simonmar, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5143

12 months agoMake CoreMonad independent of TcEnv (#14391)
Krzysztof Gogolewski [Tue, 11 Sep 2018 18:46:04 +0000 (20:46 +0200)] 
Make CoreMonad independent of TcEnv (#14391)

Summary:
This removes the last direct import from simplCore/
to typechecker/.

Test Plan: validate

Reviewers: nomeata, simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, carter

GHC Trac Issues: #14391

Differential Revision: https://phabricator.haskell.org/D5139

12 months agorts.cabal.in: advertise new default profiling ways for hadrian
Alp Mestanogullari [Tue, 11 Sep 2018 18:45:43 +0000 (20:45 +0200)] 
rts.cabal.in: advertise new default profiling ways for hadrian

Summary:
D5140 makes us build some new profiling ways by default, but since it
is not advertised in rts.cabal, hadrian doesn't know about that. This patch
fixes this and successfully lets hadrian build those flavours of libHSrts.

Test Plan: hadrian/build.sh --flavour=perf

Reviewers: bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5142

12 months agoRevert incorrect STM wakeup optimisation
Ömer Sinan Ağacan [Tue, 11 Sep 2018 18:43:50 +0000 (20:43 +0200)] 
Revert incorrect STM wakeup optimisation

Summary: (see the comments)

Reviewers: simonmar, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5144

12 months agoBuild debugged prof runtimes
Ömer Sinan Ağacan [Mon, 10 Sep 2018 10:53:59 +0000 (13:53 +0300)] 
Build debugged prof runtimes

For some reason these were disabled. I find these quite useful when
debugging profiling issues, so enable them again.

Reviewers: bgamari, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5140

12 months agoUpdate UnsafeReenter test
Ömer Sinan Ağacan [Mon, 10 Sep 2018 08:14:46 +0000 (11:14 +0300)] 
Update UnsafeReenter test

Only run the test in non-threaded, compiled mode. It hangs with threaded
runtime (which stage 2 compiler uses, so disable it for ghci too).

Reviewers: simonmar, alpmestan, bgamari

Reviewed By: simonmar

Subscribers: rwbarton, carter

GHC Trac Issues: #14912

Differential Revision: https://phabricator.haskell.org/D5136

12 months agoAvoid creating unevaluated Int thunks when iterating in GHC.Foreign
Neil Mitchell [Fri, 7 Sep 2018 18:02:18 +0000 (19:02 +0100)] 
Avoid creating unevaluated Int thunks when iterating in GHC.Foreign

12 months agoRefactor Foreign.Marshal modules for more modern style
Ömer Sinan Ağacan [Sat, 8 Sep 2018 06:55:45 +0000 (09:55 +0300)] 
Refactor Foreign.Marshal modules for more modern style

(use ScopedTypeVariables to remove dummy arguments)

Reviewers: bgamari, RyanGlScott, dfeuer, hvr, monoidal

Reviewed By: monoidal

Subscribers: monoidal, rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5124

12 months agousers-guide: Disable syntax highlighting
Takenobu Tani [Fri, 7 Sep 2018 14:02:39 +0000 (16:02 +0200)] 
users-guide: Disable syntax highlighting

Summary:
I disabled syntax highlighting for NumericUnderscores extension.

Because pygments does not yet correspond to syntax rule for NumericUnderscores.
(Sphinx uses pygments as the syntax highlighting.)

I've sent a pull-request to pygments project[1].
But development of pygments has been suspended since 2017 March.

[1]: https://bitbucket.org/birkenfeld/pygments-main/pull-requests/
       745/fix-haskell-lexer-for-numeric-literals/diff

[ci skip]

Test Plan: build

Reviewers: bgamari, monoidal

Reviewed By: monoidal

Subscribers: rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5120

12 months agoghc: Remove warning of StaticPointers not being supported by GHCi
Ben Gamari [Thu, 6 Sep 2018 22:51:31 +0000 (18:51 -0400)] 
ghc: Remove warning of StaticPointers not being supported by GHCi

Support for StaticPointers was added in #12356 but I apparently
neglected to remove the warning.

12 months agoDocumentation tweaks
Krzysztof Gogolewski [Fri, 7 Sep 2018 11:53:11 +0000 (13:53 +0200)] 
Documentation tweaks

Summary:
- Mention static pointers in "stolen syntax"
- Suggest importing Constraint and IsString from Data.* instead of GHC.*
- Remove obsolete SPECIALISE syntax; it was removed in or before 1999
  (d66d409bf6)
- Fix link in pattern signatures

Test Plan: build

Reviewers: bgamari, takenobu

Reviewed By: takenobu

Subscribers: rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5132

12 months agoVarious RTS bug fixes:
Ömer Sinan Ağacan [Fri, 7 Sep 2018 06:28:36 +0000 (09:28 +0300)] 
Various RTS bug fixes:

- Retainer profiler: init_srt_thunk() should mark the stack entry as SRT
- Retainer profiler: Remove an incorrect assertion about FUN_STATIC.
  FUN_STATIC does not have to have an SRT.
- Fix nptrs of BCO

Test Plan: validate

Reviewers: simonmar, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5134

12 months agoFix a race between GC threads in concurrent scavenging
Ömer Sinan Ağacan [Thu, 6 Sep 2018 12:52:53 +0000 (15:52 +0300)] 
Fix a race between GC threads in concurrent scavenging

While debugging #15285 I realized that free block lists (free_list in
BlockAlloc.c) get corrupted when multiple scavenge threads allocate and
release blocks concurrently. Here's a picture of one such race:

    Thread 2 (Thread 32573.32601):
    #0  check_tail
        (bd=0x940d40 <stg_TSO_info>) at rts/sm/BlockAlloc.c:860
    #1  0x0000000000928ef7 in checkFreeListSanity
        () at rts/sm/BlockAlloc.c:896
    #2  0x0000000000928979 in freeGroup
        (p=0x7e998ce02880) at rts/sm/BlockAlloc.c:721
    #3  0x0000000000928a17 in freeChain
        (bd=0x7e998ce02880) at rts/sm/BlockAlloc.c:738
    #4  0x0000000000926911 in freeChain_sync
        (bd=0x7e998ce02880) at rts/sm/GCUtils.c:80
    #5  0x0000000000934720 in scavenge_capability_mut_lists
        (cap=0x1acae80) at rts/sm/Scav.c:1665
    #6  0x000000000092b411 in gcWorkerThread
        (cap=0x1acae80) at rts/sm/GC.c:1157
    #7  0x000000000090be9a in yieldCapability
        (pCap=0x7f9994e69e20, task=0x7e9984000b70, gcAllowed=true) at rts/Capability.c:861
    #8  0x0000000000906120 in scheduleYield
        (pcap=0x7f9994e69e50, task=0x7e9984000b70) at rts/Schedule.c:673
    #9  0x0000000000905500 in schedule
        (initialCapability=0x1acae80, task=0x7e9984000b70) at rts/Schedule.c:293
    #10 0x0000000000908d4f in scheduleWorker
        (cap=0x1acae80, task=0x7e9984000b70) at rts/Schedule.c:2554
    #11 0x000000000091a30a in workerStart
        (task=0x7e9984000b70) at rts/Task.c:444
    #12 0x00007f99937fa6db in start_thread
        (arg=0x7f9994e6a700) at pthread_create.c:463
    #13 0x000061654d59f88f in clone
        () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

    Thread 1 (Thread 32573.32573):
    #0  checkFreeListSanity
        () at rts/sm/BlockAlloc.c:887
    #1  0x0000000000928979 in freeGroup
        (p=0x7e998d303540) at rts/sm/BlockAlloc.c:721
    #2  0x0000000000926f23 in todo_block_full
        (size=513, ws=0x1aa8ce0) at rts/sm/GCUtils.c:264
    #3  0x00000000009583b9 in alloc_for_copy
        (size=513, gen_no=0) at rts/sm/Evac.c:80
    #4  0x000000000095850d in copy_tag_nolock
        (p=0x7e998c675f28, info=0x421d98 <Main_Large_con_info>, src=0x7e998d075d80, size=513,
        gen_no=0, tag=1) at rts/sm/Evac.c:153
    #5  0x0000000000959177 in evacuate
        (p=0x7e998c675f28) at rts/sm/Evac.c:715
    #6  0x0000000000932388 in scavenge_small_bitmap
        (p=0x7e998c675f28, size=1, bitmap=0) at rts/sm/Scav.c:271
    #7  0x0000000000934aaf in scavenge_stack
        (p=0x7e998c675f28, stack_end=0x7e998c676000) at rts/sm/Scav.c:1908
    #8  0x0000000000934295 in scavenge_one
        (p=0x7e998c66e000) at rts/sm/Scav.c:1466
    #9  0x0000000000934662 in scavenge_mutable_list
        (bd=0x7e998d300440, gen=0x1b1d880) at rts/sm/Scav.c:1643
    #10 0x0000000000934700 in scavenge_capability_mut_lists
        (cap=0x1aaa340) at rts/sm/Scav.c:1664
    #11 0x00000000009299b6 in GarbageCollect
        (collect_gen=0, do_heap_census=false, gc_type=2, cap=0x1aaa340, idle_cap=0x1b38aa0)
        at rts/sm/GC.c:378
    #12 0x0000000000907a4a in scheduleDoGC
        (pcap=0x7ffdec5b5310, task=0x1b36650, force_major=false) at rts/Schedule.c:1798
    #13 0x0000000000905de7 in schedule
        (initialCapability=0x1aaa340, task=0x1b36650) at rts/Schedule.c:546
    #14 0x0000000000908bc4 in scheduleWaitThread
        (tso=0x7e998c0067c8, ret=0x0, pcap=0x7ffdec5b5430) at rts/Schedule.c:2537
    #15 0x000000000091b5a0 in rts_evalLazyIO
        (cap=0x7ffdec5b5430, p=0x9c11f0, ret=0x0) at rts/RtsAPI.c:530
    #16 0x000000000091ca56 in hs_main
        (argc=1, argv=0x7ffdec5b5628, main_closure=0x9c11f0, rts_config=...) at rts/RtsMain.c:72
    #17 0x0000000000421ea0 in main
        ()

In particular, dbl_link_onto() which is used to add a freed block to a
doubly-linked free list is not thread safe and corrupts the list when
called concurrently.

Note that thread 1 is to blame here as thread 2 is properly taking the
spinlock. With this patch we now take the spinlock when freeing a todo
block in GC, avoiding this race.

Test Plan:
- Tried slow validate locally: this patch does not introduce new failures.
- circleci: https://circleci.com/gh/ghc/ghc-diffs/283 The test got killed
  because it took 5 hours but T7919 (which was previously failing on circleci)
  passed.

Reviewers: simonmar, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

GHC Trac Issues: #15285

Differential Revision: https://phabricator.haskell.org/D5115

12 months agoRemove an incorrect assertion in threadPaused:
Ömer Sinan Ağacan [Thu, 6 Sep 2018 08:39:46 +0000 (11:39 +0300)] 
Remove an incorrect assertion in threadPaused:

The assertion is triggered when we have a loop in the program (in which case we
see the same update frame multiple times in the stack). See #14915 for more
details.

Reviewers: simonmar, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

GHC Trac Issues: #14915

Differential Revision: https://phabricator.haskell.org/D5133

12 months agoPreserve specialisations despite CSE
Simon Peyton Jones [Wed, 5 Sep 2018 14:54:48 +0000 (15:54 +0100)] 
Preserve specialisations despite CSE

Trac #15445 showed that, as a result of CSE, a function with an
automatically generated specialisation RULE could be inlined
before the RULE had a chance to fire.

This patch attaches a NOINLINE[2] activation to the Id, during
CSE, to stop this happening.

See Note [Delay inlining after CSE]

---- Historical note ---

This patch is simpler and more direct than an earlier
version:

  commit 2110738b280543698407924a16ac92b6d804dc36
  Author: Simon Peyton Jones <simonpj@microsoft.com>
  Date:   Mon Jul 30 13:43:56 2018 +0100

  Don't inline functions with RULES too early

We had to revert this patch because it made GHC itself slower.

Why? It delayed inlining of /all/ functions with RULES, and that was
very bad in TcFlatten.flatten_ty_con_app

* It delayed inlining of liftM
* That delayed the unravelling of the recursion in some dictionary
  bindings.
* That delayed some eta expansion, leaving
     flatten_ty_con_app = \x y. let <stuff> in \z. blah
* That allowed the float-out pass to put sguff between
  the \y and \z.
* And that permanently stopped eta expasion of the function,
  even once <stuff> was simplified.

-- End of historical note ---

12 months agoDefine activeAfterInitial, activeDuringFinal
Simon Peyton Jones [Wed, 5 Sep 2018 14:53:15 +0000 (15:53 +0100)] 
Define activeAfterInitial, activeDuringFinal

This is pure refactoring, just adding a couple of
definitions to BasicTypes, and using them.

Plus some whitespace stuff.

12 months agoExpose 'moduleToPkgConfAll' from 'PackageState'
Alec Theriault [Wed, 5 Sep 2018 12:27:40 +0000 (14:27 +0200)] 
Expose 'moduleToPkgConfAll' from 'PackageState'

Summary:
Having direct access to this field is going to enable Haddock to
compute in batch which modules to load before looking up instances
of external packages.

Reviewers: bgamari, monoidal

Reviewed By: monoidal

Subscribers: rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5100

12 months agotestsuite: Use bools for booleans, not ints
Ben Gamari [Wed, 5 Sep 2018 11:45:50 +0000 (13:45 +0200)] 
testsuite: Use bools for booleans, not ints

Summary: Just as it says on the tin.

Test Plan: Validate

Reviewers: bgamari, osa1

Reviewed By: osa1

Subscribers: osa1, monoidal, rwbarton, thomie, carter

Differential Revision: https://phabricator.haskell.org/D5010

12 months agobase: Add references to Notes for certain special imports
Chaitanya Koparkar [Wed, 5 Sep 2018 11:41:24 +0000 (13:41 +0200)] 
base: Add references to Notes for certain special imports

Summary:
Modules like GHC.Integer, GHC.Natural etc. are special and sometimes
have to be imported just to resolve build ordering issues. It's useful
to refer to the appropriate Notes at such import sites.

Test Plan: Read it.

Reviewers: RyanGlScott, bgamari, hvr, simonpj

Reviewed By: RyanGlScott, simonpj

Subscribers: simonpj, rwbarton, carter

GHC Trac Issues: #15526

Differential Revision: https://phabricator.haskell.org/D5092

12 months agotestsuite: Add test for #15368
Ben Gamari [Wed, 5 Sep 2018 11:22:24 +0000 (13:22 +0200)] 
testsuite: Add test for #15368

Reviewers: bgamari, osa1

Reviewed By: osa1

Subscribers: osa1, monoidal, rwbarton, thomie, carter

GHC Trac Issues: #15368

Differential Revision: https://phabricator.haskell.org/D4958

12 months agoSkip eventlog tests in GHCi way
Ömer Sinan Ağacan [Wed, 5 Sep 2018 11:11:30 +0000 (13:11 +0200)] 
Skip eventlog tests in GHCi way

Summary: (GHCi doesn't generate event logs)

Test Plan:
These tests were failing in GHCi way, they're now skipped in GHCi way as GHCi
doesn't generate eventlogs

Reviewers: bgamari, simonmar, maoe, alpmestan

Reviewed By: alpmestan

Subscribers: rwbarton, carter

GHC Trac Issues: #15587

Differential Revision: https://phabricator.haskell.org/D5119

12 months agoFix tests ghci057 and T9293. (#15071)
roland [Tue, 4 Sep 2018 20:23:55 +0000 (22:23 +0200)] 
Fix tests ghci057 and T9293. (#15071)

Summary: As both tests specify -fno-ghci-leak-check, the GHCi :set
command is not expected to list the -fghci-leak check flag.

Test Plan: WINDOWS: make test TESTS="ghci057 T9293"

Reviewers: bgamari, monoidal

Reviewed By: monoidal

Subscribers: rwbarton, carter

GHC Trac Issues: #15071

Differential Revision: https://phabricator.haskell.org/D5125

12 months agotestsuite: make CHECK_API_ANNOTATIONS and CHECK_PPR overridable
Alp Mestanogullari [Tue, 4 Sep 2018 17:09:06 +0000 (19:09 +0200)] 
testsuite: make CHECK_API_ANNOTATIONS and CHECK_PPR overridable

Summary:
Without this patch, boilerplate.mk (which is included by a lot of Makefiles from
our testsuite) just assumes they reside in the usual inplace directory, which is
not friendly to hadrian and this makes a lot of tests (e.g T10255) fail when
building GHC and running the testsuite with hadrian.

With this patch, the said tests pass.

Test Plan: api annotation tests (with hadrian)

Reviewers: bgamari, monoidal

Reviewed By: monoidal

Subscribers: rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5127

12 months agoAdd a test for Trac #15586
Krzysztof Gogolewski [Tue, 4 Sep 2018 13:42:52 +0000 (15:42 +0200)] 
Add a test for Trac #15586

Summary: The bug is already fixed in master.

Test Plan: make test TEST=T15586

Reviewers: bgamari, simonpj

Reviewed By: simonpj

Subscribers: rwbarton, carter

GHC Trac Issues: #15586

Differential Revision: https://phabricator.haskell.org/D5118

12 months agoCompiler panic on invalid syntax (unterminated pragma)
roland [Tue, 4 Sep 2018 12:09:20 +0000 (14:09 +0200)] 
Compiler panic on invalid syntax (unterminated pragma)

Summary: After a parse error in OPTIONS_GHC issue an error message instead of a compiler panic.

Test Plan: make test TEST=T15053

Reviewers: Phyx, thomie, bgamari, monoidal, osa1

Reviewed By: Phyx, monoidal, osa1

Subscribers: tdammers, osa1, rwbarton, carter

GHC Trac Issues: #15053

Differential Revision: https://phabricator.haskell.org/D5093

12 months agoFix typos in -Wsimplifiable-class-constraints flag docs
Sergey Vinokurov [Mon, 3 Sep 2018 23:09:45 +0000 (00:09 +0100)] 
Fix typos in -Wsimplifiable-class-constraints flag docs

12 months agoRemove duplicate "since" field in glasgow_exts.rst
Josh Price [Sun, 2 Sep 2018 23:20:28 +0000 (19:20 -0400)] 
Remove duplicate "since" field in glasgow_exts.rst