[commit: ghc] master: Fix an old and egregious specialisation bug (Trac #5113) (b5c18c9)

Simon Peyton Jones simonpj at microsoft.com
Mon Feb 11 09:39:23 CET 2013

Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master



commit b5c18c91da911a7729563207c7b95f7e452cca7e
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Fri Feb 8 17:29:40 2013 +0000

    Fix an old and egregious specialisation bug (Trac #5113)
    The specialiser needs to know if a dictionay has some structure,
    so that it can decide whether to specialise a function. Eg
     (A)    let d = $dfblah d1
            in ....(f d)....
     (B)    \d. ....(f d)....
    In (A) it's probably worth specialising f; in (B) it isn't.
    Previously we were relying on d's unfolding, but the specialiser
    does cloning as it goes, which discards the unfolding. So we
    were simply discarding all specialisations for functions with
    local dictionary bindings!  This bug seems to have been there
    for a long time.
    This is what originally caused Trac #5113.  Then we went through a phase
    where local bindings were not generalised, and that meant there was
    no locally overloaded f to specialise; so the performance problem appeared
    to be fixed.  But now we are generalising local bindings again, so it
    This patch fixes the original problem.

 compiler/specialise/Specialise.lhs |  390 ++++++++++++++++++++----------------
 1 files changed, 214 insertions(+), 176 deletions(-)

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

    git show b5c18c91da911a7729563207c7b95f7e452cca7e

More information about the ghc-commits mailing list