How unsafe are unsafeThawArray# and unsafeFreezeArray#
johan.tibell at gmail.com
Fri Mar 9 02:13:44 CET 2012
I just ran across some code that calls unsafeThawArray#, writeArray#,
and unsafeFreezeArray#, in that order. How unsafe is that?
* Is it unsafe in the sense that if someone has a reference to the
original Array# they will see the value of that pure array change?
* Is it unsafe in the sense things will crash and burn?
I looked at the implementation of unsafeFreezeArray#, which is
emitPrimOp [res] UnsafeFreezeArrayOp [arg] _
= stmtsC [ setInfo arg (CmmLit (CmmLabel mkMAP_FROZEN_infoLabel)),
CmmAssign (CmmLocal res) arg ]
but I couldn't find any implementation of unsafeThawArray#. Is it a
no-op? It seems to me that if unsafeFreezeArray# changes the head of
the array heap object so should unsafeThawArray#.
More information about the Glasgow-haskell-users