<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/haskell.git, branch wip/T16098</title>
<subtitle>gitlab.haskell.org: ghc/ghc.git
</subtitle>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/'/>
<entry>
<title>codeGen: Optimize continuation arguments</title>
<updated>2020-01-27T18:03:38+00:00</updated>
<author>
<name>Alex Biehl</name>
<email>alexbiehl@gmail.com</email>
</author>
<published>2020-01-27T17:35:12+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/commit/?id=aa9c36352c9349341ef546567dec6a3ea1ff7233'/>
<id>aa9c36352c9349341ef546567dec6a3ea1ff7233</id>
<content type='text'>
This diff implements code generation for continuation arguments, as
proposed in #16098. For primops like `catch#`/`with#`/`mask`/... which
are defined in the runtime-system there is no mechanism for inlining
them. This often leads to otherwise unnecessary allocations of closures.

This patch introduces the notion of continuation arguments to code
generation, including:

 * A way to control CorePrep to not ANFize certain primops. That is,
   leaving arguments of the form `State# s -&gt; (# State# s, a #)` in
   defined positions.
 * Teaching `CoreToStg` how to translate these to STG by extending STG
   language. Namely the `GenStgArg` type.
 * Inline primops and continuation in code generation.

This patch happily inlines `catch`#:

```
...
I64[Sp - 24] = PicBaseReg + stg_catch_frame_info;
I64[Sp - 16] = %MO_UU_Conv_W32_W64(I32[I64[BaseReg + 872] + 28]);
I64[Sp - 8] = PicBaseReg + (Test.someHandler_closure+2);
...
```

No...

 * ... call to runtime system
 * ... allocation
 * ... copying of free variables

needed

Currently this is implemented only for catch# primop. Once we agree to
merge this I will bring in the rest.

P.S. Also StgCse and Unarise are broken for continuation arguments. I
will fix that in the coming days.

[1] https://gitlab.haskell.org/ghc/ghc/blob/4898df1cc25132dc9e2599d4fa4e1bbc9423cda5/rts/Exception.cmm#L393
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This diff implements code generation for continuation arguments, as
proposed in #16098. For primops like `catch#`/`with#`/`mask`/... which
are defined in the runtime-system there is no mechanism for inlining
them. This often leads to otherwise unnecessary allocations of closures.

This patch introduces the notion of continuation arguments to code
generation, including:

 * A way to control CorePrep to not ANFize certain primops. That is,
   leaving arguments of the form `State# s -&gt; (# State# s, a #)` in
   defined positions.
 * Teaching `CoreToStg` how to translate these to STG by extending STG
   language. Namely the `GenStgArg` type.
 * Inline primops and continuation in code generation.

This patch happily inlines `catch`#:

```
...
I64[Sp - 24] = PicBaseReg + stg_catch_frame_info;
I64[Sp - 16] = %MO_UU_Conv_W32_W64(I32[I64[BaseReg + 872] + 28]);
I64[Sp - 8] = PicBaseReg + (Test.someHandler_closure+2);
...
```

No...

 * ... call to runtime system
 * ... allocation
 * ... copying of free variables

needed

Currently this is implemented only for catch# primop. Once we agree to
merge this I will bring in the rest.

P.S. Also StgCse and Unarise are broken for continuation arguments. I
will fix that in the coming days.

[1] https://gitlab.haskell.org/ghc/ghc/blob/4898df1cc25132dc9e2599d4fa4e1bbc9423cda5/rts/Exception.cmm#L393
</pre>
</div>
</content>
</entry>
<entry>
<title>Make Block.h compile with c++ compilers</title>
<updated>2020-01-27T15:04:19+00:00</updated>
<author>
<name>Matthew Pickering</name>
<email>matthewtpickering@gmail.com</email>
</author>
<published>2020-01-26T09:29:57+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/commit/?id=97d0b0a367e4c6a52a17c3299439ac7de129da24'/>
<id>97d0b0a367e4c6a52a17c3299439ac7de129da24</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Use splitLHs{ForAll,Sigma}TyInvis throughout the codebase</title>
<updated>2020-01-27T15:03:42+00:00</updated>
<author>
<name>Ryan Scott</name>
<email>ryan.gl.scott@gmail.com</email>
</author>
<published>2020-01-15T18:02:34+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/commit/?id=1132602f764ef4694b52abeaeeaa8da544915134'/>
<id>1132602f764ef4694b52abeaeeaa8da544915134</id>
<content type='text'>
Richard points out in #17688 that we use `splitLHsForAllTy` and
`splitLHsSigmaTy` in places that we ought to be using the
corresponding `-Invis` variants instead, identifying two bugs
that are caused by this oversight:

* Certain TH-quoted type signatures, such as those that appear in
  quoted `SPECIALISE` pragmas, silently turn visible `forall`s into
  invisible `forall`s.
* When quoted, the type `forall a -&gt; (a ~ a) =&gt; a` will turn into
  `forall a -&gt; a` due to a bug in `DsMeta.repForall` that drops
  contexts that follow visible `forall`s.

These are both ultimately caused by the fact that `splitLHsForAllTy`
and `splitLHsSigmaTy` split apart visible `forall`s in addition to
invisible ones. This patch cleans things up:

* We now use `splitLHsForAllTyInvis` and `splitLHsSigmaTyInvis`
  throughout the codebase. Relatedly, the `splitLHsForAllTy` and
  `splitLHsSigmaTy` have been removed, as they are easy to misuse.
* `DsMeta.repForall` now only handles invisible `forall`s to reduce
  the chance for confusion with visible `forall`s, which need to be
  handled differently. I also renamed it from `repForall` to
  `repForallT` to emphasize that its distinguishing characteristic
  is the fact that it desugars down to `L.H.TH.Syntax.ForallT`.

Fixes #17688.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Richard points out in #17688 that we use `splitLHsForAllTy` and
`splitLHsSigmaTy` in places that we ought to be using the
corresponding `-Invis` variants instead, identifying two bugs
that are caused by this oversight:

* Certain TH-quoted type signatures, such as those that appear in
  quoted `SPECIALISE` pragmas, silently turn visible `forall`s into
  invisible `forall`s.
* When quoted, the type `forall a -&gt; (a ~ a) =&gt; a` will turn into
  `forall a -&gt; a` due to a bug in `DsMeta.repForall` that drops
  contexts that follow visible `forall`s.

These are both ultimately caused by the fact that `splitLHsForAllTy`
and `splitLHsSigmaTy` split apart visible `forall`s in addition to
invisible ones. This patch cleans things up:

* We now use `splitLHsForAllTyInvis` and `splitLHsSigmaTyInvis`
  throughout the codebase. Relatedly, the `splitLHsForAllTy` and
  `splitLHsSigmaTy` have been removed, as they are easy to misuse.
* `DsMeta.repForall` now only handles invisible `forall`s to reduce
  the chance for confusion with visible `forall`s, which need to be
  handled differently. I also renamed it from `repForall` to
  `repForallT` to emphasize that its distinguishing characteristic
  is the fact that it desugars down to `L.H.TH.Syntax.ForallT`.

Fixes #17688.
</pre>
</div>
</content>
</entry>
<entry>
<title>Do not bring visible foralls into scope in hsScopedTvs</title>
<updated>2020-01-25T13:15:05+00:00</updated>
<author>
<name>Ryan Scott</name>
<email>ryan.gl.scott@gmail.com</email>
</author>
<published>2020-01-15T16:01:03+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/commit/?id=0940b59accb6926aaede045bcd5f5bdc77c7075d'/>
<id>0940b59accb6926aaede045bcd5f5bdc77c7075d</id>
<content type='text'>
Previously, `hsScopedTvs` (and its cousin `hsWcScopedTvs`) pretended
that visible dependent quantification could not possibly happen at
the term level, and cemented that assumption with an `ASSERT`:

```hs
    hsScopedTvs (HsForAllTy { hst_fvf = vis_flag, ... }) =
      ASSERT( vis_flag == ForallInvis )
      ...
```

It turns out that this assumption is wrong. You can end up tripping
this `ASSERT` if you stick it to the man and write a type for a term
that uses visible dependent quantification anyway, like in this
example:

```hs
{-# LANGUAGE ScopedTypeVariables #-}

x :: forall a -&gt; a -&gt; a
x = x
```

That won't typecheck, but that's not the point. Before the
typechecker has a chance to reject this, the renamer will try
to use `hsScopedTvs` to bring `a` into scope over the body of `x`,
since `a` is quantified by a `forall`. This, in turn, causes the
`ASSERT` to fail. Bummer.

Instead of walking on this dangerous ground, this patch makes GHC
adopt a more hardline stance by pattern-matching directly on
`ForallInvis` in `hsScopedTvs`:

```hs
    hsScopedTvs (HsForAllTy { hst_fvf = ForallInvis, ... }) = ...
```

Now `a` will not be brought over the body of `x` at all (which is how
it should be), there's no chance of the `ASSERT` failing anymore (as
it's gone), and best of all, the behavior of `hsScopedTvs` does not
change. Everyone wins!

Fixes #17687.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously, `hsScopedTvs` (and its cousin `hsWcScopedTvs`) pretended
that visible dependent quantification could not possibly happen at
the term level, and cemented that assumption with an `ASSERT`:

```hs
    hsScopedTvs (HsForAllTy { hst_fvf = vis_flag, ... }) =
      ASSERT( vis_flag == ForallInvis )
      ...
```

It turns out that this assumption is wrong. You can end up tripping
this `ASSERT` if you stick it to the man and write a type for a term
that uses visible dependent quantification anyway, like in this
example:

```hs
{-# LANGUAGE ScopedTypeVariables #-}

x :: forall a -&gt; a -&gt; a
x = x
```

That won't typecheck, but that's not the point. Before the
typechecker has a chance to reject this, the renamer will try
to use `hsScopedTvs` to bring `a` into scope over the body of `x`,
since `a` is quantified by a `forall`. This, in turn, causes the
`ASSERT` to fail. Bummer.

Instead of walking on this dangerous ground, this patch makes GHC
adopt a more hardline stance by pattern-matching directly on
`ForallInvis` in `hsScopedTvs`:

```hs
    hsScopedTvs (HsForAllTy { hst_fvf = ForallInvis, ... }) = ...
```

Now `a` will not be brought over the body of `x` at all (which is how
it should be), there's no chance of the `ASSERT` failing anymore (as
it's gone), and best of all, the behavior of `hsScopedTvs` does not
change. Everyone wins!

Fixes #17687.
</pre>
</div>
</content>
</entry>
<entry>
<title>hadrian: Throw error on duplicate-named flavours</title>
<updated>2020-01-25T10:24:57+00:00</updated>
<author>
<name>Ben Gamari</name>
<email>ben@smart-cactus.org</email>
</author>
<published>2020-01-23T19:46:21+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/commit/?id=b3e5c678851ed73897b0eb337e656ff377d242c9'/>
<id>b3e5c678851ed73897b0eb337e656ff377d242c9</id>
<content type='text'>
Throw an error if the user requests a flavour for which there is more
than one match.

Fixes #17156.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Throw an error if the user requests a flavour for which there is more
than one match.

Fixes #17156.
</pre>
</div>
</content>
</entry>
<entry>
<title>Split glasgow_exts into several files (#17316)</title>
<updated>2020-01-25T10:24:19+00:00</updated>
<author>
<name>Sylvain Henry</name>
<email>sylvain@haskus.fr</email>
</author>
<published>2020-01-15T18:52:49+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/commit/?id=0a5e4f5f7d6cef16b6b11ac8d3a269b92016ed5d'/>
<id>0a5e4f5f7d6cef16b6b11ac8d3a269b92016ed5d</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Create ghci.cabal.sh</title>
<updated>2020-01-25T10:23:39+00:00</updated>
<author>
<name>Xavier Denis</name>
<email>xldenis@gmail.com</email>
</author>
<published>2020-01-21T08:06:49+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/commit/?id=b1a32170a1b8e7a31c2dd28eb1b02f1375ea3998'/>
<id>b1a32170a1b8e7a31c2dd28eb1b02f1375ea3998</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Add ghc-in-ghci for stack based builds</title>
<updated>2020-01-25T10:23:39+00:00</updated>
<author>
<name>Xavier Denis</name>
<email>xldenis@gmail.com</email>
</author>
<published>2020-01-15T13:37:54+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/commit/?id=6eb566a0cf43aefaf451f5885ca9b56686840a23'/>
<id>6eb566a0cf43aefaf451f5885ca9b56686840a23</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix rts allocateExec() on NetBSD</title>
<updated>2020-01-25T10:23:01+00:00</updated>
<author>
<name>PHO</name>
<email>pho@cielonegro.org</email>
</author>
<published>2020-01-18T12:30:54+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/commit/?id=8b726534fa4764ad423eff9bdfb04305f330a00f'/>
<id>8b726534fa4764ad423eff9bdfb04305f330a00f</id>
<content type='text'>
Similar to SELinux, NetBSD "PaX mprotect" prohibits marking a page
mapping both writable and executable at the same time. Use libffi
which knows how to work around it.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Similar to SELinux, NetBSD "PaX mprotect" prohibits marking a page
mapping both writable and executable at the same time. Use libffi
which knows how to work around it.
</pre>
</div>
</content>
</entry>
<entry>
<title>Module hierarchy: Cmm (cf #13009)</title>
<updated>2020-01-25T10:22:20+00:00</updated>
<author>
<name>Sylvain Henry</name>
<email>sylvain@haskus.fr</email>
</author>
<published>2020-01-07T01:44:39+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/commit/?id=6e2d9ee25bce06ae51d2f1cf8df4f7422106a383'/>
<id>6e2d9ee25bce06ae51d2f1cf8df4f7422106a383</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
