[GHC] #6084: Add stg_ap_pnnv and related call patterns

GHC cvs-ghc at haskell.org
Tue May 8 13:49:44 CEST 2012


#6084: Add stg_ap_pnnv and related call patterns
------------------------------+---------------------------------------------
 Reporter:  SimonMeier        |          Owner:                  
     Type:  feature request   |         Status:  new             
 Priority:  normal            |      Component:  Compiler        
  Version:  7.4.1             |       Keywords:                  
       Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
  Failure:  None/Unknown      |       Testcase:                  
Blockedby:                    |       Blocking:                  
  Related:                    |  
------------------------------+---------------------------------------------
 In the implementation of bytestring encoding and decoding libraries, the
 call patterns stg_ap_pnnv and stg_ap_nnv occur very often. These call
 patterns are required to avoid boxing the pointers denoting the start and
 end of the memory area to write to/read from. The first 'p' often stems
 from using continuation passing style or from a record of configuration
 paramters. For example, the type of a bytestring builder looks about as
 follows.

 {{{
 newtype Builder = Builder ((Addr# -> Addr# -> IO BuildSignal) -> Addr# ->
 Addr# -> IO BuildSignal)
 }}}

 The first Addr# is the pointer to the next free byte and the second Addr#
 is the pointer to the first byte after the buffer being filled. The
 current implementation of the bytestring builder in the bytestring-0.10.
 library however uses

 {{{
 newtype Builder = Builder ((Ptr Word8 -> Ptr Word8 -> IO BuildSignal) ->
 Ptr Word8 -> Ptr Word8 -> IO BuildSignal)
 }}}

 as the benchmarks demonstrated that the repeated boxing is cheaper than
 the unknown calls implemented through a series of stg_ap_p, stg_ap_n,
 stg_ap_n, stg_ap_v calls.

 I therefore suggest adding the following call patterns

 ppnnv, pnnv, nnv, and nv.

 to allow more efficient implementations of bytestring and text
 decoding/encoding. Note that the 'ppnnv' is used for a constant
 environment, a continuation, and a range resulting in a side-effecting
 function.

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



More information about the Glasgow-haskell-bugs mailing list