Ticket #5931 (closed feature request: fixed)

Opened 15 months ago

Last modified 3 months ago

Allow 'Any' to be passed to a foreign prim function.

Reported by: nomeata Owned by: simonmar
Priority: normal Milestone: 7.6.2
Component: Compiler (FFI) Version: 7.4.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Real primops can take boxed arguments, and the Cmm code will receive the pointer to the object on the Haskell heap, e.g. for unpackClosure#. To be able to implement such a function in a "foreign prim" call, this needs to be allowed there as well, and the attached patch does that.

By only allowing Any here (instead of arbitrary types), it is clearer that the function will not receive the value in any marshalled form, but just the raw pointer. Haskell code using such functions are likely to use unsafeCoerce# to turn a Haskell value into a value of type Any.

I am working on code that helps investigating the heap, similar to vacuum, and unwrapClosure was not sufficient. With this patch in GHC I do not have to modify the compiler further to create an improved version.

If applied, the documentation at wiki:Commentary/PrimOps#Foreignout-of-linePrimOps needs to be updated. I did not find any documentation in the GHC tree to updated accordingly.

Attachments

Change History

Changed 14 months ago by simonmar

  • owner set to simonmar
  • difficulty set to Unknown
  • milestone set to 7.6.1

Changed 14 months ago by simonmar

Pushed as e29001c9e0f73885c0b85d86c3a854519448013a, please go ahead and update the wiki.

Changed 8 months ago by igloo

  • milestone changed from 7.6.1 to 7.6.2

Changed 3 months ago by simonmar

  • status changed from new to closed
  • resolution set to fixed

Looks like this has been done.

Note: See TracTickets for help on using tickets.