diff options
Diffstat (limited to 'compiler/GHC')
-rw-r--r-- | compiler/GHC/Builtin/primops.txt.pp | 34 | ||||
-rw-r--r-- | compiler/GHC/Cmm/CLabel.hs | 3 | ||||
-rw-r--r-- | compiler/GHC/StgToCmm/Prim.hs | 3 |
3 files changed, 40 insertions, 0 deletions
diff --git a/compiler/GHC/Builtin/primops.txt.pp b/compiler/GHC/Builtin/primops.txt.pp index 1fc7bd5f23..ce3f31e92e 100644 --- a/compiler/GHC/Builtin/primops.txt.pp +++ b/compiler/GHC/Builtin/primops.txt.pp @@ -1735,14 +1735,48 @@ primop NewAlignedPinnedByteArrayOp_Char "newAlignedPinnedByteArray#" GenPrimOp with out_of_line = True has_side_effects = True +primop UnsafePinMutableByteArrayOp "unsafePinMutableByteArray#" GenPrimOp + MutableByteArray# s -> State# s -> (# State# s, MutableByteArray# s #) + {Returns a pinned version of the given mutable byte array. + + * If possible the byte array will be pinned in place. + * If not a pinned array will be allocated and the contents of the given array will + be copied into it. + + If pinning was in-place or not can be checked by calling sameByteArray# with + the the argument and result of unsafePinMutableByteArray#. + + Generally the argument will be pinned in place if: + * The argument array is large enough to be considered a large object by the RTS. + * The argument array is part of a compact region. + * The argument array is already pinned (making this a no-op). + But the circumstances which allow a byte array to be pinned in place might + change in future releases of GHC. + + This function is considered unsafe as it can change the pinnedness of the argument + which can break code using compact region. If this is a concern it's always possible + to explicitly allocate a new array and copy over the contents.} + with out_of_line = True + has_side_effects = True + primop MutableByteArrayIsPinnedOp "isMutableByteArrayPinned#" GenPrimOp MutableByteArray# s -> Int# + {Determine whether a 'MutableByteArray#' is guaranteed not to move.} + with out_of_line = True + +primop MutableByteArrayIsGcPinnedOp "isMutableByteArrayGcPinned#" GenPrimOp + MutableByteArray# s -> Int# {Determine whether a 'MutableByteArray#' is guaranteed not to move during GC.} with out_of_line = True primop ByteArrayIsPinnedOp "isByteArrayPinned#" GenPrimOp ByteArray# -> Int# + {Determine whether a 'ByteArray#' is guaranteed not to move.} + with out_of_line = True + +primop ByteArrayIsGcPinnedOp "isByteArrayGcPinned#" GenPrimOp + ByteArray# -> Int# {Determine whether a 'ByteArray#' is guaranteed not to move during GC.} with out_of_line = True diff --git a/compiler/GHC/Cmm/CLabel.hs b/compiler/GHC/Cmm/CLabel.hs index 96f78b6789..25a61d226c 100644 --- a/compiler/GHC/Cmm/CLabel.hs +++ b/compiler/GHC/Cmm/CLabel.hs @@ -66,6 +66,7 @@ module GHC.Cmm.CLabel ( mkBadAlignmentLabel, mkOutOfBoundsAccessLabel, mkArrWords_infoLabel, + mkArrWordsPinned_infoLabel, mkSRTInfoLabel, mkTopTickyCtrLabel, @@ -645,6 +646,7 @@ mkDirty_MUT_VAR_Label, mkMAP_FROZEN_CLEAN_infoLabel, mkMAP_FROZEN_DIRTY_infoLabel, mkMAP_DIRTY_infoLabel, mkArrWords_infoLabel, + mkArrWordsPinned_infoLabel, mkTopTickyCtrLabel, mkCAFBlackHoleInfoTableLabel, mkSMAP_FROZEN_CLEAN_infoLabel, mkSMAP_FROZEN_DIRTY_infoLabel, @@ -663,6 +665,7 @@ mkMAP_DIRTY_infoLabel = CmmLabel rtsUnitId (NeedExternDecl False) (fsL mkTopTickyCtrLabel = CmmLabel rtsUnitId (NeedExternDecl False) (fsLit "top_ct") CmmData mkCAFBlackHoleInfoTableLabel = CmmLabel rtsUnitId (NeedExternDecl False) (fsLit "stg_CAF_BLACKHOLE") CmmInfo mkArrWords_infoLabel = CmmLabel rtsUnitId (NeedExternDecl False) (fsLit "stg_ARR_WORDS") CmmInfo +mkArrWordsPinned_infoLabel = CmmLabel rtsUnitId (NeedExternDecl False) (fsLit "stg_ARR_WORDS_PINNED") CmmInfo mkSMAP_FROZEN_CLEAN_infoLabel = CmmLabel rtsUnitId (NeedExternDecl False) (fsLit "stg_SMALL_MUT_ARR_PTRS_FROZEN_CLEAN") CmmInfo mkSMAP_FROZEN_DIRTY_infoLabel = CmmLabel rtsUnitId (NeedExternDecl False) (fsLit "stg_SMALL_MUT_ARR_PTRS_FROZEN_DIRTY") CmmInfo mkSMAP_DIRTY_infoLabel = CmmLabel rtsUnitId (NeedExternDecl False) (fsLit "stg_SMALL_MUT_ARR_PTRS_DIRTY") CmmInfo diff --git a/compiler/GHC/StgToCmm/Prim.hs b/compiler/GHC/StgToCmm/Prim.hs index 7366c529c8..8ca6cd1b68 100644 --- a/compiler/GHC/StgToCmm/Prim.hs +++ b/compiler/GHC/StgToCmm/Prim.hs @@ -1550,10 +1550,13 @@ emitPrimOp cfg primop = NewPinnedByteArrayOp_Char -> alwaysExternal NewAlignedPinnedByteArrayOp_Char -> alwaysExternal MutableByteArrayIsPinnedOp -> alwaysExternal + MutableByteArrayIsGcPinnedOp -> alwaysExternal + UnsafePinMutableByteArrayOp -> alwaysExternal DoubleDecode_2IntOp -> alwaysExternal DoubleDecode_Int64Op -> alwaysExternal FloatDecode_IntOp -> alwaysExternal ByteArrayIsPinnedOp -> alwaysExternal + ByteArrayIsGcPinnedOp -> alwaysExternal ShrinkMutableByteArrayOp_Char -> alwaysExternal ResizeMutableByteArrayOp_Char -> alwaysExternal ShrinkSmallMutableArrayOp_Char -> alwaysExternal |