Is there a way to prevent reboxing in W/W (due to OPAQUE pragma proposal)

Simon Peyton Jones simonpj at microsoft.com
Thu Jun 24 10:56:22 UTC 2021


Christiaan

I'm totally paged out on this.  Would you like to do this via a comment on !5562, giving a concrete example of a small program that doesn't behave as you expect with your patch?

Sebastian may be able to help too.

Simon

From: ghc-devs <ghc-devs-bounces at haskell.org> On Behalf Of Christiaan Baaij
Sent: 24 June 2021 10:56
To: ghc-devs <ghc-devs at haskell.org>
Subject: Is there a way to prevent reboxing in W/W (due to OPAQUE pragma proposal)

Hi Ghc-Devs,

I believe I've mostly finished the implementation of GHC proposal 0415 [1], the OPAQUE pragma, over at: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5562<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.haskell.org%2Fghc%2Fghc%2F-%2Fmerge_requests%2F5562&data=04%7C01%7Csimonpj%40microsoft.com%7C37d4e06b1380430d876f08d936f663b2%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637601254145010408%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=9lJ%2FtKKqWsckKEofFLy3nZVq3RhRowOwEdWbI6RqNdY%3D&reserved=0>

The only remaining issue is that I'm unsure whether there's a way to prevent reboxing of worker arguments as witnessed here: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5562/diffs#29ad02619a9f318d67c6cd19648917dbb17354e9_0_134<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.haskell.org%2Fghc%2Fghc%2F-%2Fmerge_requests%2F5562%2Fdiffs%2329ad02619a9f318d67c6cd19648917dbb17354e9_0_134&data=04%7C01%7Csimonpj%40microsoft.com%7C37d4e06b1380430d876f08d936f663b2%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637601254145020404%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=O5MYMFoNW2xdhtE60AZBxwMTp1sRby1fvPkEpUHpak4%3D&reserved=0>

Note that the reboxing doesn't happen in the worker of the OPAQUE-annotated bindings, because OPAQUE-annotated bindings aren't W/W-transformed, but in a worker of a function that calls the OPAQUE-annotated binding.
This reboxing was the reason behind the descision to W/W transform NOINLINE-annotated bindings in: https://gitlab.haskell.org/ghc/ghc/-/commit/b572aadb20c2e41e2f6d7b48401bd0b4239ce9f8<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.haskell.org%2Fghc%2Fghc%2F-%2Fcommit%2Fb572aadb20c2e41e2f6d7b48401bd0b4239ce9f8&data=04%7C01%7Csimonpj%40microsoft.com%7C37d4e06b1380430d876f08d936f663b2%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637601254145030396%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=3ysr8IzYCI925ZA9wh%2BL0wr3x516UZ4pFeSwuWsGv68%3D&reserved=0>

But the whole idea behind OPAQUE is not to change calls to the annotated binding f by some call of a name-mangled version of f; so W/W transforming OPAQUE-annoted binders is not an option.

Any hints on how to avoid the reboxing (if possible) would be appreciated, like:
* Do I need to change something in GHC.Core.Opt.WorkWrap? or
* Do I need to change the demand/strictness signature of OPAQUE-annoted bindings?
* or something else?

Thanks,

Christiaan

[1] https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0415-opaque-pragma.rst<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fghc-proposals%2Fghc-proposals%2Fblob%2Fmaster%2Fproposals%2F0415-opaque-pragma.rst&data=04%7C01%7Csimonpj%40microsoft.com%7C37d4e06b1380430d876f08d936f663b2%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637601254145030396%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=kkmNa2MIWmrmpq6apCtD7bh8nxEFsdVZA8zuHe8vtPE%3D&reserved=0>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20210624/7489c8a7/attachment.html>


More information about the ghc-devs mailing list