Skip to content

Draft: ghc-internal: Lower fixnums into ghc-prim

This is an experiment and a follow on to !13381 (closed). In that MR we strictified the SrcLoc fields which also removed boxing. In this MR we go further. Instead of requiring a whole machine word we specify Word32 this reduces the footprint from 12 words (4 fields, 1 pointer for each field, then each field stores an Int which is 2 words) to only 2 words (4 fields each a half machine word, unpacked, that's an 83% reduction).

The catch is that in order to do this we must lower the fixnum types Int8, Word8... into ghc-prim. Failure to do so results in some really nasty module cycles. I've attempted to break these cycles but after several hours decided this approach was better and made more sense. Key to not introducing a cycle is creating orphan instances by moving the instances out of GHC.Internel.{Word|Int} into the the module where the class is defined. I don't like it, but at this level of the compiler I think its the best we can do without adding an hs-boot file.

Merge request reports

Loading