[Git][ghc/ghc][wip/T22710] primops: Introduce unsafeThawByteArray#
Ben Gamari (@bgamari)
gitlab at gitlab.haskell.org
Tue Jan 17 21:12:14 UTC 2023
Ben Gamari pushed to branch wip/T22710 at Glasgow Haskell Compiler / GHC
Commits:
36fe85b9 by Ben Gamari at 2023-01-17T16:12:09-05:00
primops: Introduce unsafeThawByteArray#
This addresses an odd asymmetry in the ByteArray# primops, which
previously provided unsafeFreezeByteArray# but no corresponding
thaw operation.
Closes #22710
- - - - -
4 changed files:
- compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/StgToCmm/Prim.hs
- compiler/GHC/StgToJS/Prim.hs
- libraries/ghc-prim/changelog.md
Changes:
=====================================
compiler/GHC/Builtin/primops.txt.pp
=====================================
@@ -1780,7 +1780,15 @@ primop ResizeMutableByteArrayOp_Char "resizeMutableByteArray#" GenPrimOp
primop UnsafeFreezeByteArrayOp "unsafeFreezeByteArray#" GenPrimOp
MutableByteArray# s -> State# s -> (# State# s, ByteArray# #)
- {Make a mutable byte array immutable, without copying.}
+ {Make a mutable byte array immutable, without copying.
+
+ @since 0.11.0}
+ with
+ has_side_effects = True
+
+primop UnsafeThawByteArrayOp "unsafeThawByteArray#" GenPrimOp
+ MutableByteArray# s -> State# s -> (# State# s, ByteArray# #)
+ {Make an immutable byte array mutable, without copying.}
with
has_side_effects = True
=====================================
compiler/GHC/StgToCmm/Prim.hs
=====================================
@@ -375,6 +375,10 @@ emitPrimOp cfg primop =
UnsafeFreezeByteArrayOp -> \[arg] -> opIntoRegs $ \[res] ->
emitAssign (CmmLocal res) arg
+-- #define unsafeThawByteArrayzh(r,a) r=(a)
+ UnsafeThawByteArrayOp -> \[arg] -> opIntoRegs $ \[res] ->
+ emitAssign (CmmLocal res) arg
+
-- Reading/writing pointer arrays
ReadArrayOp -> \[obj, ix] -> opIntoRegs $ \[res] ->
=====================================
compiler/GHC/StgToJS/Prim.hs
=====================================
@@ -606,6 +606,7 @@ genPrim prof bound ty op = case op of
ShrinkMutableByteArrayOp_Char -> \[] [a,n] -> PrimInline $ appS "h$shrinkMutableByteArray" [a,n]
ResizeMutableByteArrayOp_Char -> \[r] [a,n] -> PrimInline $ r |= app "h$resizeMutableByteArray" [a,n]
UnsafeFreezeByteArrayOp -> \[a] [b] -> PrimInline $ a |= b
+ UnsafeThawByteArrayOp -> \[a] [b] -> PrimInline $ a |= b
SizeofByteArrayOp -> \[r] [a] -> PrimInline $ r |= a .^ "len"
SizeofMutableByteArrayOp -> \[r] [a] -> PrimInline $ r |= a .^ "len"
GetSizeofMutableByteArrayOp -> \[r] [a] -> PrimInline $ r |= a .^ "len"
=====================================
libraries/ghc-prim/changelog.md
=====================================
@@ -1,3 +1,10 @@
+## 0.11.0
+
+- Shipped with GHC 9.8.1
+
+- The `unsafeThawByteArray#` primop was added, serving as a inverse to the existing
+ `unsafeFreezeByteArray#` primop (see #22710).
+
## 0.10.0
- Shipped with GHC 9.6.1
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/36fe85b90f5cdb36f2323d6ba6f4e6f59596fbc8
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/36fe85b90f5cdb36f2323d6ba6f4e6f59596fbc8
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230117/3420dabf/attachment-0001.html>
More information about the ghc-commits
mailing list