rts: Add isPinnedByteArray# primop
ClosedPublic

Authored by bgamari on May 14 2016, 4:53 AM.

Details

Summary

Adds a primitive operation to determine whether a particular
MutableByteArray# is backed by a pinned buffer.

Test Plan

Validate with included testcase

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
bgamari retitled this revision from to rts: Add isPinnedByteArray# primop.May 14 2016, 4:53 AM
bgamari updated this object.
bgamari edited the test plan for this revision. (Show Details)
bgamari added a reviewer: simonmar.
bgamari updated the Trac tickets for this revision.
simonmar requested changes to this revision.May 14 2016, 5:35 AM

Yes, good idea. Are you planning to use this in ByteString? I have some thoughts in that direction, maybe we should discuss.

rts/PrimOps.cmm
152

BF_PINNED is more correct, I think.

This revision now requires changes to proceed.May 14 2016, 5:35 AM
bgamari updated this revision to Diff 7583.May 14 2016, 5:47 AM

Use BF_PINNED instead

bgamari marked an inline comment as done.May 14 2016, 5:49 AM

The application I had in mind wasn't *in* bytestring per se, but it certainly did involve it (namely I want to be able to opportunistically construct a ByteString out of a ByteArray in a zero-copy manner).

austin accepted this revision.May 14 2016, 4:44 PM

LGTM.

simonmar accepted this revision.May 17 2016, 9:34 AM
This revision is now accepted and ready to land.May 17 2016, 9:34 AM
This revision was automatically updated to reflect the committed changes.
duncan added a subscriber: duncan.May 30 2016, 12:31 PM

Any chance that we can have this for immutable byte arrays too? We have most other byte array primops in both forms, even when both versions end up using the same code.

In D2217#65995, @duncan wrote:

Any chance that we can have this for immutable byte arrays too? We have most other byte array primops in both forms, even when both versions end up using the same code.

See D2290.