Commit d89872a4 authored by simonmar's avatar simonmar
Browse files

[project @ 2003-06-19 10:42:24 by simonmar]

Add raiseIO# primop.

This is part of ensuring that exceptions are *precise* in the IO monad
(as opposed to imprecise exceptions in the pure world).  If we allow
the strictness analyser to see the definition of throwIO:

  throwIO e = IO $ \s -> throw e

then it might re-order evaluation in the IO monad, with the result
that we get _|_ instead of an exception, or one kind of exception when
we were expecting another.  We therefore must prevent the strictness
analyser from doing these reorderings in the IO monad.  Hiding the
definition of throwIO by making it a primop solves part of the problem
(there's more to come).

See SourceForge bug #752149.
parent 1f730da4
-----------------------------------------------------------------------
-- $Id: primops.txt.pp,v 1.26 2003/03/24 14:46:53 simonmar Exp $
-- $Id: primops.txt.pp,v 1.27 2003/06/19 10:42:26 simonmar Exp $
--
-- Primitive Operations
--
......@@ -1312,6 +1312,15 @@ primop RaiseOp "raise#" GenPrimOp
usage = { mangle RaiseOp [mkM] mkM }
out_of_line = True
-- raiseIO# needs to be a primop, because exceptions in the IO monad
-- must be *precise* - we don't want the strictness analyser turning
-- one kind of bottom into another, as it is allowed to do in pure code.
primop RaiseIOOp "raiseIO#" GenPrimOp
a -> State# RealWorld -> (# State# RealWorld, b #)
with
out_of_line = True
primop BlockAsyncExceptionsOp "blockAsyncExceptions#" GenPrimOp
(State# RealWorld -> (# State# RealWorld, a #))
-> (State# RealWorld -> (# State# RealWorld, a #))
......
/* -----------------------------------------------------------------------------
* $Id: PrimOps.h,v 1.101 2003/06/09 14:10:04 matthewc Exp $
* $Id: PrimOps.h,v 1.102 2003/06/19 10:42:24 simonmar Exp $
*
* (c) The GHC Team, 1998-2000
*
......@@ -253,6 +253,7 @@ EXTFUN_RTS(asyncWritezh_fast);
EXTFUN_RTS(catchzh_fast);
EXTFUN_RTS(raisezh_fast);
EXTFUN_RTS(raiseIOzh_fast);
extern void stg_exit(int n) __attribute__ ((noreturn));
......
/* -----------------------------------------------------------------------------
* $Id: Exception.hc,v 1.27 2003/05/14 09:13:59 simonmar Exp $
* $Id: Exception.hc,v 1.28 2003/06/19 10:42:26 simonmar Exp $
*
* (c) The GHC Team, 1998-2000
*
......@@ -350,7 +350,7 @@ FN_(raisezh_fast)
StgPtr p;
StgClosure *raise_closure;
FB_
/* args : R1 = exception */
/* args : R1.p :: Exception */
#if defined(PROFILING)
......@@ -459,3 +459,11 @@ FN_(raisezh_fast)
JMP_(stg_ap_p_ret);
FE_
}
FN_(raiseIOzh_fast)
{
FB_
/* Args :: R1.p :: Exception */
JMP_(raisezh_fast);
FE_
}
\ No newline at end of file
Supports Markdown
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