Commit 94363dd5 authored by Simon Marlow's avatar Simon Marlow
Browse files

MERGE: Fix a few uses of the wrong return convention for the scheduler

We changed the convention a while ago so that BaseReg is returned to
the scheduler in R1, because BaseReg may change during the run of a
thread, e.g. during a foreign call.  A few places got missed,
mostly for very rare events.

Should fix concprog001, although I'm not able to reliably reproduce
the failure.
parent 5aa70fe5
......@@ -484,6 +484,7 @@ RTS_FUN(stg_returnToStackTop);
RTS_FUN(stg_returnToSched);
RTS_FUN(stg_returnToSchedNotPaused);
RTS_FUN(stg_returnToSchedButFirst);
RTS_FUN(stg_threadFinished);
RTS_FUN(stg_init_finish);
RTS_FUN(stg_init);
......
......@@ -84,8 +84,7 @@ INFO_TABLE_RET( stg_unblockAsyncExceptionszh_ret,
if (r != 0::CInt) {
if (StgTSO_what_next(CurrentTSO) == ThreadKilled::I16) {
R1 = ThreadFinished;
jump StgReturn;
jump stg_threadFinished;
} else {
LOAD_THREAD_STATE();
ASSERT(StgTSO_what_next(CurrentTSO) == ThreadRunGHC::I16);
......@@ -180,8 +179,7 @@ unblockAsyncExceptionszh_fast
if (r != 0::CInt) {
if (StgTSO_what_next(CurrentTSO) == ThreadKilled::I16) {
R1 = ThreadFinished;
jump StgReturn;
jump stg_threadFinished;
} else {
LOAD_THREAD_STATE();
ASSERT(StgTSO_what_next(CurrentTSO) == ThreadRunGHC::I16);
......@@ -229,8 +227,7 @@ killThreadzh_fast
foreign "C" throwToSingleThreaded(MyCapability() "ptr",
target "ptr", exception "ptr")[R1,R2];
if (StgTSO_what_next(CurrentTSO) == ThreadKilled::I16) {
R1 = ThreadFinished;
jump StgReturn;
jump stg_threadFinished;
} else {
LOAD_THREAD_STATE();
ASSERT(StgTSO_what_next(CurrentTSO) == ThreadRunGHC::I16);
......@@ -431,11 +428,7 @@ retry_pop_stack:
StgTSO_what_next(CurrentTSO) = ThreadKilled::I16;
SAVE_THREAD_STATE(); /* inline! */
/* The return code goes in BaseReg->rRet, and BaseReg is returned in R1 */
StgRegTable_rRet(BaseReg) = ThreadFinished;
R1 = BaseReg;
jump StgReturn;
jump stg_threadFinished;
}
/* Ok, Sp points to the enclosing CATCH_FRAME or CATCH_STM_FRAME. Pop everything
......
......@@ -2142,8 +2142,7 @@ noDuplicatezh_fast
foreign "C" threadPaused (MyCapability() "ptr", CurrentTSO "ptr") [];
if (StgTSO_what_next(CurrentTSO) == ThreadKilled::I16) {
R1 = ThreadFinished;
jump StgReturn;
jump stg_threadFinished;
} else {
LOAD_THREAD_STATE();
ASSERT(StgTSO_what_next(CurrentTSO) == ThreadRunGHC::I16);
......
......@@ -128,6 +128,13 @@ stg_returnToSchedButFirst
jump R2;
}
stg_threadFinished
{
StgRegTable_rRet(BaseReg) = ThreadFinished;
R1 = BaseReg;
jump StgReturn;
}
/* -----------------------------------------------------------------------------
Strict IO application - performing an IO action and entering its result.
......
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