Skip to main content

IOG GHC Update #15

· 4 min read

Biweekly Triweekly update from the GHC DevX team at IOG.

Previous updates can be found here.


  • Sylvain: I've noticed that fusion wasn't happening for enumFrom* methods on 32-bit targets (e.g. JavaScript). For example, foo = sum [0..123456] :: Word64 was compiling into slow code using Integer operations (see GHC#23578). Jaro has made a fix for the fusion operation (thanks!). However it turned out that the JS implementation of 64-bit operations is sometimes slower than using Integer operations (see GHC#23597) so fixing fusion made the JS code slower! See Jaro's benchmark's results. I've updated the implementation of plusWord64 to fix this specific case (see GHC!10873). With my fix we get a x3.5 speedup on the previous example and with Jaro's fusion fix we get another x5.4 speedup. Overall, from 4.8s to 0.25s!
  • Jeff: I've narrowed down the performance regression in the Cardano code base when migrating to GHC-9.2.x to two functions: one which I fully understand and have a fix and another which I still do not understand. However, I have begun writing my report and will use this as a case study for the optimization handbook. I still do not understand the regression, but have found numerous other problems in the code base; such as an overly pervasive use of INLINE pragmas, which are leading to code bloat and are hurting other good optimizations such as worker/wrapper.

CI / Testsuite

  • Sylvain: implemented getMonotonicTimeNSec in JavaScript. See GHC#23687 and GHC!10900. Found while working on unix's package testsuite.

  • Luite: ran the testsuite for the JavaScript target with strict mode ("use strict") on node.js and found some missing declarations that went unnoticed when running in regular mode. Pushed a few fixes. See GHC#23775 and GHC!11028.

  • Josh: worked on adding CI to ghcjs-base using the DevX Github actions DevX.

Cross Compiling / JavaScript backend

  • Luite: We found that emsdk 3.1.42 changed the layout of the stat struct, which broke functionality. Since emsdk data structure layouts were apparently not as stable as we assumed, we needed some improvements in the way we were dealing with data structures and constants from the C compiler. We have removed hardcoded data layout information from the JavaScript support files in favour of layout information directly obtained from the C compiler through the autoconf tools. Additionally we have more toolchain version checks now to prevent inconsistencies between the Haskell code (.hsc files) and the JavaScript code. See GHC!10918.

  • Luite: Support for the JavaScript backend in the process package is now merged. See process!292.

  • Luite: Found an issue with incorrect separation of constants such as flags/masks between the node.js platform (mostly seen by jsbits .js files) and those seen by Haskell .hsc files. A solution is mostly complete, but depends on GHC!10918 to be merged first. See GHC#23777.

  • Jeff: Continued work on implementing the new JStg IR. The MR's compiler is now capable of compiling a hello world, but has a bug in code generation I am still working to understand, although I have narrowed it down to the exact line of code in the JavaScript payload and the corresponding function in the eDSL.

  • Josh: Fixed an issue with the JavaScript backend's MK_TUP* macros where these weren't using the correct constructor names. See:

  • Josh: Implemented rename and getcwd in the JavaScript backend based on nodejs functions.

  • Josh: Worked on updating ghcjs-dom to build with the JavaScript backend.

  • Josh: Worked on updating certain ghcjs-base functions that render Integral values as decimal and hexadecimal JSString values.

Incomplete Record Selectors

Deprecated Instances


  • Sylvain: fixed two typos in CPP constants used by the JS rts (noticed by Luite). These would only be problematic in uncommon erroring circumstances, explaining why they haven't been caught earlier. See GHC#23650 and GHC!10862.

  • Jeff: Finished and submitted the camera ready version of the GHC modularity paper. See you at ICFP!

  • Bartek: Working on Record Wild Cards not producing custom deprecations when used. See GHC!23382