[GHC] #11143: Feature request: Add index/read/write primops with byte offset for ByteArray#

GHC ghc-devs at haskell.org
Tue Feb 20 23:15:53 UTC 2018


#11143: Feature request: Add index/read/write primops with byte offset for
ByteArray#
-------------------------------------+-------------------------------------
        Reporter:  vagarenko         |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.10.2
      Resolution:                    |             Keywords:  newcomers
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Runtime           |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by sjakobi):

 * cc: sjakobi (added)


Comment:

 Replying to [comment:2 Mathnerd314]:
 > Can we instead have primops which take both an offset measured in bytes
 and an offset measured in terms of the type?
 > {{{#!hs
 > indexTYPEArray# :: ByteArray#          -> Int# {-byte offset-} -> Int#
 {-type offset-} -> TYPE#
 > readTYPEArray#  :: MutableByteArray# s -> Int# {-byte offset-} -> Int#
 {-type offset-} -> State# s -> (#State# s, TYPE##)
 > writeTYPEArray# :: MutableByteArray# s -> Int# {-byte offset-} -> Int#
 {-type offset-} -> TYPE# -> State# s -> State# s
 >
 > indexTYPEOffAddr# :: Addr# -> Int# {-byte offset-} -> Int# {-type
 offset-} -> TYPE
 > readTYPEOffAddr# :: Addr# -> Int# {-byte offset-} -> Int# {-type
 offset-} -> State# s -> (#State# s, TYPE ##)
 > writeTYPEOffAddr# :: Addr# -> Int# {-byte offset-} -> Int# {-type
 offset-} -> TYPE -> State# s -> State# s
 > }}}

 I like these types.

 > All of these go through the `mkBasicIndexed{Read,Write}` functions,
 which take both a byte offset and a type offset, so it seems reasonable to
 expose that.

 I currently don't see how this can be done. These functions require a byte
 offset with type `ByteOff` (`Int`) but we only have a `CmmExpr`. It seems
 to me that the new primops will require quite a bit of new plumbing down
 to `CmmRegOff`. Am I missing something?

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


More information about the ghc-tickets mailing list