Commit 68c45b65 authored by Austin Seipp's avatar Austin Seipp

[skip ci] rts: Detabify Exception.cmm

Signed-off-by: default avatarAustin Seipp <austin@well-typed.com>
parent 3d0e695e
......@@ -20,8 +20,8 @@ import ghczmprim_GHCziTypes_True_closure;
A thread can request that asynchronous exceptions not be delivered
("masked") for the duration of an I/O computation. The primitives
maskAsyncExceptions# :: IO a -> IO a
maskAsyncExceptions# :: IO a -> IO a
and
......@@ -30,7 +30,7 @@ import ghczmprim_GHCziTypes_True_closure;
are used for this purpose. During a masked section, asynchronous
exceptions may be unmasked again temporarily:
unmaskAsyncExceptions# :: IO a -> IO a
unmaskAsyncExceptions# :: IO a -> IO a
Furthermore, asynchronous exceptions are masked automatically during
the execution of an exception handler. All three of these primitives
......@@ -70,7 +70,7 @@ INFO_TABLE_RET(stg_unmaskAsyncExceptionszh_ret, RET_SMALL, W_ info_ptr)
if (StgTSO_blocked_exceptions(CurrentTSO) != END_TSO_QUEUE) {
STK_CHK_P_LL (WDS(2), stg_unmaskAsyncExceptionszh_ret_info, R1);
/*
/*
* We have to be very careful here, as in killThread#, since
* we are about to raise an async exception in the current
* thread, which might result in the thread being killed.
......@@ -95,8 +95,8 @@ INFO_TABLE_RET(stg_unmaskAsyncExceptionszh_ret, RET_SMALL, W_ info_ptr)
/*
the thread might have been removed from the
blocked_exception list by someone else in the meantime.
Just restore the stack pointer and continue.
*/
Just restore the stack pointer and continue.
*/
Sp_adj(2);
}
}
......@@ -109,9 +109,9 @@ INFO_TABLE_RET(stg_unmaskAsyncExceptionszh_ret, RET_SMALL, W_ info_ptr)
INFO_TABLE_RET(stg_maskAsyncExceptionszh_ret, RET_SMALL, W_ info_ptr)
return (P_ ret)
{
StgTSO_flags(CurrentTSO) =
StgTSO_flags(CurrentTSO) =
%lobits32(
TO_W_(StgTSO_flags(CurrentTSO))
TO_W_(StgTSO_flags(CurrentTSO))
| TSO_BLOCKEX | TSO_INTERRUPTIBLE
);
......@@ -121,9 +121,9 @@ INFO_TABLE_RET(stg_maskAsyncExceptionszh_ret, RET_SMALL, W_ info_ptr)
INFO_TABLE_RET(stg_maskUninterruptiblezh_ret, RET_SMALL, W_ info_ptr)
return (P_ ret)
{
StgTSO_flags(CurrentTSO) =
StgTSO_flags(CurrentTSO) =
%lobits32(
(TO_W_(StgTSO_flags(CurrentTSO))
(TO_W_(StgTSO_flags(CurrentTSO))
| TSO_BLOCKEX)
& ~TSO_INTERRUPTIBLE
);
......@@ -204,24 +204,24 @@ stg_unmaskAsyncExceptionszh /* explicit stack */
/* If exceptions are already unmasked, there's nothing to do */
if ((TO_W_(StgTSO_flags(CurrentTSO)) & TSO_BLOCKEX) != 0) {
/* avoid growing the stack unnecessarily */
if (Sp(0) == stg_unmaskAsyncExceptionszh_ret_info) {
Sp_adj(1);
} else {
Sp_adj(-1);
/* avoid growing the stack unnecessarily */
if (Sp(0) == stg_unmaskAsyncExceptionszh_ret_info) {
Sp_adj(1);
} else {
Sp_adj(-1);
if ((TO_W_(StgTSO_flags(CurrentTSO)) & TSO_INTERRUPTIBLE) != 0) {
Sp(0) = stg_maskAsyncExceptionszh_ret_info;
} else {
Sp(0) = stg_maskUninterruptiblezh_ret_info;
}
}
}
StgTSO_flags(CurrentTSO) = %lobits32(
StgTSO_flags(CurrentTSO) = %lobits32(
TO_W_(StgTSO_flags(CurrentTSO)) & ~(TSO_BLOCKEX|TSO_INTERRUPTIBLE));
/* Eagerly raise a masked exception, if there is one */
if (StgTSO_blocked_exceptions(CurrentTSO) != END_TSO_QUEUE) {
/*
/*
* We have to be very careful here, as in killThread#, since
* we are about to raise an async exception in the current
* thread, which might result in the thread being killed.
......@@ -244,12 +244,12 @@ stg_unmaskAsyncExceptionszh /* explicit stack */
if (r != 0::CInt) {
if (StgTSO_what_next(CurrentTSO) == ThreadKilled::I16) {
jump stg_threadFinished [];
} else {
LOAD_THREAD_STATE();
ASSERT(StgTSO_what_next(CurrentTSO) == ThreadRunGHC::I16);
} else {
LOAD_THREAD_STATE();
ASSERT(StgTSO_what_next(CurrentTSO) == ThreadRunGHC::I16);
R1 = io;
jump %ENTRY_CODE(Sp(0)) [R1];
}
}
} else {
/* we'll just call R1 directly, below */
Sp_adj(3);
......@@ -267,7 +267,7 @@ stg_unmaskAsyncExceptionszh /* explicit stack */
stg_getMaskingStatezh ()
{
/* args: none */
/*
/*
returns: 0 == unmasked,
1 == masked, non-interruptible,
2 == masked, interruptible
......@@ -285,7 +285,7 @@ stg_killThreadzh (P_ target, P_ exception)
/* We call allocate in throwTo(), so better check for GC */
MAYBE_GC_PP (stg_killThreadzh, target, exception);
/*
/*
* We might have killed ourselves. In which case, better be *very*
* careful. If the exception killed us, then return to the scheduler.
* If the exception went to a catch frame, we'll just continue from
......@@ -306,19 +306,19 @@ stg_killThreadzh (P_ target, P_ exception)
} else {
W_ msg;
(msg) = ccall throwTo(MyCapability() "ptr",
(msg) = ccall throwTo(MyCapability() "ptr",
CurrentTSO "ptr",
target "ptr",
exception "ptr");
if (msg == NULL) {
return ();
} else {
StgTSO_why_blocked(CurrentTSO) = BlockedOnMsgThrowTo;
StgTSO_block_info(CurrentTSO) = msg;
// we must block, and unlock the message before returning
// we must block, and unlock the message before returning
jump stg_block_throwto (target, exception);
}
}
}
}
......@@ -335,7 +335,7 @@ stg_killMyself
SAVE_THREAD_STATE();
/* ToDo: what if the current thread is masking exceptions? */
ccall throwToSingleThreaded(MyCapability() "ptr",
ccall throwToSingleThreaded(MyCapability() "ptr",
target "ptr", exception "ptr");
if (StgTSO_what_next(CurrentTSO) == ThreadKilled::I16) {
jump stg_threadFinished [];
......@@ -392,7 +392,7 @@ stg_catchzh ( P_ io, /* :: IO a */
W_ exceptions_blocked;
STK_CHK_GEN();
exceptions_blocked =
TO_W_(StgTSO_flags(CurrentTSO)) & (TSO_BLOCKEX | TSO_INTERRUPTIBLE);
TICK_CATCHF_PUSHED();
......@@ -409,7 +409,7 @@ stg_catchzh ( P_ io, /* :: IO a */
/* -----------------------------------------------------------------------------
* The raise infotable
*
*
* This should be exactly the same as would be generated by this STG code
*
* raise = {err} \n {} -> raise#{err}
......@@ -463,16 +463,16 @@ stg_raisezh /* explicit stack */
LOAD_THREAD_STATE();
}
#endif
retry_pop_stack:
SAVE_THREAD_STATE();
(frame_type) = ccall raiseExceptionHelper(BaseReg "ptr", CurrentTSO "ptr", exception "ptr");
LOAD_THREAD_STATE();
if (frame_type == ATOMICALLY_FRAME) {
/* The exception has reached the edge of a memory transaction. Check that
/* The exception has reached the edge of a memory transaction. Check that
* the transaction is valid. If not then perhaps the exception should
* not have been thrown: re-run the transaction. "trec" will either be
* a top-level transaction running the atomic block, or a nested
* a top-level transaction running the atomic block, or a nested
* transaction running an invariant check. In the latter case we
* abort and de-allocate the top-level transaction that encloses it
* as well (we could just abandon its transaction record, but this makes
......@@ -502,7 +502,7 @@ retry_pop_stack:
StgTSO_trec(CurrentTSO) = trec;
R1 = StgAtomicallyFrame_code(Sp);
jump stg_ap_v_fast [R1];
}
}
}
// After stripping the stack, see whether we should break here for
......@@ -535,19 +535,19 @@ retry_pop_stack:
}
if (frame_type == STOP_FRAME) {
/*
* We've stripped the entire stack, the thread is now dead.
* We will leave the stack in a GC'able state, see the stg_stop_thread
* entry code in StgStartup.cmm.
*/
/*
* We've stripped the entire stack, the thread is now dead.
* We will leave the stack in a GC'able state, see the stg_stop_thread
* entry code in StgStartup.cmm.
*/
W_ stack;
stack = StgTSO_stackobj(CurrentTSO);
Sp = stack + OFFSET_StgStack_stack
+ WDS(TO_W_(StgStack_stack_size(stack))) - WDS(2);
Sp(1) = exception; /* save the exception */
Sp(0) = stg_enter_info; /* so that GC can traverse this stack */
StgTSO_what_next(CurrentTSO) = ThreadKilled::I16;
SAVE_THREAD_STATE(); /* inline! */
Sp(1) = exception; /* save the exception */
Sp(0) = stg_enter_info; /* so that GC can traverse this stack */
StgTSO_what_next(CurrentTSO) = ThreadKilled::I16;
SAVE_THREAD_STATE(); /* inline! */
jump stg_threadFinished [];
}
......@@ -563,7 +563,7 @@ retry_pop_stack:
}
/* Restore the masked/unmasked state for asynchronous exceptions
* at the CATCH_FRAME.
* at the CATCH_FRAME.
*
* If exceptions were unmasked, arrange that they are unmasked
* again after executing the handler by pushing an
......
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