Skip to content
Snippets Groups Projects
  1. May 14, 2025
  2. May 11, 2025
    • Cheng Shao's avatar
      wasm: add zero length fast path for fromJSString · eac196df
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      This patch adds a zero length fast path for `fromJSString`; when
      marshaling a zero-length `JSString` we don't need to allocate an empty
      `ByteArray#` at all.
      eac196df
    • Cheng Shao's avatar
      wasm: mark freeJSVal as INLINE · eaa8093b
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      This patch marks `freeJSVal` as `INLINE` for the wasm backend. I
      noticed that the `freeJSVal` invocations are not inlined when
      inspecting STG/Cmm dumps of downstream libraries that use release
      build of the wasm backend. The performance benefit of inlining here is
      very modest, but so is the cost anyway; if you are using `freeJSVal`
      at all then you care about every potential chance to improve
      performance :)
      eaa8093b
    • Simon Peyton Jones's avatar
      Refine `noGivenNewtypeReprEqs` to account for quantified constraints · 7b2d1e6d
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      This little MR fixes #26020.  We are on the edge of completeness
      for newtype equalities (that doesn't change) but this MR makes GHC
      a bit more consistent -- and fixes the bug reported.
      7b2d1e6d
  3. May 09, 2025
    • Simon Peyton Jones's avatar
      Slighty improve `dropMisleading` · 51b0ce8f
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      Fix #26105, by upgrading the (horrible, hacky) `dropMisleading`
      function.
      
      This fix makes things a bit better but does not cure the underlying
      problem.
      51b0ce8f
    • Vladislav Zavialov's avatar
      Take subordinate 'type' specifiers into account · 282df905
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      This patch fixes multiple bugs (#22581, #25983, #25984, #25991)
      in name resolution of subordinate import lists.
      
      Bug #22581
      ----------
      In subordinate import lists, the use of the `type` namespace specifier
      used to be ignored. For example, this import statement was incorrectly
      accepted:
      
        import Prelude (Bool(type True))
      
      Now it results in an error message:
      
        <interactive>:2:17: error: [GHC-51433]
          In the import of ‘Prelude’:
            a data type called ‘Bool’ is exported,
            but its subordinate item ‘True’ is not in the type namespace.
      
      Bug #25983
      ----------
      In subordinate import lists within a `hiding` clause, non-existent
      items led to a poor warning message with -Wdodgy-imports. Consider:
      
        import Prelude hiding (Bool(X))
      
      The warning message for this import statement used to misreport the
      cause of the problem:
      
        <interactive>:3:24: warning: [GHC-56449] [-Wdodgy-imports]
          In the import of ‘Prelude’:
            an item called ‘Bool’...
      282df905
  4. May 08, 2025
  5. May 06, 2025
    • Simon Peyton Jones's avatar
      Fix a bad untouchability bug im simplifyInfer · 165f98d8
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      This patch addresses #26004.  The root cause was that simplifyInfer
      was willing to unify variables "far out".  The fix, in
      runTcSWithEvBinds', is to initialise the inert set given-eq level with
      the current level. See
          (TGE6) in Note [Tracking Given equalities]
      in GHC.Tc.Solver.InertSet
      
      Two loosely related refactors:
      
      * Refactored approximateWCX to return just the free type
        variables of the un-quantified constraints.  That avoids duplication
        of work (these free vars are needed in simplifyInfer) and makes it
        clearer that the constraints themselves are irrelevant.
      
      * A little local refactor of TcSMode, which reduces the number of
        parameters to runTcSWithEvBinds
      165f98d8
    • Rodrigo Mesquita's avatar
      Export sizeOccEnv from GHC.Types.Name.Occurrence · 0ce0d263
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      Counts the number of OccNames in an OccEnv
      0ce0d263
    • Rodrigo Mesquita's avatar
      Refactor mkTopLevImportedEnv out of mkTopLevEnv · e46c6b18
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      This makes the code clearer and allows the top-level import context to
      be fetched directly from the HomeModInfo through the API (e.g. useful
      for the debugger).
      e46c6b18
  6. May 05, 2025
  7. May 04, 2025
    • Serge S. Gulin's avatar
      Support for ARM64 Windows (LLVM-enabled) (fixes #24603) · 9995c2b7
      Serge S. Gulin authored
      
      1. Add Windows AArch64 cross-compilation support via CI jobs
      Introduce new CI configurations for cross-compiling to Windows ARM64 using Debian12Wine, FEX, and MSYS2.
      Configure toolchain variables for LLVM MinGW and Wine emulation in CI pipelines.
      
      2. Adjust compiler and RTS for AArch64 Windows compatibility
      Reserve register `x18` on Windows and Darwin platforms in AArch64 codegen.
      Handle Windows-specific relocations and data sections in AArch64 assembler.
      Update PEi386 linker to recognize ARM64 binaries and support exception handling.
      Adjust LLVM target definitions and data layouts for new architectures.
      Update `ghc-toolchain` and build scripts to handle `TablesNextToCode` on Windows ARM64.
      
      3. Enhance CI scripts and stability
      Modify `ci.sh` to handle mingw cross-targets, fixing GHC executable paths and test execution.
      Use `diff -w` in tests to ignore whitespace differences, improving cross-platform consistency.
      
      4. Refactor and clean up code
      Remove redundant imports in hello.hs test.
      Improve error messages and checks for unsupported configurations in the driver.
      Add `EXDEV` error code to `errno.js`.
      Add async/sync flags to IO logs at `base.js`.
      Improve POSIX compatibility for file close at `base.js`: decrease indeterminism for mixed cases of async and sync code.
      
      5. Update dependencies: `Cabal`, `Win32`, `directory`, `process`, `haskeline`, and `unix`.
      
      submodule
      
      Co-authored-by: default avatarCheng Shao <terrorjack@type.dance>
      Co-authored-by: default avatarDmitrii Egorov <egorov.d.i@icloud.com>
      Co-authored-by: default avatarAndrei Borzenkov <root@sandwitch.dev>
      9995c2b7
  8. Apr 30, 2025
  9. Apr 29, 2025
  10. Apr 28, 2025
    • Simon Peyton Jones's avatar
      Track rewriter sets more accurately in constraint solving · 22d11fa8
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      The key change, which fixed #25440, is to call `recordRewriter` in
      GHC.Tc.Solver.Rewrite.rewrite_exact_fam_app.  This missing call meant
      that we were secretly rewriting a Wanted with a Wanted, but not really
      noticing; and that led to a very bad error message, as you can see
      in the ticket.
      
      But of course that led me into rabbit hole of other refactoring around
      the RewriteSet code:
      
      * Improve Notes [Wanteds rewrite Wanteds]
      
      * Zonk the RewriterSet in `zonkCtEvidence` rather than only in GHC.Tc.Errors.
        This is tidier anyway (e.g. de-clutters debug output), and helps with the
        next point.
      
      * In GHC.Tc.Solver.Equality.inertsCanDischarge, don't replace a constraint
        with no rewriters with an equal constraint that has many. See
        See (CE4) in Note [Combining equalities]
      
      * Move zonkRewriterSet and friends from GHC.Tc.Zonk.Type into
        GHC.Tc.Zonk.TcType, where they properly belong.
      
      A handful of tests get better error messages.
      
      For some reason T24984 gets 12% less compiler allocation -- good
      
      Metric Decrease:
          T24984
      22d11fa8
  11. Apr 27, 2025
    • Simon Peyton Jones's avatar
      Fix infelicities in the Specialiser · ce616f49
      Simon Peyton Jones authored
      On the way to #23109 (unary classes) I discovered some infelicities
      (or maybe tiny bugs, I forget) in the type-class specialiser.
      
      I also tripped over #25965, an outright bug in the rule matcher
      
      Specifically:
      
      * Refactor: I enhanced `wantCallsFor`, whih previously always said
      `True`, to discard calls of class-ops, data constructors etc.  This is
      a bit more efficient; and it means we don't need to worry about
      filtering them out later.
      
      * Fix: I tidied up some tricky logic that eliminated redundant
        specialisations.  It wasn't working correctly.  See the expanded
        Note [Specialisations already covered], and
        (MP3) in Note [Specialising polymorphic dictionaries].
      
        See also the new top-level `alreadyCovered`
        function, which now goes via `GHC.Core.Rules.ruleLhsIsMoreSpecific`
      
        I also added a useful Note [The (CI-KEY) invariant]
      
      * Fix #25965: fixed a tricky bug in the `go_fam_fam` in
        `GHC.Core.Unify.uVarOrFam`, which allows matching to succeed
        without binding all type varibles.
      
        I enhanced Note [Apartness and type families] some more
      
      * #25703. This ticket "just works" with -fpolymorphic-specialisation;
        but I was surprised that it worked! In this MR I added documentation
        to Note [Interesting dictionary arguments] to explain; and tests to
        ensure it stays fixed.
      ce616f49
    • Simon Peyton Jones's avatar
      Get a decent MatchContext for pattern synonym bindings · 7641a74a
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      In particular when we have a pattern binding
          K p1 .. pn = rhs
      where K is a pattern synonym.  (It might be nested.)
      
      This small MR fixes #25995.  It's a tiny fix, to an error message,
      removing an always-dubious `unkSkol`.
      
      The bug report was in the context of horde-ad, a big program,
      and I didn't manage to make a small repro case quickly. I decided
      not to bother further.
      7641a74a
  12. Apr 25, 2025
    • Matthew Pickering's avatar
      Implement Explicit Level Imports for Template Haskell · 217caad1
      Matthew Pickering authored
      This commit introduces the `ExplicitLevelImports` and
      `ImplicitStagePersistence` language extensions as proposed in GHC
      Proposal #682.
      
      Key Features
      ------------
      
      - `ExplicitLevelImports` adds two new import modifiers - `splice` and
        `quote` - allowing precise control over the level at which imported
        identifiers are available
      - `ImplicitStagePersistence` (enabled by default) preserves existing
        path-based cross-stage persistence behavior
      - `NoImplicitStagePersistence` disables implicit cross-stage
        persistence, requiring explicit level imports
      
      Benefits
      --------
      
      - Improved compilation performance by reducing unnecessary code generation
      - Enhanced IDE experience with faster feedback in `-fno-code` mode
      - Better dependency tracking by distinguishing compile-time and runtime dependencies
      - Foundation for future cross-compilation improvements
      
      This implementation enables the separation of modules needed at
      compile-time from those needed at runtime, allowing for more efficient
      compilation pipelines and clearer code organization in projects using
      Template Haskell.
      
      Implementation Notes
      --------------------
      
      The level which a name is availble at is stored in the 'GRE', in the normal
      GlobalRdrEnv. The function `greLevels` returns the levels which a specific GRE
      is imported at. The level information for a 'Name' is computed by `getCurrentAndBindLevel`.
      The level validity is checked by `checkCrossLevelLifting`.
      
      Instances are checked by `checkWellLevelledDFun`, which computes the level an
      instance by calling `checkWellLevelledInstanceWhat`, which sees what is
      available at by looking at the module graph.
      
      Modifications to downsweep
      --------------------------
      
      Code generation is now only enabled for modules which are needed at
      compile time.
      See the Note [-fno-code mode] for more information.
      
      Uniform error messages for level errors
      ---------------------------------------
      
      All error messages to do with levels are now reported uniformly using
      the `TcRnBadlyStaged` constructor.
      
      Error messages are uniformly reported in terms of levels.
      
      0 - top-level
      1 - quote level
      -1 - splice level
      
      The only level hard-coded into the compiler is the top-level in
      GHC.Types.ThLevelIndex.topLevelIndex.
      
      Uniformly refer to levels and stages
      ------------------------------------
      
      There was much confusion about levels vs stages in the compiler.
      A level is a semantic concept, used by the typechecker to ensure a
      program can be evaluated in a well-staged manner.
      
      A stage is an operational construct, program evaluation proceeds in
      stages.
      
      Deprecate -Wbadly-staged-types
      ------------------------------
      
      `-Wbadly-staged-types` is deprecated in favour of `-Wbadly-levelled-types`.
      
      Lift derivation changed
      -----------------------
      
      Derived lift instances will now not generate code with expression
      quotations.
      
      Before:
      
      ```
      data A = A Int deriving Lift
      
      =>
      lift (A x) = [| A $(lift x) |]
      ```
      
      After:
      
      ```
      lift (A x) = conE 'A `appE` (lift x)
      ```
      
      This is because if you attempt to derive `Lift` in a module where
      `NoImplicitStagePersistence` is enabled, you would get an infinite loop
      where a constructor was attempted to be persisted using the instance you
      are currently defining.
      
      GHC API Changes
      ---------------
      
      The ModuleGraph now contains additional information about the type of
      the edges (normal, quote or splice) between modules. This is abstracted
      using the `ModuleGraphEdge` data type.
      
      Fixes #25828
      
      -------------------------
      Metric Increase:
          MultiLayerModulesTH_Make
      -------------------------
      217caad1
  13. Apr 24, 2025
    • Ben Gamari's avatar
      compiler: Ensure that Panic.Plain.assertPanic' provides callstack · 6111c5e4
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      In 36cddd2c @alt-romes removed CallStack
      output from `GHC.Utils.Panic.Plain.assertPanic'`. While this output is
      redundant due to the exception backtrace proposal, we may be
      bootstrapping with a compiler which does not yet include this machinery.
      Reintroduce the output for now.
      
      Fixes #25898.
      6111c5e4
    • Sylvain Henry's avatar
      Doc: add doc for JS interruptible calling convention (#24444) · fe6ed8d9
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      fe6ed8d9
    • Hannes Siebenhandl's avatar
      Add `UnitId` to `EvalBreakpoint` · 1bd3d13e
      Hannes Siebenhandl authored and Marge Bot's avatar Marge Bot committed
      The `EvalBreakpoint` is used to communicate that a breakpoint was
      encountered during code evaluation.
      This `EvalBreakpoint` needs to be converted to an `InternalBreakpointId`
      which stores a `Module` to uniquely find the correct `Module` in the
      Home Package Table.
      
      The `EvalBreakpoint` used to store only a `ModuleName` which is then
      converted to a `Module` based on the currently active home unit.
      This is incorrect in the face of multiple home units, the break point
      could be in an entirely other home unit!
      To fix this, we additionally store the `UnitId` of the `Module` in
      `EvalBreakpoint` to later reconstruct the correct `Module`
      
      All of the changes are the consequence of extending `EvalBreakpoint`
      with the additional `ShortByteString` of the `UnitId`.
      
      For performance reasons, we store the `ShortByteString` backing the
      `UnitId` directly, avoiding marshalling overhead.
      1bd3d13e
    • Sven Tennie's avatar
      RV64: Introduce J instruction (non-local jumps) and don't deallocate stack slots for J_TBL (#25738) · 0eef99b0
      Sven Tennie authored and Marge Bot's avatar Marge Bot committed
      J_TBL result in local jumps, there should not deallocate stack slots
      (see Note [extra spill slots].)
      
      J is for non-local jumps, these may need to deallocate stack slots.
      0eef99b0
    • Simon Peyton Jones's avatar
      Test for #23298 · 2e0c07ab
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      2e0c07ab
    • Matthew Pickering's avatar
      ghci: Use loadInterfaceForModule rather than loadSrcInterface in mkTopLevEnv · 91564daf
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      loadSrcInterface takes a user given `ModuleName` and resolves it to the
      module which needs to be loaded (taking into account module
      renaming/visibility etc).
      
      loadInterfaceForModule takes a specific module and loads it.
      
      The modules in `ImpDeclSpec` have already been resolved to the actual
      module to get the information from during renaming. Therefore we just
      need to fetch the precise interface from disk (and not attempt to rename
      it again).
      
      Fixes #25951
      91564daf
  14. Apr 22, 2025
  15. Apr 20, 2025
Loading