Skip to content
Snippets Groups Projects
  1. Apr 17, 2024
    • Teo Camarasu's avatar
      Make template-haskell a stage1 package · 42bd0407
      Teo Camarasu authored and Marge Bot's avatar Marge Bot committed
      
      Promoting template-haskell from a stage0 to a stage1 package means that
      we can much more easily refactor template-haskell.
      
      We implement this by duplicating the in-tree `template-haskell`.
      A new `template-haskell-next` library is autogenerated to mirror `template-haskell`
      `stage1:ghc` to depend on the new interface of the library including the
      `Binary` instances without adding an explicit dependency on `template-haskell`.
      
      This is controlled by the `bootstrap-th` cabal flag
      
      When building `template-haskell` modules as part of this vendoring we do
      not have access to quote syntax, so we cannot use variable quote
      notation (`'Just`). So we either replace these with hand-written `Name`s
      or hide the code behind CPP.
      
      We can remove the `th_hack` from hadrian, which was required when
      building stage0 packages using the in-tree `template-haskell` library.
      
      For more details see Note [Bootstrapping Template Haskell].
      
      Resolves #23536
      
      Co-Authored-By: default avatarSebastian Graf <sgraf1337@gmail.com>
      Co-Authored-By: default avatarMatthew Craven <5086-clyring@users.noreply.gitlab.haskell.org>
      42bd0407
  2. Apr 15, 2024
  3. Apr 12, 2024
  4. Apr 10, 2024
    • Alan Zimmerman's avatar
      EPA: Remove unnecessary XRec in CompleteMatchSig · 1b1a92bd
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      The XRec for [LIdP pass] is not needed for exact printing, remove it.
      1b1a92bd
    • Ben Gamari's avatar
      testsuite: Add test for lookupSymbolInNativeObj · dccd3ea1
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      dccd3ea1
    • Rodrigo Mesquita's avatar
      Use symbol cache in internal interpreter too · 12931698
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      This commit makes the symbol cache that was used by the external
      interpreter available for the internal interpreter too.
      
      This follows from the analysis in #23415 that suggests the internal
      interpreter could benefit from this cache too, and that there is no good
      reason not to have the cache for it too. It also makes it a bit more
      uniform to have the symbol cache range over both the internal and
      external interpreter.
      
      This commit also refactors the cache into a function which is used by
      both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the
      caching logic to `lookupSymbolInDLL` too.
      12931698
    • Rodrigo Mesquita's avatar
      rts: Make addDLL a wrapper around loadNativeObj · dcfaa190
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      Rewrite the implementation of `addDLL` as a wrapper around the more
      principled `loadNativeObj` rts linker function. The latter should be
      preferred while the former is preserved for backwards compatibility.
      
      `loadNativeObj` was previously only available on ELF platforms, so this
      commit further refactors the rts linker to transform loadNativeObj_ELF
      into loadNativeObj_POSIX, which is available in ELF and MachO platforms.
      
      The refactor made it possible to remove the `dl_mutex` mutex in favour
      of always using `linker_mutex` (rather than a combination of both).
      
      Lastly, we implement `loadNativeObj` for Windows too.
      dcfaa190
    • Alexis King's avatar
      linker: Avoid linear search when looking up Haskell symbols via dlsym · e008a19a
      Alexis King authored and Marge Bot's avatar Marge Bot committed
      
      See the primary Note [Looking up symbols in the relevant objects] for a
      more in-depth explanation.
      
      When dynamically loading a Haskell symbol (typical when running a splice or
      GHCi expression), before this commit we would search for the symbol in
      all dynamic libraries that were loaded. However, this could be very
      inefficient when too many packages are loaded (which can happen if there are
      many package dependencies) because the time to lookup the would be
      linear in the number of packages loaded.
      
      This commit drastically improves symbol loading performance by
      introducing a mapping from units to the handles of corresponding loaded
      dlls. These handles are returned by dlopen when we load a dll, and can
      then be used to look up in a specific dynamic library.
      
      Looking up a given Name is now much more precise because we can get
      lookup its unit in the mapping and lookup the symbol solely in the
      handles of the dynamic libraries loaded for that unit.
      
      In one measurement, the wait time before the expression was executed
      went from +-38 seconds down to +-2s.
      
      This commit also includes Note [Symbols may not be found in pkgs_loaded],
      explaining the fallback to the old behaviour in case no dll can be found
      in the unit mapping for a given Name.
      
      Fixes #23415
      
      Co-authored-by: default avatarRodrigo Mesquita <(@alt-romes)>
      e008a19a
    • Rodrigo Mesquita's avatar
      rts: free error message before returning · dd530bb7
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      Fixes a memory leak in rts/linker/PEi386.c
      dd530bb7
    • Jade's avatar
      Validate -main-is flag using parseIdentifier · 3d0806fc
      Jade authored and Marge Bot's avatar Marge Bot committed
      Fixes #24368
      3d0806fc
  5. Apr 09, 2024
  6. Apr 08, 2024
    • Alan Zimmerman's avatar
      EPA: Move DeltaPos and EpaLocation' into GHC.Types.SrcLoc · 12b997df
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      This allows us to use a NoCommentsLocation for the possibly trailing
      comma location in a StringLiteral.
      This in turn allows us to correctly roundtrip via makeDeltaAst.
      12b997df
    • Alan Zimmerman's avatar
      EPA: Use EpaLocation in WarningTxt · 3b7b0c1c
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      This allows us to use an EpDelta if needed when using makeDeltaAst.
      3b7b0c1c
    • Hannes Siebenhandl's avatar
      Eliminate name thunk in declaration fingerprinting · fbb91a63
      Hannes Siebenhandl authored and Marge Bot's avatar Marge Bot committed
      Thunk analysis showed that we have about 100_000 thunks (in agda and
      `-fwrite-simplified-core`) pointing to the name of the name decl.
      Forcing this thunk fixes this issue.
      
      The thunk created here is retained by the thunk created by forkM, it is
      better to eagerly force this because the result (a `Name`) is already
      retained indirectly via the `IfaceDecl`.
      fbb91a63
    • Matthew Pickering's avatar
      Force in_multi to avoid retaining entire hsc_env · c6def949
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      c6def949
    • Hannes Siebenhandl's avatar
      Never UNPACK `FastMutInt` for counting z-encoded `FastString`s · f2cc1107
      Hannes Siebenhandl authored and Marge Bot's avatar Marge Bot committed
      In `FastStringTable`, we count the number of z-encoded FastStrings
      that exist in a GHC session.
      We used to UNPACK the counters to not waste memory, but live retainer
      analysis showed that we allocate a lot of `FastMutInt`s, retained by
      `mkFastZString`.
      
      We lazily compute the `FastZString`, only incrementing the counter when the `FastZString` is
      forced.
      The function `mkFastStringWith` calls `mkZFastString` and boxes the
      `FastMutInt`, leading to the following core:
      
          mkFastStringWith
            = \ mk_fs _  ->
                   = case stringTable of
                      { FastStringTable _ n_zencs segments# _ ->
                          ...
                               case ((mk_fs (I# ...) (FastMutInt n_zencs))
                                  `cast` <Co:2> :: ...)
                                  ...
      
      Marking this field as `NOUNPACK` avoids this reboxing, eliminating the
      allocation of a fresh `FastMutInt` on every `FastString` allocation.
      f2cc1107
    • Hannes Siebenhandl's avatar
      Avoid UArray when indexing is not required · 88cb3e10
      Hannes Siebenhandl authored and Marge Bot's avatar Marge Bot committed
      `UnlinkedBCO`'s can occur many times in the heap. Each `UnlinkedBCO`
      references two `UArray`'s but never indexes them. They are only needed
      to encode the elements into a `ByteArray#`. The three words for
      the lower bound, upper bound and number of elements are essentially
      unused, thus we replace `UArray` with a wrapper around `ByteArray#`.
      This saves us up to three words for each `UnlinkedBCO`.
      
      Further, to avoid re-allocating these words for `ResolvedBCO`, we repeat
      the procedure for `ResolvedBCO` and add custom `Binary` and `Show` instances.
      
      For example, agda's repl session has around 360_000 UnlinkedBCO's,
      so avoiding these three words is already saving us around 8MB residency.
      88cb3e10
  7. Apr 05, 2024
  8. Apr 04, 2024
Loading