JS: Specialize unpackCString# CAFs (fixes #24744)
Code analysis shown that such optimization would be possible out of the box if `cachedIdentForId` allowed to do that for Haskell `Id`s which are represented by few JavaScript `Ident`s. It is a usual for strings which are represented at JavaScript as a pair of 2 values: the string content and the offset where to start reading actual string from the full content. Usually offset is 0 but technically we need to allow such complex structures to be treated as "global". Enabling it there shown that `genToplevelRhs` and `globalOccs` had inaccuracies in their implementations: 1. `globalOccs` operated over JavaScript's `Ident`s but for complex structures it didn't pay attention to the fact that different Idents actually could be pointed to same Id. Now the algo is changed to calculate occurencies for Ids. 2. `genToplevelRhs` didn't assume that different Idents pointed to same Id can have mixed order of occurence. But actually the order is important. Strings are encoded into 2 variables where first is content and second is offset and their order are not interchangeable. It is fixed by regeneration Idents from collected Ids which is fine because all Idents generation is passed through the Cache and they are quasi-stable.
parent
a9f8f1fb
No related branches found
No related tags found
Pipeline #104273 canceled
Stage: tool-lint
Stage: quick-build
Stage: full-build
Stage: packaging
Stage: testing
Stage: deploy
Showing
- compiler/GHC/StgToJS/Apply.hs 2 additions, 2 deletionscompiler/GHC/StgToJS/Apply.hs
- compiler/GHC/StgToJS/CodeGen.hs 10 additions, 3 deletionscompiler/GHC/StgToJS/CodeGen.hs
- compiler/GHC/StgToJS/Ids.hs 1 addition, 1 deletioncompiler/GHC/StgToJS/Ids.hs
- compiler/GHC/StgToJS/Monad.hs 12 additions, 15 deletionscompiler/GHC/StgToJS/Monad.hs
- testsuite/tests/javascript/Makefile 15 additions, 14 deletionstestsuite/tests/javascript/Makefile
- testsuite/tests/javascript/T23479.hs 0 additions, 0 deletionstestsuite/tests/javascript/T23479.hs
- testsuite/tests/javascript/T23479.stdout 0 additions, 0 deletionstestsuite/tests/javascript/T23479.stdout
- testsuite/tests/javascript/T24744.hs 0 additions, 0 deletionstestsuite/tests/javascript/T24744.hs
- testsuite/tests/javascript/T24744.stdout 1 addition, 0 deletionstestsuite/tests/javascript/T24744.stdout
- testsuite/tests/javascript/all.T 2 additions, 2 deletionstestsuite/tests/javascript/all.T
Loading
Please register or sign in to comment