summaryrefslogtreecommitdiff
path: root/compiler/GHC/Unit
Commit message (Collapse)AuthorAgeFilesLines
* Remove "Ord FastString" instanceSylvain Henry2020-09-014-17/+14
| | | | | | | | | | | | | | | | | | | FastStrings can be compared in 2 ways: by Unique or lexically. We don't want to bless one particular way with an "Ord" instance because it leads to bugs (#18562) or to suboptimal code (e.g. using lexical comparison while a Unique comparison would suffice). UTF-8 encoding has the advantage that sorting strings by their encoded bytes also sorts them by their Unicode code points, without having to decode the actual code points. BUT GHC uses Modified UTF-8 which diverges from UTF-8 by encoding \0 as 0xC080 instead of 0x00 (to avoid null bytes in the middle of a String so that the string can still be null-terminated). This patch adds a new `utf8CompareShortByteString` function that performs sorting by bytes but that also takes Modified UTF-8 into account. It is much more performant than decoding the strings into [Char] to perform comparisons (which we did in the previous patch). Bump haddock submodule
* Don't store HomeUnit in UnitConfigSylvain Henry2020-08-311-17/+22
| | | | | Allow the creation of a UnitConfig (hence of a UnitState) without having a HomeUnit. It's required for #14335.
* Refactor UnitId pretty-printingSylvain Henry2020-08-266-66/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we pretty-print a UnitId for the user, we try to map it back to its origin package name, version and component to print "package-version:component" instead of some hash. The UnitId type doesn't carry these information, so we have to look into a UnitState to find them. This is why the Outputable instance of UnitId used `sdocWithDynFlags` in order to access the `unitState` field of DynFlags. This is wrong for several reasons: 1. The DynFlags are accessed when the message is printed, not when it is generated. So we could imagine that the unitState may have changed in-between. Especially if we want to allow unit unloading. 2. We want GHC to support several independent sessions at once, hence several UnitState. The current approach supposes there is a unique UnitState as a UnitId doesn't indicate which UnitState to use. See the Note [Pretty-printing UnitId] in GHC.Unit for the new approach implemented by this patch. One step closer to remove `sdocDynFlags` field from `SDocContext` (#10143). Fix #18124. Also fix some Backpack code to use SDoc instead of String.
* NCG: Dwarf configurationSylvain Henry2020-08-211-3/+3
| | | | | | * remove references to DynFlags in GHC.CmmToAsm.Dwarf * add specific Dwarf options in NCGConfig instead of directly querying the debug level
* Expose UnitInfoMap as it is part of the public APIFendor2020-08-181-0/+1
|
* Add HomeUnit typeSylvain Henry2020-08-136-137/+351
| | | | | | | | | | | | | | | | | | | | | | | Since Backpack the "home unit" is much more involved than what it was before (just an identifier obtained with `-this-unit-id`). Now it is used in conjunction with `-component-id` and `-instantiated-with` to configure module instantiations and to detect if we are type-checking an indefinite unit or compiling a definite one. This patch introduces a new HomeUnit datatype which is much easier to understand. Moreover to make GHC support several packages in the same instances, we will need to handle several HomeUnits so having a dedicated (documented) type is helpful. Finally in #14335 we will also need to handle the case where we have no HomeUnit at all because we are only loading existing interfaces for plugins which live in a different space compared to units used to produce target code. Several functions will have to be refactored to accept "Maybe HomeUnit" parameters instead of implicitly querying the HomeUnit fields in DynFlags. Having a dedicated type will make this easier. Bump haddock submodule
* DynFlags: disentangle OutputableSylvain Henry2020-08-121-2/+0
| | | | | | | | | - put panic related functions into GHC.Utils.Panic - put trace related functions using DynFlags in GHC.Driver.Ppr One step closer making Outputable fully independent of DynFlags. Bump haddock submodule
* Use a type alias for WaysSylvain Henry2020-08-061-1/+1
|
* Move GHC.Platform into the compilerSylvain Henry2020-07-251-3/+3
| | | | | | | Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before).
* Rename GHC.Driver.Ways into GHC.Platform.WaysSylvain Henry2020-07-251-1/+1
|
* Minor refactoring of Unit displaySylvain Henry2020-07-225-46/+50
| | | | | | | | * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String
* Give Uniq[D]FM a phantom type for its key.Andreas Klebinger2020-07-122-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM.
* DynFlags: factor out pprUnitId from "Outputable UnitId" instanceSylvain Henry2020-07-071-7/+14
|
* Fix duplicated words and typos in comments and user guideJan HrĨek2020-06-281-1/+1
|
* Clean up haddock hyperlinks of GHC.* (part2)Takenobu Tani2020-06-252-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.*
* Update compilerSylvain Henry2020-06-172-34/+7
| | | | | | | | | | | | | | | | Thanks to ghc-bignum, the compiler can be simplified: * Types and constructors of Integer and Natural can be wired-in. It means that we don't have to query them from interfaces. It also means that numeric literals don't have to carry their type with them. * The same code is used whatever ghc-bignum backend is enabled. In particular, conversion of bignum literals into final Core expressions is now much more straightforward. Bignum closure inspection too. * GHC itself doesn't depend on any integer-* package anymore * The `integerLibrary` setting is gone.
* Doc: fix some commentsSylvain Henry2020-06-131-58/+52
|
* Don't return preload units when we set DyNFlagsSylvain Henry2020-06-131-2/+2
| | | | Preload units can be retrieved in UnitState when needed (i.e. in GHCi)
* Put database cache in UnitConfigSylvain Henry2020-06-131-43/+34
|
* Create helper upd_wired_in_home_instantiationsSylvain Henry2020-06-131-9/+17
|
* Move distrustAll into mkUnitStateSylvain Henry2020-06-131-13/+12
|
* DynFlags: add UnitConfig datatypeSylvain Henry2020-06-131-112/+172
| | | | | | Avoid directly querying flags from DynFlags to build the UnitState. Instead go via UnitConfig so that we could reuse this to make another UnitState for plugins.
* DynFlags: merge_databasesSylvain Henry2020-06-131-9/+11
|
* DynFlags: reportCycles, reportUnusableSylvain Henry2020-06-131-8/+8
|
* DynFlags: findWiredInUnitsSylvain Henry2020-06-131-6/+6
|
* Refactor and document closeUnitDepsSylvain Henry2020-06-131-30/+26
|
* Refactor and document add_packageSylvain Henry2020-06-131-25/+26
|
* DynFlags: make listVisibleModuleNames take a UnitStateSylvain Henry2020-06-131-3/+3
|
* DynFlags: remove useless add_package parameterSylvain Henry2020-06-131-9/+7
|
* Document getPreloadUnitsAndSylvain Henry2020-06-131-4/+5
|
* DynFlags: refactor unwireUnitSylvain Henry2020-06-131-3/+3
|
* Remove preload parameter of mkUnitStateSylvain Henry2020-06-131-12/+8
| | | | | | * Remove preload parameter (unused) * Don't explicitly return preloaded units: redundant because already returned as "preloadUnits" field of UnitState
* Avoid timing module map dump in initUnitsSylvain Henry2020-06-131-18/+24
|
* Move wiring of homeUnitInstantiations outside of mkUnitStateSylvain Henry2020-06-131-8/+16
|
* Move dump_mod_map into initUnitsSylvain Henry2020-06-131-8/+8
|
* Rename Package into Unit (2)Sylvain Henry2020-06-134-83/+83
| | | | | | | * rename PackageState into UnitState * rename findWiredInPackages into findWiredInUnits * rename lookupModuleInAll[Packages,Units] * etc.
* Remove ClosureUnitInfoMapSylvain Henry2020-06-135-180/+165
|
* Make ClosureUnitInfoMap uses UnitInfoMapSylvain Henry2020-06-132-18/+37
|
* Rename Package into UnitSylvain Henry2020-06-134-170/+168
| | | | | | | | | | | | | | | | | | | | | | | | | The terminology changed over time and now package databases contain "units" (there can be several units compiled from a single Cabal package: one per-component, one for each option set, one per instantiation, etc.). We should try to be consistent internally and use "units": that's what this renaming does. Maybe one day we'll fix the UI too (e.g. replace -package-id with -unit-id, we already have -this-unit-id and ghc-pkg has -unit-id...) but it's not done in this patch. * rename getPkgFrameworkOpts into getUnitFrameworkOpts * rename UnitInfoMap into ClosureUnitInfoMap * rename InstalledPackageIndex into UnitInfoMap * rename UnusablePackages into UnusableUnits * rename PackagePrecedenceIndex into UnitPrecedenceMap * rename PackageDatabase into UnitDatabase * rename pkgDatabase into unitDatabases * rename pkgState into unitState * rename initPackages into initUnits * rename renamePackage into renameUnitInfo * rename UnusablePackageReason into UnusableUnitReason * rename getPackage* into getUnit* * etc.
* Rename listUnitInfoMap into listUnitInfoSylvain Henry2020-06-131-5/+5
| | | | There is no Map involved
* Remove PreloadUnitId type aliasSylvain Henry2020-06-131-17/+15
|
* Document and refactor `mkUnit` and `mkUnitInfoMap`Sylvain Henry2020-06-132-15/+31
|
* Refactor WiredMapSylvain Henry2020-06-132-48/+33
| | | | * Remove WiredInUnitId and WiredUnitId type aliases
* Enhance UnitId useSylvain Henry2020-06-133-57/+80
| | | | | | | | * use UnitId instead of String to identify wired-in units * use UnitId instead of Unit in the backend (Unit are only use by Backpack to produce type-checked interfaces, not real code) * rename lookup functions for consistency * documentation
* Add allowVirtualUnits field in PackageStateSylvain Henry2020-06-131-41/+48
| | | | | | | | | | Instead of always querying DynFlags to know whether we are allowed to use virtual units (i.e. instantiated on-the-fly, cf Note [About units] in GHC.Unit), we store it once for all in `PackageState.allowVirtualUnits`. This avoids using DynFlags too much (cf #17957) and is preliminary work for #14335.
* Rename unsafeGetUnitInfo into unsafeLookupUnitSylvain Henry2020-06-131-4/+4
|
* Refactor homeUnitSylvain Henry2020-06-131-12/+18
| | | | | * rename thisPackage into homeUnit * document and refactor several Backpack things
* Remove unused codeSylvain Henry2020-06-131-23/+0
|
* Clarify leaf module names for new module hierarchyTakenobu Tani2020-06-101-2/+2
| | | | | | | | | | | | | | | | | | | | | This updates comments only. This patch replaces leaf module names according to new module hierarchy [1][2] as followings: * Expand leaf names to easily find the module path: for instance, `Id.hs` to `GHC.Types.Id`. * Modify leaf names according to new module hierarchy: for instance, `Convert.hs` to `GHC.ThToHs`. * Fix typo: for instance, `GHC.Core.TyCo.Rep.hs` to `GHC.Core.TyCo.Rep` See also !3375 [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009
* Clean up boot vs non-boot disambiguating typesJohn Ericson2020-06-043-12/+79
| | | | | | | | | | | | | | | We often have (ModuleName, Bool) or (Module, Bool) pairs for "extended" module names (without or with a unit id) disambiguating boot and normal modules. We think this is important enough across the compiler that it deserves a new nominal product type. We do this with synnoyms and a functor named with a `Gen` prefix, matching other newly created definitions. It was also requested that we keep custom `IsBoot` / `NotBoot` sum type. So we have it too. This means changing many the many bools to use that instead. Updates `haddock` submodule.