Optimizations for mutable structures?

Simon Marlow simonmar at microsoft.com
Wed Dec 7 09:15:24 EST 2005

On 07 December 2005 13:38, Malcolm Wallace wrote:

> Jan-Willem Maessen <jmaessen at alum.mit.edu> writes:
>>    - Fetch elimination for imperative reads:
>>      writeIORef r e >> acts >> readIORef r
>>  === writeIORef r e >> acts >> return e
> This transformation is valid only on single-threaded systems.
> If there is any possibility of an IORef being shared across threads,
> you are out of luck.

(assuming 'acts' doesn't modify 'r').

No, Jan's transformation is correct even in a multithreaded setting.  It
might eliminate some possible outcomes from a non-deterministic program,
but that's ok.  There's no requirement that all interleavings according
to the semantics have to be implemented.  This is a hard property to
state precisely, indeed we gave up trying to in the concurrency/FFI
paper: http://www.haskell.org/~simonmar/papers/conc-ffi.pdf, see Section


More information about the Glasgow-haskell-users mailing list