Skip to content
  • Matthew Craven's avatar
    CorePrep: Rework lowering of BigNat# literals · b56d2761
    Matthew Craven authored and Marge Bot's avatar Marge Bot committed
    Don't use bigNatFromWord#, because that's terrible:
     * We shouldn't have to traverse a linked list at run-time
       to build a BigNat# literal. That's just silly!
     * The static List object we have to create is much larger
       than the actual BigNat#'s contents, bloating code size.
     * We have to read the corresponding interface file,
       which causes un-tracked implicit dependencies. (#23942)
    
    Instead, encode them into the appropriate platform-dependent
    sequence of bytes, and generate code that copies these bytes
    at run-time from an Addr# literal into a new ByteArray#.
    A ByteArray# literal would be the correct thing to generate,
    but these are not yet supported; see also #17747.
    
    Somewhat surprisingly, this change results in a slight
    reduction in compiler allocations, averaging around 0.5%
    on ghc's compiler performance tests, including when compiling
    programs that contain no bignum literals to begin with.
    The specific cause of this has not been investigated.
    
    Since ...
    b56d2761