Skip to content
  • Duncan Coutts's avatar
    New primops for byte range copies ByteArray# <-> Addr# · f11289f6
    Duncan Coutts authored
    
    
    We have primops for copying ranges of bytes between ByteArray#s:
     * ByteArray# -> MutableByteArray#
     * MutableByteArray# -> MutableByteArray#
    This extends it with three further cases:
     * Addr# -> MutableByteArray#
     * ByteArray# -> Addr#
     * MutableByteArray# -> Addr#
    One use case for these is copying between ForeignPtr-based
    representations and in-heap arrays (like Text, UArray etc).
    
    The implementation is essentially the same as for the existing
    primops, and shares the memcpy stuff in the code generators.
    
    Defficiencies / future directions: none of these primops (existing
    or the new ones) let one take advantage of knowing that ByteArray#s
    are word-aligned in memory. Though it is unclear that any of the
    code generators would make use of this information unless the size
    to copy is also known at compile time.
    
    Signed-off-by: default avatarAustin Seipp <austin@well-typed.com>
    f11289f6