[commit: ghc] master: Make type-class dictionary let binds deterministic (a5cb27f)

git at git.haskell.org git at git.haskell.org
Fri Oct 30 23:06:31 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/a5cb27f323a0c78f61db1a3c5338045b0981850b/ghc

>---------------------------------------------------------------

commit a5cb27f323a0c78f61db1a3c5338045b0981850b
Author: Bartosz Nitka <niteria at gmail.com>
Date:   Fri Oct 30 23:40:21 2015 +0100

    Make type-class dictionary let binds deterministic
    
    When generating dictionary let binds in dsTcEvBinds we may
    end up generating them in arbitrary order according to Unique order.
    
    Consider:
    
    ```
    let $dEq = GHC.Classes.$fEqInt in
    let $$dNum = GHC.Num.$fNumInt in ...
    ```
    
    vs
    
    ```
    let $dNum = GHC.Num.$fNumInt in
    let $dEq = GHC.Classes.$fEqInt in ...
    ```
    
    The way this change fixes it is by using `UniqDFM` - a type of
    deterministic finite maps of things keyed on `Unique`s. This way when
    you pull out evidence variables corresponding to type-class dictionaries
    they are in deterministic order.
    
    Currently it's the order of insertion and the way it's implemented is by
    tagging the values with the time of insertion.
    
    Test Plan:
    I've added a new test case to reproduce the issue.
    ./validate
    
    Reviewers: ezyang, simonmar, austin, simonpj, bgamari
    
    Reviewed By: simonmar, simonpj, bgamari
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D1396
    
    GHC Trac Issues: #4012


>---------------------------------------------------------------

a5cb27f323a0c78f61db1a3c5338045b0981850b
 compiler/basicTypes/VarEnv.hs                      |  28 +++++
 compiler/ghc.cabal.in                              |   1 +
 compiler/ghc.mk                                    |   1 +
 compiler/typecheck/TcEvidence.hs                   |  32 ++++--
 compiler/utils/UniqDFM.hs                          | 118 +++++++++++++++++++++
 testsuite/tests/determinism/determ003/A.hs         |  22 ++++
 testsuite/tests/determinism/determ003/Makefile     |  13 +++
 testsuite/tests/determinism/determ003/all.T        |   4 +
 .../determ003.stdout}                              |   0
 9 files changed, 212 insertions(+), 7 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc a5cb27f323a0c78f61db1a3c5338045b0981850b


More information about the ghc-commits mailing list