Skip to content

Refactor interface loading, FinderCache and NameCache

Sylvain Henry requested to merge hsyl20/ghc:hsyl20/iface1 into master

Refactor interface loading, FinderCache and NameCache.

Commit 1:

In order to support several home-units and several independent
unit-databases, it's easier to explicitly pass UnitState, DynFlags, etc.
to interface loading functions.

This patch converts some functions using monads such as IfG or TcRnIf
with implicit access to HscEnv to use IO instead and to pass them
specific fields of HscEnv instead of an HscEnv value.

Commit2:

* Make NameCache the mutable one and replace NameCacheUpdater with it

* Remove NameCache related code duplicated into haddock

Commit 3:

* Make FinderCache mutable (similarly to NameCache)

Commit 4:

As suggested by @alexbiehl, this patch replaces the always updated
UniqSupply in NameCache with a fixed Char and use it with `uniqFromMask`
to generate uniques.

This required some refactoring because getting a new unique from the
NameCache can't be done in pure code anymore, in particular not in an
atomic update function for `atomicModifyIORef`. So we use an MVar
instead to store the OrigNameCache field.

Commit 5:

Use foldGet in getSymbolTable
    
Implement @alexbiehl suggestion of using a foldGet function to avoid the
creation of an intermediate list while reading the symbol table.
Edited by Sylvain Henry

Merge request reports