[GHC] #15560: Full laziness destroys opportunities for join points

GHC ghc-devs at haskell.org
Fri Aug 24 21:58:03 UTC 2018


#15560: Full laziness destroys opportunities for join points
-------------------------------------+-------------------------------------
        Reporter:  AndreasK          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  8.4.3
  (CodeGen)                          |
      Resolution:                    |             Keywords:  JoinPoints
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #14287            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 > I was under the impression that join points never allocate and that they
 rather re-use the closure of their enclosing scope

 Correct.  But consider
 {{{
 f x = let j y = Just (y,y)
       in case x of
            A -> j (True, False)
            B -> j (False, True)
            C -> j (True, True)
 }}}
 Suppose branch `A` is taken.  Then GHC must allocate the object `(True,
 False)` and jump to `j`.  Then `j` must allocate `(y,y)` and return it.

 I suspect that there's a heap check at the beginning of the `A` branch;
 and then a second heap check at the start of the body of `j`.  But instead
 we could make `j` not do a heap check (ever) and instead put on the caller
 (of `j`) the responsibility for making sure that there's enough heap space
 for `j` to do its allocation.

 That way we'd get one heap check, at the beginning of the `A` branch,
 which would ensure there was enough space for both pairs.

 (As you say, no closure is allocated for `j` itself, but that's an
 entirely different matter.)

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15560#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list