Skip to content
Snippets Groups Projects
  1. Mar 05, 2025
    • wygulmage's avatar
      use Foldable's !! for Data.List.NonEmpty · cf303d07
      wygulmage authored
      cf303d07
    • wygulmage's avatar
      043a8365
    • 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
  2. Mar 04, 2025
  3. 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
  4. Mar 01, 2025
  5. Feb 28, 2025
  6. Feb 27, 2025
  7. 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
    • Cheng Shao's avatar
      ci: build haddock/sphinx-html for wasm jobs · 6dba56e1
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      This commit enables building haddock & sphinx-html documentation for
      wasm targets. The docs are useful for end users and should be tested
      in CI.
      
      I've omitted pdf & manpage generation for the wasm target; I've never
      found the pdf version of docs to be useful, and the manpage only
      contains `ghc.1` where we really want `wasm32-wasi-ghc.1` but that
      should be a separate issue to fix.
      6dba56e1
Loading