[GHC] #8296: Patch: new primops for byte range copies ByteArray# <-> Addr#

GHC ghc-devs at haskell.org
Sat Sep 14 11:50:01 CEST 2013


#8296: Patch: new primops for byte range copies ByteArray# <-> Addr#
------------------------------------+-------------------------------------
       Reporter:  duncan            |             Owner:
           Type:  feature request   |            Status:  new
       Priority:  normal            |         Milestone:
      Component:  Compiler          |           Version:  7.6.3
       Keywords:                    |  Operating System:  Unknown/Multiple
   Architecture:  Unknown/Multiple  |   Type of failure:  None/Unknown
     Difficulty:  Unknown           |         Test Case:
     Blocked By:                    |          Blocking:
Related Tickets:                    |
------------------------------------+-------------------------------------
 Currently we have:

  * `copyByteArray#` for `ByteArray#` to `MutableByteArray#`
  * `copyMutableByteArray#` for `MutableByteArray#` to `MutableByteArray#`

 This patch adds primops for similar cases involving `Addr#`s, that is
 pointers to pinned or foreign memory.

  * `copyByteArrayToAddr#` for `ByteArray#` to `Addr#`
  * `copyMutableByteArrayToAddr#` for `MutableByteArray#` to `Addr#`
  * `copyAddrToByteArray#` for `Addr#` to `MutableByteArray#`

 These are not covered by the existing primops of course, and are useful
 because `ByteArray#`s are a bit special, sometimes being unpinned, and
 being aligned, and being so primitve/built-in. It's true we could use FFI
 import of memcpy using the GHC's FFI extension to turn `ByteArray#` into a
 pointer on the C side. However we don't do that for the existing primops
 and we're following the same pattern here. (Good reasons for them all to
 be primops: abstracts the backend/platform better, can take advantage of
 known allignment and size info).

 In particular, these primops would be useful in the impl of low level libs
 like bytestring, text, array, binary etc.

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



More information about the ghc-tickets mailing list