Commit 4dbacbc8 authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari
Browse files

Rename isPinnedByteArray# to isByteArrayPinned#

Reviewers: simonmar, duncan, erikd, austin

Reviewed By: austin

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2290

GHC Trac Issues: #12059
parent eda73a3a
......@@ -1077,9 +1077,15 @@ primop NewAlignedPinnedByteArrayOp_Char "newAlignedPinnedByteArray#" GenPrimOp
with out_of_line = True
has_side_effects = True
primop ByteArrayIsPinnedOp "isPinnedByteArray#" GenPrimOp
primop MutableByteArrayIsPinnedOp "isMutableByteArrayPinned#" GenPrimOp
MutableByteArray# s -> Int#
{Determine whether a {\tt MutableByteArray\#} is guaranteed not to move.}
{Determine whether a {\tt MutableByteArray\#} is guaranteed not to move
during GC.}
with out_of_line = True
primop ByteArrayIsPinnedOp "isByteArrayPinned#" GenPrimOp
ByteArray# -> Int#
{Determine whether a {\tt ByteArray\#} is guaranteed not to move during GC.}
with out_of_line = True
primop ByteArrayContents_Char "byteArrayContents#" GenPrimOp
......
......@@ -131,7 +131,7 @@ ghc-prim
- Version number XXXXX (was 0.3.1.0)
- Added new ``isPinnedbyteArray#`` operation.
- Added new ``isByteArrayPinned#`` and ``isMutableByteArrayPinned#`` operation.
haskell98
~~~~~~~~~
......
......@@ -347,7 +347,8 @@ RTS_FUN_DECL(stg_casArrayzh);
RTS_FUN_DECL(stg_newByteArrayzh);
RTS_FUN_DECL(stg_newPinnedByteArrayzh);
RTS_FUN_DECL(stg_newAlignedPinnedByteArrayzh);
RTS_FUN_DECL(stg_isPinnedByteArrayzh);
RTS_FUN_DECL(stg_isByteArrayPinnedzh);
RTS_FUN_DECL(stg_isMutableByteArrayPinnedzh);
RTS_FUN_DECL(stg_shrinkMutableByteArrayzh);
RTS_FUN_DECL(stg_resizzeMutableByteArrayzh);
RTS_FUN_DECL(stg_casIntArrayzh);
......
......@@ -141,17 +141,23 @@ stg_newAlignedPinnedByteArrayzh ( W_ n, W_ alignment )
return (p);
}
stg_isPinnedByteArrayzh ( gcptr mba )
// MutableByteArray# s -> Int#
stg_isByteArrayPinnedzh ( gcptr ba )
// ByteArray# s -> Int#
{
W_ bd, flags;
bd = Bdescr(mba);
bd = Bdescr(ba);
// pinned byte arrays live in blocks with the BF_PINNED flag set.
// See the comment in Storage.c:allocatePinned.
flags = TO_W_(bdescr_flags(bd));
return (flags & BF_PINNED != 0);
}
stg_isMutableByteArrayPinnedzh ( gcptr mba )
// MutableByteArray# s -> Int#
{
jump stg_isByteArrayPinnedzh(mba);
}
// shrink size of MutableByteArray in-place
stg_shrinkMutableByteArrayzh ( gcptr mba, W_ new_size )
// MutableByteArray# s -> Int# -> State# s -> State# s
......
......@@ -514,7 +514,8 @@
SymI_HasProto(stg_casMutVarzh) \
SymI_HasProto(stg_newPinnedByteArrayzh) \
SymI_HasProto(stg_newAlignedPinnedByteArrayzh) \
SymI_HasProto(stg_isPinnedByteArrayzh) \
SymI_HasProto(stg_isByteArrayPinnedzh) \
SymI_HasProto(stg_isMutableByteArrayPinnedzh) \
SymI_HasProto(stg_shrinkMutableByteArrayzh) \
SymI_HasProto(stg_resizzeMutableByteArrayzh) \
SymI_HasProto(newSpark) \
......
......@@ -8,20 +8,41 @@ import GHC.IO
main :: IO ()
main = do
-- Unpinned MutableByteArray
r <- IO $ \s0 ->
case newByteArray# 1024# s0 of
(# s1, mba #) ->
(# s1, isTrue# (isPinnedByteArray# mba) #)
(# s1, isTrue# (isMutableByteArrayPinned# mba) #)
print r
-- Pinned MutableByteArray
r <- IO $ \s0 ->
case newPinnedByteArray# 1024# s0 of
(# s1, mba #) ->
(# s1, isTrue# (isPinnedByteArray# mba) #)
(# s1, isTrue# (isMutableByteArrayPinned# mba) #)
print r
-- Pinned, Aligned MutableByteArray
r <- IO $ \s0 ->
case newAlignedPinnedByteArray# 1024# 16# s0 of
(# s1, mba #) ->
(# s1, isTrue# (isPinnedByteArray# mba) #)
(# s1, isTrue# (isMutableByteArrayPinned# mba) #)
print r
-- Unpinned ByteArray
r <- IO $ \s0 ->
case newByteArray# 1024# s0 of
(# s1, mba #) ->
case unsafeFreezeByteArray# mba s1 of
(# s2, ba #) ->
(# s2, isTrue# (isByteArrayPinned# ba) #)
print r
-- Pinned ByteArray
r <- IO $ \s0 ->
case newPinnedByteArray# 1024# s0 of
(# s1, mba #) ->
case unsafeFreezeByteArray# mba s1 of
(# s2, ba #) ->
(# s2, isTrue# (isByteArrayPinned# ba) #)
print r
False
True
True
False
True
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment