1. 21 Sep, 2022 3 commits
  2. 17 Sep, 2022 2 commits
  3. 12 Sep, 2022 1 commit
  4. 11 Sep, 2022 1 commit
    • Alexis King's avatar
      Add native delimited continuations to the RTS · 04062510
      Alexis King authored
      This patch implements GHC proposal 313, "Delimited continuation
      primops", by adding native support for delimited continuations to the
      GHC RTS.
      
      All things considered, the patch is relatively small. It almost
      exclusively consists of changes to the RTS; the compiler itself is
      essentially unaffected. The primops come with fairly extensive Haddock
      documentation, and an overview of the implementation strategy is given
      in the Notes in rts/Continuation.c.
      
      This first stab at the implementation prioritizes simplicity over
      performance. Most notably, every continuation is always stored as a
      single, contiguous chunk of stack. If one of these chunks is
      particularly large, it can result in poor performance, as the current
      implementation does not attempt to cleverly squeeze a subset of the
      stack frames into the existing stack: it must fit all at once. If this
      proves to be a performance issue in practice, a cleverer strategy would
      be a worthwhile target for future improvements.
      04062510
  5. 26 Aug, 2022 2 commits
  6. 24 Aug, 2022 1 commit
  7. 18 Aug, 2022 1 commit
    • Ben Gamari's avatar
      compiler: Drop --build-id=none hack · 989b844d
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      Since 2011 the object-joining implementation has had a hack to pass
      `--build-id=none` to `ld` when supported, seemingly to work around a
      linker bug. This hack is now unnecessary and may break downstream users
      who expect objects to have valid build-ids. Remove it.
      
      Closes #22060.
      989b844d
  8. 16 Aug, 2022 1 commit
  9. 09 Aug, 2022 1 commit
    • Ben Gamari's avatar
      rts/linker: Resolve iconv_* on FreeBSD · 66d2e927
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      FreeBSD's libiconv includes an implementation of the
      iconv_* functions in libc. Unfortunately these can
      only be resolved using dlvsym, which is how the RTS linker
      usually resolves such functions. To fix this we include an ad-hoc
      special case for iconv_*.
      
      Fixes #20354.
      66d2e927
  10. 08 Aug, 2022 2 commits
    • Ben Gamari's avatar
      rts: Ensure that Array# card arrays are initialized · 50912d68
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      In #19143 I noticed that newArray# failed to initialize the card table
      of newly-allocated arrays. However, embarrassingly, I then only fixed
      the issue in newArrayArray# and, in so doing, introduced the potential
      for an integer underflow on zero-length arrays (#21962).
      
      Here I fix the issue in newArray#, this time ensuring that we do not
      underflow in pathological cases.
      
      Fixes #19143.
      50912d68
    • Cheng Shao's avatar
      rts: remove redundant stg_traceCcszh · 1504a93e
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      This out-of-line primop has no Haskell wrapper and hasn't been used
      anywhere in the tree. Furthermore, the code gets in the way of !7632, so
      it should be garbage collected.
      1504a93e
  11. 06 Aug, 2022 6 commits
  12. 26 Jul, 2022 2 commits
    • Ben Gamari's avatar
      rts/nonmoving: Don't scavenge objects which weren't evacuated · 54a5c32d
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      This fixes a rather subtle bug in the logic responsible for scavenging
      objects evacuated to the non-moving generation. In particular, objects
      can be allocated into the non-moving generation by two ways:
      
       a. evacuation out of from-space by the garbage collector
       b. direct allocation by the mutator
      
      Like all evacuation, objects moved by (a) must be scavenged, since they
      may contain references to other objects located in from-space. To
      accomplish this we have the following scheme:
      
       * each nonmoving segment's block descriptor has a scan pointer which
         points to the first object which has yet to be scavenged
      
       * the GC tracks a set of "todo" segments which have pending scavenging
         work
      
       * to scavenge a segment, we scavenge each of the unmarked blocks
         between the scan pointer and segment's `next_free` pointer.
      
         We skip marked blocks since we know the allocator wouldn't have
         allocated into marked blocks (since they contain presumably live
         data).
      
         We can stop at `next_free` since, by
         definition, the GC could not have evacuated any objects to blocks
         above `next_free` (otherwise `next_free wouldn't be the first free
         block).
      
      However, this neglected to consider objects allocated by path (b).
      In short, the problem is that objects directly allocated by the mutator
      may become unreachable (but not swept, since the containing segment is
      not yet full), at which point they may contain references to swept objects.
      Specifically, we observed this in #21885 in the following way:
      
      1. the mutator (specifically in #21885, a `lockCAF`) allocates an object
         (specifically a blackhole, which here we will call `blkh`; see Note
         [Static objects under the nonmoving collector] for the reason why) on
         the non-moving heap. The bitmap of the allocated block remains 0
         (since allocation doesn't affect the bitmap) and the containing
         segment's (which we will call `blkh_seg`) `next_free` is advanced.
      2. We enter the blackhole, evaluating the blackhole to produce a result
         (specificaly a cons cell) in the nursery
      3. The blackhole gets updated into an indirection pointing to the cons
         cell; it is pushed to the generational remembered set
      4. we perform a GC, the cons cell is evacuated into the nonmoving heap
         (into segment `cons_seg`)
      5. the cons cell is marked
      6. the GC concludes
      7. the CAF and blackhole become unreachable
      8. `cons_seg` is filled
      9. we start another GC; the cons cell is swept
      10. we start a new GC
      11. something is evacuated into `blkh_seg`, adding it to the "todo" list
      12. we attempt to scavenge `blkh_seg` (namely, all unmarked blocks
          between `scan` and `next_free`, which includes `blkh`). We attempt to
          evacuate `blkh`'s indirectee, which is the previously-swept cons cell.
          This is unsafe, since the indirectee is no longer a valid heap
          object.
      
      The problem here was that the scavenging logic *assumed* that (a) was
      the only source of allocations into the non-moving heap and therefore
      *all* unmarked blocks between `scan` and `next_free` were evacuated.
      However, due to (b) this is not true.
      
      The solution is to ensure that that the scanned region only encompasses
      the region of objects allocated during evacuation. We do this by
      updating `scan` as we push the segment to the todo-segment list to
      point to the block which was evacuated into.
      
      Doing this required changing the nonmoving scavenging implementation's
      update of the `scan` pointer to bump it *once*, instead of after
      scavenging each block as was done previously. This is because we may end
      up evacuating into the segment being scavenged as we scavenge it. This
      was quite tricky to discover but the result is quite simple,
      demonstrating yet again that global mutable state should be used
      exceedingly sparingly.
      
      Fixes #21885
      
      (cherry picked from commit 0b27ea23)
      54a5c32d
    • Ben Gamari's avatar
      rts/nonmoving: Track segment state · 4b087973
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      It can often be useful during debugging to be able to determine the
      state of a nonmoving segment. Introduce some state, enabled by DEBUG, to
      track this.
      
      (cherry picked from commit 40e797ef)
      4b087973
  13. 19 Jul, 2022 1 commit
    • Ben Gamari's avatar
      rts/ProfHeap: Ensure new Censuses are zeroed · e2f0094c
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      When growing the Census array ProfHeap previously neglected to
      zero the new part of the array. Consequently `freeEra` would attempt to
      free random words that often looked suspiciously like pointers.
      
      Fixes #21880.
      e2f0094c
  14. 18 Jul, 2022 1 commit
  15. 17 Jul, 2022 15 commits