Implement shrinkSmallMutableArray# and resizeSmallMutableArray#.
This is a part of GHC Proposal #25: "Offer more array resizing primitives". Resources related to the proposal: - Discussion: https://github.com/ghc-proposals/ghc-proposals/pull/121 - Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0025-resize-boxed.rst Only shrinkSmallMutableArray# is implemented as a primop since a library-space implementation of resizeSmallMutableArray# (in GHC.Exts) is no less efficient than a primop would be. This may be replaced by a primop in the future if someone devises a strategy for growing arrays in-place. The library-space implementation always copies the array when growing it. This commit also tweaks the documentation of the deprecated sizeofMutableByteArray#, removing the mention of concurrency. That primop is unsound even in single-threaded applications. Additionally, the non-negativity assertion on the existing shrinkMutableByteArray# primop has been removed since this predicate is trivially always true.
Showing
- compiler/GHC/StgToCmm/Prim.hs 2 additions, 0 deletionscompiler/GHC/StgToCmm/Prim.hs
- compiler/prelude/primops.txt.pp 16 additions, 1 deletioncompiler/prelude/primops.txt.pp
- includes/rts/storage/ClosureMacros.h 10 additions, 3 deletionsincludes/rts/storage/ClosureMacros.h
- includes/stg/MiscClosures.h 1 addition, 0 deletionsincludes/stg/MiscClosures.h
- libraries/base/GHC/Exts.hs 39 additions, 0 deletionslibraries/base/GHC/Exts.hs
- libraries/base/changelog.md 3 additions, 1 deletionlibraries/base/changelog.md
- libraries/ghc-prim/changelog.md 9 additions, 0 deletionslibraries/ghc-prim/changelog.md
- rts/PrimOps.cmm 18 additions, 1 deletionrts/PrimOps.cmm
- rts/RtsSymbols.c 1 addition, 0 deletionsrts/RtsSymbols.c
- testsuite/tests/primops/should_run/ShrinkSmallMutableArrayA.hs 35 additions, 0 deletions...uite/tests/primops/should_run/ShrinkSmallMutableArrayA.hs
- testsuite/tests/primops/should_run/ShrinkSmallMutableArrayB.hs 53 additions, 0 deletions...uite/tests/primops/should_run/ShrinkSmallMutableArrayB.hs
- testsuite/tests/primops/should_run/all.T 2 additions, 0 deletionstestsuite/tests/primops/should_run/all.T
Loading
Please register or sign in to comment