Skip to content
  • Ömer Sinan Ağacan's avatar
    Refactor iface file generation: · f3cb8c7c
    Ömer Sinan Ağacan authored and Marge Bot's avatar Marge Bot committed
    This commit refactors interface file generation to allow information
    from the later passed (NCG, STG) to be stored in interface files.
    
    We achieve this by splitting interface file generation into two parts:
    * Partial interfaces, built based on the result of the core pipeline
    * A fully instantiated interface, which also contains the final
    fingerprints and can optionally contain information produced by the backend.
    
    This change is required by !1304 and !1530.
    
    -dynamic-too handling is refactored too: previously when generating code
    we'd branch on -dynamic-too *before* code generation, but now we do it
    after.
    
    (Original code written by @AndreasK
    
     in !1530)
    
    Performance
    ~~~~~~~~~~~
    
    Before this patch interface files where created and immediately flushed
    to disk which made space leaks impossible.
    With this change we instead use NFData to force all iface related data
    structures to avoid space leaks.
    
    In the process of refactoring it was discovered that the code in the
    ToIface Module allocated a lot of thunks which were immediately forced
    when writing/forcing the interface file. So we made this module more
    strict to avoid creating many of those thunks.
    
    Bottom line is that allocations go down by about ~0.1% compared to
    master.
    Residency is not meaningfully different after this patch.
    Runtime was not benchmarked.
    
    Co-Authored-By: default avatarAndreas Klebinger <klebinger.andreas@gmx.at>
    Co-Authored-By: default avatarÖmer Sinan Ağacan <omer@well-typed.com>
    f3cb8c7c