Skip to content
Snippets Groups Projects
  1. Mar 06, 2025
    • Matthew Craven's avatar
      Add tests for #25771 · 30bdea67
      Matthew Craven authored and Marge Bot's avatar Marge Bot committed
      30bdea67
    • Matthew Craven's avatar
      Cmm: Add constant-folding for Word->Float bitcasts · 25c4a2a2
      Matthew Craven authored and Marge Bot's avatar Marge Bot committed
      25c4a2a2
    • Matthew Craven's avatar
      Cmm: Add surface syntax for Word/Float bitcast ops · 1d4c9824
      Matthew Craven authored and Marge Bot's avatar Marge Bot committed
      1d4c9824
    • Matthew Pickering's avatar
      Disable self recomp in release flavour · 5b05c27b
      Matthew Pickering authored
      The interface files that we distribute should not contain any
      information which is used by the recompilation checking logic since
      source file will never be compiled again.
      
      I am not 100% sure this won't cause unexpected issues, there many be
      downstream consumers which are incorrectly using the information from
      interfaces, but this commit can be reverted if we detect issues.
      5b05c27b
    • Matthew Pickering's avatar
      Add flag to control whether self-recompilation information is written to interface · a510b861
      Matthew Pickering authored
      This patch adds the flag -fwrite-if-self-recomp which controls whether
      interface files contain the information necessary to answer the
      question:
      
        Do I need to recompile myself or is this current interface file
        suitable?
      
      Why? Most packages are only built once either by a distribution or cabal
      and then placed into an immutable store, after which we will never ask
      this question. Therefore we can derive two benefits from omitting this
      information.
      
      * Primary motivation: It vastly reduces the surface area for creating
        non-deterministic interface files. See issue #10424 which motivated a
        proper fix to that issue. Distributions have long contained versions
        of GHC which just have broken self-recompilation checking (in order to
        get deterministic interface files).
      
      * Secondary motivation: This reduces the size of interface files
        slightly.. the `mi_usages` field can be quite big but probably this
        isn't such a great benefit.
      
      * Third motivation: Conceptually clarity about which parts of an
        interface file are used in order to **communicate** with subsequent
        packages about the **interface** for a module. And which parts are
        used to self-communicate during recompilation checking.
      
      The main tracking issue is #22188 but fixes issues such as #10424 in a
      proper way.
      a510b861
  2. Mar 05, 2025
    • Rodrigo Mesquita's avatar
      docs: Fix ghci :doc documentation · 07fe6d1d
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      Fixes #25799
      07fe6d1d
    • Matthew Pickering's avatar
      simplifier: Zap Id unfoldings before constructing InScopeSet in simpleOptExpr · 8273d7d1
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      Care must be taken to remove unfoldings from `Var`s collected by exprFreeVars
      before using them to construct an in-scope set hence `zapIdUnfolding` in `init_subst`.
      Consider calling `simpleOptExpr` on an expression like
      
      ```
       case x of (a,b) -> (x,a)
      ```
      
      * One of those two occurrences of x has an unfolding (the one in (x,a), with
      unfolding x = (a,b)) and the other does not. (Inside a case GHC adds
      unfolding-info to the scrutinee's Id.)
      * But exprFreeVars just builds a set, so it's a bit random which occurrence is collected.
      * Then simpleOptExpr replaces each occurrence of x with the one in the in-scope set.
      * Bad bad bad: then the x in  case x of ... may be replaced with a version that has an unfolding.
      
      Fixes #25790
      8273d7d1
    • Cheng Shao's avatar
      ghc-experimental: add mkWeakJSVal · 55af20e6
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      This commit adds a mkWeakJSVal function that can be used to set up a
      Weak pointer with a JSVal key to observe the key's lifetime and
      optionally attach a finalizer.
      55af20e6
    • Cheng Shao's avatar
      wasm: make JSVal internal Weak# point to lifted JSVal · 4f342431
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      JSVal has an internal Weak# with the unlifted JSVal# object as key to
      arrange its builtin finalization logic. The Weak# used to designate
      Unit_closure as a dummy value; now this commit designates the lifted
      JSVal closure as the Weak# value. This allows the implementation of
      mkWeakJSVal which can be used to observe the liveliness of a JSVal and
      attach a user-specified finalizer.
      4f342431
    • Cheng Shao's avatar
      ghc-experimental: make JSVal abstract in GHC.Wasm.Prim · 8037f487
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      This commit makes JSVal an abstract type in the export list of
      GHC.Wasm.Prim. JSVal's internal representation is supposed to be a non
      user facing implementation detail subject to change at any time. We
      should only expose things that are newtypes of JSVal, not JSVal
      itself.
      8037f487
    • Brandon Chinn's avatar
      Collapse string gaps as \& (#25784) · eb9fe1ec
      Brandon Chinn authored and Marge Bot's avatar Marge Bot committed
      In 9.10, "\65\ \0" would result in "A0", but in 9.12, it results in
      "\650", due to the string refactoring I did in !13128. Previously, we
      were resolving escape codes and collapsing string gaps as we come across
      them, but after the refactor, string processing is broken out into
      phases, which is both more readable and useful for multiline strings.
      eb9fe1ec
    • Teo Camarasu's avatar
      ghc-boot-th: fix synopsis formatting · 91ef82df
      Teo Camarasu authored and Marge Bot's avatar Marge Bot committed
      `@...@` syntax doesn't seem to work in synposes and is just kept by
      Haddock verbatim.
      91ef82df
    • Teo Camarasu's avatar
      ghc-boot-th: expose all TH packages from proper GHC.Boot.* modules · f2d43e11
      Teo Camarasu authored and Marge Bot's avatar Marge Bot committed
      Previously we defined some modules here in the GHC.Internal namespace.
      Others were merely re-exposed from GHC.Internal.
      
      Re-exposed modules weren't handled correctly by Haddock, so the
      Haddocks for the `template-haskell` library couldn't see them.
      This change also makes the home package of these modules a bit clearer.
      
      Work towards #25705
      f2d43e11
    • Matthew Pickering's avatar
      perf: Speed up the bytecode assembler · 8f6cc90c
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      This commit contains a number of optimisations to the bytecode
      assembler. In programs which generate a large amount of bytecode, the
      assembler is called a lot of times on many instructions.
      
      1. Specialise the assembleI function for the two intepreters to avoid
      having to materialise the intermediate free-monad like structure.
      2. Directly compute the UArray and SmallArray needed rather than going
         via the intermediate SizedSeq
      3. Use optimised monads
      4. Define unrolled "any" and "mapM6" functions which can be inlined
         and avoid calling recursive functions.
      
      The resulting generated code is much more direct.
      
      Before:
      
      ./ByteCodeAsm /home/matt/ghc-profiling-light/_build/stage1/lib/ +RTS  -s
        48,923,125,664 bytes allocated in the heap
           678,221,152 bytes copied during GC
               395,648 bytes maximum residency (2 sample(s))
                50,040 bytes maximum slop
                     6 MiB total memory in use (0 MiB lost due to fragmentation)
      
                                           Tot time (elapsed)  Avg pause  Max pause
        Gen  0     11731 colls,     0 par    0.419s   0.425s     0.0000s    0.0004s
        Gen  1         2 colls,     0 par    0.001s   0.001s     0.0007s    0.0012s
      
        INIT    time    0.000s  (  0.000s elapsed)
        MUT     time    6.466s  (  6.484s elapsed)
        GC      time    0.421s  (  0.426s elapsed)
        EXIT    time    0.000s  (  0.000s elapsed)
        Total   time    6.887s  (  6.910s elapsed)
      
      After:
      
         1,518,321,200 bytes allocated in the heap
             4,299,552 bytes copied during GC
               322,288 bytes maximum residency (2 sample(s))
                50,280 bytes maximum slop
                     6 MiB total memory in use (0 MiB lost due to fragmentation)
      
                                           Tot time (elapsed)  Avg pause  Max pause
        Gen  0       369 colls,     0 par    0.003s   0.003s     0.0000s    0.0002s
        Gen  1         2 colls,     0 par    0.001s   0.001s     0.0007s    0.0012s
      
        INIT    time    0.001s  (  0.001s elapsed)
        MUT     time    0.465s  (  0.466s elapsed)
        GC      time    0.004s  (  0.004s elapsed)
        EXIT    time    0.000s  (  0.000s elapsed)
        Total   time    0.470s  (  0.471s elapsed)
      8f6cc90c
  3. Mar 04, 2025
    • Alan Zimmerman's avatar
      [EPA] Sync with the ghc-exactprint repo · 7ca72844
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      This brings it into line with the changes in
      https://hackage.haskell.org/package/ghc-exactprint-1.12.0.0
      
      But also keeps the latest changes from master.
      7ca72844
    • Ben Gamari's avatar
      hadrian: Refactor handling of test suite environment · 0a99825d
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      Previously we would set the environment variables used to run the
      testsuite driver using `setEnv` to set them in the Hadrian process.
      While looking into failures of a fix to #25752 I noticed this and took
      the opportunity to refactor.
      0a99825d
    • Matthew Pickering's avatar
      Implement reifyModule in terms of mi_top_env · 73e02068
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      mi_top_env provides precisely the information that reifyModule needs,
      the user written imports.
      
      This is important as it unblocks !9604 and #22188
      
      Fixes #8489
      73e02068
    • Matthew Pickering's avatar
      ghci: Serialise mi_top_env · e9b7802b
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      When loading core from interface files (or from a bytecode object in
      future) it's important to store what the top-level context of a module
      is.
      Otherwise, when you load the module into GHCi from the interface files,
      only exported identifiers from the top-level module are in scope on the
      repl.
      
      See the added test which demonstrates what this enables.
      
      The context at the GHCi prompt is everything that's in-scope in the
      TopEnvIface module. Since TopEnvIface imports identifier "a", we can
      evaluate "a" in the repl.
      
      In addition to all this, we can use this information in order to
      implement reifyModule in a more principled manner.
      
      This becomes even more important when you're debugging and what to set
      break-points on functions which are not imported.
      e9b7802b
    • Cheng Shao's avatar
      compiler: avoid overwriting existing writers in putWithTables · c331eebf
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      This patch makes `putWithTables` avoid overwriting all existing
      UserData writers in the handle. This is crucial for GHC API users that
      use putWithUserData/getWithUserData for serialization logic that
      involve Names.
      c331eebf
  4. Mar 03, 2025
    • Cheng Shao's avatar
      wasm: add error message to WouldBlockException · 9b54eecb
      Cheng Shao authored
      This commit attaches an error message to WouldBlockException, for now
      the error message consists of the JS async import code snippet that
      thunk is trying to block for. This is useful for debugging synchronous
      callbacks that accidentally call an async JS function.
      9b54eecb
    • Cheng Shao's avatar
      docs: document wasm backend JSFFI sync exports · edae2874
      Cheng Shao authored
      This commit updates wasm backend documentation to reflect the new
      JSFFI sync exports feature.
      edae2874
    • Cheng Shao's avatar
      testsuite: test wasm backend JSFFI sync exports · b6ae908b
      Cheng Shao authored
      This commit repurposes some existing JSFFI test cases to make them
      cover JSFFI sync exports as well.
      b6ae908b
    • Cheng Shao's avatar
      compiler: wasm backend JSFFI sync exports · 03ebab52
      Cheng Shao authored
      This commit implements the synchronous flavour of the wasm backend
      JSFFI exports:
      
      - `foreign export javascript "foo sync"` exports a top-level Haskell
        binding as a synchronous JS function
      - `foreign import javascript "wrapper sync"` dynamically exports a
        Haskell function closure as a synchronous JS function
      - `foreign import javascript unsafe` is now re-entrant by lowering to
        a safe ccall
      - Also fix the issue that JSFFI dynamic exports didn't really work in
        TH & ghci (#25473)
      03ebab52
    • Cheng Shao's avatar
      compiler: allow arbitrary label string for JSFFI exports · a204df3a
      Cheng Shao authored
      This commit allows arbitrary label string to appear in a foreign
      export declaration, as long as the calling convention is javascript.
      Well, doesn't make sense to enforce it's a C function symbol for a
      JSFFI declaration anyway, and it gets in the way of implementing the
      "sync" flavour of exports.
      a204df3a
    • Cheng Shao's avatar
      rts: fix top handler closure type signatures · c78d8f55
      Cheng Shao authored
      This commit fixes the runIO/runNonIO closure type signatures in the
      RTS which should be extern StgClosure. This allows us to remove an
      unnecessary type cast in the C foreign desugaring logic, as well as
      unneeded complications of JSFFI desugaring logic that also needs to
      generate C stubs that may refer to those top handler closures.
      Otherwise, we'll have to take special care to avoid generating "extern
      StgClosure" declarations for them as we would for other closures, just
      to avoid conflicting type signature error at stub compile time.
      c78d8f55
    • Rodrigo Mesquita's avatar
      ghci debugger: improve break/resume control flow · 73ba1e6e
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      After interpreting bytecode (`evalStmt`), we may want to hand off
      control to "GHCi.UI" in order to display an interactive break prompt:
      
      1. When an /active/ breakpoint (one set with :break ...) is hit
      2. At any breakpoint, when using :step from a breakpoint
      3. At any breakpoint in the same function f, when :steplocal is called
        from a breakpoint in f
      4. At any breakpoint in the same module, when :stepmodule is used
      
      Whether to pass control to the UI is now fully determined by
      `handleRunStatus` which transforms an `EvalStatus_` into an
      `ExecResult`. When `ExecBreak` is returned from `handleRunStatus` to
      GHCi, it always means GHCi breaks.
      
      `handleRunStatus` determines whether to loop and resume evaluation right away, or
      when to return to GHCi (by returning `ExecBreak` or `ExecComplete`).
      - (1) is queried using the `BreakpointStatus` message (the
        `breakpointStatus` call)
      - (2,3,4) are determined by the predicate `breakHere step span`, which
        inspects the improved `SingleStep` type to determine whether we care
        about this breakpoint even if it is not active.
      
      This refactor solves two big performance problems with the previous control flow:
      - We no longer call `withArgs/withProgram` repeatedly in the
        break/resume loop, but rather just once "at the top".
      - We now avoid computing the expensive `bindLocalsAtBreakpoint` for
        breakpoints we'd never inspect.
      
      In the interpreter_steplocal test added, calling `:steplocal` after breaking on `main = fib 25`
      now takes 12 seconds rather than 49 seconds on my machine.
      
      ```
      interpreter_steplocal(ghci) ghc/alloc  6,124,821,176    540,181,392 -91.2% GOOD
      ```
      
      Fixes #25779
      
      -------------------------
      Metric Decrease:
          interpreter_steplocal
      -------------------------
      73ba1e6e
    • Rodrigo Mesquita's avatar
      ghci: Don't set virtualCWD on every iteration · b4fe0850
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      The calls to withVirtualCWD were introduced to fix #2973, but this bug
      is no longer reproducible, even when `withVirtualCWD` is dropped.
      
      This cleanup was originally motivated by the performance of :steplocal,
      but the performance problem has now been fixed at its root in the next
      commit.
      
      Even then, `withVirtualCWD` seems to now be an unnecessary artifact, and
      removing it simplifies the interpreter with no apparent drawbacks (testsuite is
      also happy with this change)
      b4fe0850
    • John Ericson's avatar
      Remove most of `GHC.Internal.Pack` · 3b78e139
      John Ericson authored and Marge Bot's avatar Marge Bot committed
      Since bd82ac9f when `GHC.Pack` was
      deleted, it is no longer used except for one function by the RTS.
      3b78e139
  5. Mar 01, 2025
  6. Feb 28, 2025
  7. Feb 27, 2025
  8. Feb 26, 2025
    • Vladislav Zavialov's avatar
      Tidy up error messages for TypeAbstractions · 6acaff2b
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      1. Print the '@' symbol before invisible patterns and improve phrasing:
      
            T24557c.hs:8:4: error: [GHC-11983]
           -    Invisible type pattern pat is not allowed here
           +    Illegal invisible type pattern: @pat
           +    An invisible type pattern must occur in an argument position.
      
      2. Use a single error code for all type abstractions deemed illegal
         due to the TypeAbstractions extension being disabled.
      
         Before this change:
           * [GHC-78249] was used in function equations, lambdas
           * [GHC-17916] was used in constructor patterns
      
         After this change:
           * [GHC-78249] is used to report all illegal type abstractions
           * [GHC-17916] is no longer used
      
         There was no reason for both error codes to exist and this distinction
         was a source of complexity in GHC/Tc/Errors/* and GHC/Rename/Pat.hs
      
      3. Group the different "invisible type pattern" error constructors
         under a single parent constructor, TcRnIllegalInvisibleTypePattern
         containing BadInvisPatReason
      6acaff2b
    • Rodrigo Mesquita's avatar
      ghci-debugger: display thunks provenance if avail · ec02f8c2
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      Improves reporting on ghci breakpoints when IPE information is available
      by printing, next to the thunk, the source file and src span where the
      thunk originated.
      
      Closes #25746
      ec02f8c2
    • Cheng Shao's avatar
      ghc-heap: fix HalfWord incompatible Binary instances for cross GHC · b228fcb5
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      ghc-heap defines HalfWord as Word32/Word16 depending on host word
      size. For cross GHC with different host/target word sizes, the Binary
      instances are incompatible and breaks iserv serialization of any
      message type that involves HalfWord, breaking the ghci debugger. This
      patch fixes the issue and has been tested to fix ghci debugger
      functionality of the wasm backend. Fixes #25420 #25781.
      b228fcb5
    • Cheng Shao's avatar
      ghci: remove unused showBreakArray function · 2d6a63ab
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      GHCi.BreakArray.showBreakArray is not used anywhere, hence the
      housecleaning.
      2d6a63ab
Loading