[GHC] #9447: Add support for resizing `MutableByteArray#`s

GHC ghc-devs at haskell.org
Sat Aug 16 14:04:39 UTC 2014


#9447: Add support for resizing `MutableByteArray#`s
-------------------------------------+-------------------------------------
              Reporter:  hvr         |            Owner:
                  Type:  bug         |           Status:  new
              Priority:  normal      |        Milestone:
             Component:  Compiler    |          Version:  7.8.2
            Resolution:              |         Keywords:
      Operating System:              |     Architecture:  Unknown/Multiple
  Unknown/Multiple                   |       Difficulty:  Unknown
       Type of failure:              |       Blocked By:
  None/Unknown                       |  Related Tickets:
             Test Case:              |
              Blocking:              |
Differential Revisions:  Phab:D133   |
-------------------------------------+-------------------------------------

Comment (by Herbert Valerio Riedel <hvr@…>):

 In [changeset:"246436f13739593d2a211ceb830393338118ca4d/ghc"]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="246436f13739593d2a211ceb830393338118ca4d"
 Implement {resize,shrink}MutableByteArray# primops

 The two new primops with the type-signatures

   resizeMutableByteArray# :: MutableByteArray# s -> Int#
                           -> State# s -> (# State# s, MutableByteArray# s
 #)

   shrinkMutableByteArray# :: MutableByteArray# s -> Int#
                           -> State# s -> State# s

 allow to resize MutableByteArray#s in-place (when possible), and are
 useful
 for algorithms where memory is temporarily over-allocated. The motivating
 use-case is for implementing integer backends, where the final target size
 of
 the result is either N or N+1, and only known after the operation has been
 performed.

 A future commit will implement a stateful variant of the
 `sizeofMutableByteArray#` operation (see #9447 for details), since now the
 size of a `MutableByteArray#` may change over its lifetime (i.e before
 it gets frozen or GCed).

 Test Plan: ./validate --slow

 Reviewers: ezyang, austin, simonmar

 Reviewed By: austin, simonmar

 Differential Revision: https://phabricator.haskell.org/D133
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9447#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list