Skip to content
Snippets Groups Projects
  1. Mar 03, 2025
    • Rodrigo Mesquita's avatar
      ghci debugger: improve break/resume control flow · 607e573d
      Rodrigo Mesquita authored
      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
      -------------------------
      607e573d
  2. Feb 28, 2025
  3. Feb 27, 2025
  4. 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
    • Cheng Shao's avatar
      hadrian: enable building docs for cross targets · a794e733
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      Hadrian used to omit the docs target as a part of binary-dist-dir for
      cross targets. This commit enables docs to be built as a part of cross
      bindists and it works just fine in CI.
      a794e733
    • Cheng Shao's avatar
      hadrian: enable building stage1 haddock for cross ghc · 272eaef0
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      This commit enables building stage1 haddock for cross ghc. Without
      this change, hadrian would panic with "Unknown program" error when
      building the _build/stage1/bin/cross-prefix-haddock program needed by
      the docs-haddock target, even if it only needs to copy from
      _build/stage0/bin/cross-prefix-haddock.
      272eaef0
    • Fangyi Zhou's avatar
      wasm: use primitive opcodes for fabs and sqrt · 64b0d4d0
      Fangyi Zhou authored and Marge Bot's avatar Marge Bot committed
      - Add new `WasmInstr` constructor `WasmSqrt` for sqrt, corresponding to
        primitivie operations in wasm.
      - When lowering CallishMachOp, use `WasmAbs` and `WasmSqrt` for F32 and
        F64 fabs and sqrt.
      64b0d4d0
    • sheaf's avatar
      Propagate long distance info to guarded let binds · 0f2241e9
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This commit ensures that we propagate the enclosing long distance
      information to let bindings inside guards, in order to get accurate
      pattern-match checking warnings, in particular incomplete record
      selector warnings.
      
      Example:
      
        data D = K0 | K1 { fld :: Int }
        f :: D -> Int
        f d@(K1 {})
          | let i = fld d
          = i
        f _ = 3
      
      We now correctly recognise that the field selector 'fld' cannot fail,
      due to the outer pattern match which guarantees that the value 'd' has
      the field 'fld'.
      
      Fixes #25749
      0f2241e9
  5. Feb 25, 2025
    • Vladislav Zavialov's avatar
      Remove ArgPatBuilder · c3f2d284
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      ArgPatBuilder in Parser/PostProcess.hs became redundant with the
      introduction of InvisPat (36a75b80).
      
      This small refactoring removes it.
      c3f2d284
    • Matthew Pickering's avatar
      interpreter: Fix underflow frame lookups · f4da90f1
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      BCOs can be nested, resulting in nested BCO stack frames where the inner most
      stack frame can refer to variables stored on earlier stack frames via the
      PUSH_L instruction.
      
      |---------|
      |  BCO_1  | -<-┐
      |---------|
       .........     |
      |---------|    | PUSH_L <n>
      |  BCO_N  | ->-┘
      |---------|
      
      Here BCO_N is syntactically nested within the code for BCO_1 and will result
      in code that references the prior stack frame of BCO_1 for some of it's local
      variables. If a stack overflow happens between the creation of the stack frame
      for BCO_1 and BCO_N the RTS might move BCO_N to a new stack chunk while leaving
      BCO_1 in place, invalidating a simple offset based reference to the outer stack
      frames.
      Therefore `ReadSpW` first performs a bounds check to ensure that accesses onto
      the stack will succeed. If the target address would not be a valid location for
      the current stack chunk then `slow_spw` function is called, which dereferences
      the underflow frame to adjust the offset before performing the lookup.
      
                     ┌->--x   |  CHK_1  |
      |  CHK_2  |    |    |   |---------|
      |---------|    |    └-> |  BCO_1  |
      | UD_FLOW | -- x        |---------|
      |---------|    |
      | ......  |    |
      |---------|    | PUSH_L <n>
      |  BCO_ N | ->-┘
      |---------|
      
      Fixes #25750
      f4da90f1
    • sheaf's avatar
      base: make Data.List.NonEmpty.unzip match Data.List · 0eb58b0e
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This commit makes Data.List.NonEmpty.unzip match the implementation
      of Data.List, as was suggested in approved CLC proposal #107.
      0eb58b0e
    • sheaf's avatar
      LLVM: account for register type in funPrologue · 33aca30f
      sheaf authored and Marge Bot's avatar Marge Bot committed
      We were not properly accounting for the live register type of
      global registers in GHC.CmmToLlvm.CodeGen.funPrologue. This meant that
      we could allocated a register at type <4 x i32> but try to write to it
      at type <8 x i16>, which LLVM doesn't much like.
      
      This patch fixes that by inserting intermerdiate casts when necessary.
      
      Fixes #25730
      33aca30f
  6. Feb 23, 2025
  7. Feb 22, 2025
    • Cheng Shao's avatar
      driver: fix wasm backend sysroot lookup logic when -flto is passed · 7eea38c8
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      For the wasm target, the driver calls `wasm32-wasi-clang
      --print-search-dirs` and finds the sysroot directory that contains
      libc.so etc, then passes the directory path to dyld. However, when GHC
      is configured with -flto as a part of C/C++ compiler flags, the clang
      driver would insert a llvm-lto specific directory in the
      --print-search-dirs output and the driver didn't take that into
      account. This patch fixes it and always selects the non-lto sysroot
      directory to be passed to dyld. This is one small step towards
      supporting building all cbits with lto for wasm.
      7eea38c8
    • Cheng Shao's avatar
      wasm: fix dyld for shared libraries created by llvm 20.x · cb60da24
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      This patch fixes wasm dyld script for shared libraries created by llvm
      20.x. The __wasm_apply_data_relocs function is now optional and may be
      omitted for shared libraries without any runtime relocatable data
      segments, so only call __wasm_apply_data_relocs when it's present.
      cb60da24
    • Cheng Shao's avatar
      wasm: bump dyld v8 heap size limit · fbf3d020
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      This patch sets `--max-old-space-size=65536` as wasm dyld shebang
      arguments to lessen v8 heap pressure in certain workloads that load
      the full ghc package. It doesn't really commit 64G memory but it does
      help reduce v8 gc overhead.
      fbf3d020
    • Ben Gamari's avatar
      rts/linker/MachO: Mark internal symbols as static · 549e0aff
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      There is no reason why these should have external linkage.
      549e0aff
    • Cheng Shao's avatar
      compiler: use fromAscList when applicable · 1c8e608a
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      This patch uses fromAscList (with O(n) complexity) instead of fromList
      (with O(nlogn) complexity) in certain Binary instances. It's safe to
      do so since the corresponding serialization logic is based on toList
      (same as toAscList).
      1c8e608a
  8. Feb 20, 2025
  9. Feb 19, 2025
  10. Feb 18, 2025
Loading