[GHC] #15127: Unbox around runRW#
GHC
ghc-devs at haskell.org
Mon May 7 02:25:19 UTC 2018
#15127: Unbox around runRW#
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner: (none)
Type: bug | Status: new
Priority: low | Milestone: 8.8.1
Component: Compiler | Version: 8.4.2
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: Runtime
Unknown/Multiple | performance bug
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
Because `runRW#` inlines so late, we don't end up unboxing around it. For
example, suppose we write
{{{#!hs
f x = runST $ do
mar <- newArray 100 x
unsafeFreeze mar
}}}
This will compile to something like
{{{#!hs
f x = case runRW# (\s ->
case newArray# 100# x s of { (# s', mar #) ->
case unsafeFreezeArray# mar s' of { (# s'', ar# #) ->
(# s'', Array ar# #) }}) of
(# _, ar #) -> ar
}}}
We generally want to pull the constructor application out of the `runRW#`
argument:
{{{#!hs
f x = case runRW# (\s ->
case newArray# 100# x s of { (# s', mar #) ->
unsafeFreezeArray# mar s' }) of
(# _, ar# #) -> Array ar#
}}}
This exposes the `Array` constructor to case-of-case.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15127>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list