From 94363dd5c2c443db08e5d3885b582247822c43b3 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Mon, 16 Apr 2007 14:19:02 +0000 Subject: [PATCH] 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. --- includes/StgMiscClosures.h | 1 + rts/Exception.cmm | 15 ++++----------- rts/PrimOps.cmm | 3 +-- rts/StgStartup.cmm | 7 +++++++ 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/includes/StgMiscClosures.h b/includes/StgMiscClosures.h index 72a7b55..8267128 100644 --- a/includes/StgMiscClosures.h +++ b/includes/StgMiscClosures.h @@ -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); diff --git a/rts/Exception.cmm b/rts/Exception.cmm index ce2ea27..8ed83b3 100644 --- a/rts/Exception.cmm +++ b/rts/Exception.cmm @@ -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 diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm index 437ce55..31f58d1 100644 --- a/rts/PrimOps.cmm +++ b/rts/PrimOps.cmm @@ -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); diff --git a/rts/StgStartup.cmm b/rts/StgStartup.cmm index 33345cf..2d83a67 100644 --- a/rts/StgStartup.cmm +++ b/rts/StgStartup.cmm @@ -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. -- 1.7.10.4