[GHC] #9281: Rewrite `integer-gmp` to use only non-allocating GMP functions

GHC ghc-devs at haskell.org
Mon Jul 21 15:22:22 UTC 2014


#9281: Rewrite `integer-gmp` to use only non-allocating GMP functions
-------------------------------------+-------------------------------------
              Reporter:  hvr         |             Owner:  hvr
                  Type:  task        |            Status:  patch
              Priority:  normal      |         Milestone:  7.10.1
             Component:  libraries   |           Version:
  (other)                            |          Keywords:  integer-gmp
            Resolution:              |  Operating System:  Unknown/Multiple
Differential Revisions:  Phab:D82    |   Type of failure:  None/Unknown
          Architecture:              |         Test Case:
  Unknown/Multiple                   |          Blocking:
            Difficulty:  Unknown     |
            Blocked By:              |
       Related Tickets:  #8647       |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 What happens if you try
 {{{
 foreign import ccall unsafe "integer_gmp_mpn_tdiv_q"
   c_mpn_tdiv_q :: MutableByteArray# s -> ByteArray# -> GmpSize# ->
 ByteArray# -> GmpSize# -> State# s -> State# s
 }}}
 with `-XUnliftedFFITypes`?  Answer
 {{{
     Unacceptable argument type in foreign declaration: State# s
 }}}
 But why is `State# s` unacceptable?  I can think of no good reason.

 So I think that it might be as simple as
  * Adding `State#` to the list of acceptable FFI types (with
 `-XUnliftedFFITypes`.
  * Making sure that, since it's a zero-width value, we don't actually pass
 it to the C function.
 The latter step is in the code generator itself; these zero-width values
 ''do'' (and must) survive into `Cmm`.

 If you'd like to tackle this I'm sure Simon and I would help with any bits
 you don't grok.

 I think this would be MUCH simpler than trying to allow types like `IO
 Int#`, which has global implications that I don't know how to deal with.

 Simon

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


More information about the ghc-tickets mailing list