Make sure mkSplitUniqSupply stores the precomputed mask only.
authorAndreas Klebinger <klebinger.andreas@gmx.at>
Mon, 17 Jun 2019 13:40:14 +0000 (15:40 +0200)
committerMarge Bot <ben+marge-bot@smart-cactus.org>
Tue, 18 Jun 2019 20:03:19 +0000 (16:03 -0400)
commit4549cadf855d14a6b737ceddf4e474faf8e343ff
tree4f4fd00e86b3679b3d44f9077e5b549ef181f250
parent6a92f59d7385397fb9ee013efe102c797319243c
Make sure mkSplitUniqSupply stores the precomputed mask only.

mkSplitUniqSupply was lazy on the boxed char.

This caused a bunch of issues:
* The closure captured the boxed Char
* The mask was recomputed on every split of the supply.
* It also caused the allocation of MkSplitSupply to happen in it's own
(allocated) closure. The reason of which I did not further investigate.

We know force the computation of the mask inside mkSplitUniqSupply.
* This way the mask is computed at most once per UniqSupply creation.
* It allows ww to kick in, causing the closure to retain the unboxed
value.

Requesting Uniques in a loop is now faster by about 20%.

I did not check the impact on the overall compiler, but I added a test
to avoid regressions.
compiler/basicTypes/UniqSupply.hs
testsuite/tests/perf/should_run/UniqLoop.hs [new file with mode: 0644]
testsuite/tests/perf/should_run/all.T